@capgo/cli 7.81.2 → 7.82.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/src/sdk.js CHANGED
@@ -11,18 +11,18 @@ import{createRequire as nDD}from"node:module";var gDD=Object.create;var{getProto
11
11
  `).length-1;this.output.write(D1.cursor.move(-999,D*-1))}render(){let D=DG(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(D!==this._prevFrame){if(this.state==="initial")this.output.write(D1.cursor.hide);else{let $=U0D(this._prevFrame,D),X=FG(this.output);if(this.restoreCursor(),$){let Y=Math.max(0,$.numLinesAfter-X),J=Math.max(0,$.numLinesBefore-X),Q=$.lines.find((F)=>F>=Y);if(Q===void 0){this._prevFrame=D;return}if($.lines.length===1){this.output.write(D1.cursor.move(0,Q-J)),this.output.write(D1.erase.lines(1));let F=D.split(`
12
12
  `);this.output.write(F[Q]),this._prevFrame=D,this.output.write(D1.cursor.move(0,F.length-Q-1));return}else if($.lines.length>1){if(Y<J)Q=Y;else{let w=Q-J;w>0&&this.output.write(D1.cursor.move(0,w))}this.output.write(D1.erase.down());let F=D.split(`
13
13
  `).slice(Q);this.output.write(F.join(`
14
- `)),this._prevFrame=D;return}}this.output.write(D1.erase.down())}this.output.write(D),this.state==="initial"&&(this.state="active"),this._prevFrame=D}}}function z0D(D,$){if(D===void 0||$.length===0)return 0;let X=$.findIndex((Y)=>Y.value===D);return X!==-1?X:0}function B0D(D,$){return($.label??String($.value)).toLowerCase().includes(D.toLowerCase())}function K0D(D,$){if($)return D?$:$[0]}var u6,D1,sDD=(D)=>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,eDD=(D)=>D===12288||D>=65281&&D<=65376||D>=65504&&D<=65510,D0D=(D)=>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>=9800&&D<=9811||D===9855||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<=12771||D>=12783&&D<=12830||D>=12832&&D<=12871||D>=12880&&D<=19903||D>=19968&&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===94193||D>=94208&&D<=100343||D>=100352&&D<=101589||D>=101632&&D<=101640||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===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<=128727||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<=129672||D>=129680&&D<=129725||D>=129727&&D<=129733||D>=129742&&D<=129755||D>=129760&&D<=129768||D>=129776&&D<=129784||D>=131072&&D<=196605||D>=196608&&D<=262141,tZ,P2,x2,sZ,S2,$0D,X0D,oL=(D,$={},X={})=>{let Y=$.limit??1/0,J=$.ellipsis??"",Q=$?.ellipsisWidth??(J?oL(J,X0D,X).width:0),F=X.ansiWidth??0,w=X.controlWidth??0,Z=X.tabWidth??8,G=X.ambiguousWidth??1,O=X.emojiWidth??2,U=X.fullWidthWidth??2,z=X.regularWidth??1,q=X.wideWidth??2,B=0,K=0,M=D.length,L=0,I=!1,W=M,N=Math.max(0,Y-Q),V=0,R=0,P=0,A=0;D:for(;;){if(R>V||K>=M&&K>B){let _=D.slice(V,R)||D.slice(B,K);L=0;for(let v of _.replaceAll($0D,"")){let S=v.codePointAt(0)||0;if(eDD(S)?A=U:D0D(S)?A=q:G!==z&&sDD(S)?A=G:A=z,P+A>N&&(W=Math.min(W,Math.max(V,B)+L)),P+A>Y){I=!0;break D}L+=v.length,P+=A}V=R=0}if(K>=M)break;if(S2.lastIndex=K,S2.test(D)){if(L=S2.lastIndex-K,A=L*z,P+A>N&&(W=Math.min(W,K+Math.floor((N-P)/z))),P+A>Y){I=!0;break}P+=A,V=B,R=K,K=B=S2.lastIndex;continue}if(tZ.lastIndex=K,tZ.test(D)){if(P+F>N&&(W=Math.min(W,K)),P+F>Y){I=!0;break}P+=F,V=B,R=K,K=B=tZ.lastIndex;continue}if(P2.lastIndex=K,P2.test(D)){if(L=P2.lastIndex-K,A=L*w,P+A>N&&(W=Math.min(W,K+Math.floor((N-P)/w))),P+A>Y){I=!0;break}P+=A,V=B,R=K,K=B=P2.lastIndex;continue}if(x2.lastIndex=K,x2.test(D)){if(L=x2.lastIndex-K,A=L*Z,P+A>N&&(W=Math.min(W,K+Math.floor((N-P)/Z))),P+A>Y){I=!0;break}P+=A,V=B,R=K,K=B=x2.lastIndex;continue}if(sZ.lastIndex=K,sZ.test(D)){if(P+O>N&&(W=Math.min(W,K)),P+O>Y){I=!0;break}P+=O,V=B,R=K,K=B=sZ.lastIndex;continue}K+=1}return{width:I?N:P,index:I?W:M,truncated:I,ellipsed:I&&Y>=Q}},J0D,z7=(D,$={})=>oL(D,J0D,$).width,v2="\x1B",aL="›",Y0D=39,JG="\x07",tL="[",Q0D="]",sL="m",YG,nL,F0D=(D)=>{if(D>=30&&D<=37||D>=90&&D<=97)return 39;if(D>=40&&D<=47||D>=100&&D<=107)return 49;if(D===1||D===2)return 22;if(D===3)return 23;if(D===4)return 24;if(D===7)return 27;if(D===8)return 28;if(D===9)return 29;if(D===0)return 0},iL=(D)=>`${v2}${tL}${D}${sL}`,pL=(D)=>`${v2}${YG}${D}${JG}`,w0D=(D)=>D.map(($)=>z7($)),eZ=(D,$,X)=>{let Y=$[Symbol.iterator](),J=!1,Q=!1,F=D.at(-1),w=F===void 0?0:z7(F),Z=Y.next(),G=Y.next(),O=0;for(;!Z.done;){let U=Z.value,z=z7(U);w+z<=X?D[D.length-1]+=U:(D.push(U),w=0),(U===v2||U===aL)&&(J=!0,Q=$.startsWith(YG,O+1)),J?Q?U===JG&&(J=!1,Q=!1):U===sL&&(J=!1):(w+=z,w===X&&!G.done&&(D.push(""),w=0)),Z=G,G=Y.next(),O+=U.length}F=D.at(-1),!w&&F!==void 0&&F.length>0&&D.length>1&&(D[D.length-2]+=D.pop())},Z0D=(D)=>{let $=D.split(" "),X=$.length;for(;X>0&&!(z7($[X-1])>0);)X--;return X===$.length?D:$.slice(0,X).join(" ")+$.slice(X).join("")},G0D=(D,$,X={})=>{if(X.trim!==!1&&D.trim()==="")return"";let Y="",J,Q,F=D.split(" "),w=w0D(F),Z=[""];for(let[B,K]of F.entries()){X.trim!==!1&&(Z[Z.length-1]=(Z.at(-1)??"").trimStart());let M=z7(Z.at(-1)??"");if(B!==0&&(M>=$&&(X.wordWrap===!1||X.trim===!1)&&(Z.push(""),M=0),(M>0||X.trim===!1)&&(Z[Z.length-1]+=" ",M++)),X.hard&&w[B]>$){let L=$-M,I=1+Math.floor((w[B]-L-1)/$);Math.floor((w[B]-1)/$)<I&&Z.push(""),eZ(Z,K,$);continue}if(M+w[B]>$&&M>0&&w[B]>0){if(X.wordWrap===!1&&M<$){eZ(Z,K,$);continue}Z.push("")}if(M+w[B]>$&&X.wordWrap===!1){eZ(Z,K,$);continue}Z[Z.length-1]+=K}X.trim!==!1&&(Z=Z.map((B)=>Z0D(B)));let G=Z.join(`
14
+ `)),this._prevFrame=D;return}}this.output.write(D1.erase.down())}this.output.write(D),this.state==="initial"&&(this.state="active"),this._prevFrame=D}}}function z0D(D,$){if(D===void 0||$.length===0)return 0;let X=$.findIndex((Y)=>Y.value===D);return X!==-1?X:0}function B0D(D,$){return($.label??String($.value)).toLowerCase().includes(D.toLowerCase())}function K0D(D,$){if($)return D?$:$[0]}var u6,D1,sDD=(D)=>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,eDD=(D)=>D===12288||D>=65281&&D<=65376||D>=65504&&D<=65510,D0D=(D)=>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>=9800&&D<=9811||D===9855||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<=12771||D>=12783&&D<=12830||D>=12832&&D<=12871||D>=12880&&D<=19903||D>=19968&&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===94193||D>=94208&&D<=100343||D>=100352&&D<=101589||D>=101632&&D<=101640||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===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<=128727||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<=129672||D>=129680&&D<=129725||D>=129727&&D<=129733||D>=129742&&D<=129755||D>=129760&&D<=129768||D>=129776&&D<=129784||D>=131072&&D<=196605||D>=196608&&D<=262141,tZ,P2,x2,sZ,S2,$0D,X0D,oL=(D,$={},X={})=>{let Y=$.limit??1/0,J=$.ellipsis??"",Q=$?.ellipsisWidth??(J?oL(J,X0D,X).width:0),F=X.ansiWidth??0,w=X.controlWidth??0,Z=X.tabWidth??8,G=X.ambiguousWidth??1,O=X.emojiWidth??2,U=X.fullWidthWidth??2,z=X.regularWidth??1,q=X.wideWidth??2,B=0,K=0,M=D.length,L=0,I=!1,W=M,N=Math.max(0,Y-Q),V=0,R=0,C=0,A=0;D:for(;;){if(R>V||K>=M&&K>B){let _=D.slice(V,R)||D.slice(B,K);L=0;for(let v of _.replaceAll($0D,"")){let S=v.codePointAt(0)||0;if(eDD(S)?A=U:D0D(S)?A=q:G!==z&&sDD(S)?A=G:A=z,C+A>N&&(W=Math.min(W,Math.max(V,B)+L)),C+A>Y){I=!0;break D}L+=v.length,C+=A}V=R=0}if(K>=M)break;if(S2.lastIndex=K,S2.test(D)){if(L=S2.lastIndex-K,A=L*z,C+A>N&&(W=Math.min(W,K+Math.floor((N-C)/z))),C+A>Y){I=!0;break}C+=A,V=B,R=K,K=B=S2.lastIndex;continue}if(tZ.lastIndex=K,tZ.test(D)){if(C+F>N&&(W=Math.min(W,K)),C+F>Y){I=!0;break}C+=F,V=B,R=K,K=B=tZ.lastIndex;continue}if(P2.lastIndex=K,P2.test(D)){if(L=P2.lastIndex-K,A=L*w,C+A>N&&(W=Math.min(W,K+Math.floor((N-C)/w))),C+A>Y){I=!0;break}C+=A,V=B,R=K,K=B=P2.lastIndex;continue}if(x2.lastIndex=K,x2.test(D)){if(L=x2.lastIndex-K,A=L*Z,C+A>N&&(W=Math.min(W,K+Math.floor((N-C)/Z))),C+A>Y){I=!0;break}C+=A,V=B,R=K,K=B=x2.lastIndex;continue}if(sZ.lastIndex=K,sZ.test(D)){if(C+O>N&&(W=Math.min(W,K)),C+O>Y){I=!0;break}C+=O,V=B,R=K,K=B=sZ.lastIndex;continue}K+=1}return{width:I?N:C,index:I?W:M,truncated:I,ellipsed:I&&Y>=Q}},J0D,z7=(D,$={})=>oL(D,J0D,$).width,v2="\x1B",aL="›",Y0D=39,JG="\x07",tL="[",Q0D="]",sL="m",YG,nL,F0D=(D)=>{if(D>=30&&D<=37||D>=90&&D<=97)return 39;if(D>=40&&D<=47||D>=100&&D<=107)return 49;if(D===1||D===2)return 22;if(D===3)return 23;if(D===4)return 24;if(D===7)return 27;if(D===8)return 28;if(D===9)return 29;if(D===0)return 0},iL=(D)=>`${v2}${tL}${D}${sL}`,pL=(D)=>`${v2}${YG}${D}${JG}`,w0D=(D)=>D.map(($)=>z7($)),eZ=(D,$,X)=>{let Y=$[Symbol.iterator](),J=!1,Q=!1,F=D.at(-1),w=F===void 0?0:z7(F),Z=Y.next(),G=Y.next(),O=0;for(;!Z.done;){let U=Z.value,z=z7(U);w+z<=X?D[D.length-1]+=U:(D.push(U),w=0),(U===v2||U===aL)&&(J=!0,Q=$.startsWith(YG,O+1)),J?Q?U===JG&&(J=!1,Q=!1):U===sL&&(J=!1):(w+=z,w===X&&!G.done&&(D.push(""),w=0)),Z=G,G=Y.next(),O+=U.length}F=D.at(-1),!w&&F!==void 0&&F.length>0&&D.length>1&&(D[D.length-2]+=D.pop())},Z0D=(D)=>{let $=D.split(" "),X=$.length;for(;X>0&&!(z7($[X-1])>0);)X--;return X===$.length?D:$.slice(0,X).join(" ")+$.slice(X).join("")},G0D=(D,$,X={})=>{if(X.trim!==!1&&D.trim()==="")return"";let Y="",J,Q,F=D.split(" "),w=w0D(F),Z=[""];for(let[B,K]of F.entries()){X.trim!==!1&&(Z[Z.length-1]=(Z.at(-1)??"").trimStart());let M=z7(Z.at(-1)??"");if(B!==0&&(M>=$&&(X.wordWrap===!1||X.trim===!1)&&(Z.push(""),M=0),(M>0||X.trim===!1)&&(Z[Z.length-1]+=" ",M++)),X.hard&&w[B]>$){let L=$-M,I=1+Math.floor((w[B]-L-1)/$);Math.floor((w[B]-1)/$)<I&&Z.push(""),eZ(Z,K,$);continue}if(M+w[B]>$&&M>0&&w[B]>0){if(X.wordWrap===!1&&M<$){eZ(Z,K,$);continue}Z.push("")}if(M+w[B]>$&&X.wordWrap===!1){eZ(Z,K,$);continue}Z[Z.length-1]+=K}X.trim!==!1&&(Z=Z.map((B)=>Z0D(B)));let G=Z.join(`
15
15
  `),O=G[Symbol.iterator](),U=O.next(),z=O.next(),q=0;for(;!U.done;){let B=U.value,K=z.value;if(Y+=B,B===v2||B===aL){nL.lastIndex=q+1;let L=nL.exec(G)?.groups;if(L?.code!==void 0){let I=Number.parseFloat(L.code);J=I===Y0D?void 0:I}else L?.uri!==void 0&&(Q=L.uri.length===0?void 0:L.uri)}let M=J?F0D(J):void 0;K===`
16
16
  `?(Q&&(Y+=pL("")),J&&M&&(Y+=iL(M))):B===`
17
17
  `&&(J&&M&&(Y+=iL(J)),Q&&(Y+=pL(Q))),q+=B.length,U=z,z=O.next()}return Y},O0D,T1,q0D,$G,_2=(D)=>("columns"in D)&&typeof D.columns=="number"?D.columns:80,FG=(D)=>("rows"in D)&&typeof D.rows=="number"?D.rows:20,DI,wG,$I,XI,ZG,GG;var OG=o(()=>{u6=V0(oZ(),1),D1=V0(O0(),1);tZ=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,P2=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,x2=/\t{1,1000}/y,sZ=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,S2=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,$0D=/\p{M}+/gu,X0D={limit:1/0,ellipsis:""},J0D={limit:1/0,ellipsis:"",ellipsisWidth:0},YG=`${Q0D}8;;`,nL=new RegExp(`(?:\\${tL}(?<code>\\d+)m|\\${YG}(?<uri>.*)${JG})`,"y");O0D=["up","down","left","right","space","enter","cancel"],T1={actions:new Set(O0D),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0};q0D=globalThis.process.platform.startsWith("win"),$G=Symbol("clack:cancel");DI=class DI extends P4{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#D=0;#X="";#J;#$;get cursor(){return this.#D}get userInputWithCursor(){if(!this.userInput)return u6.default.inverse(u6.default.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let D=this.userInput.slice(0,this._cursor),[$,...X]=this.userInput.slice(this._cursor);return`${D}${u6.default.inverse($)}${X.join("")}`}get options(){return typeof this.#$=="function"?this.#$():this.#$}constructor(D){super(D),this.#$=D.options;let $=this.options;this.filteredOptions=[...$],this.multiple=D.multiple===!0,this.#J=D.filter??B0D;let X;if(D.initialValue&&Array.isArray(D.initialValue)?this.multiple?X=D.initialValue:X=D.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(X=[this.options[0].value]),X)for(let Y of X){let J=$.findIndex((Q)=>Q.value===Y);J!==-1&&(this.toggleSelected(Y),this.#D=J)}this.focusedValue=this.options[this.#D]?.value,this.on("key",(Y,J)=>this.#Y(Y,J)),this.on("userInput",(Y)=>this.#Q(Y))}_isActionKey(D,$){return D==="\t"||this.multiple&&this.isNavigating&&$.name==="space"&&D!==void 0&&D!==""}#Y(D,$){let X=$.name==="up",Y=$.name==="down",J=$.name==="return";X||Y?(this.#D=r8(this.#D,X?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#D]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):J?this.value=K0D(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&($.name==="tab"||this.isNavigating&&$.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(D){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(D)?this.selectedValues=this.selectedValues.filter(($)=>$!==D):this.selectedValues=[...this.selectedValues,D]:this.selectedValues=[D])}#Q(D){if(D!==this.#X){this.#X=D;let $=this.options;D?this.filteredOptions=$.filter((J)=>this.#J(D,J)):this.filteredOptions=[...$];let X=z0D(this.focusedValue,this.filteredOptions);this.#D=r8(X,0,this.filteredOptions);let Y=this.filteredOptions[this.#D];Y&&!Y.disabled?this.focusedValue=Y.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};wG=class wG extends P4{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(D){super(D,!1),this.value=!!D.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",($)=>{this.output.write(D1.cursor.move(0,-1)),this.value=$,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};$I=class $I extends P4{options;cursor=0;#D;getGroupItems(D){return this.options.filter(($)=>$.group===D)}isGroupSelected(D){let $=this.getGroupItems(D),X=this.value;return X===void 0?!1:$.every((Y)=>X.includes(Y.value))}toggleValue(){let D=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),D.group===!0){let $=D.value,X=this.getGroupItems($);this.isGroupSelected($)?this.value=this.value.filter((Y)=>X.findIndex((J)=>J.value===Y)===-1):this.value=[...this.value,...X.map((Y)=>Y.value)],this.value=Array.from(new Set(this.value))}else{let $=this.value.includes(D.value);this.value=$?this.value.filter((X)=>X!==D.value):[...this.value,D.value]}}constructor(D){super(D,!1);let{options:$}=D;this.#D=D.selectableGroups!==!1,this.options=Object.entries($).flatMap(([X,Y])=>[{value:X,group:!0,label:X},...Y.map((J)=>({...J,group:X}))]),this.value=[...D.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:X})=>X===D.cursorAt),this.#D?0:1),this.on("cursor",(X)=>{switch(X){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let Y=this.options[this.cursor]?.group===!0;!this.#D&&Y&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let Y=this.options[this.cursor]?.group===!0;!this.#D&&Y&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}};XI=class extends P4{_mask="•";get cursor(){return this._cursor}get masked(){return this.userInput.replaceAll(/./g,this._mask)}get userInputWithCursor(){if(this.state==="submit"||this.state==="cancel")return this.masked;let D=this.userInput;if(this.cursor>=D.length)return`${this.masked}${u6.default.inverse(u6.default.hidden("_"))}`;let $=this.masked,X=$.slice(0,this.cursor),Y=$.slice(this.cursor);return`${X}${u6.default.inverse(Y[0])}${Y.slice(1)}`}clear(){this._clearUserInput()}constructor({mask:D,...$}){super($),this._mask=D??"•",this.on("userInput",(X)=>{this._setValue(X)})}};ZG=class ZG extends P4{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(D){super(D,!1),this.options=D.options;let $=this.options.findIndex(({value:Y})=>Y===D.initialValue),X=$===-1?0:$;this.cursor=this.options[X].disabled?r8(X,1,this.options):X,this.changeValue(),this.on("cursor",(Y)=>{switch(Y){case"left":case"up":this.cursor=r8(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=r8(this.cursor,1,this.options);break}this.changeValue()})}};GG=class GG extends P4{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let D=this.userInput;if(this.cursor>=D.length)return`${this.userInput}█`;let $=D.slice(0,this.cursor),[X,...Y]=D.slice(this.cursor);return`${$}${u6.default.inverse(X)}${Y.join("")}`}get cursor(){return this._cursor}constructor(D){super({...D,initialUserInput:D.initialUserInput??D.initialValue}),this.on("userInput",($)=>{this._setValue($)}),this.on("finalize",()=>{this.value||(this.value=D.defaultValue),this.value===void 0&&(this.value="")})}}});import U$ from"node:process";function W0D(){return U$.platform!=="win32"?U$.env.TERM!=="linux":!!U$.env.CI||!!U$.env.WT_SESSION||!!U$.env.TERMINUS_SUBLIME||U$.env.ConEmuTask==="{cmd::Cmder}"||U$.env.TERM_PROGRAM==="Terminus-Sublime"||U$.env.TERM_PROGRAM==="vscode"||U$.env.TERM==="xterm-256color"||U$.env.TERM==="alacritty"||U$.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}function WG(D,$,X){return String(D).normalize().replaceAll(`\r
18
18
  `,`
19
19
  `).split(`
20
20
  `).map((Y)=>y0D(Y,$,X)).join(`
21
- `)}var JD,B7,BG,H0D=()=>process.env.CI==="true",aD=(D,$)=>BG?D:$,V0D,FI,wI,HG,N0D,bD,x4,LuD,IuD,KG,h2,AuD,RuD,juD,M0D,EuD,TuD,CuD,PuD,xuD,SuD,L0D,I0D,A0D,R0D,m2=(D)=>{switch(D){case"initial":case"active":return JD.default.cyan(V0D);case"cancel":return JD.default.red(FI);case"error":return JD.default.yellow(wI);case"submit":return JD.default.green(HG)}},j0D=(D)=>{switch(D){case"initial":case"active":return JD.default.cyan(bD);case"cancel":return JD.default.red(bD);case"error":return JD.default.yellow(bD);case"submit":return JD.default.green(bD)}},E0D=(D)=>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,T0D=(D)=>D===12288||D>=65281&&D<=65376||D>=65504&&D<=65510,C0D=(D)=>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>=9800&&D<=9811||D===9855||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<=12771||D>=12783&&D<=12830||D>=12832&&D<=12871||D>=12880&&D<=19903||D>=19968&&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===94193||D>=94208&&D<=100343||D>=100352&&D<=101589||D>=101632&&D<=101640||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===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<=128727||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<=129672||D>=129680&&D<=129725||D>=129727&&D<=129733||D>=129742&&D<=129755||D>=129760&&D<=129768||D>=129776&&D<=129784||D>=131072&&D<=196605||D>=196608&&D<=262141,UG,f2,y2,qG,b2,P0D,x0D,ZI=(D,$={},X={})=>{let Y=$.limit??1/0,J=$.ellipsis??"",Q=$?.ellipsisWidth??(J?ZI(J,x0D,X).width:0),F=X.ansiWidth??0,w=X.controlWidth??0,Z=X.tabWidth??8,G=X.ambiguousWidth??1,O=X.emojiWidth??2,U=X.fullWidthWidth??2,z=X.regularWidth??1,q=X.wideWidth??2,B=0,K=0,M=D.length,L=0,I=!1,W=M,N=Math.max(0,Y-Q),V=0,R=0,P=0,A=0;D:for(;;){if(R>V||K>=M&&K>B){let _=D.slice(V,R)||D.slice(B,K);L=0;for(let v of _.replaceAll(P0D,"")){let S=v.codePointAt(0)||0;if(T0D(S)?A=U:C0D(S)?A=q:G!==z&&E0D(S)?A=G:A=z,P+A>N&&(W=Math.min(W,Math.max(V,B)+L)),P+A>Y){I=!0;break D}L+=v.length,P+=A}V=R=0}if(K>=M)break;if(b2.lastIndex=K,b2.test(D)){if(L=b2.lastIndex-K,A=L*z,P+A>N&&(W=Math.min(W,K+Math.floor((N-P)/z))),P+A>Y){I=!0;break}P+=A,V=B,R=K,K=B=b2.lastIndex;continue}if(UG.lastIndex=K,UG.test(D)){if(P+F>N&&(W=Math.min(W,K)),P+F>Y){I=!0;break}P+=F,V=B,R=K,K=B=UG.lastIndex;continue}if(f2.lastIndex=K,f2.test(D)){if(L=f2.lastIndex-K,A=L*w,P+A>N&&(W=Math.min(W,K+Math.floor((N-P)/w))),P+A>Y){I=!0;break}P+=A,V=B,R=K,K=B=f2.lastIndex;continue}if(y2.lastIndex=K,y2.test(D)){if(L=y2.lastIndex-K,A=L*Z,P+A>N&&(W=Math.min(W,K+Math.floor((N-P)/Z))),P+A>Y){I=!0;break}P+=A,V=B,R=K,K=B=y2.lastIndex;continue}if(qG.lastIndex=K,qG.test(D)){if(P+O>N&&(W=Math.min(W,K)),P+O>Y){I=!0;break}P+=O,V=B,R=K,K=B=qG.lastIndex;continue}K+=1}return{width:I?N:P,index:I?W:M,truncated:I,ellipsed:I&&Y>=Q}},S0D,K7=(D,$={})=>ZI(D,S0D,$).width,d2="\x1B",GI="›",u0D=39,VG="\x07",OI="[",v0D="]",UI="m",NG,JI,_0D=(D)=>{if(D>=30&&D<=37||D>=90&&D<=97)return 39;if(D>=40&&D<=47||D>=100&&D<=107)return 49;if(D===1||D===2)return 22;if(D===3)return 23;if(D===4)return 24;if(D===7)return 27;if(D===8)return 28;if(D===9)return 29;if(D===0)return 0},YI=(D)=>`${d2}${OI}${D}${UI}`,QI=(D)=>`${d2}${NG}${D}${VG}`,k0D=(D)=>D.map(($)=>K7($)),zG=(D,$,X)=>{let Y=$[Symbol.iterator](),J=!1,Q=!1,F=D.at(-1),w=F===void 0?0:K7(F),Z=Y.next(),G=Y.next(),O=0;for(;!Z.done;){let U=Z.value,z=K7(U);w+z<=X?D[D.length-1]+=U:(D.push(U),w=0),(U===d2||U===GI)&&(J=!0,Q=$.startsWith(NG,O+1)),J?Q?U===VG&&(J=!1,Q=!1):U===UI&&(J=!1):(w+=z,w===X&&!G.done&&(D.push(""),w=0)),Z=G,G=Y.next(),O+=U.length}F=D.at(-1),!w&&F!==void 0&&F.length>0&&D.length>1&&(D[D.length-2]+=D.pop())},f0D=(D)=>{let $=D.split(" "),X=$.length;for(;X>0&&!(K7($[X-1])>0);)X--;return X===$.length?D:$.slice(0,X).join(" ")+$.slice(X).join("")},y0D=(D,$,X={})=>{if(X.trim!==!1&&D.trim()==="")return"";let Y="",J,Q,F=D.split(" "),w=k0D(F),Z=[""];for(let[B,K]of F.entries()){X.trim!==!1&&(Z[Z.length-1]=(Z.at(-1)??"").trimStart());let M=K7(Z.at(-1)??"");if(B!==0&&(M>=$&&(X.wordWrap===!1||X.trim===!1)&&(Z.push(""),M=0),(M>0||X.trim===!1)&&(Z[Z.length-1]+=" ",M++)),X.hard&&w[B]>$){let L=$-M,I=1+Math.floor((w[B]-L-1)/$);Math.floor((w[B]-1)/$)<I&&Z.push(""),zG(Z,K,$);continue}if(M+w[B]>$&&M>0&&w[B]>0){if(X.wordWrap===!1&&M<$){zG(Z,K,$);continue}Z.push("")}if(M+w[B]>$&&X.wordWrap===!1){zG(Z,K,$);continue}Z[Z.length-1]+=K}X.trim!==!1&&(Z=Z.map((B)=>f0D(B)));let G=Z.join(`
21
+ `)}var JD,B7,BG,H0D=()=>process.env.CI==="true",aD=(D,$)=>BG?D:$,V0D,FI,wI,HG,N0D,bD,x4,LuD,IuD,KG,h2,AuD,RuD,juD,M0D,EuD,TuD,CuD,PuD,xuD,SuD,L0D,I0D,A0D,R0D,m2=(D)=>{switch(D){case"initial":case"active":return JD.default.cyan(V0D);case"cancel":return JD.default.red(FI);case"error":return JD.default.yellow(wI);case"submit":return JD.default.green(HG)}},j0D=(D)=>{switch(D){case"initial":case"active":return JD.default.cyan(bD);case"cancel":return JD.default.red(bD);case"error":return JD.default.yellow(bD);case"submit":return JD.default.green(bD)}},E0D=(D)=>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,T0D=(D)=>D===12288||D>=65281&&D<=65376||D>=65504&&D<=65510,C0D=(D)=>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>=9800&&D<=9811||D===9855||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<=12771||D>=12783&&D<=12830||D>=12832&&D<=12871||D>=12880&&D<=19903||D>=19968&&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===94193||D>=94208&&D<=100343||D>=100352&&D<=101589||D>=101632&&D<=101640||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===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<=128727||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<=129672||D>=129680&&D<=129725||D>=129727&&D<=129733||D>=129742&&D<=129755||D>=129760&&D<=129768||D>=129776&&D<=129784||D>=131072&&D<=196605||D>=196608&&D<=262141,UG,f2,y2,qG,b2,P0D,x0D,ZI=(D,$={},X={})=>{let Y=$.limit??1/0,J=$.ellipsis??"",Q=$?.ellipsisWidth??(J?ZI(J,x0D,X).width:0),F=X.ansiWidth??0,w=X.controlWidth??0,Z=X.tabWidth??8,G=X.ambiguousWidth??1,O=X.emojiWidth??2,U=X.fullWidthWidth??2,z=X.regularWidth??1,q=X.wideWidth??2,B=0,K=0,M=D.length,L=0,I=!1,W=M,N=Math.max(0,Y-Q),V=0,R=0,C=0,A=0;D:for(;;){if(R>V||K>=M&&K>B){let _=D.slice(V,R)||D.slice(B,K);L=0;for(let v of _.replaceAll(P0D,"")){let S=v.codePointAt(0)||0;if(T0D(S)?A=U:C0D(S)?A=q:G!==z&&E0D(S)?A=G:A=z,C+A>N&&(W=Math.min(W,Math.max(V,B)+L)),C+A>Y){I=!0;break D}L+=v.length,C+=A}V=R=0}if(K>=M)break;if(b2.lastIndex=K,b2.test(D)){if(L=b2.lastIndex-K,A=L*z,C+A>N&&(W=Math.min(W,K+Math.floor((N-C)/z))),C+A>Y){I=!0;break}C+=A,V=B,R=K,K=B=b2.lastIndex;continue}if(UG.lastIndex=K,UG.test(D)){if(C+F>N&&(W=Math.min(W,K)),C+F>Y){I=!0;break}C+=F,V=B,R=K,K=B=UG.lastIndex;continue}if(f2.lastIndex=K,f2.test(D)){if(L=f2.lastIndex-K,A=L*w,C+A>N&&(W=Math.min(W,K+Math.floor((N-C)/w))),C+A>Y){I=!0;break}C+=A,V=B,R=K,K=B=f2.lastIndex;continue}if(y2.lastIndex=K,y2.test(D)){if(L=y2.lastIndex-K,A=L*Z,C+A>N&&(W=Math.min(W,K+Math.floor((N-C)/Z))),C+A>Y){I=!0;break}C+=A,V=B,R=K,K=B=y2.lastIndex;continue}if(qG.lastIndex=K,qG.test(D)){if(C+O>N&&(W=Math.min(W,K)),C+O>Y){I=!0;break}C+=O,V=B,R=K,K=B=qG.lastIndex;continue}K+=1}return{width:I?N:C,index:I?W:M,truncated:I,ellipsed:I&&Y>=Q}},S0D,K7=(D,$={})=>ZI(D,S0D,$).width,d2="\x1B",GI="›",u0D=39,VG="\x07",OI="[",v0D="]",UI="m",NG,JI,_0D=(D)=>{if(D>=30&&D<=37||D>=90&&D<=97)return 39;if(D>=40&&D<=47||D>=100&&D<=107)return 49;if(D===1||D===2)return 22;if(D===3)return 23;if(D===4)return 24;if(D===7)return 27;if(D===8)return 28;if(D===9)return 29;if(D===0)return 0},YI=(D)=>`${d2}${OI}${D}${UI}`,QI=(D)=>`${d2}${NG}${D}${VG}`,k0D=(D)=>D.map(($)=>K7($)),zG=(D,$,X)=>{let Y=$[Symbol.iterator](),J=!1,Q=!1,F=D.at(-1),w=F===void 0?0:K7(F),Z=Y.next(),G=Y.next(),O=0;for(;!Z.done;){let U=Z.value,z=K7(U);w+z<=X?D[D.length-1]+=U:(D.push(U),w=0),(U===d2||U===GI)&&(J=!0,Q=$.startsWith(NG,O+1)),J?Q?U===VG&&(J=!1,Q=!1):U===UI&&(J=!1):(w+=z,w===X&&!G.done&&(D.push(""),w=0)),Z=G,G=Y.next(),O+=U.length}F=D.at(-1),!w&&F!==void 0&&F.length>0&&D.length>1&&(D[D.length-2]+=D.pop())},f0D=(D)=>{let $=D.split(" "),X=$.length;for(;X>0&&!(K7($[X-1])>0);)X--;return X===$.length?D:$.slice(0,X).join(" ")+$.slice(X).join("")},y0D=(D,$,X={})=>{if(X.trim!==!1&&D.trim()==="")return"";let Y="",J,Q,F=D.split(" "),w=k0D(F),Z=[""];for(let[B,K]of F.entries()){X.trim!==!1&&(Z[Z.length-1]=(Z.at(-1)??"").trimStart());let M=K7(Z.at(-1)??"");if(B!==0&&(M>=$&&(X.wordWrap===!1||X.trim===!1)&&(Z.push(""),M=0),(M>0||X.trim===!1)&&(Z[Z.length-1]+=" ",M++)),X.hard&&w[B]>$){let L=$-M,I=1+Math.floor((w[B]-L-1)/$);Math.floor((w[B]-1)/$)<I&&Z.push(""),zG(Z,K,$);continue}if(M+w[B]>$&&M>0&&w[B]>0){if(X.wordWrap===!1&&M<$){zG(Z,K,$);continue}Z.push("")}if(M+w[B]>$&&X.wordWrap===!1){zG(Z,K,$);continue}Z[Z.length-1]+=K}X.trim!==!1&&(Z=Z.map((B)=>f0D(B)));let G=Z.join(`
22
22
  `),O=G[Symbol.iterator](),U=O.next(),z=O.next(),q=0;for(;!U.done;){let B=U.value,K=z.value;if(Y+=B,B===d2||B===GI){JI.lastIndex=q+1;let L=JI.exec(G)?.groups;if(L?.code!==void 0){let I=Number.parseFloat(L.code);J=I===u0D?void 0:I}else L?.uri!==void 0&&(Q=L.uri.length===0?void 0:L.uri)}let M=J?_0D(J):void 0;K===`
23
23
  `?(Q&&(Y+=QI("")),J&&M&&(Y+=YI(M))):B===`
24
- `&&(J&&M&&(Y+=YI(J)),Q&&(Y+=QI(Q))),q+=B.length,U=z,z=O.next()}return Y},b0D=(D,$,X,Y,J)=>{let Q=$,F=0;for(let w=X;w<Y;w++){let Z=D[w];if(Q=Q-Z.length,F++,Q<=J)break}return{lineCount:Q,removals:F}},g0D=(D)=>{let{cursor:$,options:X,style:Y}=D,J=D.output??process.stdout,Q=_2(J),F=D.columnPadding??0,w=D.rowPadding??4,Z=Q-F,G=FG(J),O=JD.default.dim("..."),U=D.maxItems??Number.POSITIVE_INFINITY,z=Math.max(G-w,0),q=Math.max(Math.min(U,z),5),B=0;$>=q-3&&(B=Math.max(Math.min($-q+3,X.length-q),0));let K=q<X.length&&B>0,M=q<X.length&&B+q<X.length,L=Math.min(B+q,X.length),I=[],W=0;K&&W++,M&&W++;let N=B+(K?1:0),V=L-(M?1:0);for(let P=N;P<V;P++){let A=WG(Y(X[P],P===$),Z,{hard:!0,trim:!1}).split(`
25
- `);I.push(A),W+=A.length}if(W>z){let P=0,A=0,_=W,v=$-N,S=(h,g)=>b0D(I,_,h,g,z);K?({lineCount:_,removals:P}=S(0,v),_>z&&({lineCount:_,removals:A}=S(v+1,I.length))):({lineCount:_,removals:A}=S(v+1,I.length),_>z&&({lineCount:_,removals:P}=S(0,v))),P>0&&(K=!0,I.splice(0,P)),A>0&&(M=!0,I.splice(I.length-A,A))}let R=[];K&&R.push(O);for(let P of I)for(let A of P)R.push(A);return M&&R.push(O),R},c0=(D)=>{let $=D.active??"Yes",X=D.inactive??"No";return new wG({active:$,inactive:X,signal:D.signal,input:D.input,output:D.output,initialValue:D.initialValue??!0,render(){let Y=D.withGuide??T1.withGuide,J=`${Y?`${JD.default.gray(bD)}
24
+ `&&(J&&M&&(Y+=YI(J)),Q&&(Y+=QI(Q))),q+=B.length,U=z,z=O.next()}return Y},b0D=(D,$,X,Y,J)=>{let Q=$,F=0;for(let w=X;w<Y;w++){let Z=D[w];if(Q=Q-Z.length,F++,Q<=J)break}return{lineCount:Q,removals:F}},g0D=(D)=>{let{cursor:$,options:X,style:Y}=D,J=D.output??process.stdout,Q=_2(J),F=D.columnPadding??0,w=D.rowPadding??4,Z=Q-F,G=FG(J),O=JD.default.dim("..."),U=D.maxItems??Number.POSITIVE_INFINITY,z=Math.max(G-w,0),q=Math.max(Math.min(U,z),5),B=0;$>=q-3&&(B=Math.max(Math.min($-q+3,X.length-q),0));let K=q<X.length&&B>0,M=q<X.length&&B+q<X.length,L=Math.min(B+q,X.length),I=[],W=0;K&&W++,M&&W++;let N=B+(K?1:0),V=L-(M?1:0);for(let C=N;C<V;C++){let A=WG(Y(X[C],C===$),Z,{hard:!0,trim:!1}).split(`
25
+ `);I.push(A),W+=A.length}if(W>z){let C=0,A=0,_=W,v=$-N,S=(h,g)=>b0D(I,_,h,g,z);K?({lineCount:_,removals:C}=S(0,v),_>z&&({lineCount:_,removals:A}=S(v+1,I.length))):({lineCount:_,removals:A}=S(v+1,I.length),_>z&&({lineCount:_,removals:C}=S(0,v))),C>0&&(K=!0,I.splice(0,C)),A>0&&(M=!0,I.splice(I.length-A,A))}let R=[];K&&R.push(O);for(let C of I)for(let A of C)R.push(A);return M&&R.push(O),R},c0=(D)=>{let $=D.active??"Yes",X=D.inactive??"No";return new wG({active:$,inactive:X,signal:D.signal,input:D.input,output:D.output,initialValue:D.initialValue??!0,render(){let Y=D.withGuide??T1.withGuide,J=`${Y?`${JD.default.gray(bD)}
26
26
  `:""}${m2(this.state)} ${D.message}
27
27
  `,Q=this.value?$:X;switch(this.state){case"submit":{let F=Y?`${JD.default.gray(bD)} `:"";return`${J}${F}${JD.default.dim(Q)}`}case"cancel":{let F=Y?`${JD.default.gray(bD)} `:"";return`${J}${F}${JD.default.strikethrough(JD.default.dim(Q))}${Y?`
28
28
  ${JD.default.gray(bD)}`:""}`}default:{let F=Y?`${JD.default.cyan(bD)} `:"",w=Y?JD.default.cyan(x4):"";return`${J}${F}${this.value?`${JD.default.green(KG)} ${$}`:`${JD.default.dim(h2)} ${JD.default.dim($)}`}${D.vertical?Y?`
@@ -41,12 +41,12 @@ ${F}${JD.default.yellow(this.error)}
41
41
  `}case"submit":{let Q=$?`${JD.default.gray(bD)} `:"",F=J?JD.default.dim(J):"";return`${X}${Q}${F}`}case"cancel":{let Q=$?`${JD.default.gray(bD)} `:"",F=J?JD.default.strikethrough(JD.default.dim(J)):"";return`${X}${Q}${F}${J&&$?`
42
42
  ${JD.default.gray(bD)}`:""}`}default:{let Q=$?`${JD.default.cyan(bD)} `:"",F=$?JD.default.cyan(x4):"";return`${X}${Q}${Y}
43
43
  ${F}
44
- `}}}}).prompt(),h0D,A0=({indicator:D="dots",onCancel:$,output:X=process.stdout,cancelMessage:Y,errorMessage:J,frames:Q=BG?["◒","◐","◓","◑"]:["•","o","O","0"],delay:F=BG?80:120,signal:w,...Z}={})=>{let G=H0D(),O,U,z=!1,q=!1,B="",K,M=performance.now(),L=_2(X),I=Z?.styleFrame??h0D,W=(l)=>{let f=l>1?J??T1.messages.error:Y??T1.messages.cancel;q=l===1,z&&(g(f,l),q&&typeof $=="function"&&$())},N=()=>W(2),V=()=>W(1),R=()=>{process.on("uncaughtExceptionMonitor",N),process.on("unhandledRejection",N),process.on("SIGINT",V),process.on("SIGTERM",V),process.on("exit",W),w&&w.addEventListener("abort",V)},P=()=>{process.removeListener("uncaughtExceptionMonitor",N),process.removeListener("unhandledRejection",N),process.removeListener("SIGINT",V),process.removeListener("SIGTERM",V),process.removeListener("exit",W),w&&w.removeEventListener("abort",V)},A=()=>{if(K===void 0)return;G&&X.write(`
44
+ `}}}}).prompt(),h0D,A0=({indicator:D="dots",onCancel:$,output:X=process.stdout,cancelMessage:Y,errorMessage:J,frames:Q=BG?["◒","◐","◓","◑"]:["•","o","O","0"],delay:F=BG?80:120,signal:w,...Z}={})=>{let G=H0D(),O,U,z=!1,q=!1,B="",K,M=performance.now(),L=_2(X),I=Z?.styleFrame??h0D,W=(l)=>{let f=l>1?J??T1.messages.error:Y??T1.messages.cancel;q=l===1,z&&(g(f,l),q&&typeof $=="function"&&$())},N=()=>W(2),V=()=>W(1),R=()=>{process.on("uncaughtExceptionMonitor",N),process.on("unhandledRejection",N),process.on("SIGINT",V),process.on("SIGTERM",V),process.on("exit",W),w&&w.addEventListener("abort",V)},C=()=>{process.removeListener("uncaughtExceptionMonitor",N),process.removeListener("unhandledRejection",N),process.removeListener("SIGINT",V),process.removeListener("SIGTERM",V),process.removeListener("exit",W),w&&w.removeEventListener("abort",V)},A=()=>{if(K===void 0)return;G&&X.write(`
45
45
  `);let l=WG(K,L,{hard:!0,trim:!1}).split(`
46
46
  `);l.length>1&&X.write(B7.cursor.up(l.length-1)),X.write(B7.cursor.to(0)),X.write(B7.erase.down())},_=(l)=>l.replace(/\.+$/,""),v=(l)=>{let f=(performance.now()-l)/1000,j=Math.floor(f/60),x=Math.floor(f%60);return j>0?`[${j}m ${x}s]`:`[${x}s]`},S=Z.withGuide??T1.withGuide,h=(l="")=>{z=!0,O=eL({output:X}),B=_(l),M=performance.now(),S&&X.write(`${JD.default.gray(bD)}
47
47
  `);let f=0,j=0;R(),U=setInterval(()=>{if(G&&B===K)return;A(),K=B;let x=I(Q[f]),u;if(G)u=`${x} ${B}...`;else if(D==="timer")u=`${x} ${B} ${v(M)}`;else{let d=".".repeat(Math.floor(j)).slice(0,3);u=`${x} ${B}${d}`}let y=WG(u,L,{hard:!0,trim:!1});X.write(y),f=f+1<Q.length?f+1:0,j=j<4?j+0.125:0},F)},g=(l="",f=0,j=!1)=>{if(!z)return;z=!1,clearInterval(U),A();let x=f===0?JD.default.green(HG):f===1?JD.default.red(FI):JD.default.red(wI);B=l??B,j||(D==="timer"?X.write(`${x} ${B} ${v(M)}
48
48
  `):X.write(`${x} ${B}
49
- `)),P(),O()};return{start:h,stop:(l="")=>g(l,0),message:(l="")=>{B=_(l??B)},cancel:(l="")=>g(l,1),error:(l="")=>g(l,2),clear:()=>g("",0,!0),get isCancelled(){return q}}},uuD,g2=(D,$)=>D.includes(`
49
+ `)),C(),O()};return{start:h,stop:(l="")=>g(l,0),message:(l="")=>{B=_(l??B)},cancel:(l="")=>g(l,1),error:(l="")=>g(l,2),clear:()=>g("",0,!0),get isCancelled(){return q}}},uuD,g2=(D,$)=>D.includes(`
50
50
  `)?D.split(`
51
51
  `).map((X)=>$(X)).join(`
52
52
  `):$(D),t1=(D)=>{let $=(X,Y)=>{let J=X.label??String(X.value);switch(Y){case"disabled":return`${JD.default.gray(h2)} ${g2(J,JD.default.gray)}${X.hint?` ${JD.default.dim(`(${X.hint??"disabled"})`)}`:""}`;case"selected":return`${g2(J,JD.default.dim)}`;case"active":return`${JD.default.green(KG)} ${J}${X.hint?` ${JD.default.dim(`(${X.hint})`)}`:""}`;case"cancelled":return`${g2(J,(Q)=>JD.default.strikethrough(JD.default.dim(Q)))}`;default:return`${JD.default.dim(h2)} ${g2(J,JD.default.dim)}`}};return new ZG({options:D.options,signal:D.signal,input:D.input,output:D.output,initialValue:D.initialValue,render(){let X=D.withGuide??T1.withGuide,Y=`${m2(this.state)} `,J=`${j0D(this.state)} `,Q=k2(D.output,D.message,J,Y),F=`${X?`${JD.default.gray(bD)}
@@ -75,7 +75,7 @@ ${O.stack}`}else{var K;w=(K=Q===null||Q===void 0?void 0:Q.stack)!==null&&K!==voi
75
75
  import ws from "ws"
76
76
  new RealtimeClient(url, { transport: ws })`}}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){let D=this.detectEnvironment();if(D.constructor)return D.constructor;let $=D.error||"WebSocket not supported in this environment.";if(D.workaround)$+=`
77
77
 
78
- Suggested solution: ${D.workaround}`;throw Error($)}static createWebSocket(D,$){return new(this.getWebSocketConstructor())(D,$)}static isWebSocketSupported(){try{let D=this.detectEnvironment();return D.type==="native"||D.type==="ws"}catch(D){return!1}}}mA.WebSocketFactory=kG;mA.default=kG});var nA=T((cA)=>{Object.defineProperty(cA,"__esModule",{value:!0});cA.version=void 0;cA.version="2.95.3"});var JJ=T((sA)=>{Object.defineProperty(sA,"__esModule",{value:!0});sA.CONNECTION_STATE=sA.TRANSPORTS=sA.CHANNEL_EVENTS=sA.CHANNEL_STATES=sA.SOCKET_STATES=sA.MAX_PUSH_BUFFER_SIZE=sA.WS_CLOSE_NORMAL=sA.DEFAULT_TIMEOUT=sA.VERSION=sA.DEFAULT_VSN=sA.VSN_2_0_0=sA.VSN_1_0_0=sA.DEFAULT_VERSION=void 0;var tA=nA();sA.DEFAULT_VERSION=`realtime-js/${tA.version}`;sA.VSN_1_0_0="1.0.0";sA.VSN_2_0_0="2.0.0";sA.DEFAULT_VSN=sA.VSN_2_0_0;sA.VERSION=tA.version;sA.DEFAULT_TIMEOUT=1e4;sA.WS_CLOSE_NORMAL=1000;sA.MAX_PUSH_BUFFER_SIZE=100;var iA;(function(D){D[D.connecting=0]="connecting",D[D.open=1]="open",D[D.closing=2]="closing",D[D.closed=3]="closed"})(iA||(sA.SOCKET_STATES=iA={}));var pA;(function(D){D.closed="closed",D.errored="errored",D.joined="joined",D.joining="joining",D.leaving="leaving"})(pA||(sA.CHANNEL_STATES=pA={}));var rA;(function(D){D.close="phx_close",D.error="phx_error",D.join="phx_join",D.reply="phx_reply",D.leave="phx_leave",D.access_token="access_token"})(rA||(sA.CHANNEL_EVENTS=rA={}));var oA;(function(D){D.websocket="websocket"})(oA||(sA.TRANSPORTS=oA={}));var aA;(function(D){D.Connecting="connecting",D.Open="open",D.Closing="closing",D.Closed="closed"})(aA||(sA.CONNECTION_STATE=aA={}))});var JR=T((XR)=>{Object.defineProperty(XR,"__esModule",{value:!0});class $R{constructor(D){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=D!==null&&D!==void 0?D:[]}encode(D,$){if(D.event===this.BROADCAST_EVENT&&!(D.payload instanceof ArrayBuffer)&&typeof D.payload.event==="string")return $(this._binaryEncodeUserBroadcastPush(D));let X=[D.join_ref,D.ref,D.topic,D.event,D.payload];return $(JSON.stringify(X))}_binaryEncodeUserBroadcastPush(D){var $;if(this._isArrayBuffer(($=D.payload)===null||$===void 0?void 0:$.payload))return this._encodeBinaryUserBroadcastPush(D);else return this._encodeJsonUserBroadcastPush(D)}_encodeBinaryUserBroadcastPush(D){var $,X;let Y=(X=($=D.payload)===null||$===void 0?void 0:$.payload)!==null&&X!==void 0?X:new ArrayBuffer(0);return this._encodeUserBroadcastPush(D,this.BINARY_ENCODING,Y)}_encodeJsonUserBroadcastPush(D){var $,X;let Y=(X=($=D.payload)===null||$===void 0?void 0:$.payload)!==null&&X!==void 0?X:{},Q=new TextEncoder().encode(JSON.stringify(Y)).buffer;return this._encodeUserBroadcastPush(D,this.JSON_ENCODING,Q)}_encodeUserBroadcastPush(D,$,X){var Y,J;let Q=D.topic,F=(Y=D.ref)!==null&&Y!==void 0?Y:"",w=(J=D.join_ref)!==null&&J!==void 0?J:"",Z=D.payload.event,G=this.allowedMetadataKeys?this._pick(D.payload,this.allowedMetadataKeys):{},O=Object.keys(G).length===0?"":JSON.stringify(G);if(w.length>255)throw Error(`joinRef length ${w.length} exceeds maximum of 255`);if(F.length>255)throw Error(`ref length ${F.length} exceeds maximum of 255`);if(Q.length>255)throw Error(`topic length ${Q.length} exceeds maximum of 255`);if(Z.length>255)throw Error(`userEvent length ${Z.length} exceeds maximum of 255`);if(O.length>255)throw Error(`metadata length ${O.length} exceeds maximum of 255`);let U=this.USER_BROADCAST_PUSH_META_LENGTH+w.length+F.length+Q.length+Z.length+O.length,z=new ArrayBuffer(this.HEADER_LENGTH+U),q=new DataView(z),B=0;q.setUint8(B++,this.KINDS.userBroadcastPush),q.setUint8(B++,w.length),q.setUint8(B++,F.length),q.setUint8(B++,Q.length),q.setUint8(B++,Z.length),q.setUint8(B++,O.length),q.setUint8(B++,$),Array.from(w,(M)=>q.setUint8(B++,M.charCodeAt(0))),Array.from(F,(M)=>q.setUint8(B++,M.charCodeAt(0))),Array.from(Q,(M)=>q.setUint8(B++,M.charCodeAt(0))),Array.from(Z,(M)=>q.setUint8(B++,M.charCodeAt(0))),Array.from(O,(M)=>q.setUint8(B++,M.charCodeAt(0)));var K=new Uint8Array(z.byteLength+X.byteLength);return K.set(new Uint8Array(z),0),K.set(new Uint8Array(X),z.byteLength),K.buffer}decode(D,$){if(this._isArrayBuffer(D)){let X=this._binaryDecode(D);return $(X)}if(typeof D==="string"){let X=JSON.parse(D),[Y,J,Q,F,w]=X;return $({join_ref:Y,ref:J,topic:Q,event:F,payload:w})}return $({})}_binaryDecode(D){let $=new DataView(D),X=$.getUint8(0),Y=new TextDecoder;switch(X){case this.KINDS.userBroadcast:return this._decodeUserBroadcast(D,$,Y)}}_decodeUserBroadcast(D,$,X){let Y=$.getUint8(1),J=$.getUint8(2),Q=$.getUint8(3),F=$.getUint8(4),w=this.HEADER_LENGTH+4,Z=X.decode(D.slice(w,w+Y));w=w+Y;let G=X.decode(D.slice(w,w+J));w=w+J;let O=X.decode(D.slice(w,w+Q));w=w+Q;let U=D.slice(w,D.byteLength),z=F===this.JSON_ENCODING?JSON.parse(X.decode(U)):U,q={type:this.BROADCAST_EVENT,event:G,payload:z};if(Q>0)q.meta=JSON.parse(O);return{join_ref:null,ref:null,topic:Z,event:this.BROADCAST_EVENT,payload:q}}_isArrayBuffer(D){var $;return D instanceof ArrayBuffer||(($=D===null||D===void 0?void 0:D.constructor)===null||$===void 0?void 0:$.name)==="ArrayBuffer"}_pick(D,$){if(!D||typeof D!=="object")return{};return Object.fromEntries(Object.entries(D).filter(([X])=>$.includes(X)))}}XR.default=$R});var yG=T((QR)=>{Object.defineProperty(QR,"__esModule",{value:!0});class YR{constructor(D,$){this.callback=D,this.timerCalc=$,this.timer=void 0,this.tries=0,this.callback=D,this.timerCalc=$}reset(){this.tries=0,clearTimeout(this.timer),this.timer=void 0}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}QR.default=YR});var YJ=T((FR)=>{Object.defineProperty(FR,"__esModule",{value:!0});FR.httpEndpointURL=FR.toTimestampString=FR.toArray=FR.toJson=FR.toNumber=FR.toBoolean=FR.convertCell=FR.convertColumn=FR.convertChangeData=FR.PostgresTypes=void 0;var Y0;(function(D){D.abstime="abstime",D.bool="bool",D.date="date",D.daterange="daterange",D.float4="float4",D.float8="float8",D.int2="int2",D.int4="int4",D.int4range="int4range",D.int8="int8",D.int8range="int8range",D.json="json",D.jsonb="jsonb",D.money="money",D.numeric="numeric",D.oid="oid",D.reltime="reltime",D.text="text",D.time="time",D.timestamp="timestamp",D.timestamptz="timestamptz",D.timetz="timetz",D.tsrange="tsrange",D.tstzrange="tstzrange"})(Y0||(FR.PostgresTypes=Y0={}));var n1D=(D,$,X={})=>{var Y;let J=(Y=X.skipTypes)!==null&&Y!==void 0?Y:[];if(!$)return{};return Object.keys($).reduce((Q,F)=>{return Q[F]=FR.convertColumn(F,D,$,J),Q},{})};FR.convertChangeData=n1D;var i1D=(D,$,X,Y)=>{let J=$.find((w)=>w.name===D),Q=J===null||J===void 0?void 0:J.type,F=X[D];if(Q&&!Y.includes(Q))return FR.convertCell(Q,F);return bG(F)};FR.convertColumn=i1D;var p1D=(D,$)=>{if(D.charAt(0)==="_"){let X=D.slice(1,D.length);return FR.toArray($,X)}switch(D){case Y0.bool:return FR.toBoolean($);case Y0.float4:case Y0.float8:case Y0.int2:case Y0.int4:case Y0.int8:case Y0.numeric:case Y0.oid:return FR.toNumber($);case Y0.json:case Y0.jsonb:return FR.toJson($);case Y0.timestamp:return FR.toTimestampString($);case Y0.abstime:case Y0.date:case Y0.daterange:case Y0.int4range:case Y0.int8range:case Y0.money:case Y0.reltime:case Y0.text:case Y0.time:case Y0.timestamptz:case Y0.timetz:case Y0.tsrange:case Y0.tstzrange:return bG($);default:return bG($)}};FR.convertCell=p1D;var bG=(D)=>{return D},r1D=(D)=>{switch(D){case"t":return!0;case"f":return!1;default:return D}};FR.toBoolean=r1D;var o1D=(D)=>{if(typeof D==="string"){let $=parseFloat(D);if(!Number.isNaN($))return $}return D};FR.toNumber=o1D;var a1D=(D)=>{if(typeof D==="string")try{return JSON.parse(D)}catch($){return D}return D};FR.toJson=a1D;var t1D=(D,$)=>{if(typeof D!=="string")return D;let X=D.length-1,Y=D[X];if(D[0]==="{"&&Y==="}"){let Q,F=D.slice(1,X);try{Q=JSON.parse("["+F+"]")}catch(w){Q=F?F.split(","):[]}return Q.map((w)=>FR.convertCell($,w))}return D};FR.toArray=t1D;var s1D=(D)=>{if(typeof D==="string")return D.replace(" ","T");return D};FR.toTimestampString=s1D;var e1D=(D)=>{let $=new URL(D);if($.protocol=$.protocol.replace(/^ws/i,"http"),$.pathname=$.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),$.pathname===""||$.pathname==="/")$.pathname="/api/broadcast";else $.pathname=$.pathname+"/api/broadcast";return $.href};FR.httpEndpointURL=e1D});var WR=T((KR)=>{Object.defineProperty(KR,"__esModule",{value:!0});var X$D=JJ();class BR{constructor(D,$,X={},Y=X$D.DEFAULT_TIMEOUT){this.channel=D,this.event=$,this.payload=X,this.timeout=Y,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(D){this.timeout=D,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){if(this._hasReceived("timeout"))return;this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()})}updatePayload(D){this.payload=Object.assign(Object.assign({},this.payload),D)}receive(D,$){var X;if(this._hasReceived(D))$((X=this.receivedResp)===null||X===void 0?void 0:X.response);return this.recHooks.push({status:D,callback:$}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);let D=($)=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=$,this._matchReceive($)};this.channel._on(this.refEvent,{},D),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(D,$){if(this.refEvent)this.channel._trigger(this.refEvent,{status:D,response:$})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){if(!this.refEvent)return;this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:D,response:$}){this.recHooks.filter((X)=>X.status===D).forEach((X)=>X.callback($))}_hasReceived(D){return this.receivedResp&&this.receivedResp.status===D}}KR.default=BR});var hG=T((VR)=>{Object.defineProperty(VR,"__esModule",{value:!0});VR.REALTIME_PRESENCE_LISTEN_EVENTS=void 0;var HR;(function(D){D.SYNC="sync",D.JOIN="join",D.LEAVE="leave"})(HR||(VR.REALTIME_PRESENCE_LISTEN_EVENTS=HR={}));class E7{constructor(D,$){this.channel=D,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};let X=($===null||$===void 0?void 0:$.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(X.state,{},(Y)=>{let{onJoin:J,onLeave:Q,onSync:F}=this.caller;this.joinRef=this.channel._joinRef(),this.state=E7.syncState(this.state,Y,J,Q),this.pendingDiffs.forEach((w)=>{this.state=E7.syncDiff(this.state,w,J,Q)}),this.pendingDiffs=[],F()}),this.channel._on(X.diff,{},(Y)=>{let{onJoin:J,onLeave:Q,onSync:F}=this.caller;if(this.inPendingSyncState())this.pendingDiffs.push(Y);else this.state=E7.syncDiff(this.state,Y,J,Q),F()}),this.onJoin((Y,J,Q)=>{this.channel._trigger("presence",{event:"join",key:Y,currentPresences:J,newPresences:Q})}),this.onLeave((Y,J,Q)=>{this.channel._trigger("presence",{event:"leave",key:Y,currentPresences:J,leftPresences:Q})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(D,$,X,Y){let J=this.cloneDeep(D),Q=this.transformState($),F={},w={};return this.map(J,(Z,G)=>{if(!Q[Z])w[Z]=G}),this.map(Q,(Z,G)=>{let O=J[Z];if(O){let U=G.map((K)=>K.presence_ref),z=O.map((K)=>K.presence_ref),q=G.filter((K)=>z.indexOf(K.presence_ref)<0),B=O.filter((K)=>U.indexOf(K.presence_ref)<0);if(q.length>0)F[Z]=q;if(B.length>0)w[Z]=B}else F[Z]=G}),this.syncDiff(J,{joins:F,leaves:w},X,Y)}static syncDiff(D,$,X,Y){let{joins:J,leaves:Q}={joins:this.transformState($.joins),leaves:this.transformState($.leaves)};if(!X)X=()=>{};if(!Y)Y=()=>{};return this.map(J,(F,w)=>{var Z;let G=(Z=D[F])!==null&&Z!==void 0?Z:[];if(D[F]=this.cloneDeep(w),G.length>0){let O=D[F].map((z)=>z.presence_ref),U=G.filter((z)=>O.indexOf(z.presence_ref)<0);D[F].unshift(...U)}X(F,G,w)}),this.map(Q,(F,w)=>{let Z=D[F];if(!Z)return;let G=w.map((O)=>O.presence_ref);if(Z=Z.filter((O)=>G.indexOf(O.presence_ref)<0),D[F]=Z,Y(F,Z,w),Z.length===0)delete D[F]}),D}static map(D,$){return Object.getOwnPropertyNames(D).map((X)=>$(X,D[X]))}static transformState(D){return D=this.cloneDeep(D),Object.getOwnPropertyNames(D).reduce(($,X)=>{let Y=D[X];if("metas"in Y)$[X]=Y.metas.map((J)=>{return J.presence_ref=J.phx_ref,delete J.phx_ref,delete J.phx_ref_prev,J});else $[X]=Y;return $},{})}static cloneDeep(D){return JSON.parse(JSON.stringify(D))}onJoin(D){this.caller.onJoin=D}onLeave(D){this.caller.onLeave=D}onSync(D){this.caller.onSync=D}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}VR.default=E7});var dG=T((IR)=>{Object.defineProperty(IR,"__esModule",{value:!0});IR.REALTIME_CHANNEL_STATES=IR.REALTIME_SUBSCRIBE_STATES=IR.REALTIME_LISTEN_TYPES=IR.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT=void 0;var QJ=lD(),Q0=JJ(),mG=QJ.__importDefault(WR()),Q$D=QJ.__importDefault(yG()),F$D=QJ.__importDefault(hG()),MR=QJ.__importStar(YJ()),w$D=YJ(),LR;(function(D){D.ALL="*",D.INSERT="INSERT",D.UPDATE="UPDATE",D.DELETE="DELETE"})(LR||(IR.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT=LR={}));var T7;(function(D){D.BROADCAST="broadcast",D.PRESENCE="presence",D.POSTGRES_CHANGES="postgres_changes",D.SYSTEM="system"})(T7||(IR.REALTIME_LISTEN_TYPES=T7={}));var $6;(function(D){D.SUBSCRIBED="SUBSCRIBED",D.TIMED_OUT="TIMED_OUT",D.CLOSED="CLOSED",D.CHANNEL_ERROR="CHANNEL_ERROR"})($6||(IR.REALTIME_SUBSCRIBE_STATES=$6={}));IR.REALTIME_CHANNEL_STATES=Q0.CHANNEL_STATES;class D9{constructor(D,$={config:{}},X){var Y,J;if(this.topic=D,this.params=$,this.socket=X,this.bindings={},this.state=Q0.CHANNEL_STATES.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=D.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},$.config),this.timeout=this.socket.timeout,this.joinPush=new mG.default(this,Q0.CHANNEL_EVENTS.join,this.params,this.timeout),this.rejoinTimer=new Q$D.default(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=Q0.CHANNEL_STATES.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach((Q)=>Q.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=Q0.CHANNEL_STATES.closed,this.socket._remove(this)}),this._onError((Q)=>{if(this._isLeaving()||this._isClosed())return;this.socket.log("channel",`error ${this.topic}`,Q),this.state=Q0.CHANNEL_STATES.errored,this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{if(!this._isJoining())return;this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=Q0.CHANNEL_STATES.errored,this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("error",(Q)=>{if(this._isLeaving()||this._isClosed())return;this.socket.log("channel",`error ${this.topic}`,Q),this.state=Q0.CHANNEL_STATES.errored,this.rejoinTimer.scheduleTimeout()}),this._on(Q0.CHANNEL_EVENTS.reply,{},(Q,F)=>{this._trigger(this._replyEventName(F),Q)}),this.presence=new F$D.default(this),this.broadcastEndpointURL=(0,w$D.httpEndpointURL)(this.socket.endPoint),this.private=this.params.config.private||!1,!this.private&&((J=(Y=this.params.config)===null||Y===void 0?void 0:Y.broadcast)===null||J===void 0?void 0:J.replay))throw`tried to use replay on public channel '${this.topic}'. It must be a private channel.`}subscribe(D,$=this.timeout){var X,Y,J;if(!this.socket.isConnected())this.socket.connect();if(this.state==Q0.CHANNEL_STATES.closed){let{config:{broadcast:Q,presence:F,private:w}}=this.params,Z=(Y=(X=this.bindings.postgres_changes)===null||X===void 0?void 0:X.map((z)=>z.filter))!==null&&Y!==void 0?Y:[],G=!!this.bindings[T7.PRESENCE]&&this.bindings[T7.PRESENCE].length>0||((J=this.params.config.presence)===null||J===void 0?void 0:J.enabled)===!0,O={},U={broadcast:Q,presence:Object.assign(Object.assign({},F),{enabled:G}),postgres_changes:Z,private:w};if(this.socket.accessTokenValue)O.access_token=this.socket.accessTokenValue;this._onError((z)=>D===null||D===void 0?void 0:D($6.CHANNEL_ERROR,z)),this._onClose(()=>D===null||D===void 0?void 0:D($6.CLOSED)),this.updateJoinPayload(Object.assign({config:U},O)),this.joinedOnce=!0,this._rejoin($),this.joinPush.receive("ok",async({postgres_changes:z})=>{var q;if(!this.socket._isManualToken())this.socket.setAuth();if(z===void 0){D===null||D===void 0||D($6.SUBSCRIBED);return}else{let B=this.bindings.postgres_changes,K=(q=B===null||B===void 0?void 0:B.length)!==null&&q!==void 0?q:0,M=[];for(let L=0;L<K;L++){let I=B[L],{filter:{event:W,schema:N,table:V,filter:R}}=I,P=z&&z[L];if(P&&P.event===W&&D9.isFilterValueEqual(P.schema,N)&&D9.isFilterValueEqual(P.table,V)&&D9.isFilterValueEqual(P.filter,R))M.push(Object.assign(Object.assign({},I),{id:P.id}));else{this.unsubscribe(),this.state=Q0.CHANNEL_STATES.errored,D===null||D===void 0||D($6.CHANNEL_ERROR,Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=M,D&&D($6.SUBSCRIBED);return}}).receive("error",(z)=>{this.state=Q0.CHANNEL_STATES.errored,D===null||D===void 0||D($6.CHANNEL_ERROR,Error(JSON.stringify(Object.values(z).join(", ")||"error")));return}).receive("timeout",()=>{D===null||D===void 0||D($6.TIMED_OUT);return})}return this}presenceState(){return this.presence.state}async track(D,$={}){return await this.send({type:"presence",event:"track",payload:D},$.timeout||this.timeout)}async untrack(D={}){return await this.send({type:"presence",event:"untrack"},D)}on(D,$,X){if(this.state===Q0.CHANNEL_STATES.joined&&D===T7.PRESENCE)this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(async()=>await this.subscribe());return this._on(D,$,X)}async httpSend(D,$,X={}){var Y;if($===void 0||$===null)return Promise.reject("Payload is required for httpSend()");let J={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};if(this.socket.accessTokenValue)J.Authorization=`Bearer ${this.socket.accessTokenValue}`;let Q={method:"POST",headers:J,body:JSON.stringify({messages:[{topic:this.subTopic,event:D,payload:$,private:this.private}]})},F=await this._fetchWithTimeout(this.broadcastEndpointURL,Q,(Y=X.timeout)!==null&&Y!==void 0?Y:this.timeout);if(F.status===202)return{success:!0};let w=F.statusText;try{let Z=await F.json();w=Z.error||Z.message||w}catch(Z){}return Promise.reject(Error(w))}async send(D,$={}){var X,Y;if(!this._canPush()&&D.type==="broadcast"){console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");let{event:J,payload:Q}=D,F={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};if(this.socket.accessTokenValue)F.Authorization=`Bearer ${this.socket.accessTokenValue}`;let w={method:"POST",headers:F,body:JSON.stringify({messages:[{topic:this.subTopic,event:J,payload:Q,private:this.private}]})};try{let Z=await this._fetchWithTimeout(this.broadcastEndpointURL,w,(X=$.timeout)!==null&&X!==void 0?X:this.timeout);return await((Y=Z.body)===null||Y===void 0?void 0:Y.cancel()),Z.ok?"ok":"error"}catch(Z){if(Z.name==="AbortError")return"timed out";else return"error"}}else return new Promise((J)=>{var Q,F,w;let Z=this._push(D.type,D,$.timeout||this.timeout);if(D.type==="broadcast"&&!((w=(F=(Q=this.params)===null||Q===void 0?void 0:Q.config)===null||F===void 0?void 0:F.broadcast)===null||w===void 0?void 0:w.ack))J("ok");Z.receive("ok",()=>J("ok")),Z.receive("error",()=>J("error")),Z.receive("timeout",()=>J("timed out"))})}updateJoinPayload(D){this.joinPush.updatePayload(D)}unsubscribe(D=this.timeout){this.state=Q0.CHANNEL_STATES.leaving;let $=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(Q0.CHANNEL_EVENTS.close,"leave",this._joinRef())};this.joinPush.destroy();let X=null;return new Promise((Y)=>{if(X=new mG.default(this,Q0.CHANNEL_EVENTS.leave,{},D),X.receive("ok",()=>{$(),Y("ok")}).receive("timeout",()=>{$(),Y("timed out")}).receive("error",()=>{Y("error")}),X.send(),!this._canPush())X.trigger("ok",{})}).finally(()=>{X===null||X===void 0||X.destroy()})}teardown(){this.pushBuffer.forEach((D)=>D.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=Q0.CHANNEL_STATES.closed,this.bindings={}}async _fetchWithTimeout(D,$,X){let Y=new AbortController,J=setTimeout(()=>Y.abort(),X),Q=await this.socket.fetch(D,Object.assign(Object.assign({},$),{signal:Y.signal}));return clearTimeout(J),Q}_push(D,$,X=this.timeout){if(!this.joinedOnce)throw`tried to push '${D}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let Y=new mG.default(this,D,$,X);if(this._canPush())Y.send();else this._addToPushBuffer(Y);return Y}_addToPushBuffer(D){if(D.startTimeout(),this.pushBuffer.push(D),this.pushBuffer.length>Q0.MAX_PUSH_BUFFER_SIZE){let $=this.pushBuffer.shift();if($)$.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${$.event}`,$.payload)}}_onMessage(D,$,X){return $}_isMember(D){return this.topic===D}_joinRef(){return this.joinPush.ref}_trigger(D,$,X){var Y,J;let Q=D.toLocaleLowerCase(),{close:F,error:w,leave:Z,join:G}=Q0.CHANNEL_EVENTS;if(X&&[F,w,Z,G].indexOf(Q)>=0&&X!==this._joinRef())return;let U=this._onMessage(Q,$,X);if($&&!U)throw"channel onMessage callbacks must return the payload, modified or unmodified";if(["insert","update","delete"].includes(Q))(Y=this.bindings.postgres_changes)===null||Y===void 0||Y.filter((z)=>{var q,B,K;return((q=z.filter)===null||q===void 0?void 0:q.event)==="*"||((K=(B=z.filter)===null||B===void 0?void 0:B.event)===null||K===void 0?void 0:K.toLocaleLowerCase())===Q}).map((z)=>z.callback(U,X));else(J=this.bindings[Q])===null||J===void 0||J.filter((z)=>{var q,B,K,M,L,I;if(["broadcast","presence","postgres_changes"].includes(Q))if("id"in z){let W=z.id,N=(q=z.filter)===null||q===void 0?void 0:q.event;return W&&((B=$.ids)===null||B===void 0?void 0:B.includes(W))&&(N==="*"||(N===null||N===void 0?void 0:N.toLocaleLowerCase())===((K=$.data)===null||K===void 0?void 0:K.type.toLocaleLowerCase()))}else{let W=(L=(M=z===null||z===void 0?void 0:z.filter)===null||M===void 0?void 0:M.event)===null||L===void 0?void 0:L.toLocaleLowerCase();return W==="*"||W===((I=$===null||$===void 0?void 0:$.event)===null||I===void 0?void 0:I.toLocaleLowerCase())}else return z.type.toLocaleLowerCase()===Q}).map((z)=>{if(typeof U==="object"&&"ids"in U){let q=U.data,{schema:B,table:K,commit_timestamp:M,type:L,errors:I}=q;U=Object.assign(Object.assign({},{schema:B,table:K,commit_timestamp:M,eventType:L,new:{},old:{},errors:I}),this._getPayloadRecords(q))}z.callback(U,X)})}_isClosed(){return this.state===Q0.CHANNEL_STATES.closed}_isJoined(){return this.state===Q0.CHANNEL_STATES.joined}_isJoining(){return this.state===Q0.CHANNEL_STATES.joining}_isLeaving(){return this.state===Q0.CHANNEL_STATES.leaving}_replyEventName(D){return`chan_reply_${D}`}_on(D,$,X){let Y=D.toLocaleLowerCase(),J={type:Y,filter:$,callback:X};if(this.bindings[Y])this.bindings[Y].push(J);else this.bindings[Y]=[J];return this}_off(D,$){let X=D.toLocaleLowerCase();if(this.bindings[X])this.bindings[X]=this.bindings[X].filter((Y)=>{var J;return!(((J=Y.type)===null||J===void 0?void 0:J.toLocaleLowerCase())===X&&D9.isEqual(Y.filter,$))});return this}static isEqual(D,$){if(Object.keys(D).length!==Object.keys($).length)return!1;for(let X in D)if(D[X]!==$[X])return!1;return!0}static isFilterValueEqual(D,$){return(D!==null&&D!==void 0?D:void 0)===($!==null&&$!==void 0?$:void 0)}_rejoinUntilConnected(){if(this.rejoinTimer.scheduleTimeout(),this.socket.isConnected())this._rejoin()}_onClose(D){this._on(Q0.CHANNEL_EVENTS.close,{},D)}_onError(D){this._on(Q0.CHANNEL_EVENTS.error,{},($)=>D($))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(D=this.timeout){if(this._isLeaving())return;this.socket._leaveOpenTopic(this.topic),this.state=Q0.CHANNEL_STATES.joining,this.joinPush.resend(D)}_getPayloadRecords(D){let $={new:{},old:{}};if(D.type==="INSERT"||D.type==="UPDATE")$.new=MR.convertChangeData(D.columns,D.record);if(D.type==="UPDATE"||D.type==="DELETE")$.old=MR.convertChangeData(D.columns,D.old_record);return $}}IR.default=D9});var ER=T((jR)=>{Object.defineProperty(jR,"__esModule",{value:!0});var wJ=lD(),q$D=wJ.__importDefault(fG()),j0=JJ(),z$D=wJ.__importDefault(JR()),B$D=wJ.__importDefault(yG()),K$D=YJ(),W$D=wJ.__importDefault(dG()),cG=()=>{},FJ={HEARTBEAT_INTERVAL:25000,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},H$D=[1000,2000,5000,1e4],V$D=1e4,N$D=`
78
+ Suggested solution: ${D.workaround}`;throw Error($)}static createWebSocket(D,$){return new(this.getWebSocketConstructor())(D,$)}static isWebSocketSupported(){try{let D=this.detectEnvironment();return D.type==="native"||D.type==="ws"}catch(D){return!1}}}mA.WebSocketFactory=kG;mA.default=kG});var nA=T((cA)=>{Object.defineProperty(cA,"__esModule",{value:!0});cA.version=void 0;cA.version="2.95.3"});var JJ=T((sA)=>{Object.defineProperty(sA,"__esModule",{value:!0});sA.CONNECTION_STATE=sA.TRANSPORTS=sA.CHANNEL_EVENTS=sA.CHANNEL_STATES=sA.SOCKET_STATES=sA.MAX_PUSH_BUFFER_SIZE=sA.WS_CLOSE_NORMAL=sA.DEFAULT_TIMEOUT=sA.VERSION=sA.DEFAULT_VSN=sA.VSN_2_0_0=sA.VSN_1_0_0=sA.DEFAULT_VERSION=void 0;var tA=nA();sA.DEFAULT_VERSION=`realtime-js/${tA.version}`;sA.VSN_1_0_0="1.0.0";sA.VSN_2_0_0="2.0.0";sA.DEFAULT_VSN=sA.VSN_2_0_0;sA.VERSION=tA.version;sA.DEFAULT_TIMEOUT=1e4;sA.WS_CLOSE_NORMAL=1000;sA.MAX_PUSH_BUFFER_SIZE=100;var iA;(function(D){D[D.connecting=0]="connecting",D[D.open=1]="open",D[D.closing=2]="closing",D[D.closed=3]="closed"})(iA||(sA.SOCKET_STATES=iA={}));var pA;(function(D){D.closed="closed",D.errored="errored",D.joined="joined",D.joining="joining",D.leaving="leaving"})(pA||(sA.CHANNEL_STATES=pA={}));var rA;(function(D){D.close="phx_close",D.error="phx_error",D.join="phx_join",D.reply="phx_reply",D.leave="phx_leave",D.access_token="access_token"})(rA||(sA.CHANNEL_EVENTS=rA={}));var oA;(function(D){D.websocket="websocket"})(oA||(sA.TRANSPORTS=oA={}));var aA;(function(D){D.Connecting="connecting",D.Open="open",D.Closing="closing",D.Closed="closed"})(aA||(sA.CONNECTION_STATE=aA={}))});var JR=T((XR)=>{Object.defineProperty(XR,"__esModule",{value:!0});class $R{constructor(D){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=D!==null&&D!==void 0?D:[]}encode(D,$){if(D.event===this.BROADCAST_EVENT&&!(D.payload instanceof ArrayBuffer)&&typeof D.payload.event==="string")return $(this._binaryEncodeUserBroadcastPush(D));let X=[D.join_ref,D.ref,D.topic,D.event,D.payload];return $(JSON.stringify(X))}_binaryEncodeUserBroadcastPush(D){var $;if(this._isArrayBuffer(($=D.payload)===null||$===void 0?void 0:$.payload))return this._encodeBinaryUserBroadcastPush(D);else return this._encodeJsonUserBroadcastPush(D)}_encodeBinaryUserBroadcastPush(D){var $,X;let Y=(X=($=D.payload)===null||$===void 0?void 0:$.payload)!==null&&X!==void 0?X:new ArrayBuffer(0);return this._encodeUserBroadcastPush(D,this.BINARY_ENCODING,Y)}_encodeJsonUserBroadcastPush(D){var $,X;let Y=(X=($=D.payload)===null||$===void 0?void 0:$.payload)!==null&&X!==void 0?X:{},Q=new TextEncoder().encode(JSON.stringify(Y)).buffer;return this._encodeUserBroadcastPush(D,this.JSON_ENCODING,Q)}_encodeUserBroadcastPush(D,$,X){var Y,J;let Q=D.topic,F=(Y=D.ref)!==null&&Y!==void 0?Y:"",w=(J=D.join_ref)!==null&&J!==void 0?J:"",Z=D.payload.event,G=this.allowedMetadataKeys?this._pick(D.payload,this.allowedMetadataKeys):{},O=Object.keys(G).length===0?"":JSON.stringify(G);if(w.length>255)throw Error(`joinRef length ${w.length} exceeds maximum of 255`);if(F.length>255)throw Error(`ref length ${F.length} exceeds maximum of 255`);if(Q.length>255)throw Error(`topic length ${Q.length} exceeds maximum of 255`);if(Z.length>255)throw Error(`userEvent length ${Z.length} exceeds maximum of 255`);if(O.length>255)throw Error(`metadata length ${O.length} exceeds maximum of 255`);let U=this.USER_BROADCAST_PUSH_META_LENGTH+w.length+F.length+Q.length+Z.length+O.length,z=new ArrayBuffer(this.HEADER_LENGTH+U),q=new DataView(z),B=0;q.setUint8(B++,this.KINDS.userBroadcastPush),q.setUint8(B++,w.length),q.setUint8(B++,F.length),q.setUint8(B++,Q.length),q.setUint8(B++,Z.length),q.setUint8(B++,O.length),q.setUint8(B++,$),Array.from(w,(M)=>q.setUint8(B++,M.charCodeAt(0))),Array.from(F,(M)=>q.setUint8(B++,M.charCodeAt(0))),Array.from(Q,(M)=>q.setUint8(B++,M.charCodeAt(0))),Array.from(Z,(M)=>q.setUint8(B++,M.charCodeAt(0))),Array.from(O,(M)=>q.setUint8(B++,M.charCodeAt(0)));var K=new Uint8Array(z.byteLength+X.byteLength);return K.set(new Uint8Array(z),0),K.set(new Uint8Array(X),z.byteLength),K.buffer}decode(D,$){if(this._isArrayBuffer(D)){let X=this._binaryDecode(D);return $(X)}if(typeof D==="string"){let X=JSON.parse(D),[Y,J,Q,F,w]=X;return $({join_ref:Y,ref:J,topic:Q,event:F,payload:w})}return $({})}_binaryDecode(D){let $=new DataView(D),X=$.getUint8(0),Y=new TextDecoder;switch(X){case this.KINDS.userBroadcast:return this._decodeUserBroadcast(D,$,Y)}}_decodeUserBroadcast(D,$,X){let Y=$.getUint8(1),J=$.getUint8(2),Q=$.getUint8(3),F=$.getUint8(4),w=this.HEADER_LENGTH+4,Z=X.decode(D.slice(w,w+Y));w=w+Y;let G=X.decode(D.slice(w,w+J));w=w+J;let O=X.decode(D.slice(w,w+Q));w=w+Q;let U=D.slice(w,D.byteLength),z=F===this.JSON_ENCODING?JSON.parse(X.decode(U)):U,q={type:this.BROADCAST_EVENT,event:G,payload:z};if(Q>0)q.meta=JSON.parse(O);return{join_ref:null,ref:null,topic:Z,event:this.BROADCAST_EVENT,payload:q}}_isArrayBuffer(D){var $;return D instanceof ArrayBuffer||(($=D===null||D===void 0?void 0:D.constructor)===null||$===void 0?void 0:$.name)==="ArrayBuffer"}_pick(D,$){if(!D||typeof D!=="object")return{};return Object.fromEntries(Object.entries(D).filter(([X])=>$.includes(X)))}}XR.default=$R});var yG=T((QR)=>{Object.defineProperty(QR,"__esModule",{value:!0});class YR{constructor(D,$){this.callback=D,this.timerCalc=$,this.timer=void 0,this.tries=0,this.callback=D,this.timerCalc=$}reset(){this.tries=0,clearTimeout(this.timer),this.timer=void 0}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}QR.default=YR});var YJ=T((FR)=>{Object.defineProperty(FR,"__esModule",{value:!0});FR.httpEndpointURL=FR.toTimestampString=FR.toArray=FR.toJson=FR.toNumber=FR.toBoolean=FR.convertCell=FR.convertColumn=FR.convertChangeData=FR.PostgresTypes=void 0;var Y0;(function(D){D.abstime="abstime",D.bool="bool",D.date="date",D.daterange="daterange",D.float4="float4",D.float8="float8",D.int2="int2",D.int4="int4",D.int4range="int4range",D.int8="int8",D.int8range="int8range",D.json="json",D.jsonb="jsonb",D.money="money",D.numeric="numeric",D.oid="oid",D.reltime="reltime",D.text="text",D.time="time",D.timestamp="timestamp",D.timestamptz="timestamptz",D.timetz="timetz",D.tsrange="tsrange",D.tstzrange="tstzrange"})(Y0||(FR.PostgresTypes=Y0={}));var n1D=(D,$,X={})=>{var Y;let J=(Y=X.skipTypes)!==null&&Y!==void 0?Y:[];if(!$)return{};return Object.keys($).reduce((Q,F)=>{return Q[F]=FR.convertColumn(F,D,$,J),Q},{})};FR.convertChangeData=n1D;var i1D=(D,$,X,Y)=>{let J=$.find((w)=>w.name===D),Q=J===null||J===void 0?void 0:J.type,F=X[D];if(Q&&!Y.includes(Q))return FR.convertCell(Q,F);return bG(F)};FR.convertColumn=i1D;var p1D=(D,$)=>{if(D.charAt(0)==="_"){let X=D.slice(1,D.length);return FR.toArray($,X)}switch(D){case Y0.bool:return FR.toBoolean($);case Y0.float4:case Y0.float8:case Y0.int2:case Y0.int4:case Y0.int8:case Y0.numeric:case Y0.oid:return FR.toNumber($);case Y0.json:case Y0.jsonb:return FR.toJson($);case Y0.timestamp:return FR.toTimestampString($);case Y0.abstime:case Y0.date:case Y0.daterange:case Y0.int4range:case Y0.int8range:case Y0.money:case Y0.reltime:case Y0.text:case Y0.time:case Y0.timestamptz:case Y0.timetz:case Y0.tsrange:case Y0.tstzrange:return bG($);default:return bG($)}};FR.convertCell=p1D;var bG=(D)=>{return D},r1D=(D)=>{switch(D){case"t":return!0;case"f":return!1;default:return D}};FR.toBoolean=r1D;var o1D=(D)=>{if(typeof D==="string"){let $=parseFloat(D);if(!Number.isNaN($))return $}return D};FR.toNumber=o1D;var a1D=(D)=>{if(typeof D==="string")try{return JSON.parse(D)}catch($){return D}return D};FR.toJson=a1D;var t1D=(D,$)=>{if(typeof D!=="string")return D;let X=D.length-1,Y=D[X];if(D[0]==="{"&&Y==="}"){let Q,F=D.slice(1,X);try{Q=JSON.parse("["+F+"]")}catch(w){Q=F?F.split(","):[]}return Q.map((w)=>FR.convertCell($,w))}return D};FR.toArray=t1D;var s1D=(D)=>{if(typeof D==="string")return D.replace(" ","T");return D};FR.toTimestampString=s1D;var e1D=(D)=>{let $=new URL(D);if($.protocol=$.protocol.replace(/^ws/i,"http"),$.pathname=$.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),$.pathname===""||$.pathname==="/")$.pathname="/api/broadcast";else $.pathname=$.pathname+"/api/broadcast";return $.href};FR.httpEndpointURL=e1D});var WR=T((KR)=>{Object.defineProperty(KR,"__esModule",{value:!0});var X$D=JJ();class BR{constructor(D,$,X={},Y=X$D.DEFAULT_TIMEOUT){this.channel=D,this.event=$,this.payload=X,this.timeout=Y,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(D){this.timeout=D,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){if(this._hasReceived("timeout"))return;this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()})}updatePayload(D){this.payload=Object.assign(Object.assign({},this.payload),D)}receive(D,$){var X;if(this._hasReceived(D))$((X=this.receivedResp)===null||X===void 0?void 0:X.response);return this.recHooks.push({status:D,callback:$}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);let D=($)=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=$,this._matchReceive($)};this.channel._on(this.refEvent,{},D),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(D,$){if(this.refEvent)this.channel._trigger(this.refEvent,{status:D,response:$})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){if(!this.refEvent)return;this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:D,response:$}){this.recHooks.filter((X)=>X.status===D).forEach((X)=>X.callback($))}_hasReceived(D){return this.receivedResp&&this.receivedResp.status===D}}KR.default=BR});var hG=T((VR)=>{Object.defineProperty(VR,"__esModule",{value:!0});VR.REALTIME_PRESENCE_LISTEN_EVENTS=void 0;var HR;(function(D){D.SYNC="sync",D.JOIN="join",D.LEAVE="leave"})(HR||(VR.REALTIME_PRESENCE_LISTEN_EVENTS=HR={}));class E7{constructor(D,$){this.channel=D,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};let X=($===null||$===void 0?void 0:$.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(X.state,{},(Y)=>{let{onJoin:J,onLeave:Q,onSync:F}=this.caller;this.joinRef=this.channel._joinRef(),this.state=E7.syncState(this.state,Y,J,Q),this.pendingDiffs.forEach((w)=>{this.state=E7.syncDiff(this.state,w,J,Q)}),this.pendingDiffs=[],F()}),this.channel._on(X.diff,{},(Y)=>{let{onJoin:J,onLeave:Q,onSync:F}=this.caller;if(this.inPendingSyncState())this.pendingDiffs.push(Y);else this.state=E7.syncDiff(this.state,Y,J,Q),F()}),this.onJoin((Y,J,Q)=>{this.channel._trigger("presence",{event:"join",key:Y,currentPresences:J,newPresences:Q})}),this.onLeave((Y,J,Q)=>{this.channel._trigger("presence",{event:"leave",key:Y,currentPresences:J,leftPresences:Q})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(D,$,X,Y){let J=this.cloneDeep(D),Q=this.transformState($),F={},w={};return this.map(J,(Z,G)=>{if(!Q[Z])w[Z]=G}),this.map(Q,(Z,G)=>{let O=J[Z];if(O){let U=G.map((K)=>K.presence_ref),z=O.map((K)=>K.presence_ref),q=G.filter((K)=>z.indexOf(K.presence_ref)<0),B=O.filter((K)=>U.indexOf(K.presence_ref)<0);if(q.length>0)F[Z]=q;if(B.length>0)w[Z]=B}else F[Z]=G}),this.syncDiff(J,{joins:F,leaves:w},X,Y)}static syncDiff(D,$,X,Y){let{joins:J,leaves:Q}={joins:this.transformState($.joins),leaves:this.transformState($.leaves)};if(!X)X=()=>{};if(!Y)Y=()=>{};return this.map(J,(F,w)=>{var Z;let G=(Z=D[F])!==null&&Z!==void 0?Z:[];if(D[F]=this.cloneDeep(w),G.length>0){let O=D[F].map((z)=>z.presence_ref),U=G.filter((z)=>O.indexOf(z.presence_ref)<0);D[F].unshift(...U)}X(F,G,w)}),this.map(Q,(F,w)=>{let Z=D[F];if(!Z)return;let G=w.map((O)=>O.presence_ref);if(Z=Z.filter((O)=>G.indexOf(O.presence_ref)<0),D[F]=Z,Y(F,Z,w),Z.length===0)delete D[F]}),D}static map(D,$){return Object.getOwnPropertyNames(D).map((X)=>$(X,D[X]))}static transformState(D){return D=this.cloneDeep(D),Object.getOwnPropertyNames(D).reduce(($,X)=>{let Y=D[X];if("metas"in Y)$[X]=Y.metas.map((J)=>{return J.presence_ref=J.phx_ref,delete J.phx_ref,delete J.phx_ref_prev,J});else $[X]=Y;return $},{})}static cloneDeep(D){return JSON.parse(JSON.stringify(D))}onJoin(D){this.caller.onJoin=D}onLeave(D){this.caller.onLeave=D}onSync(D){this.caller.onSync=D}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}VR.default=E7});var dG=T((IR)=>{Object.defineProperty(IR,"__esModule",{value:!0});IR.REALTIME_CHANNEL_STATES=IR.REALTIME_SUBSCRIBE_STATES=IR.REALTIME_LISTEN_TYPES=IR.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT=void 0;var QJ=lD(),Q0=JJ(),mG=QJ.__importDefault(WR()),Q$D=QJ.__importDefault(yG()),F$D=QJ.__importDefault(hG()),MR=QJ.__importStar(YJ()),w$D=YJ(),LR;(function(D){D.ALL="*",D.INSERT="INSERT",D.UPDATE="UPDATE",D.DELETE="DELETE"})(LR||(IR.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT=LR={}));var T7;(function(D){D.BROADCAST="broadcast",D.PRESENCE="presence",D.POSTGRES_CHANGES="postgres_changes",D.SYSTEM="system"})(T7||(IR.REALTIME_LISTEN_TYPES=T7={}));var $6;(function(D){D.SUBSCRIBED="SUBSCRIBED",D.TIMED_OUT="TIMED_OUT",D.CLOSED="CLOSED",D.CHANNEL_ERROR="CHANNEL_ERROR"})($6||(IR.REALTIME_SUBSCRIBE_STATES=$6={}));IR.REALTIME_CHANNEL_STATES=Q0.CHANNEL_STATES;class D9{constructor(D,$={config:{}},X){var Y,J;if(this.topic=D,this.params=$,this.socket=X,this.bindings={},this.state=Q0.CHANNEL_STATES.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=D.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},$.config),this.timeout=this.socket.timeout,this.joinPush=new mG.default(this,Q0.CHANNEL_EVENTS.join,this.params,this.timeout),this.rejoinTimer=new Q$D.default(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=Q0.CHANNEL_STATES.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach((Q)=>Q.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=Q0.CHANNEL_STATES.closed,this.socket._remove(this)}),this._onError((Q)=>{if(this._isLeaving()||this._isClosed())return;this.socket.log("channel",`error ${this.topic}`,Q),this.state=Q0.CHANNEL_STATES.errored,this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{if(!this._isJoining())return;this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=Q0.CHANNEL_STATES.errored,this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("error",(Q)=>{if(this._isLeaving()||this._isClosed())return;this.socket.log("channel",`error ${this.topic}`,Q),this.state=Q0.CHANNEL_STATES.errored,this.rejoinTimer.scheduleTimeout()}),this._on(Q0.CHANNEL_EVENTS.reply,{},(Q,F)=>{this._trigger(this._replyEventName(F),Q)}),this.presence=new F$D.default(this),this.broadcastEndpointURL=(0,w$D.httpEndpointURL)(this.socket.endPoint),this.private=this.params.config.private||!1,!this.private&&((J=(Y=this.params.config)===null||Y===void 0?void 0:Y.broadcast)===null||J===void 0?void 0:J.replay))throw`tried to use replay on public channel '${this.topic}'. It must be a private channel.`}subscribe(D,$=this.timeout){var X,Y,J;if(!this.socket.isConnected())this.socket.connect();if(this.state==Q0.CHANNEL_STATES.closed){let{config:{broadcast:Q,presence:F,private:w}}=this.params,Z=(Y=(X=this.bindings.postgres_changes)===null||X===void 0?void 0:X.map((z)=>z.filter))!==null&&Y!==void 0?Y:[],G=!!this.bindings[T7.PRESENCE]&&this.bindings[T7.PRESENCE].length>0||((J=this.params.config.presence)===null||J===void 0?void 0:J.enabled)===!0,O={},U={broadcast:Q,presence:Object.assign(Object.assign({},F),{enabled:G}),postgres_changes:Z,private:w};if(this.socket.accessTokenValue)O.access_token=this.socket.accessTokenValue;this._onError((z)=>D===null||D===void 0?void 0:D($6.CHANNEL_ERROR,z)),this._onClose(()=>D===null||D===void 0?void 0:D($6.CLOSED)),this.updateJoinPayload(Object.assign({config:U},O)),this.joinedOnce=!0,this._rejoin($),this.joinPush.receive("ok",async({postgres_changes:z})=>{var q;if(!this.socket._isManualToken())this.socket.setAuth();if(z===void 0){D===null||D===void 0||D($6.SUBSCRIBED);return}else{let B=this.bindings.postgres_changes,K=(q=B===null||B===void 0?void 0:B.length)!==null&&q!==void 0?q:0,M=[];for(let L=0;L<K;L++){let I=B[L],{filter:{event:W,schema:N,table:V,filter:R}}=I,C=z&&z[L];if(C&&C.event===W&&D9.isFilterValueEqual(C.schema,N)&&D9.isFilterValueEqual(C.table,V)&&D9.isFilterValueEqual(C.filter,R))M.push(Object.assign(Object.assign({},I),{id:C.id}));else{this.unsubscribe(),this.state=Q0.CHANNEL_STATES.errored,D===null||D===void 0||D($6.CHANNEL_ERROR,Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=M,D&&D($6.SUBSCRIBED);return}}).receive("error",(z)=>{this.state=Q0.CHANNEL_STATES.errored,D===null||D===void 0||D($6.CHANNEL_ERROR,Error(JSON.stringify(Object.values(z).join(", ")||"error")));return}).receive("timeout",()=>{D===null||D===void 0||D($6.TIMED_OUT);return})}return this}presenceState(){return this.presence.state}async track(D,$={}){return await this.send({type:"presence",event:"track",payload:D},$.timeout||this.timeout)}async untrack(D={}){return await this.send({type:"presence",event:"untrack"},D)}on(D,$,X){if(this.state===Q0.CHANNEL_STATES.joined&&D===T7.PRESENCE)this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(async()=>await this.subscribe());return this._on(D,$,X)}async httpSend(D,$,X={}){var Y;if($===void 0||$===null)return Promise.reject("Payload is required for httpSend()");let J={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};if(this.socket.accessTokenValue)J.Authorization=`Bearer ${this.socket.accessTokenValue}`;let Q={method:"POST",headers:J,body:JSON.stringify({messages:[{topic:this.subTopic,event:D,payload:$,private:this.private}]})},F=await this._fetchWithTimeout(this.broadcastEndpointURL,Q,(Y=X.timeout)!==null&&Y!==void 0?Y:this.timeout);if(F.status===202)return{success:!0};let w=F.statusText;try{let Z=await F.json();w=Z.error||Z.message||w}catch(Z){}return Promise.reject(Error(w))}async send(D,$={}){var X,Y;if(!this._canPush()&&D.type==="broadcast"){console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");let{event:J,payload:Q}=D,F={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};if(this.socket.accessTokenValue)F.Authorization=`Bearer ${this.socket.accessTokenValue}`;let w={method:"POST",headers:F,body:JSON.stringify({messages:[{topic:this.subTopic,event:J,payload:Q,private:this.private}]})};try{let Z=await this._fetchWithTimeout(this.broadcastEndpointURL,w,(X=$.timeout)!==null&&X!==void 0?X:this.timeout);return await((Y=Z.body)===null||Y===void 0?void 0:Y.cancel()),Z.ok?"ok":"error"}catch(Z){if(Z.name==="AbortError")return"timed out";else return"error"}}else return new Promise((J)=>{var Q,F,w;let Z=this._push(D.type,D,$.timeout||this.timeout);if(D.type==="broadcast"&&!((w=(F=(Q=this.params)===null||Q===void 0?void 0:Q.config)===null||F===void 0?void 0:F.broadcast)===null||w===void 0?void 0:w.ack))J("ok");Z.receive("ok",()=>J("ok")),Z.receive("error",()=>J("error")),Z.receive("timeout",()=>J("timed out"))})}updateJoinPayload(D){this.joinPush.updatePayload(D)}unsubscribe(D=this.timeout){this.state=Q0.CHANNEL_STATES.leaving;let $=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(Q0.CHANNEL_EVENTS.close,"leave",this._joinRef())};this.joinPush.destroy();let X=null;return new Promise((Y)=>{if(X=new mG.default(this,Q0.CHANNEL_EVENTS.leave,{},D),X.receive("ok",()=>{$(),Y("ok")}).receive("timeout",()=>{$(),Y("timed out")}).receive("error",()=>{Y("error")}),X.send(),!this._canPush())X.trigger("ok",{})}).finally(()=>{X===null||X===void 0||X.destroy()})}teardown(){this.pushBuffer.forEach((D)=>D.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=Q0.CHANNEL_STATES.closed,this.bindings={}}async _fetchWithTimeout(D,$,X){let Y=new AbortController,J=setTimeout(()=>Y.abort(),X),Q=await this.socket.fetch(D,Object.assign(Object.assign({},$),{signal:Y.signal}));return clearTimeout(J),Q}_push(D,$,X=this.timeout){if(!this.joinedOnce)throw`tried to push '${D}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let Y=new mG.default(this,D,$,X);if(this._canPush())Y.send();else this._addToPushBuffer(Y);return Y}_addToPushBuffer(D){if(D.startTimeout(),this.pushBuffer.push(D),this.pushBuffer.length>Q0.MAX_PUSH_BUFFER_SIZE){let $=this.pushBuffer.shift();if($)$.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${$.event}`,$.payload)}}_onMessage(D,$,X){return $}_isMember(D){return this.topic===D}_joinRef(){return this.joinPush.ref}_trigger(D,$,X){var Y,J;let Q=D.toLocaleLowerCase(),{close:F,error:w,leave:Z,join:G}=Q0.CHANNEL_EVENTS;if(X&&[F,w,Z,G].indexOf(Q)>=0&&X!==this._joinRef())return;let U=this._onMessage(Q,$,X);if($&&!U)throw"channel onMessage callbacks must return the payload, modified or unmodified";if(["insert","update","delete"].includes(Q))(Y=this.bindings.postgres_changes)===null||Y===void 0||Y.filter((z)=>{var q,B,K;return((q=z.filter)===null||q===void 0?void 0:q.event)==="*"||((K=(B=z.filter)===null||B===void 0?void 0:B.event)===null||K===void 0?void 0:K.toLocaleLowerCase())===Q}).map((z)=>z.callback(U,X));else(J=this.bindings[Q])===null||J===void 0||J.filter((z)=>{var q,B,K,M,L,I;if(["broadcast","presence","postgres_changes"].includes(Q))if("id"in z){let W=z.id,N=(q=z.filter)===null||q===void 0?void 0:q.event;return W&&((B=$.ids)===null||B===void 0?void 0:B.includes(W))&&(N==="*"||(N===null||N===void 0?void 0:N.toLocaleLowerCase())===((K=$.data)===null||K===void 0?void 0:K.type.toLocaleLowerCase()))}else{let W=(L=(M=z===null||z===void 0?void 0:z.filter)===null||M===void 0?void 0:M.event)===null||L===void 0?void 0:L.toLocaleLowerCase();return W==="*"||W===((I=$===null||$===void 0?void 0:$.event)===null||I===void 0?void 0:I.toLocaleLowerCase())}else return z.type.toLocaleLowerCase()===Q}).map((z)=>{if(typeof U==="object"&&"ids"in U){let q=U.data,{schema:B,table:K,commit_timestamp:M,type:L,errors:I}=q;U=Object.assign(Object.assign({},{schema:B,table:K,commit_timestamp:M,eventType:L,new:{},old:{},errors:I}),this._getPayloadRecords(q))}z.callback(U,X)})}_isClosed(){return this.state===Q0.CHANNEL_STATES.closed}_isJoined(){return this.state===Q0.CHANNEL_STATES.joined}_isJoining(){return this.state===Q0.CHANNEL_STATES.joining}_isLeaving(){return this.state===Q0.CHANNEL_STATES.leaving}_replyEventName(D){return`chan_reply_${D}`}_on(D,$,X){let Y=D.toLocaleLowerCase(),J={type:Y,filter:$,callback:X};if(this.bindings[Y])this.bindings[Y].push(J);else this.bindings[Y]=[J];return this}_off(D,$){let X=D.toLocaleLowerCase();if(this.bindings[X])this.bindings[X]=this.bindings[X].filter((Y)=>{var J;return!(((J=Y.type)===null||J===void 0?void 0:J.toLocaleLowerCase())===X&&D9.isEqual(Y.filter,$))});return this}static isEqual(D,$){if(Object.keys(D).length!==Object.keys($).length)return!1;for(let X in D)if(D[X]!==$[X])return!1;return!0}static isFilterValueEqual(D,$){return(D!==null&&D!==void 0?D:void 0)===($!==null&&$!==void 0?$:void 0)}_rejoinUntilConnected(){if(this.rejoinTimer.scheduleTimeout(),this.socket.isConnected())this._rejoin()}_onClose(D){this._on(Q0.CHANNEL_EVENTS.close,{},D)}_onError(D){this._on(Q0.CHANNEL_EVENTS.error,{},($)=>D($))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(D=this.timeout){if(this._isLeaving())return;this.socket._leaveOpenTopic(this.topic),this.state=Q0.CHANNEL_STATES.joining,this.joinPush.resend(D)}_getPayloadRecords(D){let $={new:{},old:{}};if(D.type==="INSERT"||D.type==="UPDATE")$.new=MR.convertChangeData(D.columns,D.record);if(D.type==="UPDATE"||D.type==="DELETE")$.old=MR.convertChangeData(D.columns,D.old_record);return $}}IR.default=D9});var ER=T((jR)=>{Object.defineProperty(jR,"__esModule",{value:!0});var wJ=lD(),q$D=wJ.__importDefault(fG()),j0=JJ(),z$D=wJ.__importDefault(JR()),B$D=wJ.__importDefault(yG()),K$D=YJ(),W$D=wJ.__importDefault(dG()),cG=()=>{},FJ={HEARTBEAT_INTERVAL:25000,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},H$D=[1000,2000,5000,1e4],V$D=1e4,N$D=`
79
79
  addEventListener("message", (e) => {
80
80
  if (e.data.event === "start") {
81
81
  setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
@@ -109,17 +109,17 @@ Not Before: ${w.toISOString()}`;if(Z)L+=`
109
109
  Request ID: ${Z}`;if(G){let I=`
110
110
  Resources:`;for(let W of G){if(!W||typeof W!=="string")throw Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${W}`);I+=`
111
111
  - ${W}`}L+=I}return`${M}
112
- ${L}`}});var fj=T((_j)=>{Object.defineProperty(_j,"__esModule",{value:!0});_j.WebAuthnUnknownError=_j.WebAuthnError=void 0;_j.isWebAuthnError=C8D;_j.identifyRegistrationError=P8D;_j.identifyAuthenticationError=x8D;var uj=FO();class E0 extends Error{constructor({message:D,code:$,cause:X,name:Y}){var J;super(D,{cause:X});this.__isWebAuthnError=!0,this.name=(J=Y!==null&&Y!==void 0?Y:X instanceof Error?X.name:void 0)!==null&&J!==void 0?J:"Unknown Error",this.code=$}}_j.WebAuthnError=E0;class vj extends E0{constructor(D,$){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:$,message:D});this.name="WebAuthnUnknownError",this.originalError=$}}_j.WebAuthnUnknownError=vj;function C8D(D){return typeof D==="object"&&D!==null&&"__isWebAuthnError"in D}function P8D({error:D,options:$}){var X,Y,J;let{publicKey:Q}=$;if(!Q)throw Error("options was missing required publicKey property");if(D.name==="AbortError"){if($.signal instanceof AbortSignal)return new E0({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:D})}else if(D.name==="ConstraintError"){if(((X=Q.authenticatorSelection)===null||X===void 0?void 0:X.requireResidentKey)===!0)return new E0({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:D});else if($.mediation==="conditional"&&((Y=Q.authenticatorSelection)===null||Y===void 0?void 0:Y.userVerification)==="required")return new E0({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:D});else if(((J=Q.authenticatorSelection)===null||J===void 0?void 0:J.userVerification)==="required")return new E0({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:D})}else if(D.name==="InvalidStateError")return new E0({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:D});else if(D.name==="NotAllowedError")return new E0({message:D.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:D});else if(D.name==="NotSupportedError"){if(Q.pubKeyCredParams.filter((w)=>w.type==="public-key").length===0)return new E0({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:D});return new E0({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:D})}else if(D.name==="SecurityError"){let F=window.location.hostname;if(!(0,uj.isValidDomain)(F))return new E0({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:D});else if(Q.rp.id!==F)return new E0({message:`The RP ID "${Q.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:D})}else if(D.name==="TypeError"){if(Q.user.id.byteLength<1||Q.user.id.byteLength>64)return new E0({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:D})}else if(D.name==="UnknownError")return new E0({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:D});return new E0({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:D})}function x8D({error:D,options:$}){let{publicKey:X}=$;if(!X)throw Error("options was missing required publicKey property");if(D.name==="AbortError"){if($.signal instanceof AbortSignal)return new E0({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:D})}else if(D.name==="NotAllowedError")return new E0({message:D.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:D});else if(D.name==="SecurityError"){let Y=window.location.hostname;if(!(0,uj.isValidDomain)(Y))return new E0({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:D});else if(X.rpId!==Y)return new E0({message:`The RP ID "${X.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:D})}else if(D.name==="UnknownError")return new E0({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:D});return new E0({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:D})}});var FO=T((Y9)=>{Object.defineProperty(Y9,"__esModule",{value:!0});Y9.WebAuthnApi=Y9.DEFAULT_REQUEST_OPTIONS=Y9.DEFAULT_CREATION_OPTIONS=Y9.webAuthnAbortService=Y9.WebAuthnAbortService=Y9.identifyAuthenticationError=Y9.identifyRegistrationError=Y9.isWebAuthnError=Y9.WebAuthnError=void 0;Y9.deserializeCredentialCreationOptions=f8D;Y9.deserializeCredentialRequestOptions=y8D;Y9.serializeCredentialCreationResponse=b8D;Y9.serializeCredentialRequestResponse=g8D;Y9.isValidDomain=h8D;Y9.createCredential=gj;Y9.getCredential=hj;Y9.mergeCredentialCreationOptions=mj;Y9.mergeCredentialRequestOptions=dj;var bj=lD(),W$=KJ(),E$=_4(),k8D=J9(),T$=fj();Object.defineProperty(Y9,"identifyAuthenticationError",{enumerable:!0,get:function(){return T$.identifyAuthenticationError}});Object.defineProperty(Y9,"identifyRegistrationError",{enumerable:!0,get:function(){return T$.identifyRegistrationError}});Object.defineProperty(Y9,"isWebAuthnError",{enumerable:!0,get:function(){return T$.isWebAuthnError}});Object.defineProperty(Y9,"WebAuthnError",{enumerable:!0,get:function(){return T$.WebAuthnError}});class wO{createNewAbortSignal(){if(this.controller){let $=Error("Cancelling existing WebAuthn API call for new one");$.name="AbortError",this.controller.abort($)}let D=new AbortController;return this.controller=D,D.signal}cancelCeremony(){if(this.controller){let D=Error("Manually cancelling existing WebAuthn API call");D.name="AbortError",this.controller.abort(D),this.controller=void 0}}}Y9.WebAuthnAbortService=wO;Y9.webAuthnAbortService=new wO;function f8D(D){if(!D)throw Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON==="function")return PublicKeyCredential.parseCreationOptionsFromJSON(D);let{challenge:$,user:X,excludeCredentials:Y}=D,J=bj.__rest(D,["challenge","user","excludeCredentials"]),Q=(0,W$.base64UrlToUint8Array)($).buffer,F=Object.assign(Object.assign({},X),{id:(0,W$.base64UrlToUint8Array)(X.id).buffer}),w=Object.assign(Object.assign({},J),{challenge:Q,user:F});if(Y&&Y.length>0){w.excludeCredentials=Array(Y.length);for(let Z=0;Z<Y.length;Z++){let G=Y[Z];w.excludeCredentials[Z]=Object.assign(Object.assign({},G),{id:(0,W$.base64UrlToUint8Array)(G.id).buffer,type:G.type||"public-key",transports:G.transports})}}return w}function y8D(D){if(!D)throw Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON==="function")return PublicKeyCredential.parseRequestOptionsFromJSON(D);let{challenge:$,allowCredentials:X}=D,Y=bj.__rest(D,["challenge","allowCredentials"]),J=(0,W$.base64UrlToUint8Array)($).buffer,Q=Object.assign(Object.assign({},Y),{challenge:J});if(X&&X.length>0){Q.allowCredentials=Array(X.length);for(let F=0;F<X.length;F++){let w=X[F];Q.allowCredentials[F]=Object.assign(Object.assign({},w),{id:(0,W$.base64UrlToUint8Array)(w.id).buffer,type:w.type||"public-key",transports:w.transports})}}return Q}function b8D(D){var $;if("toJSON"in D&&typeof D.toJSON==="function")return D.toJSON();let X=D;return{id:D.id,rawId:D.id,response:{attestationObject:(0,W$.bytesToBase64URL)(new Uint8Array(D.response.attestationObject)),clientDataJSON:(0,W$.bytesToBase64URL)(new Uint8Array(D.response.clientDataJSON))},type:"public-key",clientExtensionResults:D.getClientExtensionResults(),authenticatorAttachment:($=X.authenticatorAttachment)!==null&&$!==void 0?$:void 0}}function g8D(D){var $;if("toJSON"in D&&typeof D.toJSON==="function")return D.toJSON();let X=D,Y=D.getClientExtensionResults(),J=D.response;return{id:D.id,rawId:D.id,response:{authenticatorData:(0,W$.bytesToBase64URL)(new Uint8Array(J.authenticatorData)),clientDataJSON:(0,W$.bytesToBase64URL)(new Uint8Array(J.clientDataJSON)),signature:(0,W$.bytesToBase64URL)(new Uint8Array(J.signature)),userHandle:J.userHandle?(0,W$.bytesToBase64URL)(new Uint8Array(J.userHandle)):void 0},type:"public-key",clientExtensionResults:Y,authenticatorAttachment:($=X.authenticatorAttachment)!==null&&$!==void 0?$:void 0}}function h8D(D){return D==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(D)}function yj(){var D,$;return!!((0,k8D.isBrowser)()&&("PublicKeyCredential"in window)&&window.PublicKeyCredential&&("credentials"in navigator)&&typeof((D=navigator===null||navigator===void 0?void 0:navigator.credentials)===null||D===void 0?void 0:D.create)==="function"&&typeof(($=navigator===null||navigator===void 0?void 0:navigator.credentials)===null||$===void 0?void 0:$.get)==="function")}async function gj(D){try{let $=await navigator.credentials.create(D);if(!$)return{data:null,error:new T$.WebAuthnUnknownError("Empty credential response",$)};if(!($ instanceof PublicKeyCredential))return{data:null,error:new T$.WebAuthnUnknownError("Browser returned unexpected credential type",$)};return{data:$,error:null}}catch($){return{data:null,error:(0,T$.identifyRegistrationError)({error:$,options:D})}}}async function hj(D){try{let $=await navigator.credentials.get(D);if(!$)return{data:null,error:new T$.WebAuthnUnknownError("Empty credential response",$)};if(!($ instanceof PublicKeyCredential))return{data:null,error:new T$.WebAuthnUnknownError("Browser returned unexpected credential type",$)};return{data:$,error:null}}catch($){return{data:null,error:(0,T$.identifyAuthenticationError)({error:$,options:D})}}}Y9.DEFAULT_CREATION_OPTIONS={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"};Y9.DEFAULT_REQUEST_OPTIONS={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function MJ(...D){let $=(J)=>J!==null&&typeof J==="object"&&!Array.isArray(J),X=(J)=>J instanceof ArrayBuffer||ArrayBuffer.isView(J),Y={};for(let J of D){if(!J)continue;for(let Q in J){let F=J[Q];if(F===void 0)continue;if(Array.isArray(F))Y[Q]=F;else if(X(F))Y[Q]=F;else if($(F)){let w=Y[Q];if($(w))Y[Q]=MJ(w,F);else Y[Q]=MJ(F)}else Y[Q]=F}}return Y}function mj(D,$){return MJ(Y9.DEFAULT_CREATION_OPTIONS,D,$||{})}function dj(D,$){return MJ(Y9.DEFAULT_REQUEST_OPTIONS,D,$||{})}class cj{constructor(D){this.client=D,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(D){return this.client.mfa.enroll(Object.assign(Object.assign({},D),{factorType:"webauthn"}))}async _challenge({factorId:D,webauthn:$,friendlyName:X,signal:Y},J){var Q;try{let{data:F,error:w}=await this.client.mfa.challenge({factorId:D,webauthn:$});if(!F)return{data:null,error:w};let Z=Y!==null&&Y!==void 0?Y:Y9.webAuthnAbortService.createNewAbortSignal();if(F.webauthn.type==="create"){let{user:G}=F.webauthn.credential_options.publicKey;if(!G.name){let O=X;if(!O){let z=(await this.client.getUser()).data.user,q=((Q=z===null||z===void 0?void 0:z.user_metadata)===null||Q===void 0?void 0:Q.name)||(z===null||z===void 0?void 0:z.email)||(z===null||z===void 0?void 0:z.id)||"User";G.name=`${G.id}:${q}`}else G.name=`${G.id}:${O}`}if(!G.displayName)G.displayName=G.name}switch(F.webauthn.type){case"create":{let G=mj(F.webauthn.credential_options.publicKey,J===null||J===void 0?void 0:J.create),{data:O,error:U}=await gj({publicKey:G,signal:Z});if(O)return{data:{factorId:D,challengeId:F.id,webauthn:{type:F.webauthn.type,credential_response:O}},error:null};return{data:null,error:U}}case"request":{let G=dj(F.webauthn.credential_options.publicKey,J===null||J===void 0?void 0:J.request),{data:O,error:U}=await hj(Object.assign(Object.assign({},F.webauthn.credential_options),{publicKey:G,signal:Z}));if(O)return{data:{factorId:D,challengeId:F.id,webauthn:{type:F.webauthn.type,credential_response:O}},error:null};return{data:null,error:U}}}}catch(F){if((0,E$.isAuthError)(F))return{data:null,error:F};return{data:null,error:new E$.AuthUnknownError("Unexpected error in challenge",F)}}}async _verify({challengeId:D,factorId:$,webauthn:X}){return this.client.mfa.verify({factorId:$,challengeId:D,webauthn:X})}async _authenticate({factorId:D,webauthn:{rpId:$=typeof window<"u"?window.location.hostname:void 0,rpOrigins:X=typeof window<"u"?[window.location.origin]:void 0,signal:Y}={}},J){if(!$)return{data:null,error:new E$.AuthError("rpId is required for WebAuthn authentication")};try{if(!yj())return{data:null,error:new E$.AuthUnknownError("Browser does not support WebAuthn",null)};let{data:Q,error:F}=await this.challenge({factorId:D,webauthn:{rpId:$,rpOrigins:X},signal:Y},{request:J});if(!Q)return{data:null,error:F};let{webauthn:w}=Q;return this._verify({factorId:D,challengeId:Q.challengeId,webauthn:{type:w.type,rpId:$,rpOrigins:X,credential_response:w.credential_response}})}catch(Q){if((0,E$.isAuthError)(Q))return{data:null,error:Q};return{data:null,error:new E$.AuthUnknownError("Unexpected error in authenticate",Q)}}}async _register({friendlyName:D,webauthn:{rpId:$=typeof window<"u"?window.location.hostname:void 0,rpOrigins:X=typeof window<"u"?[window.location.origin]:void 0,signal:Y}={}},J){if(!$)return{data:null,error:new E$.AuthError("rpId is required for WebAuthn registration")};try{if(!yj())return{data:null,error:new E$.AuthUnknownError("Browser does not support WebAuthn",null)};let{data:Q,error:F}=await this._enroll({friendlyName:D});if(!Q)return await this.client.mfa.listFactors().then((G)=>{var O;return(O=G.data)===null||O===void 0?void 0:O.all.find((U)=>U.factor_type==="webauthn"&&U.friendly_name===D&&U.status!=="unverified")}).then((G)=>G?this.client.mfa.unenroll({factorId:G===null||G===void 0?void 0:G.id}):void 0),{data:null,error:F};let{data:w,error:Z}=await this._challenge({factorId:Q.id,friendlyName:Q.friendly_name,webauthn:{rpId:$,rpOrigins:X},signal:Y},{create:J});if(!w)return{data:null,error:Z};return this._verify({factorId:Q.id,challengeId:w.challengeId,webauthn:{rpId:$,rpOrigins:X,type:w.webauthn.type,credential_response:w.webauthn.credential_response}})}catch(Q){if((0,E$.isAuthError)(Q))return{data:null,error:Q};return{data:null,error:new E$.AuthUnknownError("Unexpected error in register",Q)}}}}Y9.WebAuthnApi=cj});var ZO=T((sj)=>{Object.defineProperty(sj,"__esModule",{value:!0});var t8D=lD(),s8D=t8D.__importDefault(VJ()),P1=zJ(),QD=_4(),MD=DO(),ZD=J9(),rj=Aj(),oj=QO(),e8D=Cj(),D9D=rG(),aj=KJ(),LJ=Sj(),f7=FO();(0,e8D.polyfillGlobalThis)();var $9D={url:P1.GOTRUE_URL,storageKey:P1.STORAGE_KEY,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:P1.DEFAULT_HEADERS,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:1e4};async function tj(D,$,X){return await X()}var Q9={};class y7{get jwks(){var D,$;return($=(D=Q9[this.storageKey])===null||D===void 0?void 0:D.jwks)!==null&&$!==void 0?$:{keys:[]}}set jwks(D){Q9[this.storageKey]=Object.assign(Object.assign({},Q9[this.storageKey]),{jwks:D})}get jwks_cached_at(){var D,$;return($=(D=Q9[this.storageKey])===null||D===void 0?void 0:D.cachedAt)!==null&&$!==void 0?$:Number.MIN_SAFE_INTEGER}set jwks_cached_at(D){Q9[this.storageKey]=Object.assign(Object.assign({},Q9[this.storageKey]),{cachedAt:D})}constructor(D){var $,X,Y;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;let J=Object.assign(Object.assign({},$9D),D);if(this.storageKey=J.storageKey,this.instanceID=($=y7.nextInstanceID[this.storageKey])!==null&&$!==void 0?$:0,y7.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!J.debug,typeof J.debug==="function")this.logger=J.debug;if(this.instanceID>0&&(0,ZD.isBrowser)()){let Q=`${this._logPrefix()} Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.`;if(console.warn(Q),this.logDebugMessages)console.trace(Q)}if(this.persistSession=J.persistSession,this.autoRefreshToken=J.autoRefreshToken,this.admin=new s8D.default({url:J.url,headers:J.headers,fetch:J.fetch}),this.url=J.url,this.headers=J.headers,this.fetch=(0,ZD.resolveFetch)(J.fetch),this.lock=J.lock||tj,this.detectSessionInUrl=J.detectSessionInUrl,this.flowType=J.flowType,this.hasCustomAuthorizationHeader=J.hasCustomAuthorizationHeader,this.throwOnError=J.throwOnError,this.lockAcquireTimeout=J.lockAcquireTimeout,J.lock)this.lock=J.lock;else if(this.persistSession&&(0,ZD.isBrowser)()&&((X=globalThis===null||globalThis===void 0?void 0:globalThis.navigator)===null||X===void 0?void 0:X.locks))this.lock=oj.navigatorLock;else this.lock=tj;if(!this.jwks)this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER;if(this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this),webauthn:new f7.WebAuthnApi(this)},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this),listGrants:this._listOAuthGrants.bind(this),revokeGrant:this._revokeOAuthGrant.bind(this)},this.persistSession){if(J.storage)this.storage=J.storage;else if((0,ZD.supportsLocalStorage)())this.storage=globalThis.localStorage;else this.memoryStorage={},this.storage=(0,rj.memoryLocalStorageAdapter)(this.memoryStorage);if(J.userStorage)this.userStorage=J.userStorage}else this.memoryStorage={},this.storage=(0,rj.memoryLocalStorageAdapter)(this.memoryStorage);if((0,ZD.isBrowser)()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(Q){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",Q)}(Y=this.broadcastChannel)===null||Y===void 0||Y.addEventListener("message",async(Q)=>{this._debug("received broadcast notification from other tab or client",Q);try{await this._notifyAllSubscribers(Q.data.event,Q.data.session,!1)}catch(F){this._debug("#broadcastChannel","error",F)}})}this.initialize().catch((Q)=>{this._debug("#initialize()","error",Q)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(D){if(this.throwOnError&&D&&D.error)throw D.error;return D}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${D9D.version}) ${new Date().toISOString()}`}_debug(...D){if(this.logDebugMessages)this.logger(this._logPrefix(),...D);return this}async initialize(){if(this.initializePromise)return await this.initializePromise;return this.initializePromise=(async()=>{return await this._acquireLock(this.lockAcquireTimeout,async()=>{return await this._initialize()})})(),await this.initializePromise}async _initialize(){var D;try{let $={},X="none";if((0,ZD.isBrowser)()){if($=(0,ZD.parseParametersFromURL)(window.location.href),this._isImplicitGrantCallback($))X="implicit";else if(await this._isPKCECallback($))X="pkce"}if((0,ZD.isBrowser)()&&this.detectSessionInUrl&&X!=="none"){let{data:Y,error:J}=await this._getSessionFromURL($,X);if(J){if(this._debug("#_initialize()","error detecting session from URL",J),(0,QD.isAuthImplicitGrantRedirectError)(J)){let w=(D=J.details)===null||D===void 0?void 0:D.code;if(w==="identity_already_exists"||w==="identity_not_found"||w==="single_identity_not_deletable")return{error:J}}return{error:J}}let{session:Q,redirectType:F}=Y;return this._debug("#_initialize()","detected session in URL",Q,"redirect type",F),await this._saveSession(Q),setTimeout(async()=>{if(F==="recovery")await this._notifyAllSubscribers("PASSWORD_RECOVERY",Q);else await this._notifyAllSubscribers("SIGNED_IN",Q)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch($){if((0,QD.isAuthError)($))return this._returnResult({error:$});return this._returnResult({error:new QD.AuthUnknownError("Unexpected error during initialization",$)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(D){var $,X,Y;try{let J=await(0,MD._request)(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(X=($=D===null||D===void 0?void 0:D.options)===null||$===void 0?void 0:$.data)!==null&&X!==void 0?X:{},gotrue_meta_security:{captcha_token:(Y=D===null||D===void 0?void 0:D.options)===null||Y===void 0?void 0:Y.captchaToken}},xform:MD._sessionResponse}),{data:Q,error:F}=J;if(F||!Q)return this._returnResult({data:{user:null,session:null},error:F});let{session:w,user:Z}=Q;if(Q.session)await this._saveSession(Q.session),await this._notifyAllSubscribers("SIGNED_IN",w);return this._returnResult({data:{user:Z,session:w},error:null})}catch(J){if((0,QD.isAuthError)(J))return this._returnResult({data:{user:null,session:null},error:J});throw J}}async signUp(D){var $,X,Y;try{let J;if("email"in D){let{email:G,password:O,options:U}=D,z=null,q=null;if(this.flowType==="pkce")[z,q]=await(0,ZD.getCodeChallengeAndMethod)(this.storage,this.storageKey);J=await(0,MD._request)(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:U===null||U===void 0?void 0:U.emailRedirectTo,body:{email:G,password:O,data:($=U===null||U===void 0?void 0:U.data)!==null&&$!==void 0?$:{},gotrue_meta_security:{captcha_token:U===null||U===void 0?void 0:U.captchaToken},code_challenge:z,code_challenge_method:q},xform:MD._sessionResponse})}else if("phone"in D){let{phone:G,password:O,options:U}=D;J=await(0,MD._request)(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:G,password:O,data:(X=U===null||U===void 0?void 0:U.data)!==null&&X!==void 0?X:{},channel:(Y=U===null||U===void 0?void 0:U.channel)!==null&&Y!==void 0?Y:"sms",gotrue_meta_security:{captcha_token:U===null||U===void 0?void 0:U.captchaToken}},xform:MD._sessionResponse})}else throw new QD.AuthInvalidCredentialsError("You must provide either an email or phone number and a password");let{data:Q,error:F}=J;if(F||!Q)return await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:F});let{session:w,user:Z}=Q;if(Q.session)await this._saveSession(Q.session),await this._notifyAllSubscribers("SIGNED_IN",w);return this._returnResult({data:{user:Z,session:w},error:null})}catch(J){if(await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,QD.isAuthError)(J))return this._returnResult({data:{user:null,session:null},error:J});throw J}}async signInWithPassword(D){try{let $;if("email"in D){let{email:J,password:Q,options:F}=D;$=await(0,MD._request)(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:J,password:Q,gotrue_meta_security:{captcha_token:F===null||F===void 0?void 0:F.captchaToken}},xform:MD._sessionResponsePassword})}else if("phone"in D){let{phone:J,password:Q,options:F}=D;$=await(0,MD._request)(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:J,password:Q,gotrue_meta_security:{captcha_token:F===null||F===void 0?void 0:F.captchaToken}},xform:MD._sessionResponsePassword})}else throw new QD.AuthInvalidCredentialsError("You must provide either an email or phone number and a password");let{data:X,error:Y}=$;if(Y)return this._returnResult({data:{user:null,session:null},error:Y});else if(!X||!X.session||!X.user){let J=new QD.AuthInvalidTokenResponseError;return this._returnResult({data:{user:null,session:null},error:J})}if(X.session)await this._saveSession(X.session),await this._notifyAllSubscribers("SIGNED_IN",X.session);return this._returnResult({data:Object.assign({user:X.user,session:X.session},X.weak_password?{weakPassword:X.weak_password}:null),error:Y})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:{user:null,session:null},error:$});throw $}}async signInWithOAuth(D){var $,X,Y,J;return await this._handleProviderSignIn(D.provider,{redirectTo:($=D.options)===null||$===void 0?void 0:$.redirectTo,scopes:(X=D.options)===null||X===void 0?void 0:X.scopes,queryParams:(Y=D.options)===null||Y===void 0?void 0:Y.queryParams,skipBrowserRedirect:(J=D.options)===null||J===void 0?void 0:J.skipBrowserRedirect})}async exchangeCodeForSession(D){return await this.initializePromise,this._acquireLock(this.lockAcquireTimeout,async()=>{return this._exchangeCodeForSession(D)})}async signInWithWeb3(D){let{chain:$}=D;switch($){case"ethereum":return await this.signInWithEthereum(D);case"solana":return await this.signInWithSolana(D);default:throw Error(`@supabase/auth-js: Unsupported chain "${$}"`)}}async signInWithEthereum(D){var $,X,Y,J,Q,F,w,Z,G,O,U;let z,q;if("message"in D)z=D.message,q=D.signature;else{let{chain:B,wallet:K,statement:M,options:L}=D,I;if(!(0,ZD.isBrowser)()){if(typeof K!=="object"||!(L===null||L===void 0?void 0:L.url))throw Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");I=K}else if(typeof K==="object")I=K;else{let A=window;if("ethereum"in A&&typeof A.ethereum==="object"&&"request"in A.ethereum&&typeof A.ethereum.request==="function")I=A.ethereum;else throw Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}let W=new URL(($=L===null||L===void 0?void 0:L.url)!==null&&$!==void 0?$:window.location.href),N=await I.request({method:"eth_requestAccounts"}).then((A)=>A).catch(()=>{throw Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!N||N.length===0)throw Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");let V=(0,LJ.getAddress)(N[0]),R=(X=L===null||L===void 0?void 0:L.signInWithEthereum)===null||X===void 0?void 0:X.chainId;if(!R){let A=await I.request({method:"eth_chainId"});R=(0,LJ.fromHex)(A)}let P={domain:W.host,address:V,statement:M,uri:W.href,version:"1",chainId:R,nonce:(Y=L===null||L===void 0?void 0:L.signInWithEthereum)===null||Y===void 0?void 0:Y.nonce,issuedAt:(Q=(J=L===null||L===void 0?void 0:L.signInWithEthereum)===null||J===void 0?void 0:J.issuedAt)!==null&&Q!==void 0?Q:new Date,expirationTime:(F=L===null||L===void 0?void 0:L.signInWithEthereum)===null||F===void 0?void 0:F.expirationTime,notBefore:(w=L===null||L===void 0?void 0:L.signInWithEthereum)===null||w===void 0?void 0:w.notBefore,requestId:(Z=L===null||L===void 0?void 0:L.signInWithEthereum)===null||Z===void 0?void 0:Z.requestId,resources:(G=L===null||L===void 0?void 0:L.signInWithEthereum)===null||G===void 0?void 0:G.resources};z=(0,LJ.createSiweMessage)(P),q=await I.request({method:"personal_sign",params:[(0,LJ.toHex)(z),V]})}try{let{data:B,error:K}=await(0,MD._request)(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:z,signature:q},((O=D.options)===null||O===void 0?void 0:O.captchaToken)?{gotrue_meta_security:{captcha_token:(U=D.options)===null||U===void 0?void 0:U.captchaToken}}:null),xform:MD._sessionResponse});if(K)throw K;if(!B||!B.session||!B.user){let M=new QD.AuthInvalidTokenResponseError;return this._returnResult({data:{user:null,session:null},error:M})}if(B.session)await this._saveSession(B.session),await this._notifyAllSubscribers("SIGNED_IN",B.session);return this._returnResult({data:Object.assign({},B),error:K})}catch(B){if((0,QD.isAuthError)(B))return this._returnResult({data:{user:null,session:null},error:B});throw B}}async signInWithSolana(D){var $,X,Y,J,Q,F,w,Z,G,O,U,z;let q,B;if("message"in D)q=D.message,B=D.signature;else{let{chain:K,wallet:M,statement:L,options:I}=D,W;if(!(0,ZD.isBrowser)()){if(typeof M!=="object"||!(I===null||I===void 0?void 0:I.url))throw Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");W=M}else if(typeof M==="object")W=M;else{let V=window;if("solana"in V&&typeof V.solana==="object"&&(("signIn"in V.solana)&&typeof V.solana.signIn==="function"||("signMessage"in V.solana)&&typeof V.solana.signMessage==="function"))W=V.solana;else throw Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}let N=new URL(($=I===null||I===void 0?void 0:I.url)!==null&&$!==void 0?$:window.location.href);if("signIn"in W&&W.signIn){let V=await W.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},I===null||I===void 0?void 0:I.signInWithSolana),{version:"1",domain:N.host,uri:N.href}),L?{statement:L}:null)),R;if(Array.isArray(V)&&V[0]&&typeof V[0]==="object")R=V[0];else if(V&&typeof V==="object"&&"signedMessage"in V&&"signature"in V)R=V;else throw Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in R&&"signature"in R&&(typeof R.signedMessage==="string"||R.signedMessage instanceof Uint8Array)&&R.signature instanceof Uint8Array)q=typeof R.signedMessage==="string"?R.signedMessage:new TextDecoder().decode(R.signedMessage),B=R.signature;else throw Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in W)||typeof W.signMessage!=="function"||!("publicKey"in W)||typeof W!=="object"||!W.publicKey||!("toBase58"in W.publicKey)||typeof W.publicKey.toBase58!=="function")throw Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");q=[`${N.host} wants you to sign in with your Solana account:`,W.publicKey.toBase58(),...L?["",L,""]:[""],"Version: 1",`URI: ${N.href}`,`Issued At: ${(Y=(X=I===null||I===void 0?void 0:I.signInWithSolana)===null||X===void 0?void 0:X.issuedAt)!==null&&Y!==void 0?Y:new Date().toISOString()}`,...((J=I===null||I===void 0?void 0:I.signInWithSolana)===null||J===void 0?void 0:J.notBefore)?[`Not Before: ${I.signInWithSolana.notBefore}`]:[],...((Q=I===null||I===void 0?void 0:I.signInWithSolana)===null||Q===void 0?void 0:Q.expirationTime)?[`Expiration Time: ${I.signInWithSolana.expirationTime}`]:[],...((F=I===null||I===void 0?void 0:I.signInWithSolana)===null||F===void 0?void 0:F.chainId)?[`Chain ID: ${I.signInWithSolana.chainId}`]:[],...((w=I===null||I===void 0?void 0:I.signInWithSolana)===null||w===void 0?void 0:w.nonce)?[`Nonce: ${I.signInWithSolana.nonce}`]:[],...((Z=I===null||I===void 0?void 0:I.signInWithSolana)===null||Z===void 0?void 0:Z.requestId)?[`Request ID: ${I.signInWithSolana.requestId}`]:[],...((O=(G=I===null||I===void 0?void 0:I.signInWithSolana)===null||G===void 0?void 0:G.resources)===null||O===void 0?void 0:O.length)?["Resources",...I.signInWithSolana.resources.map((R)=>`- ${R}`)]:[]].join(`
113
- `);let V=await W.signMessage(new TextEncoder().encode(q),"utf8");if(!V||!(V instanceof Uint8Array))throw Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");B=V}}try{let{data:K,error:M}=await(0,MD._request)(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:q,signature:(0,aj.bytesToBase64URL)(B)},((U=D.options)===null||U===void 0?void 0:U.captchaToken)?{gotrue_meta_security:{captcha_token:(z=D.options)===null||z===void 0?void 0:z.captchaToken}}:null),xform:MD._sessionResponse});if(M)throw M;if(!K||!K.session||!K.user){let L=new QD.AuthInvalidTokenResponseError;return this._returnResult({data:{user:null,session:null},error:L})}if(K.session)await this._saveSession(K.session),await this._notifyAllSubscribers("SIGNED_IN",K.session);return this._returnResult({data:Object.assign({},K),error:M})}catch(K){if((0,QD.isAuthError)(K))return this._returnResult({data:{user:null,session:null},error:K});throw K}}async _exchangeCodeForSession(D){let $=await(0,ZD.getItemAsync)(this.storage,`${this.storageKey}-code-verifier`),[X,Y]=($!==null&&$!==void 0?$:"").split("/");try{if(!X&&this.flowType==="pkce")throw new QD.AuthPKCECodeVerifierMissingError;let{data:J,error:Q}=await(0,MD._request)(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:D,code_verifier:X},xform:MD._sessionResponse});if(await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),Q)throw Q;if(!J||!J.session||!J.user){let F=new QD.AuthInvalidTokenResponseError;return this._returnResult({data:{user:null,session:null,redirectType:null},error:F})}if(J.session)await this._saveSession(J.session),await this._notifyAllSubscribers("SIGNED_IN",J.session);return this._returnResult({data:Object.assign(Object.assign({},J),{redirectType:Y!==null&&Y!==void 0?Y:null}),error:Q})}catch(J){if(await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,QD.isAuthError)(J))return this._returnResult({data:{user:null,session:null,redirectType:null},error:J});throw J}}async signInWithIdToken(D){try{let{options:$,provider:X,token:Y,access_token:J,nonce:Q}=D,F=await(0,MD._request)(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:X,id_token:Y,access_token:J,nonce:Q,gotrue_meta_security:{captcha_token:$===null||$===void 0?void 0:$.captchaToken}},xform:MD._sessionResponse}),{data:w,error:Z}=F;if(Z)return this._returnResult({data:{user:null,session:null},error:Z});else if(!w||!w.session||!w.user){let G=new QD.AuthInvalidTokenResponseError;return this._returnResult({data:{user:null,session:null},error:G})}if(w.session)await this._saveSession(w.session),await this._notifyAllSubscribers("SIGNED_IN",w.session);return this._returnResult({data:w,error:Z})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:{user:null,session:null},error:$});throw $}}async signInWithOtp(D){var $,X,Y,J,Q;try{if("email"in D){let{email:F,options:w}=D,Z=null,G=null;if(this.flowType==="pkce")[Z,G]=await(0,ZD.getCodeChallengeAndMethod)(this.storage,this.storageKey);let{error:O}=await(0,MD._request)(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:F,data:($=w===null||w===void 0?void 0:w.data)!==null&&$!==void 0?$:{},create_user:(X=w===null||w===void 0?void 0:w.shouldCreateUser)!==null&&X!==void 0?X:!0,gotrue_meta_security:{captcha_token:w===null||w===void 0?void 0:w.captchaToken},code_challenge:Z,code_challenge_method:G},redirectTo:w===null||w===void 0?void 0:w.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:O})}if("phone"in D){let{phone:F,options:w}=D,{data:Z,error:G}=await(0,MD._request)(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:F,data:(Y=w===null||w===void 0?void 0:w.data)!==null&&Y!==void 0?Y:{},create_user:(J=w===null||w===void 0?void 0:w.shouldCreateUser)!==null&&J!==void 0?J:!0,gotrue_meta_security:{captcha_token:w===null||w===void 0?void 0:w.captchaToken},channel:(Q=w===null||w===void 0?void 0:w.channel)!==null&&Q!==void 0?Q:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:Z===null||Z===void 0?void 0:Z.message_id},error:G})}throw new QD.AuthInvalidCredentialsError("You must provide either an email or phone number.")}catch(F){if(await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,QD.isAuthError)(F))return this._returnResult({data:{user:null,session:null},error:F});throw F}}async verifyOtp(D){var $,X;try{let Y=void 0,J=void 0;if("options"in D)Y=($=D.options)===null||$===void 0?void 0:$.redirectTo,J=(X=D.options)===null||X===void 0?void 0:X.captchaToken;let{data:Q,error:F}=await(0,MD._request)(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},D),{gotrue_meta_security:{captcha_token:J}}),redirectTo:Y,xform:MD._sessionResponse});if(F)throw F;if(!Q)throw Error("An error occurred on token verification.");let{session:w,user:Z}=Q;if(w===null||w===void 0?void 0:w.access_token)await this._saveSession(w),await this._notifyAllSubscribers(D.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",w);return this._returnResult({data:{user:Z,session:w},error:null})}catch(Y){if((0,QD.isAuthError)(Y))return this._returnResult({data:{user:null,session:null},error:Y});throw Y}}async signInWithSSO(D){var $,X,Y,J,Q;try{let F=null,w=null;if(this.flowType==="pkce")[F,w]=await(0,ZD.getCodeChallengeAndMethod)(this.storage,this.storageKey);let Z=await(0,MD._request)(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in D?{provider_id:D.providerId}:null),"domain"in D?{domain:D.domain}:null),{redirect_to:(X=($=D.options)===null||$===void 0?void 0:$.redirectTo)!==null&&X!==void 0?X:void 0}),((Y=D===null||D===void 0?void 0:D.options)===null||Y===void 0?void 0:Y.captchaToken)?{gotrue_meta_security:{captcha_token:D.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:F,code_challenge_method:w}),headers:this.headers,xform:MD._ssoResponse});if(((J=Z.data)===null||J===void 0?void 0:J.url)&&(0,ZD.isBrowser)()&&!((Q=D.options)===null||Q===void 0?void 0:Q.skipBrowserRedirect))window.location.assign(Z.data.url);return this._returnResult(Z)}catch(F){if(await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,QD.isAuthError)(F))return this._returnResult({data:null,error:F});throw F}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{return await this._reauthenticate()})}async _reauthenticate(){try{return await this._useSession(async(D)=>{let{data:{session:$},error:X}=D;if(X)throw X;if(!$)throw new QD.AuthSessionMissingError;let{error:Y}=await(0,MD._request)(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:$.access_token});return this._returnResult({data:{user:null,session:null},error:Y})})}catch(D){if((0,QD.isAuthError)(D))return this._returnResult({data:{user:null,session:null},error:D});throw D}}async resend(D){try{let $=`${this.url}/resend`;if("email"in D){let{email:X,type:Y,options:J}=D,{error:Q}=await(0,MD._request)(this.fetch,"POST",$,{headers:this.headers,body:{email:X,type:Y,gotrue_meta_security:{captcha_token:J===null||J===void 0?void 0:J.captchaToken}},redirectTo:J===null||J===void 0?void 0:J.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:Q})}else if("phone"in D){let{phone:X,type:Y,options:J}=D,{data:Q,error:F}=await(0,MD._request)(this.fetch,"POST",$,{headers:this.headers,body:{phone:X,type:Y,gotrue_meta_security:{captcha_token:J===null||J===void 0?void 0:J.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:Q===null||Q===void 0?void 0:Q.message_id},error:F})}throw new QD.AuthInvalidCredentialsError("You must provide either an email or phone number and a type")}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:{user:null,session:null},error:$});throw $}}async getSession(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{return this._useSession(async($)=>{return $})})}async _acquireLock(D,$){this._debug("#_acquireLock","begin",D);try{if(this.lockAcquired){let X=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),Y=(async()=>{return await X,await $()})();return this.pendingInLock.push((async()=>{try{await Y}catch(J){}})()),Y}return await this.lock(`lock:${this.storageKey}`,D,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;let X=$();this.pendingInLock.push((async()=>{try{await X}catch(Y){}})()),await X;while(this.pendingInLock.length){let Y=[...this.pendingInLock];await Promise.all(Y),this.pendingInLock.splice(0,Y.length)}return await X}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(D){this._debug("#_useSession","begin");try{let $=await this.__loadSession();return await D($)}finally{this._debug("#_useSession","end")}}async __loadSession(){if(this._debug("#__loadSession()","begin"),!this.lockAcquired)this._debug("#__loadSession()","used outside of an acquired lock!",Error().stack);try{let D=null,$=await(0,ZD.getItemAsync)(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",$),$!==null)if(this._isValidSession($))D=$;else this._debug("#getSession()","session from storage is not valid"),await this._removeSession();if(!D)return{data:{session:null},error:null};let X=D.expires_at?D.expires_at*1000-Date.now()<P1.EXPIRY_MARGIN_MS:!1;if(this._debug("#__loadSession()",`session has${X?"":" not"} expired`,"expires_at",D.expires_at),!X){if(this.userStorage){let Q=await(0,ZD.getItemAsync)(this.userStorage,this.storageKey+"-user");if(Q===null||Q===void 0?void 0:Q.user)D.user=Q.user;else D.user=(0,ZD.userNotAvailableProxy)()}if(this.storage.isServer&&D.user&&!D.user.__isUserNotAvailableProxy){let Q={value:this.suppressGetSessionWarning};if(D.user=(0,ZD.insecureUserWarningProxy)(D.user,Q),Q.value)this.suppressGetSessionWarning=!0}return{data:{session:D},error:null}}let{data:Y,error:J}=await this._callRefreshToken(D.refresh_token);if(J)return this._returnResult({data:{session:null},error:J});return this._returnResult({data:{session:Y},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(D){if(D)return await this._getUser(D);await this.initializePromise;let $=await this._acquireLock(this.lockAcquireTimeout,async()=>{return await this._getUser()});if($.data.user)this.suppressGetSessionWarning=!0;return $}async _getUser(D){try{if(D)return await(0,MD._request)(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:D,xform:MD._userResponse});return await this._useSession(async($)=>{var X,Y,J;let{data:Q,error:F}=$;if(F)throw F;if(!((X=Q.session)===null||X===void 0?void 0:X.access_token)&&!this.hasCustomAuthorizationHeader)return{data:{user:null},error:new QD.AuthSessionMissingError};return await(0,MD._request)(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(J=(Y=Q.session)===null||Y===void 0?void 0:Y.access_token)!==null&&J!==void 0?J:void 0,xform:MD._userResponse})})}catch($){if((0,QD.isAuthError)($)){if((0,QD.isAuthSessionMissingError)($))await this._removeSession(),await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`);return this._returnResult({data:{user:null},error:$})}throw $}}async updateUser(D,$={}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{return await this._updateUser(D,$)})}async _updateUser(D,$={}){try{return await this._useSession(async(X)=>{let{data:Y,error:J}=X;if(J)throw J;if(!Y.session)throw new QD.AuthSessionMissingError;let Q=Y.session,F=null,w=null;if(this.flowType==="pkce"&&D.email!=null)[F,w]=await(0,ZD.getCodeChallengeAndMethod)(this.storage,this.storageKey);let{data:Z,error:G}=await(0,MD._request)(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:$===null||$===void 0?void 0:$.emailRedirectTo,body:Object.assign(Object.assign({},D),{code_challenge:F,code_challenge_method:w}),jwt:Q.access_token,xform:MD._userResponse});if(G)throw G;return Q.user=Z.user,await this._saveSession(Q),await this._notifyAllSubscribers("USER_UPDATED",Q),this._returnResult({data:{user:Q.user},error:null})})}catch(X){if(await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,QD.isAuthError)(X))return this._returnResult({data:{user:null},error:X});throw X}}async setSession(D){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{return await this._setSession(D)})}async _setSession(D){try{if(!D.access_token||!D.refresh_token)throw new QD.AuthSessionMissingError;let $=Date.now()/1000,X=$,Y=!0,J=null,{payload:Q}=(0,ZD.decodeJWT)(D.access_token);if(Q.exp)X=Q.exp,Y=X<=$;if(Y){let{data:F,error:w}=await this._callRefreshToken(D.refresh_token);if(w)return this._returnResult({data:{user:null,session:null},error:w});if(!F)return{data:{user:null,session:null},error:null};J=F}else{let{data:F,error:w}=await this._getUser(D.access_token);if(w)return this._returnResult({data:{user:null,session:null},error:w});J={access_token:D.access_token,refresh_token:D.refresh_token,user:F.user,token_type:"bearer",expires_in:X-$,expires_at:X},await this._saveSession(J),await this._notifyAllSubscribers("SIGNED_IN",J)}return this._returnResult({data:{user:J.user,session:J},error:null})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:{session:null,user:null},error:$});throw $}}async refreshSession(D){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{return await this._refreshSession(D)})}async _refreshSession(D){try{return await this._useSession(async($)=>{var X;if(!D){let{data:Q,error:F}=$;if(F)throw F;D=(X=Q.session)!==null&&X!==void 0?X:void 0}if(!(D===null||D===void 0?void 0:D.refresh_token))throw new QD.AuthSessionMissingError;let{data:Y,error:J}=await this._callRefreshToken(D.refresh_token);if(J)return this._returnResult({data:{user:null,session:null},error:J});if(!Y)return this._returnResult({data:{user:null,session:null},error:null});return this._returnResult({data:{user:Y.user,session:Y},error:null})})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:{user:null,session:null},error:$});throw $}}async _getSessionFromURL(D,$){try{if(!(0,ZD.isBrowser)())throw new QD.AuthImplicitGrantRedirectError("No browser detected.");if(D.error||D.error_description||D.error_code)throw new QD.AuthImplicitGrantRedirectError(D.error_description||"Error in URL with unspecified error_description",{error:D.error||"unspecified_error",code:D.error_code||"unspecified_code"});switch($){case"implicit":if(this.flowType==="pkce")throw new QD.AuthPKCEGrantCodeExchangeError("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new QD.AuthImplicitGrantRedirectError("Not a valid implicit grant flow url.");break;default:}if($==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!D.code)throw new QD.AuthPKCEGrantCodeExchangeError("No code detected.");let{data:L,error:I}=await this._exchangeCodeForSession(D.code);if(I)throw I;let W=new URL(window.location.href);return W.searchParams.delete("code"),window.history.replaceState(window.history.state,"",W.toString()),{data:{session:L.session,redirectType:null},error:null}}let{provider_token:X,provider_refresh_token:Y,access_token:J,refresh_token:Q,expires_in:F,expires_at:w,token_type:Z}=D;if(!J||!F||!Q||!Z)throw new QD.AuthImplicitGrantRedirectError("No session defined in URL");let G=Math.round(Date.now()/1000),O=parseInt(F),U=G+O;if(w)U=parseInt(w);let z=U-G;if(z*1000<=P1.AUTO_REFRESH_TICK_DURATION_MS)console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${z}s, should have been closer to ${O}s`);let q=U-O;if(G-q>=120)console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",q,U,G);else if(G-q<0)console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",q,U,G);let{data:B,error:K}=await this._getUser(J);if(K)throw K;let M={provider_token:X,provider_refresh_token:Y,access_token:J,expires_in:O,expires_at:U,refresh_token:Q,token_type:Z,user:B.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:M,redirectType:D.type},error:null})}catch(X){if((0,QD.isAuthError)(X))return this._returnResult({data:{session:null,redirectType:null},error:X});throw X}}_isImplicitGrantCallback(D){if(typeof this.detectSessionInUrl==="function")return this.detectSessionInUrl(new URL(window.location.href),D);return Boolean(D.access_token||D.error_description)}async _isPKCECallback(D){let $=await(0,ZD.getItemAsync)(this.storage,`${this.storageKey}-code-verifier`);return!!(D.code&&$)}async signOut(D={scope:"global"}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{return await this._signOut(D)})}async _signOut({scope:D}={scope:"global"}){return await this._useSession(async($)=>{var X;let{data:Y,error:J}=$;if(J&&!(0,QD.isAuthSessionMissingError)(J))return this._returnResult({error:J});let Q=(X=Y.session)===null||X===void 0?void 0:X.access_token;if(Q){let{error:F}=await this.admin.signOut(Q,D);if(F){if(!((0,QD.isAuthApiError)(F)&&(F.status===404||F.status===401||F.status===403)||(0,QD.isAuthSessionMissingError)(F)))return this._returnResult({error:F})}}if(D!=="others")await this._removeSession(),await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`);return this._returnResult({error:null})})}onAuthStateChange(D){let $=(0,ZD.generateCallbackId)(),X={id:$,callback:D,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",$),this.stateChangeEmitters.delete($)}};return this._debug("#onAuthStateChange()","registered callback with id",$),this.stateChangeEmitters.set($,X),(async()=>{await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession($)})})(),{data:{subscription:X}}}async _emitInitialSession(D){return await this._useSession(async($)=>{var X,Y;try{let{data:{session:J},error:Q}=$;if(Q)throw Q;await((X=this.stateChangeEmitters.get(D))===null||X===void 0?void 0:X.callback("INITIAL_SESSION",J)),this._debug("INITIAL_SESSION","callback id",D,"session",J)}catch(J){await((Y=this.stateChangeEmitters.get(D))===null||Y===void 0?void 0:Y.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",D,"error",J),console.error(J)}})}async resetPasswordForEmail(D,$={}){let X=null,Y=null;if(this.flowType==="pkce")[X,Y]=await(0,ZD.getCodeChallengeAndMethod)(this.storage,this.storageKey,!0);try{return await(0,MD._request)(this.fetch,"POST",`${this.url}/recover`,{body:{email:D,code_challenge:X,code_challenge_method:Y,gotrue_meta_security:{captcha_token:$.captchaToken}},headers:this.headers,redirectTo:$.redirectTo})}catch(J){if(await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,QD.isAuthError)(J))return this._returnResult({data:null,error:J});throw J}}async getUserIdentities(){var D;try{let{data:$,error:X}=await this.getUser();if(X)throw X;return this._returnResult({data:{identities:(D=$.user.identities)!==null&&D!==void 0?D:[]},error:null})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:null,error:$});throw $}}async linkIdentity(D){if("token"in D)return this.linkIdentityIdToken(D);return this.linkIdentityOAuth(D)}async linkIdentityOAuth(D){var $;try{let{data:X,error:Y}=await this._useSession(async(J)=>{var Q,F,w,Z,G;let{data:O,error:U}=J;if(U)throw U;let z=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,D.provider,{redirectTo:(Q=D.options)===null||Q===void 0?void 0:Q.redirectTo,scopes:(F=D.options)===null||F===void 0?void 0:F.scopes,queryParams:(w=D.options)===null||w===void 0?void 0:w.queryParams,skipBrowserRedirect:!0});return await(0,MD._request)(this.fetch,"GET",z,{headers:this.headers,jwt:(G=(Z=O.session)===null||Z===void 0?void 0:Z.access_token)!==null&&G!==void 0?G:void 0})});if(Y)throw Y;if((0,ZD.isBrowser)()&&!(($=D.options)===null||$===void 0?void 0:$.skipBrowserRedirect))window.location.assign(X===null||X===void 0?void 0:X.url);return this._returnResult({data:{provider:D.provider,url:X===null||X===void 0?void 0:X.url},error:null})}catch(X){if((0,QD.isAuthError)(X))return this._returnResult({data:{provider:D.provider,url:null},error:X});throw X}}async linkIdentityIdToken(D){return await this._useSession(async($)=>{var X;try{let{error:Y,data:{session:J}}=$;if(Y)throw Y;let{options:Q,provider:F,token:w,access_token:Z,nonce:G}=D,O=await(0,MD._request)(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(X=J===null||J===void 0?void 0:J.access_token)!==null&&X!==void 0?X:void 0,body:{provider:F,id_token:w,access_token:Z,nonce:G,link_identity:!0,gotrue_meta_security:{captcha_token:Q===null||Q===void 0?void 0:Q.captchaToken}},xform:MD._sessionResponse}),{data:U,error:z}=O;if(z)return this._returnResult({data:{user:null,session:null},error:z});else if(!U||!U.session||!U.user)return this._returnResult({data:{user:null,session:null},error:new QD.AuthInvalidTokenResponseError});if(U.session)await this._saveSession(U.session),await this._notifyAllSubscribers("USER_UPDATED",U.session);return this._returnResult({data:U,error:z})}catch(Y){if(await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,QD.isAuthError)(Y))return this._returnResult({data:{user:null,session:null},error:Y});throw Y}})}async unlinkIdentity(D){try{return await this._useSession(async($)=>{var X,Y;let{data:J,error:Q}=$;if(Q)throw Q;return await(0,MD._request)(this.fetch,"DELETE",`${this.url}/user/identities/${D.identity_id}`,{headers:this.headers,jwt:(Y=(X=J.session)===null||X===void 0?void 0:X.access_token)!==null&&Y!==void 0?Y:void 0})})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:null,error:$});throw $}}async _refreshAccessToken(D){let $=`#_refreshAccessToken(${D.substring(0,5)}...)`;this._debug($,"begin");try{let X=Date.now();return await(0,ZD.retryable)(async(Y)=>{if(Y>0)await(0,ZD.sleep)(200*Math.pow(2,Y-1));return this._debug($,"refreshing attempt",Y),await(0,MD._request)(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:D},headers:this.headers,xform:MD._sessionResponse})},(Y,J)=>{let Q=200*Math.pow(2,Y);return J&&(0,QD.isAuthRetryableFetchError)(J)&&Date.now()+Q-X<P1.AUTO_REFRESH_TICK_DURATION_MS})}catch(X){if(this._debug($,"error",X),(0,QD.isAuthError)(X))return this._returnResult({data:{session:null,user:null},error:X});throw X}finally{this._debug($,"end")}}_isValidSession(D){return typeof D==="object"&&D!==null&&"access_token"in D&&"refresh_token"in D&&"expires_at"in D}async _handleProviderSignIn(D,$){let X=await this._getUrlForProvider(`${this.url}/authorize`,D,{redirectTo:$.redirectTo,scopes:$.scopes,queryParams:$.queryParams});if(this._debug("#_handleProviderSignIn()","provider",D,"options",$,"url",X),(0,ZD.isBrowser)()&&!$.skipBrowserRedirect)window.location.assign(X);return{data:{provider:D,url:X},error:null}}async _recoverAndRefresh(){var D,$;let X="#_recoverAndRefresh()";this._debug("#_recoverAndRefresh()","begin");try{let Y=await(0,ZD.getItemAsync)(this.storage,this.storageKey);if(Y&&this.userStorage){let Q=await(0,ZD.getItemAsync)(this.userStorage,this.storageKey+"-user");if(!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!Q)Q={user:Y.user},await(0,ZD.setItemAsync)(this.userStorage,this.storageKey+"-user",Q);Y.user=(D=Q===null||Q===void 0?void 0:Q.user)!==null&&D!==void 0?D:(0,ZD.userNotAvailableProxy)()}else if(Y&&!Y.user){if(!Y.user){let Q=await(0,ZD.getItemAsync)(this.storage,this.storageKey+"-user");if(Q&&(Q===null||Q===void 0?void 0:Q.user))Y.user=Q.user,await(0,ZD.removeItemAsync)(this.storage,this.storageKey+"-user"),await(0,ZD.setItemAsync)(this.storage,this.storageKey,Y);else Y.user=(0,ZD.userNotAvailableProxy)()}}if(this._debug("#_recoverAndRefresh()","session from storage",Y),!this._isValidSession(Y)){if(this._debug("#_recoverAndRefresh()","session is not valid"),Y!==null)await this._removeSession();return}let J=(($=Y.expires_at)!==null&&$!==void 0?$:1/0)*1000-Date.now()<P1.EXPIRY_MARGIN_MS;if(this._debug("#_recoverAndRefresh()",`session has${J?"":" not"} expired with margin of ${P1.EXPIRY_MARGIN_MS}s`),J){if(this.autoRefreshToken&&Y.refresh_token){let{error:Q}=await this._callRefreshToken(Y.refresh_token);if(Q){if(console.error(Q),!(0,QD.isAuthRetryableFetchError)(Q))this._debug("#_recoverAndRefresh()","refresh failed with a non-retryable error, removing the session",Q),await this._removeSession()}}}else if(Y.user&&Y.user.__isUserNotAvailableProxy===!0)try{let{data:Q,error:F}=await this._getUser(Y.access_token);if(!F&&(Q===null||Q===void 0?void 0:Q.user))Y.user=Q.user,await this._saveSession(Y),await this._notifyAllSubscribers("SIGNED_IN",Y);else this._debug("#_recoverAndRefresh()","could not get user data, skipping SIGNED_IN notification")}catch(Q){console.error("Error getting user data:",Q),this._debug("#_recoverAndRefresh()","error getting user data, skipping SIGNED_IN notification",Q)}else await this._notifyAllSubscribers("SIGNED_IN",Y)}catch(Y){this._debug("#_recoverAndRefresh()","error",Y),console.error(Y);return}finally{this._debug("#_recoverAndRefresh()","end")}}async _callRefreshToken(D){var $,X;if(!D)throw new QD.AuthSessionMissingError;if(this.refreshingDeferred)return this.refreshingDeferred.promise;let Y=`#_callRefreshToken(${D.substring(0,5)}...)`;this._debug(Y,"begin");try{this.refreshingDeferred=new ZD.Deferred;let{data:J,error:Q}=await this._refreshAccessToken(D);if(Q)throw Q;if(!J.session)throw new QD.AuthSessionMissingError;await this._saveSession(J.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",J.session);let F={data:J.session,error:null};return this.refreshingDeferred.resolve(F),F}catch(J){if(this._debug(Y,"error",J),(0,QD.isAuthError)(J)){let Q={data:null,error:J};if(!(0,QD.isAuthRetryableFetchError)(J))await this._removeSession();return($=this.refreshingDeferred)===null||$===void 0||$.resolve(Q),Q}throw(X=this.refreshingDeferred)===null||X===void 0||X.reject(J),J}finally{this.refreshingDeferred=null,this._debug(Y,"end")}}async _notifyAllSubscribers(D,$,X=!0){let Y=`#_notifyAllSubscribers(${D})`;this._debug(Y,"begin",$,`broadcast = ${X}`);try{if(this.broadcastChannel&&X)this.broadcastChannel.postMessage({event:D,session:$});let J=[],Q=Array.from(this.stateChangeEmitters.values()).map(async(F)=>{try{await F.callback(D,$)}catch(w){J.push(w)}});if(await Promise.all(Q),J.length>0){for(let F=0;F<J.length;F+=1)console.error(J[F]);throw J[0]}}finally{this._debug(Y,"end")}}async _saveSession(D){this._debug("#_saveSession()",D),this.suppressGetSessionWarning=!0,await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`);let $=Object.assign({},D),X=$.user&&$.user.__isUserNotAvailableProxy===!0;if(this.userStorage){if(!X&&$.user)await(0,ZD.setItemAsync)(this.userStorage,this.storageKey+"-user",{user:$.user});let Y=Object.assign({},$);delete Y.user;let J=(0,ZD.deepClone)(Y);await(0,ZD.setItemAsync)(this.storage,this.storageKey,J)}else{let Y=(0,ZD.deepClone)($);await(0,ZD.setItemAsync)(this.storage,this.storageKey,Y)}}async _removeSession(){if(this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await(0,ZD.removeItemAsync)(this.storage,this.storageKey),await(0,ZD.removeItemAsync)(this.storage,this.storageKey+"-code-verifier"),await(0,ZD.removeItemAsync)(this.storage,this.storageKey+"-user"),this.userStorage)await(0,ZD.removeItemAsync)(this.userStorage,this.storageKey+"-user");await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");let D=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{if(D&&(0,ZD.isBrowser)()&&(window===null||window===void 0?void 0:window.removeEventListener))window.removeEventListener("visibilitychange",D)}catch($){console.error("removing visibilitychange callback failed",$)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");let D=setInterval(()=>this._autoRefreshTokenTick(),P1.AUTO_REFRESH_TICK_DURATION_MS);if(this.autoRefreshTicker=D,D&&typeof D==="object"&&typeof D.unref==="function")D.unref();else if(typeof Deno<"u"&&typeof Deno.unrefTimer==="function")Deno.unrefTimer(D);let $=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);if(this.autoRefreshTickTimeout=$,$&&typeof $==="object"&&typeof $.unref==="function")$.unref();else if(typeof Deno<"u"&&typeof Deno.unrefTimer==="function")Deno.unrefTimer($)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");let D=this.autoRefreshTicker;if(this.autoRefreshTicker=null,D)clearInterval(D);let $=this.autoRefreshTickTimeout;if(this.autoRefreshTickTimeout=null,$)clearTimeout($)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{let D=Date.now();try{return await this._useSession(async($)=>{let{data:{session:X}}=$;if(!X||!X.refresh_token||!X.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}let Y=Math.floor((X.expires_at*1000-D)/P1.AUTO_REFRESH_TICK_DURATION_MS);if(this._debug("#_autoRefreshTokenTick()",`access token expires in ${Y} ticks, a tick lasts ${P1.AUTO_REFRESH_TICK_DURATION_MS}ms, refresh threshold is ${P1.AUTO_REFRESH_TICK_THRESHOLD} ticks`),Y<=P1.AUTO_REFRESH_TICK_THRESHOLD)await this._callRefreshToken(X.refresh_token)})}catch($){console.error("Auto refresh tick failed with error. This is likely a transient error.",$)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(D){if(D.isAcquireTimeout||D instanceof oj.LockAcquireTimeoutError)this._debug("auto refresh token tick lock not available");else throw D}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!(0,ZD.isBrowser)()||!(window===null||window===void 0?void 0:window.addEventListener)){if(this.autoRefreshToken)this.startAutoRefresh();return!1}try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(D){this._debug("#visibilityChangedCallback","error",D)}},window===null||window===void 0||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(D){console.error("_handleVisibilityChange",D)}}async _onVisibilityChanged(D){let $=`#_onVisibilityChanged(${D})`;if(this._debug($,"visibilityState",document.visibilityState),document.visibilityState==="visible"){if(this.autoRefreshToken)this._startAutoRefresh();if(!D)await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{if(document.visibilityState!=="visible"){this._debug($,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()})}else if(document.visibilityState==="hidden"){if(this.autoRefreshToken)this._stopAutoRefresh()}}async _getUrlForProvider(D,$,X){let Y=[`provider=${encodeURIComponent($)}`];if(X===null||X===void 0?void 0:X.redirectTo)Y.push(`redirect_to=${encodeURIComponent(X.redirectTo)}`);if(X===null||X===void 0?void 0:X.scopes)Y.push(`scopes=${encodeURIComponent(X.scopes)}`);if(this.flowType==="pkce"){let[J,Q]=await(0,ZD.getCodeChallengeAndMethod)(this.storage,this.storageKey),F=new URLSearchParams({code_challenge:`${encodeURIComponent(J)}`,code_challenge_method:`${encodeURIComponent(Q)}`});Y.push(F.toString())}if(X===null||X===void 0?void 0:X.queryParams){let J=new URLSearchParams(X.queryParams);Y.push(J.toString())}if(X===null||X===void 0?void 0:X.skipBrowserRedirect)Y.push(`skip_http_redirect=${X.skipBrowserRedirect}`);return`${D}?${Y.join("&")}`}async _unenroll(D){try{return await this._useSession(async($)=>{var X;let{data:Y,error:J}=$;if(J)return this._returnResult({data:null,error:J});return await(0,MD._request)(this.fetch,"DELETE",`${this.url}/factors/${D.factorId}`,{headers:this.headers,jwt:(X=Y===null||Y===void 0?void 0:Y.session)===null||X===void 0?void 0:X.access_token})})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:null,error:$});throw $}}async _enroll(D){try{return await this._useSession(async($)=>{var X,Y;let{data:J,error:Q}=$;if(Q)return this._returnResult({data:null,error:Q});let F=Object.assign({friendly_name:D.friendlyName,factor_type:D.factorType},D.factorType==="phone"?{phone:D.phone}:D.factorType==="totp"?{issuer:D.issuer}:{}),{data:w,error:Z}=await(0,MD._request)(this.fetch,"POST",`${this.url}/factors`,{body:F,headers:this.headers,jwt:(X=J===null||J===void 0?void 0:J.session)===null||X===void 0?void 0:X.access_token});if(Z)return this._returnResult({data:null,error:Z});if(D.factorType==="totp"&&w.type==="totp"&&((Y=w===null||w===void 0?void 0:w.totp)===null||Y===void 0?void 0:Y.qr_code))w.totp.qr_code=`data:image/svg+xml;utf-8,${w.totp.qr_code}`;return this._returnResult({data:w,error:null})})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:null,error:$});throw $}}async _verify(D){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async($)=>{var X;let{data:Y,error:J}=$;if(J)return this._returnResult({data:null,error:J});let Q=Object.assign({challenge_id:D.challengeId},"webauthn"in D?{webauthn:Object.assign(Object.assign({},D.webauthn),{credential_response:D.webauthn.type==="create"?(0,f7.serializeCredentialCreationResponse)(D.webauthn.credential_response):(0,f7.serializeCredentialRequestResponse)(D.webauthn.credential_response)})}:{code:D.code}),{data:F,error:w}=await(0,MD._request)(this.fetch,"POST",`${this.url}/factors/${D.factorId}/verify`,{body:Q,headers:this.headers,jwt:(X=Y===null||Y===void 0?void 0:Y.session)===null||X===void 0?void 0:X.access_token});if(w)return this._returnResult({data:null,error:w});return await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1000)+F.expires_in},F)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",F),this._returnResult({data:F,error:w})})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:null,error:$});throw $}})}async _challenge(D){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async($)=>{var X;let{data:Y,error:J}=$;if(J)return this._returnResult({data:null,error:J});let Q=await(0,MD._request)(this.fetch,"POST",`${this.url}/factors/${D.factorId}/challenge`,{body:D,headers:this.headers,jwt:(X=Y===null||Y===void 0?void 0:Y.session)===null||X===void 0?void 0:X.access_token});if(Q.error)return Q;let{data:F}=Q;if(F.type!=="webauthn")return{data:F,error:null};switch(F.webauthn.type){case"create":return{data:Object.assign(Object.assign({},F),{webauthn:Object.assign(Object.assign({},F.webauthn),{credential_options:Object.assign(Object.assign({},F.webauthn.credential_options),{publicKey:(0,f7.deserializeCredentialCreationOptions)(F.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},F),{webauthn:Object.assign(Object.assign({},F.webauthn),{credential_options:Object.assign(Object.assign({},F.webauthn.credential_options),{publicKey:(0,f7.deserializeCredentialRequestOptions)(F.webauthn.credential_options.publicKey)})})}),error:null}}})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:null,error:$});throw $}})}async _challengeAndVerify(D){let{data:$,error:X}=await this._challenge({factorId:D.factorId});if(X)return this._returnResult({data:null,error:X});return await this._verify({factorId:D.factorId,challengeId:$.id,code:D.code})}async _listFactors(){var D;let{data:{user:$},error:X}=await this.getUser();if(X)return{data:null,error:X};let Y={all:[],phone:[],totp:[],webauthn:[]};for(let J of(D=$===null||$===void 0?void 0:$.factors)!==null&&D!==void 0?D:[])if(Y.all.push(J),J.status==="verified")Y[J.factor_type].push(J);return{data:Y,error:null}}async _getAuthenticatorAssuranceLevel(D){var $,X,Y,J;if(D)try{let{payload:z}=(0,ZD.decodeJWT)(D),q=null;if(z.aal)q=z.aal;let B=q,{data:{user:K},error:M}=await this.getUser(D);if(M)return this._returnResult({data:null,error:M});if(((X=($=K===null||K===void 0?void 0:K.factors)===null||$===void 0?void 0:$.filter((W)=>W.status==="verified"))!==null&&X!==void 0?X:[]).length>0)B="aal2";let I=z.amr||[];return{data:{currentLevel:q,nextLevel:B,currentAuthenticationMethods:I},error:null}}catch(z){if((0,QD.isAuthError)(z))return this._returnResult({data:null,error:z});throw z}let{data:{session:Q},error:F}=await this.getSession();if(F)return this._returnResult({data:null,error:F});if(!Q)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};let{payload:w}=(0,ZD.decodeJWT)(Q.access_token),Z=null;if(w.aal)Z=w.aal;let G=Z;if(((J=(Y=Q.user.factors)===null||Y===void 0?void 0:Y.filter((z)=>z.status==="verified"))!==null&&J!==void 0?J:[]).length>0)G="aal2";let U=w.amr||[];return{data:{currentLevel:Z,nextLevel:G,currentAuthenticationMethods:U},error:null}}async _getAuthorizationDetails(D){try{return await this._useSession(async($)=>{let{data:{session:X},error:Y}=$;if(Y)return this._returnResult({data:null,error:Y});if(!X)return this._returnResult({data:null,error:new QD.AuthSessionMissingError});return await(0,MD._request)(this.fetch,"GET",`${this.url}/oauth/authorizations/${D}`,{headers:this.headers,jwt:X.access_token,xform:(J)=>({data:J,error:null})})})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:null,error:$});throw $}}async _approveAuthorization(D,$){try{return await this._useSession(async(X)=>{let{data:{session:Y},error:J}=X;if(J)return this._returnResult({data:null,error:J});if(!Y)return this._returnResult({data:null,error:new QD.AuthSessionMissingError});let Q=await(0,MD._request)(this.fetch,"POST",`${this.url}/oauth/authorizations/${D}/consent`,{headers:this.headers,jwt:Y.access_token,body:{action:"approve"},xform:(F)=>({data:F,error:null})});if(Q.data&&Q.data.redirect_url){if((0,ZD.isBrowser)()&&!($===null||$===void 0?void 0:$.skipBrowserRedirect))window.location.assign(Q.data.redirect_url)}return Q})}catch(X){if((0,QD.isAuthError)(X))return this._returnResult({data:null,error:X});throw X}}async _denyAuthorization(D,$){try{return await this._useSession(async(X)=>{let{data:{session:Y},error:J}=X;if(J)return this._returnResult({data:null,error:J});if(!Y)return this._returnResult({data:null,error:new QD.AuthSessionMissingError});let Q=await(0,MD._request)(this.fetch,"POST",`${this.url}/oauth/authorizations/${D}/consent`,{headers:this.headers,jwt:Y.access_token,body:{action:"deny"},xform:(F)=>({data:F,error:null})});if(Q.data&&Q.data.redirect_url){if((0,ZD.isBrowser)()&&!($===null||$===void 0?void 0:$.skipBrowserRedirect))window.location.assign(Q.data.redirect_url)}return Q})}catch(X){if((0,QD.isAuthError)(X))return this._returnResult({data:null,error:X});throw X}}async _listOAuthGrants(){try{return await this._useSession(async(D)=>{let{data:{session:$},error:X}=D;if(X)return this._returnResult({data:null,error:X});if(!$)return this._returnResult({data:null,error:new QD.AuthSessionMissingError});return await(0,MD._request)(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:$.access_token,xform:(Y)=>({data:Y,error:null})})})}catch(D){if((0,QD.isAuthError)(D))return this._returnResult({data:null,error:D});throw D}}async _revokeOAuthGrant(D){try{return await this._useSession(async($)=>{let{data:{session:X},error:Y}=$;if(Y)return this._returnResult({data:null,error:Y});if(!X)return this._returnResult({data:null,error:new QD.AuthSessionMissingError});return await(0,MD._request)(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:X.access_token,query:{client_id:D.clientId},noResolveJson:!0}),{data:{},error:null}})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:null,error:$});throw $}}async fetchJwk(D,$={keys:[]}){let X=$.keys.find((F)=>F.kid===D);if(X)return X;let Y=Date.now();if(X=this.jwks.keys.find((F)=>F.kid===D),X&&this.jwks_cached_at+P1.JWKS_TTL>Y)return X;let{data:J,error:Q}=await(0,MD._request)(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(Q)throw Q;if(!J.keys||J.keys.length===0)return null;if(this.jwks=J,this.jwks_cached_at=Y,X=J.keys.find((F)=>F.kid===D),!X)return null;return X}async getClaims(D,$={}){try{let X=D;if(!X){let{data:z,error:q}=await this.getSession();if(q||!z.session)return this._returnResult({data:null,error:q});X=z.session.access_token}let{header:Y,payload:J,signature:Q,raw:{header:F,payload:w}}=(0,ZD.decodeJWT)(X);if(!($===null||$===void 0?void 0:$.allowExpired))(0,ZD.validateExp)(J.exp);let Z=!Y.alg||Y.alg.startsWith("HS")||!Y.kid||!(("crypto"in globalThis)&&("subtle"in globalThis.crypto))?null:await this.fetchJwk(Y.kid,($===null||$===void 0?void 0:$.keys)?{keys:$.keys}:$===null||$===void 0?void 0:$.jwks);if(!Z){let{error:z}=await this.getUser(X);if(z)throw z;return{data:{claims:J,header:Y,signature:Q},error:null}}let G=(0,ZD.getAlgorithm)(Y.alg),O=await crypto.subtle.importKey("jwk",Z,G,!0,["verify"]);if(!await crypto.subtle.verify(G,O,Q,(0,aj.stringToUint8Array)(`${F}.${w}`)))throw new QD.AuthInvalidJwtError("Invalid JWT signature");return{data:{claims:J,header:Y,signature:Q},error:null}}catch(X){if((0,QD.isAuthError)(X))return this._returnResult({data:null,error:X});throw X}}}y7.nextInstanceID={};sj.default=y7});var DE=T((ej)=>{Object.defineProperty(ej,"__esModule",{value:!0});var J9D=lD(),Y9D=J9D.__importDefault(VJ()),Q9D=Y9D.default;ej.default=Q9D});var XE=T(($E)=>{Object.defineProperty($E,"__esModule",{value:!0});var w9D=lD(),Z9D=w9D.__importDefault(ZO()),G9D=Z9D.default;$E.default=G9D});var GO=T((g6)=>{Object.defineProperty(g6,"__esModule",{value:!0});g6.processLock=g6.lockInternals=g6.NavigatorLockAcquireTimeoutError=g6.navigatorLock=g6.AuthClient=g6.AuthAdminApi=g6.GoTrueClient=g6.GoTrueAdminApi=void 0;var F9=lD(),U9D=F9.__importDefault(VJ());g6.GoTrueAdminApi=U9D.default;var q9D=F9.__importDefault(ZO());g6.GoTrueClient=q9D.default;var z9D=F9.__importDefault(DE());g6.AuthAdminApi=z9D.default;var B9D=F9.__importDefault(XE());g6.AuthClient=B9D.default;F9.__exportStar($O(),g6);F9.__exportStar(_4(),g6);var IJ=QO();Object.defineProperty(g6,"navigatorLock",{enumerable:!0,get:function(){return IJ.navigatorLock}});Object.defineProperty(g6,"NavigatorLockAcquireTimeoutError",{enumerable:!0,get:function(){return IJ.NavigatorLockAcquireTimeoutError}});Object.defineProperty(g6,"lockInternals",{enumerable:!0,get:function(){return IJ.internals}});Object.defineProperty(g6,"processLock",{enumerable:!0,get:function(){return IJ.processLock}})});var GD={};a1(GD,{createClient:()=>OO,SupabaseClient:()=>FE,PostgrestError:()=>_G,FunctionsRelayError:()=>X1.FunctionsRelayError,FunctionsHttpError:()=>X1.FunctionsHttpError,FunctionsFetchError:()=>X1.FunctionsFetchError,FunctionsError:()=>X1.FunctionsError,FunctionRegion:()=>X1.FunctionRegion});function g7(D){return g7=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},g7(D)}function E9D(D,$){if(g7(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(g7(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}function T9D(D){var $=E9D(D,"string");return g7($)=="symbol"?$:$+""}function C9D(D,$,X){return($=T9D($))in D?Object.defineProperty(D,$,{value:X,enumerable:!0,configurable:!0,writable:!0}):D[$]=X,D}function JE(D,$){var X=Object.keys(D);if(Object.getOwnPropertySymbols){var Y=Object.getOwnPropertySymbols(D);$&&(Y=Y.filter(function(J){return Object.getOwnPropertyDescriptor(D,J).enumerable})),X.push.apply(X,Y)}return X}function T0(D){for(var $=1;$<arguments.length;$++){var X=arguments[$]!=null?arguments[$]:{};$%2?JE(Object(X),!0).forEach(function(Y){C9D(D,Y,X[Y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(D,Object.getOwnPropertyDescriptors(X)):JE(Object(X)).forEach(function(Y){Object.defineProperty(D,Y,Object.getOwnPropertyDescriptor(X,Y))})}return D}function u9D(D){return D.endsWith("/")?D:D+"/"}function v9D(D,$){var X,Y;let{db:J,auth:Q,realtime:F,global:w}=D,{db:Z,auth:G,realtime:O,global:U}=$,z={db:T0(T0({},Z),J),auth:T0(T0({},G),Q),realtime:T0(T0({},O),F),storage:{},global:T0(T0(T0({},U),w),{},{headers:T0(T0({},(X=U===null||U===void 0?void 0:U.headers)!==null&&X!==void 0?X:{}),(Y=w===null||w===void 0?void 0:w.headers)!==null&&Y!==void 0?Y:{})}),accessToken:async()=>""};if(D.accessToken)z.accessToken=D.accessToken;else delete z.accessToken;return z}function _9D(D){let $=D===null||D===void 0?void 0:D.trim();if(!$)throw Error("supabaseUrl is required.");if(!$.match(/^https?:\/\//i))throw Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(u9D($))}catch(X){throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}function f9D(){if(typeof window<"u")return!1;let D=globalThis.process;if(!D)return!1;let $=D.version;if($===void 0||$===null)return!1;let X=$.match(/^v(\d+)\./);if(!X)return!1;return parseInt(X[1],10)<=18}var X1,YE,QE,M9D="2.95.3",b7="",L9D,I9D,A9D,R9D,j9D,P9D=(D)=>{if(D)return(...$)=>D(...$);return(...$)=>fetch(...$)},x9D=()=>{return Headers},S9D=(D,$,X)=>{let Y=P9D(X),J=x9D();return async(Q,F)=>{var w;let Z=(w=await $())!==null&&w!==void 0?w:D,G=new J(F===null||F===void 0?void 0:F.headers);if(!G.has("apikey"))G.set("apikey",D);if(!G.has("Authorization"))G.set("Authorization",`Bearer ${Z}`);return Y(Q,T0(T0({},F),{},{headers:G}))}},k9D,FE=class{constructor(D,$,X){var Y,J;this.supabaseUrl=D,this.supabaseKey=$;let Q=_9D(D);if(!$)throw Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",Q),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",Q),this.storageUrl=new URL("storage/v1",Q),this.functionsUrl=new URL("functions/v1",Q);let F=`sb-${Q.hostname.split(".")[0]}-auth-token`,w={db:A9D,realtime:j9D,auth:T0(T0({},R9D),{},{storageKey:F}),global:I9D},Z=v9D(X!==null&&X!==void 0?X:{},w);if(this.storageKey=(Y=Z.auth.storageKey)!==null&&Y!==void 0?Y:"",this.headers=(J=Z.global.headers)!==null&&J!==void 0?J:{},!Z.accessToken){var G;this.auth=this._initSupabaseAuthClient((G=Z.auth)!==null&&G!==void 0?G:{},this.headers,Z.global.fetch)}else this.accessToken=Z.accessToken,this.auth=new Proxy({},{get:(O,U)=>{throw Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(U)} is not possible`)}});if(this.fetch=S9D($,this._getAccessToken.bind(this),Z.global.fetch),this.realtime=this._initRealtimeClient(T0({headers:this.headers,accessToken:this._getAccessToken.bind(this)},Z.realtime)),this.accessToken)Promise.resolve(this.accessToken()).then((O)=>this.realtime.setAuth(O)).catch((O)=>console.warn("Failed to set initial Realtime auth token:",O));if(this.rest=new gA(new URL("rest/v1",Q).href,{headers:this.headers,schema:Z.db.schema,fetch:this.fetch,timeout:Z.db.timeout,urlLengthLimit:Z.db.urlLengthLimit}),this.storage=new yR(this.storageUrl.href,this.headers,this.fetch,X===null||X===void 0?void 0:X.storage),!Z.accessToken)this._listenForAuthEvents()}get functions(){return new X1.FunctionsClient(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(D){return this.rest.from(D)}schema(D){return this.rest.schema(D)}rpc(D,$={},X={head:!1,get:!1,count:void 0}){return this.rest.rpc(D,$,X)}channel(D,$={config:{}}){return this.realtime.channel(D,$)}getChannels(){return this.realtime.getChannels()}removeChannel(D){return this.realtime.removeChannel(D)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var D=this,$,X;if(D.accessToken)return await D.accessToken();let{data:Y}=await D.auth.getSession();return($=(X=Y.session)===null||X===void 0?void 0:X.access_token)!==null&&$!==void 0?$:D.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:D,persistSession:$,detectSessionInUrl:X,storage:Y,userStorage:J,storageKey:Q,flowType:F,lock:w,debug:Z,throwOnError:G},O,U){let z={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new k9D({url:this.authUrl.href,headers:T0(T0({},z),O),storageKey:Q,autoRefreshToken:D,persistSession:$,detectSessionInUrl:X,storage:Y,userStorage:J,flowType:F,lock:w,debug:Z,throwOnError:G,fetch:U,hasCustomAuthorizationHeader:Object.keys(this.headers).some((q)=>q.toLowerCase()==="authorization")})}_initRealtimeClient(D){return new YE.RealtimeClient(this.realtimeUrl.href,T0(T0({},D),{},{params:T0(T0({},{apikey:this.supabaseKey}),D===null||D===void 0?void 0:D.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((D,$)=>{this._handleTokenChanged(D,"CLIENT",$===null||$===void 0?void 0:$.access_token)})}_handleTokenChanged(D,$,X){if((D==="TOKEN_REFRESHED"||D==="SIGNED_IN")&&this.changedAccessToken!==X)this.changedAccessToken=X,this.realtime.setAuth(X);else if(D==="SIGNED_OUT"){if(this.realtime.setAuth(),$=="STORAGE")this.auth.signOut();this.changedAccessToken=void 0}}},OO=(D,$,X)=>{return new FE(D,$,X)};var wE=o(()=>{hA();bR();X1=V0(fA(),1),YE=V0(lG(),1),QE=V0(GO(),1);OD(GD,V0(lG(),1));OD(GD,V0(GO(),1));if(typeof Deno<"u")b7="deno";else if(typeof document<"u")b7="web";else if(typeof navigator<"u"&&navigator.product==="ReactNative")b7="react-native";else b7="node";L9D={"X-Client-Info":`supabase-js-${b7}/${M9D}`},I9D={headers:L9D},A9D={schema:"public"},R9D={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},j9D={};k9D=class extends QE.AuthClient{constructor(D){super(D)}};if(f9D())console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217")});var UO=T((wfD,ZE)=>{ZE.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var AJ=T((OE)=>{var GE={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function y9D(D){return function(...$){if($.length)D=D.replace(/\{(\d)\}/g,(X,Y)=>$[Y]||"");return Error("ADM-ZIP: "+D)}}for(let D of Object.keys(GE))OE[D]=y9D(GE[D])});var KE=T((GfD,BE)=>{var b9D=p("fs"),g0=p("path"),UE=UO(),g9D=AJ(),h9D=typeof process==="object"&&process.platform==="win32",qE=(D)=>typeof D==="object"&&D!==null,zE=new Uint32Array(256).map((D,$)=>{for(let X=0;X<8;X++)if(($&1)!==0)$=3988292384^$>>>1;else $>>>=1;return $>>>0});function C0(D){if(this.sep=g0.sep,this.fs=b9D,qE(D)){if(qE(D.fs)&&typeof D.fs.statSync==="function")this.fs=D.fs}}BE.exports=C0;C0.prototype.makeDir=function(D){let $=this;function X(Y){let J=Y.split($.sep)[0];Y.split($.sep).forEach(function(Q){if(!Q||Q.substr(-1,1)===":")return;J+=$.sep+Q;var F;try{F=$.fs.statSync(J)}catch(w){$.fs.mkdirSync(J)}if(F&&F.isFile())throw g9D.FILE_IN_THE_WAY(`"${J}"`)})}X(D)};C0.prototype.writeFileTo=function(D,$,X,Y){let J=this;if(J.fs.existsSync(D)){if(!X)return!1;var Q=J.fs.statSync(D);if(Q.isDirectory())return!1}var F=g0.dirname(D);if(!J.fs.existsSync(F))J.makeDir(F);var w;try{w=J.fs.openSync(D,"w",438)}catch(Z){J.fs.chmodSync(D,438),w=J.fs.openSync(D,"w",438)}if(w)try{J.fs.writeSync(w,$,0,$.length,0)}finally{J.fs.closeSync(w)}return J.fs.chmodSync(D,Y||438),!0};C0.prototype.writeFileToAsync=function(D,$,X,Y,J){if(typeof Y==="function")J=Y,Y=void 0;let Q=this;Q.fs.exists(D,function(F){if(F&&!X)return J(!1);Q.fs.stat(D,function(w,Z){if(F&&Z.isDirectory())return J(!1);var G=g0.dirname(D);Q.fs.exists(G,function(O){if(!O)Q.makeDir(G);Q.fs.open(D,"w",438,function(U,z){if(U)Q.fs.chmod(D,438,function(){Q.fs.open(D,"w",438,function(q,B){Q.fs.write(B,$,0,$.length,0,function(){Q.fs.close(B,function(){Q.fs.chmod(D,Y||438,function(){J(!0)})})})})});else if(z)Q.fs.write(z,$,0,$.length,0,function(){Q.fs.close(z,function(){Q.fs.chmod(D,Y||438,function(){J(!0)})})});else Q.fs.chmod(D,Y||438,function(){J(!0)})})})})})};C0.prototype.findFiles=function(D){let $=this;function X(Y,J,Q){if(typeof J==="boolean")Q=J,J=void 0;let F=[];return $.fs.readdirSync(Y).forEach(function(w){let Z=g0.join(Y,w),G=$.fs.statSync(Z);if(!J||J.test(Z))F.push(g0.normalize(Z)+(G.isDirectory()?$.sep:""));if(G.isDirectory()&&Q)F=F.concat(X(Z,J,Q))}),F}return X(D,void 0,!0)};C0.prototype.findFilesAsync=function(D,$){let X=this,Y=[];X.fs.readdir(D,function(J,Q){if(J)return $(J);let F=Q.length;if(!F)return $(null,Y);Q.forEach(function(w){w=g0.join(D,w),X.fs.stat(w,function(Z,G){if(Z)return $(Z);if(G){if(Y.push(g0.normalize(w)+(G.isDirectory()?X.sep:"")),G.isDirectory())X.findFilesAsync(w,function(O,U){if(O)return $(O);if(Y=Y.concat(U),!--F)$(null,Y)});else if(!--F)$(null,Y)}})})})};C0.prototype.getAttributes=function(){};C0.prototype.setAttributes=function(){};C0.crc32update=function(D,$){return zE[(D^$)&255]^D>>>8};C0.crc32=function(D){if(typeof D==="string")D=Buffer.from(D,"utf8");let $=D.length,X=-1;for(let Y=0;Y<$;)X=C0.crc32update(X,D[Y++]);return~X>>>0};C0.methodToString=function(D){switch(D){case UE.STORED:return"STORED ("+D+")";case UE.DEFLATED:return"DEFLATED ("+D+")";default:return"UNSUPPORTED ("+D+")"}};C0.canonical=function(D){if(!D)return"";let $=g0.posix.normalize("/"+D.split("\\").join("/"));return g0.join(".",$)};C0.zipnamefix=function(D){if(!D)return"";let $=g0.posix.normalize("/"+D.split("\\").join("/"));return g0.posix.join(".",$)};C0.findLast=function(D,$){if(!Array.isArray(D))throw TypeError("arr is not array");let X=D.length>>>0;for(let Y=X-1;Y>=0;Y--)if($(D[Y],Y,D))return D[Y];return};C0.sanitize=function(D,$){D=g0.resolve(g0.normalize(D));var X=$.split("/");for(var Y=0,J=X.length;Y<J;Y++){var Q=g0.normalize(g0.join(D,X.slice(Y,J).join(g0.sep)));if(Q.indexOf(D)===0)return Q}return g0.normalize(g0.join(D,g0.basename($)))};C0.toBuffer=function($,X){if(Buffer.isBuffer($))return $;else if($ instanceof Uint8Array)return Buffer.from($);else return typeof $==="string"?X($):Buffer.alloc(0)};C0.readBigUInt64LE=function(D,$){var X=Buffer.from(D.slice($,$+8));return X.swap64(),parseInt(`0x${X.toString("hex")}`)};C0.fromDOS2Date=function(D){return new Date((D>>25&127)+1980,Math.max((D>>21&15)-1,0),Math.max(D>>16&31,1),D>>11&31,D>>5&63,(D&31)<<1)};C0.fromDate2DOS=function(D){let $=0,X=0;if(D.getFullYear()>1979)$=(D.getFullYear()-1980&127)<<9|D.getMonth()+1<<5|D.getDate(),X=D.getHours()<<11|D.getMinutes()<<5|D.getSeconds()>>1;return $<<16|X};C0.isWin=h9D;C0.crcTable=zE});var HE=T((OfD,WE)=>{var m9D=p("path");WE.exports=function(D,{fs:$}){var X=D||"",Y=Q(),J=null;function Q(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}if(X&&$.existsSync(X))J=$.statSync(X),Y.directory=J.isDirectory(),Y.mtime=J.mtime,Y.atime=J.atime,Y.executable=(73&J.mode)!==0,Y.readonly=(128&J.mode)===0,Y.hidden=m9D.basename(X)[0]===".";else console.warn("Invalid path: "+X);return{get directory(){return Y.directory},get readOnly(){return Y.readonly},get hidden(){return Y.hidden},get mtime(){return Y.mtime},get atime(){return Y.atime},get executable(){return Y.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:X,isDirectory:Y.directory,isReadOnly:Y.readonly,isHidden:Y.hidden,isExecutable:Y.executable,mTime:Y.mtime,aTime:Y.atime}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var NE=T((UfD,VE)=>{VE.exports={efs:!0,encode:(D)=>Buffer.from(D,"utf8"),decode:(D)=>D.toString("utf8")}});var Z9=T((qfD,w9)=>{w9.exports=KE();w9.exports.Constants=UO();w9.exports.Errors=AJ();w9.exports.FileAttr=HE();w9.exports.decoder=NE()});var LE=T((zfD,ME)=>{var h6=Z9(),wD=h6.Constants;ME.exports=function(){var D=20,$=10,X=0,Y=0,J=0,Q=0,F=0,w=0,Z=0,G=0,O=0,U=0,z=0,q=0,B=0;D|=h6.isWin?2560:768,X|=wD.FLG_EFS;let K={extraLen:0},M=(W)=>Math.max(0,W)>>>0,L=(W)=>Math.max(0,W)&65535,I=(W)=>Math.max(0,W)&255;return J=h6.fromDate2DOS(new Date),{get made(){return D},set made(W){D=W},get version(){return $},set version(W){$=W},get flags(){return X},set flags(W){X=W},get flags_efs(){return(X&wD.FLG_EFS)>0},set flags_efs(W){if(W)X|=wD.FLG_EFS;else X&=~wD.FLG_EFS},get flags_desc(){return(X&wD.FLG_DESC)>0},set flags_desc(W){if(W)X|=wD.FLG_DESC;else X&=~wD.FLG_DESC},get method(){return Y},set method(W){switch(W){case wD.STORED:this.version=10;case wD.DEFLATED:default:this.version=20}Y=W},get time(){return h6.fromDOS2Date(this.timeval)},set time(W){this.timeval=h6.fromDate2DOS(W)},get timeval(){return J},set timeval(W){J=M(W)},get timeHighByte(){return I(J>>>8)},get crc(){return Q},set crc(W){Q=M(W)},get compressedSize(){return F},set compressedSize(W){F=M(W)},get size(){return w},set size(W){w=M(W)},get fileNameLength(){return Z},set fileNameLength(W){Z=W},get extraLength(){return G},set extraLength(W){G=W},get extraLocalLength(){return K.extraLen},set extraLocalLength(W){K.extraLen=W},get commentLength(){return O},set commentLength(W){O=W},get diskNumStart(){return U},set diskNumStart(W){U=M(W)},get inAttr(){return z},set inAttr(W){z=M(W)},get attr(){return q},set attr(W){q=M(W)},get fileAttr(){return(q||0)>>16&4095},get offset(){return B},set offset(W){B=M(W)},get encrypted(){return(X&wD.FLG_ENC)===wD.FLG_ENC},get centralHeaderSize(){return wD.CENHDR+Z+G+O},get realDataOffset(){return B+wD.LOCHDR+K.fnameLen+K.extraLen},get localHeader(){return K},loadLocalHeaderFromBinary:function(W){var N=W.slice(B,B+wD.LOCHDR);if(N.readUInt32LE(0)!==wD.LOCSIG)throw h6.Errors.INVALID_LOC();K.version=N.readUInt16LE(wD.LOCVER),K.flags=N.readUInt16LE(wD.LOCFLG),K.method=N.readUInt16LE(wD.LOCHOW),K.time=N.readUInt32LE(wD.LOCTIM),K.crc=N.readUInt32LE(wD.LOCCRC),K.compressedSize=N.readUInt32LE(wD.LOCSIZ),K.size=N.readUInt32LE(wD.LOCLEN),K.fnameLen=N.readUInt16LE(wD.LOCNAM),K.extraLen=N.readUInt16LE(wD.LOCEXT);let V=B+wD.LOCHDR+K.fnameLen,R=V+K.extraLen;return W.slice(V,R)},loadFromBinary:function(W){if(W.length!==wD.CENHDR||W.readUInt32LE(0)!==wD.CENSIG)throw h6.Errors.INVALID_CEN();D=W.readUInt16LE(wD.CENVEM),$=W.readUInt16LE(wD.CENVER),X=W.readUInt16LE(wD.CENFLG),Y=W.readUInt16LE(wD.CENHOW),J=W.readUInt32LE(wD.CENTIM),Q=W.readUInt32LE(wD.CENCRC),F=W.readUInt32LE(wD.CENSIZ),w=W.readUInt32LE(wD.CENLEN),Z=W.readUInt16LE(wD.CENNAM),G=W.readUInt16LE(wD.CENEXT),O=W.readUInt16LE(wD.CENCOM),U=W.readUInt16LE(wD.CENDSK),z=W.readUInt16LE(wD.CENATT),q=W.readUInt32LE(wD.CENATX),B=W.readUInt32LE(wD.CENOFF)},localHeaderToBinary:function(){var W=Buffer.alloc(wD.LOCHDR);return W.writeUInt32LE(wD.LOCSIG,0),W.writeUInt16LE($,wD.LOCVER),W.writeUInt16LE(X,wD.LOCFLG),W.writeUInt16LE(Y,wD.LOCHOW),W.writeUInt32LE(J,wD.LOCTIM),W.writeUInt32LE(Q,wD.LOCCRC),W.writeUInt32LE(F,wD.LOCSIZ),W.writeUInt32LE(w,wD.LOCLEN),W.writeUInt16LE(Z,wD.LOCNAM),W.writeUInt16LE(K.extraLen,wD.LOCEXT),W},centralHeaderToBinary:function(){var W=Buffer.alloc(wD.CENHDR+Z+G+O);return W.writeUInt32LE(wD.CENSIG,0),W.writeUInt16LE(D,wD.CENVEM),W.writeUInt16LE($,wD.CENVER),W.writeUInt16LE(X,wD.CENFLG),W.writeUInt16LE(Y,wD.CENHOW),W.writeUInt32LE(J,wD.CENTIM),W.writeUInt32LE(Q,wD.CENCRC),W.writeUInt32LE(F,wD.CENSIZ),W.writeUInt32LE(w,wD.CENLEN),W.writeUInt16LE(Z,wD.CENNAM),W.writeUInt16LE(G,wD.CENEXT),W.writeUInt16LE(O,wD.CENCOM),W.writeUInt16LE(U,wD.CENDSK),W.writeUInt16LE(z,wD.CENATT),W.writeUInt32LE(q,wD.CENATX),W.writeUInt32LE(B,wD.CENOFF),W},toJSON:function(){let W=function(N){return N+" bytes"};return{made:D,version:$,flags:X,method:h6.methodToString(Y),time:this.time,crc:"0x"+Q.toString(16).toUpperCase(),compressedSize:W(F),size:W(w),fileNameLength:W(Z),extraLength:W(G),commentLength:W(O),diskNumStart:U,inAttr:z,attr:q,offset:B,centralHeaderSize:W(wD.CENHDR+Z+G+O)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var AE=T((BfD,IE)=>{var G9=Z9(),N0=G9.Constants;IE.exports=function(){var D=0,$=0,X=0,Y=0,J=0;return{get diskEntries(){return D},set diskEntries(Q){D=$=Q},get totalEntries(){return $},set totalEntries(Q){$=D=Q},get size(){return X},set size(Q){X=Q},get offset(){return Y},set offset(Q){Y=Q},get commentLength(){return J},set commentLength(Q){J=Q},get mainHeaderSize(){return N0.ENDHDR+J},loadFromBinary:function(Q){if((Q.length!==N0.ENDHDR||Q.readUInt32LE(0)!==N0.ENDSIG)&&(Q.length<N0.ZIP64HDR||Q.readUInt32LE(0)!==N0.ZIP64SIG))throw G9.Errors.INVALID_END();if(Q.readUInt32LE(0)===N0.ENDSIG)D=Q.readUInt16LE(N0.ENDSUB),$=Q.readUInt16LE(N0.ENDTOT),X=Q.readUInt32LE(N0.ENDSIZ),Y=Q.readUInt32LE(N0.ENDOFF),J=Q.readUInt16LE(N0.ENDCOM);else D=G9.readBigUInt64LE(Q,N0.ZIP64SUB),$=G9.readBigUInt64LE(Q,N0.ZIP64TOT),X=G9.readBigUInt64LE(Q,N0.ZIP64SIZE),Y=G9.readBigUInt64LE(Q,N0.ZIP64OFF),J=0},toBinary:function(){var Q=Buffer.alloc(N0.ENDHDR+J);return Q.writeUInt32LE(N0.ENDSIG,0),Q.writeUInt32LE(0,4),Q.writeUInt16LE(D,N0.ENDSUB),Q.writeUInt16LE($,N0.ENDTOT),Q.writeUInt32LE(X,N0.ENDSIZ),Q.writeUInt32LE(Y,N0.ENDOFF),Q.writeUInt16LE(J,N0.ENDCOM),Q.fill(" ",N0.ENDHDR),Q},toJSON:function(){let Q=function(F,w){let Z=F.toString(16).toUpperCase();while(Z.length<w)Z="0"+Z;return"0x"+Z};return{diskEntries:D,totalEntries:$,size:X+" bytes",offset:Q(Y,4),commentLength:J}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var qO=T((d9D)=>{d9D.EntryHeader=LE();d9D.MainHeader=AE()});var jE=T((WfD,RE)=>{RE.exports=function(D){var $=p("zlib"),X={chunkSize:(parseInt(D.length/1024)+1)*1024};return{deflate:function(){return $.deflateRawSync(D,X)},deflateAsync:function(Y){var J=$.createDeflateRaw(X),Q=[],F=0;J.on("data",function(w){Q.push(w),F+=w.length}),J.on("end",function(){var w=Buffer.alloc(F),Z=0;w.fill(0);for(var G=0;G<Q.length;G++){var O=Q[G];O.copy(w,Z),Z+=O.length}Y&&Y(w)}),J.end(D)}}}});var TE=T((HfD,EE)=>{var n9D=+(process.versions?process.versions.node:"").split(".")[0]||0;EE.exports=function(D,$){var X=p("zlib");let Y=n9D>=15&&$>0?{maxOutputLength:$}:{};return{inflate:function(){return X.inflateRawSync(D,Y)},inflateAsync:function(J){var Q=X.createInflateRaw(Y),F=[],w=0;Q.on("data",function(Z){F.push(Z),w+=Z.length}),Q.on("end",function(){var Z=Buffer.alloc(w),G=0;Z.fill(0);for(var O=0;O<F.length;O++){var U=F[O];U.copy(Z,G),G+=U.length}J&&J(Z)}),Q.end(D)}}}});var uE=T((VfD,SE)=>{var{randomFillSync:CE}=p("crypto"),i9D=AJ(),p9D=new Uint32Array(256).map((D,$)=>{for(let X=0;X<8;X++)if(($&1)!==0)$=$>>>1^3988292384;else $>>>=1;return $>>>0}),xE=(D,$)=>Math.imul(D,$)>>>0,PE=(D,$)=>{return p9D[(D^$)&255]^D>>>8},h7=()=>{if(typeof CE==="function")return CE(Buffer.alloc(12));else return h7.node()};h7.node=()=>{let D=Buffer.alloc(12),$=D.length;for(let X=0;X<$;X++)D[X]=Math.random()*256&255;return D};var RJ={genSalt:h7};function jJ(D){let $=Buffer.isBuffer(D)?D:Buffer.from(D);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let X=0;X<$.length;X++)this.updateKeys($[X])}jJ.prototype.updateKeys=function(D){let $=this.keys;return $[0]=PE($[0],D),$[1]+=$[0]&255,$[1]=xE($[1],134775813)+1,$[2]=PE($[2],$[1]>>>24),D};jJ.prototype.next=function(){let D=(this.keys[2]|2)>>>0;return xE(D,D^1)>>8&255};function r9D(D){let $=new jJ(D);return function(X){let Y=Buffer.alloc(X.length),J=0;for(let Q of X)Y[J++]=$.updateKeys(Q^$.next());return Y}}function o9D(D){let $=new jJ(D);return function(X,Y,J=0){if(!Y)Y=Buffer.alloc(X.length);for(let Q of X){let F=$.next();Y[J++]=Q^F,$.updateKeys(Q)}return Y}}function a9D(D,$,X){if(!D||!Buffer.isBuffer(D)||D.length<12)return Buffer.alloc(0);let Y=r9D(X),J=Y(D.slice(0,12)),Q=($.flags&8)===8?$.timeHighByte:$.crc>>>24;if(J[11]!==Q)throw i9D.WRONG_PASSWORD();return Y(D.slice(12))}function t9D(D){if(Buffer.isBuffer(D)&&D.length>=12)RJ.genSalt=function(){return D.slice(0,12)};else if(D==="node")RJ.genSalt=h7.node;else RJ.genSalt=h7}function s9D(D,$,X,Y=!1){if(D==null)D=Buffer.alloc(0);if(!Buffer.isBuffer(D))D=Buffer.from(D.toString());let J=o9D(X),Q=RJ.genSalt();if(Q[11]=$.crc>>>24&255,Y)Q[10]=$.crc>>>16&255;let F=Buffer.alloc(D.length+12);return J(Q,F),J(D,F,12)}SE.exports={decrypt:a9D,encrypt:s9D,_salter:t9D}});var vE=T((e9D)=>{e9D.Deflater=jE();e9D.Inflater=TE();e9D.ZipCrypto=uE()});var BO=T((MfD,_E)=>{var nD=Z9(),J5D=qO(),P0=nD.Constants,zO=vE();_E.exports=function(D,$){var X=new J5D.EntryHeader,Y=Buffer.alloc(0),J=Buffer.alloc(0),Q=!1,F=null,w=Buffer.alloc(0),Z=Buffer.alloc(0),G=!0;let O=D,U=typeof O.decoder==="object"?O.decoder:nD.decoder;G=U.hasOwnProperty("efs")?U.efs:!1;function z(){if(!$||!($ instanceof Uint8Array))return Buffer.alloc(0);return Z=X.loadLocalHeaderFromBinary($),$.slice(X.realDataOffset,X.realDataOffset+X.compressedSize)}function q(W){if(!X.flags_desc){if(nD.crc32(W)!==X.localHeader.crc)return!1}else{let N={},V=X.realDataOffset+X.compressedSize;if($.readUInt32LE(V)==P0.LOCSIG||$.readUInt32LE(V)==P0.CENSIG)throw nD.Errors.DESCRIPTOR_NOT_EXIST();if($.readUInt32LE(V)==P0.EXTSIG)N.crc=$.readUInt32LE(V+P0.EXTCRC),N.compressedSize=$.readUInt32LE(V+P0.EXTSIZ),N.size=$.readUInt32LE(V+P0.EXTLEN);else if($.readUInt16LE(V+12)===19280)N.crc=$.readUInt32LE(V+P0.EXTCRC-4),N.compressedSize=$.readUInt32LE(V+P0.EXTSIZ-4),N.size=$.readUInt32LE(V+P0.EXTLEN-4);else throw nD.Errors.DESCRIPTOR_UNKNOWN();if(N.compressedSize!==X.compressedSize||N.size!==X.size||N.crc!==X.crc)throw nD.Errors.DESCRIPTOR_FAULTY();if(nD.crc32(W)!==N.crc)return!1}return!0}function B(W,N,V){if(typeof N>"u"&&typeof W==="string")V=W,W=void 0;if(Q){if(W&&N)N(Buffer.alloc(0),nD.Errors.DIRECTORY_CONTENT_ERROR());return Buffer.alloc(0)}var R=z();if(R.length===0){if(W&&N)N(R);return R}if(X.encrypted){if(typeof V!=="string"&&!Buffer.isBuffer(V))throw nD.Errors.INVALID_PASS_PARAM();R=zO.ZipCrypto.decrypt(R,X,V)}var P=Buffer.alloc(X.size);switch(X.method){case nD.Constants.STORED:if(R.copy(P),!q(P)){if(W&&N)N(P,nD.Errors.BAD_CRC());throw nD.Errors.BAD_CRC()}else{if(W&&N)N(P);return P}case nD.Constants.DEFLATED:var A=new zO.Inflater(R,X.size);if(!W){if(A.inflate(P).copy(P,0),!q(P))throw nD.Errors.BAD_CRC(`"${U.decode(Y)}"`);return P}else A.inflateAsync(function(_){if(_.copy(_,0),N)if(!q(_))N(_,nD.Errors.BAD_CRC());else N(_)});break;default:if(W&&N)N(Buffer.alloc(0),nD.Errors.UNKNOWN_METHOD());throw nD.Errors.UNKNOWN_METHOD()}}function K(W,N){if((!F||!F.length)&&Buffer.isBuffer($)){if(W&&N)N(z());return z()}if(F.length&&!Q){var V;switch(X.method){case nD.Constants.STORED:if(X.compressedSize=X.size,V=Buffer.alloc(F.length),F.copy(V),W&&N)N(V);return V;default:case nD.Constants.DEFLATED:var R=new zO.Deflater(F);if(!W){var P=R.deflate();return X.compressedSize=P.length,P}else R.deflateAsync(function(A){V=Buffer.alloc(A.length),X.compressedSize=A.length,A.copy(V),N&&N(V)});R=null;break}}else if(W&&N)N(Buffer.alloc(0));else return Buffer.alloc(0)}function M(W,N){return(W.readUInt32LE(N+4)<<4)+W.readUInt32LE(N)}function L(W){try{var N=0,V,R,P;while(N+4<W.length)if(V=W.readUInt16LE(N),N+=2,R=W.readUInt16LE(N),N+=2,P=W.slice(N,N+R),N+=R,P0.ID_ZIP64===V)I(P)}catch(A){throw nD.Errors.EXTRA_FIELD_PARSE_ERROR()}}function I(W){var N,V,R,P;if(W.length>=P0.EF_ZIP64_SCOMP){if(N=M(W,P0.EF_ZIP64_SUNCOMP),X.size===P0.EF_ZIP64_OR_32)X.size=N}if(W.length>=P0.EF_ZIP64_RHO){if(V=M(W,P0.EF_ZIP64_SCOMP),X.compressedSize===P0.EF_ZIP64_OR_32)X.compressedSize=V}if(W.length>=P0.EF_ZIP64_DSN){if(R=M(W,P0.EF_ZIP64_RHO),X.offset===P0.EF_ZIP64_OR_32)X.offset=R}if(W.length>=P0.EF_ZIP64_DSN+4){if(P=W.readUInt32LE(P0.EF_ZIP64_DSN),X.diskNumStart===P0.EF_ZIP64_OR_16)X.diskNumStart=P}}return{get entryName(){return U.decode(Y)},get rawEntryName(){return Y},set entryName(W){Y=nD.toBuffer(W,U.encode);var N=Y[Y.length-1];Q=N===47||N===92,X.fileNameLength=Y.length},get efs(){if(typeof G==="function")return G(this.entryName);else return G},get extra(){return w},set extra(W){w=W,X.extraLength=W.length,L(W)},get comment(){return U.decode(J)},set comment(W){if(J=nD.toBuffer(W,U.encode),X.commentLength=J.length,J.length>65535)throw nD.Errors.COMMENT_TOO_LONG()},get name(){var W=U.decode(Y);return Q?W.substr(W.length-1).split("/").pop():W.split("/").pop()},get isDirectory(){return Q},getCompressedData:function(){return K(!1,null)},getCompressedDataAsync:function(W){K(!0,W)},setData:function(W){if(F=nD.toBuffer(W,nD.decoder.encode),!Q&&F.length)X.size=F.length,X.method=nD.Constants.DEFLATED,X.crc=nD.crc32(W),X.changed=!0;else X.method=nD.Constants.STORED},getData:function(W){if(X.changed)return F;else return B(!1,null,W)},getDataAsync:function(W,N){if(X.changed)W(F);else B(!0,W,N)},set attr(W){X.attr=W},get attr(){return X.attr},set header(W){X.loadFromBinary(W)},get header(){return X},packCentralHeader:function(){X.flags_efs=this.efs,X.extraLength=w.length;var W=X.centralHeaderToBinary(),N=nD.Constants.CENHDR;return Y.copy(W,N),N+=Y.length,w.copy(W,N),N+=X.extraLength,J.copy(W,N),W},packLocalHeader:function(){let W=0;X.flags_efs=this.efs,X.extraLocalLength=Z.length;let N=X.localHeaderToBinary(),V=Buffer.alloc(N.length+Y.length+X.extraLocalLength);return N.copy(V,W),W+=N.length,Y.copy(V,W),W+=Y.length,Z.copy(V,W),W+=Z.length,V},toJSON:function(){let W=function(N){return"<"+(N&&N.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:X.toJSON(),compressedData:W($),data:W(F)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var yE=T((LfD,fE)=>{var kE=BO(),Y5D=qO(),p0=Z9();fE.exports=function(D,$){var X=[],Y={},J=Buffer.alloc(0),Q=new Y5D.MainHeader,F=!1,w=null;let Z=new Set,G=$,{noSort:O,decoder:U}=G;if(D)B(G.readEntries);else F=!0;function z(){let M=new Set;for(let L of Object.keys(Y)){let I=L.split("/");if(I.pop(),!I.length)continue;for(let W=0;W<I.length;W++){let N=I.slice(0,W+1).join("/")+"/";M.add(N)}}for(let L of M)if(!(L in Y)){let I=new kE(G);I.entryName=L,I.attr=16,I.temporary=!0,X.push(I),Y[I.entryName]=I,Z.add(I)}}function q(){if(F=!0,Y={},Q.diskEntries>(D.length-Q.offset)/p0.Constants.CENHDR)throw p0.Errors.DISK_ENTRY_TOO_LARGE();X=Array(Q.diskEntries);var M=Q.offset;for(var L=0;L<X.length;L++){var I=M,W=new kE(G,D);if(W.header=D.slice(I,I+=p0.Constants.CENHDR),W.entryName=D.slice(I,I+=W.header.fileNameLength),W.header.extraLength)W.extra=D.slice(I,I+=W.header.extraLength);if(W.header.commentLength)W.comment=D.slice(I,I+W.header.commentLength);M+=W.header.centralHeaderSize,X[L]=W,Y[W.entryName]=W}Z.clear(),z()}function B(M){var L=D.length-p0.Constants.ENDHDR,I=Math.max(0,L-65535),W=I,N=D.length,V=-1,R=0;if(typeof G.trailingSpace==="boolean"?G.trailingSpace:!1)I=0;for(L;L>=W;L--){if(D[L]!==80)continue;if(D.readUInt32LE(L)===p0.Constants.ENDSIG){V=L,R=L,N=L+p0.Constants.ENDHDR,W=L-p0.Constants.END64HDR;continue}if(D.readUInt32LE(L)===p0.Constants.END64SIG){W=I;continue}if(D.readUInt32LE(L)===p0.Constants.ZIP64SIG){V=L,N=L+p0.readBigUInt64LE(D,L+p0.Constants.ZIP64SIZE)+p0.Constants.ZIP64LEAD;break}}if(V==-1)throw p0.Errors.INVALID_FORMAT();if(Q.loadFromBinary(D.slice(V,N)),Q.commentLength)J=D.slice(R+p0.Constants.ENDHDR);if(M)q()}function K(){if(X.length>1&&!O)X.sort((M,L)=>M.entryName.toLowerCase().localeCompare(L.entryName.toLowerCase()))}return{get entries(){if(!F)q();return X.filter((M)=>!Z.has(M))},get comment(){return U.decode(J)},set comment(M){J=p0.toBuffer(M,U.encode),Q.commentLength=J.length},getEntryCount:function(){if(!F)return Q.diskEntries;return X.length},forEach:function(M){this.entries.forEach(M)},getEntry:function(M){if(!F)q();return Y[M]||null},setEntry:function(M){if(!F)q();X.push(M),Y[M.entryName]=M,Q.totalEntries=X.length},deleteFile:function(M,L=!0){if(!F)q();let I=Y[M];this.getEntryChildren(I,L).map((N)=>N.entryName).forEach(this.deleteEntry)},deleteEntry:function(M){if(!F)q();let L=Y[M],I=X.indexOf(L);if(I>=0)X.splice(I,1),delete Y[M],Q.totalEntries=X.length},getEntryChildren:function(M,L=!0){if(!F)q();if(typeof M==="object")if(M.isDirectory&&L){let I=[],W=M.entryName;for(let N of X)if(N.entryName.startsWith(W))I.push(N);return I}else return[M];return[]},getChildCount:function(M){if(M&&M.isDirectory){let L=this.getEntryChildren(M);return L.includes(M)?L.length-1:L.length}return 0},compressToBuffer:function(){if(!F)q();K();let M=[],L=[],I=0,W=0;Q.size=0,Q.offset=0;let N=0;for(let P of this.entries){let A=P.getCompressedData();P.header.offset=W;let _=P.packLocalHeader(),v=_.length+A.length;W+=v,M.push(_),M.push(A);let S=P.packCentralHeader();L.push(S),Q.size+=S.length,I+=v+S.length,N++}I+=Q.mainHeaderSize,Q.offset=W,Q.totalEntries=N,W=0;let V=Buffer.alloc(I);for(let P of M)P.copy(V,W),W+=P.length;for(let P of L)P.copy(V,W),W+=P.length;let R=Q.toBinary();if(J)J.copy(R,p0.Constants.ENDHDR);return R.copy(V,W),D=V,F=!1,V},toAsyncBuffer:function(M,L,I,W){try{if(!F)q();K();let N=[],V=[],R=0,P=0,A=0;Q.size=0,Q.offset=0;let _=function(v){if(v.length>0){let S=v.shift(),h=S.entryName+S.extra.toString();if(I)I(h);S.getCompressedDataAsync(function(g){if(W)W(h);S.header.offset=P;let l=S.packLocalHeader(),f=l.length+g.length;P+=f,N.push(l),N.push(g);let j=S.packCentralHeader();V.push(j),Q.size+=j.length,R+=f+j.length,A++,_(v)})}else{R+=Q.mainHeaderSize,Q.offset=P,Q.totalEntries=A,P=0;let S=Buffer.alloc(R);N.forEach(function(g){g.copy(S,P),P+=g.length}),V.forEach(function(g){g.copy(S,P),P+=g.length});let h=Q.toBinary();if(J)J.copy(h,p0.Constants.ENDHDR);h.copy(S,P),D=S,F=!1,M(S)}};_(Array.from(this.entries))}catch(N){L(N)}}}}});var KO=T((IfD,gE)=>{var M0=Z9(),x0=p("path"),Q5D=BO(),F5D=yE(),g4=(...D)=>M0.findLast(D,($)=>typeof $==="boolean"),bE=(...D)=>M0.findLast(D,($)=>typeof $==="string"),w5D=(...D)=>M0.findLast(D,($)=>typeof $==="function"),Z5D={noSort:!1,readEntries:!1,method:M0.Constants.NONE,fs:null};gE.exports=function(D,$){let X=null,Y=Object.assign(Object.create(null),Z5D);if(D&&typeof D==="object"){if(!(D instanceof Uint8Array)){if(Object.assign(Y,D),D=Y.input?Y.input:void 0,Y.input)delete Y.input}if(Buffer.isBuffer(D))X=D,Y.method=M0.Constants.BUFFER,D=void 0}Object.assign(Y,$);let J=new M0(Y);if(typeof Y.decoder!=="object"||typeof Y.decoder.encode!=="function"||typeof Y.decoder.decode!=="function")Y.decoder=M0.decoder;if(D&&typeof D==="string")if(J.fs.existsSync(D))Y.method=M0.Constants.FILE,Y.filename=D,X=J.fs.readFileSync(D);else throw M0.Errors.INVALID_FILENAME();let Q=new F5D(X,Y),{canonical:F,sanitize:w,zipnamefix:Z}=M0;function G(q){if(q&&Q){var B;if(typeof q==="string")B=Q.getEntry(x0.posix.normalize(q));if(typeof q==="object"&&typeof q.entryName<"u"&&typeof q.header<"u")B=Q.getEntry(q.entryName);if(B)return B}return null}function O(q){let{join:B,normalize:K,sep:M}=x0.posix;return B(".",K(M+q.split("\\").join(M)+M))}function U(q){if(q instanceof RegExp)return function(B){return function(K){return B.test(K)}}(q);else if(typeof q!=="function")return()=>!0;return q}let z=(q,B)=>{let K=B.slice(-1);return K=K===J.sep?J.sep:"",x0.relative(q,B)+K};return{readFile:function(q,B){var K=G(q);return K&&K.getData(B)||null},childCount:function(q){let B=G(q);if(B)return Q.getChildCount(B)},readFileAsync:function(q,B){var K=G(q);if(K)K.getDataAsync(B);else B(null,"getEntry failed for:"+q)},readAsText:function(q,B){var K=G(q);if(K){var M=K.getData();if(M&&M.length)return M.toString(B||"utf8")}return""},readAsTextAsync:function(q,B,K){var M=G(q);if(M)M.getDataAsync(function(L,I){if(I){B(L,I);return}if(L&&L.length)B(L.toString(K||"utf8"));else B("")});else B("")},deleteFile:function(q,B=!0){var K=G(q);if(K)Q.deleteFile(K.entryName,B)},deleteEntry:function(q){var B=G(q);if(B)Q.deleteEntry(B.entryName)},addZipComment:function(q){Q.comment=q},getZipComment:function(){return Q.comment||""},addZipEntryComment:function(q,B){var K=G(q);if(K)K.comment=B},getZipEntryComment:function(q){var B=G(q);if(B)return B.comment||"";return""},updateFile:function(q,B){var K=G(q);if(K)K.setData(B)},addLocalFile:function(q,B,K,M){if(J.fs.existsSync(q)){B=B?O(B):"";let L=x0.win32.basename(x0.win32.normalize(q));B+=K?K:L;let I=J.fs.statSync(q),W=I.isFile()?J.fs.readFileSync(q):Buffer.alloc(0);if(I.isDirectory())B+=J.sep;this.addFile(B,W,M,I)}else throw M0.Errors.FILE_NOT_FOUND(q)},addLocalFileAsync:function(q,B){q=typeof q==="object"?q:{localPath:q};let K=x0.resolve(q.localPath),{comment:M}=q,{zipPath:L,zipName:I}=q,W=this;J.fs.stat(K,function(N,V){if(N)return B(N,!1);L=L?O(L):"";let R=x0.win32.basename(x0.win32.normalize(K));if(L+=I?I:R,V.isFile())J.fs.readFile(K,function(P,A){if(P)return B(P,!1);return W.addFile(L,A,M,V),setImmediate(B,void 0,!0)});else if(V.isDirectory())return L+=J.sep,W.addFile(L,Buffer.alloc(0),M,V),setImmediate(B,void 0,!0)})},addLocalFolder:function(q,B,K){if(K=U(K),B=B?O(B):"",q=x0.normalize(q),J.fs.existsSync(q)){let M=J.findFiles(q),L=this;if(M.length)for(let I of M){let W=x0.join(B,z(q,I));if(K(W))L.addLocalFile(I,x0.dirname(W))}}else throw M0.Errors.FILE_NOT_FOUND(q)},addLocalFolderAsync:function(q,B,K,M){M=U(M),K=K?O(K):"",q=x0.normalize(q);var L=this;J.fs.open(q,"r",function(I){if(I&&I.code==="ENOENT")B(void 0,M0.Errors.FILE_NOT_FOUND(q));else if(I)B(void 0,I);else{var W=J.findFiles(q),N=-1,V=function(){if(N+=1,N<W.length){var R=W[N],P=z(q,R).split("\\").join("/");if(P=P.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),M(P))J.fs.stat(R,function(A,_){if(A)B(void 0,A);if(_.isFile())J.fs.readFile(R,function(v,S){if(v)B(void 0,v);else L.addFile(K+P,S,"",_),V()});else L.addFile(K+P+"/",Buffer.alloc(0),"",_),V()});else process.nextTick(()=>{V()})}else B(!0,void 0)};V()}})},addLocalFolderAsync2:function(q,B){let K=this;q=typeof q==="object"?q:{localPath:q},localPath=x0.resolve(O(q.localPath));let{zipPath:M,filter:L,namefix:I}=q;if(L instanceof RegExp)L=function(V){return function(R){return V.test(R)}}(L);else if(typeof L!=="function")L=function(){return!0};if(M=M?O(M):"",I=="latin1")I=(V)=>V.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"");if(typeof I!=="function")I=(V)=>V;let W=(V)=>x0.join(M,I(z(localPath,V))),N=(V)=>x0.win32.basename(x0.win32.normalize(I(V)));J.fs.open(localPath,"r",function(V){if(V&&V.code==="ENOENT")B(void 0,M0.Errors.FILE_NOT_FOUND(localPath));else if(V)B(void 0,V);else J.findFilesAsync(localPath,function(R,P){if(R)return B(R);if(P=P.filter((A)=>L(W(A))),!P.length)B(void 0,!1);setImmediate(P.reverse().reduce(function(A,_){return function(v,S){if(v||S===!1)return setImmediate(A,v,!1);K.addLocalFileAsync({localPath:_,zipPath:x0.dirname(W(_)),zipName:N(_)},A)}},B))})})},addLocalFolderPromise:function(q,B){return new Promise((K,M)=>{this.addLocalFolderAsync2(Object.assign({localPath:q},B),(L,I)=>{if(L)M(L);if(I)K(this)})})},addFile:function(q,B,K,M){q=Z(q);let L=G(q),I=L!=null;if(!I)L=new Q5D(Y),L.entryName=q;L.comment=K||"";let W=typeof M==="object"&&M instanceof J.fs.Stats;if(W)L.header.time=M.mtime;var N=L.isDirectory?16:0;let V=L.isDirectory?16384:32768;if(W)V|=4095&M.mode;else if(typeof M==="number")V|=4095&M;else V|=L.isDirectory?493:420;if(N=(N|V<<16)>>>0,L.attr=N,L.setData(B),!I)Q.setEntry(L);return L},getEntries:function(q){return Q.password=q,Q?Q.entries:[]},getEntry:function(q){return G(q)},getEntryCount:function(){return Q.getEntryCount()},forEach:function(q){return Q.forEach(q)},extractEntryTo:function(q,B,K,M,L,I){M=g4(!1,M),L=g4(!1,L),K=g4(!0,K),I=bE(L,I);var W=G(q);if(!W)throw M0.Errors.NO_ENTRY();var N=F(W.entryName),V=w(B,I&&!W.isDirectory?I:K?N:x0.basename(N));if(W.isDirectory){var R=Q.getEntryChildren(W);return R.forEach(function(_){if(_.isDirectory)return;var v=_.getData();if(!v)throw M0.Errors.CANT_EXTRACT_FILE();var S=F(_.entryName),h=w(B,K?S:x0.basename(S));let g=L?_.header.fileAttr:void 0;J.writeFileTo(h,v,M,g)}),!0}var P=W.getData(Q.password);if(!P)throw M0.Errors.CANT_EXTRACT_FILE();if(J.fs.existsSync(V)&&!M)throw M0.Errors.CANT_OVERRIDE();let A=L?q.header.fileAttr:void 0;return J.writeFileTo(V,P,M,A),!0},test:function(q){if(!Q)return!1;for(var B in Q.entries)try{if(B.isDirectory)continue;var K=Q.entries[B].getData(q);if(!K)return!1}catch(M){return!1}return!0},extractAllTo:function(q,B,K,M){if(K=g4(!1,K),M=bE(K,M),B=g4(!1,B),!Q)throw M0.Errors.NO_ZIP();Q.entries.forEach(function(L){var I=w(q,F(L.entryName));if(L.isDirectory){J.makeDir(I);return}var W=L.getData(M);if(!W)throw M0.Errors.CANT_EXTRACT_FILE();let N=K?L.header.fileAttr:void 0;J.writeFileTo(I,W,B,N);try{J.fs.utimesSync(I,L.header.time,L.header.time)}catch(V){throw M0.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(q,B,K,M){if(M=w5D(B,K,M),K=g4(!1,K),B=g4(!1,B),!M)return new Promise((V,R)=>{this.extractAllToAsync(q,B,K,function(P){if(P)R(P);else V(this)})});if(!Q){M(M0.Errors.NO_ZIP());return}q=x0.resolve(q);let L=(V)=>w(q,x0.normalize(F(V.entryName))),I=(V,R)=>Error(V+': "'+R+'"'),W=[],N=[];Q.entries.forEach((V)=>{if(V.isDirectory)W.push(V);else N.push(V)});for(let V of W){let R=L(V),P=K?V.header.fileAttr:void 0;try{if(J.makeDir(R),P)J.fs.chmodSync(R,P);J.fs.utimesSync(R,V.header.time,V.header.time)}catch(A){M(I("Unable to create folder",R))}}N.reverse().reduce(function(V,R){return function(P){if(P)V(P);else{let A=x0.normalize(F(R.entryName)),_=w(q,A);R.getDataAsync(function(v,S){if(S)V(S);else if(!v)V(M0.Errors.CANT_EXTRACT_FILE());else{let h=K?R.header.fileAttr:void 0;J.writeFileToAsync(_,v,B,h,function(g){if(!g)V(I("Unable to write file",_));J.fs.utimes(_,R.header.time,R.header.time,function(l){if(l)V(I("Unable to set times",_));else V()})})}})}}},M)()},writeZip:function(q,B){if(arguments.length===1){if(typeof q==="function")B=q,q=""}if(!q&&Y.filename)q=Y.filename;if(!q)return;var K=Q.compressToBuffer();if(K){var M=J.writeFileTo(q,K,!0);if(typeof B==="function")B(!M?Error("failed"):null,"")}},writeZipPromise:function(q,B){let{overwrite:K,perm:M}=Object.assign({overwrite:!0},B);return new Promise((L,I)=>{if(!q&&Y.filename)q=Y.filename;if(!q)I("ADM-ZIP: ZIP File Name Missing");this.toBufferPromise().then((W)=>{let N=(V)=>V?L(V):I("ADM-ZIP: Wasn't able to write zip file");J.writeFileToAsync(q,W,K,M,N)},I)})},toBufferPromise:function(){return new Promise((q,B)=>{Q.toAsyncBuffer(q,B)})},toBuffer:function(q,B,K,M){if(typeof q==="function")return Q.toAsyncBuffer(q,B,K,M),null;return Q.compressToBuffer()}}}});var cE=T((AfD,dE)=>{var mE={};dE.exports=mE;var hE={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],brightRed:[91,39],brightGreen:[92,39],brightYellow:[93,39],brightBlue:[94,39],brightMagenta:[95,39],brightCyan:[96,39],brightWhite:[97,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgGray:[100,49],bgGrey:[100,49],bgBrightRed:[101,49],bgBrightGreen:[102,49],bgBrightYellow:[103,49],bgBrightBlue:[104,49],bgBrightMagenta:[105,49],bgBrightCyan:[106,49],bgBrightWhite:[107,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(hE).forEach(function(D){var $=hE[D],X=mE[D]=[];X.open="\x1B["+$[0]+"m",X.close="\x1B["+$[1]+"m"})});var nE=T((RfD,lE)=>{lE.exports=function(D,$){$=$||process.argv;var X=$.indexOf("--"),Y=/^-{1,2}/.test(D)?"":"--",J=$.indexOf(Y+D);return J!==-1&&(X===-1?!0:J<X)}});var pE=T((jfD,iE)=>{var G5D=p("os"),H$=nE(),U1=process.env,O9=void 0;if(H$("no-color")||H$("no-colors")||H$("color=false"))O9=!1;else if(H$("color")||H$("colors")||H$("color=true")||H$("color=always"))O9=!0;if("FORCE_COLOR"in U1)O9=U1.FORCE_COLOR.length===0||parseInt(U1.FORCE_COLOR,10)!==0;function O5D(D){if(D===0)return!1;return{level:D,hasBasic:!0,has256:D>=2,has16m:D>=3}}function U5D(D){if(O9===!1)return 0;if(H$("color=16m")||H$("color=full")||H$("color=truecolor"))return 3;if(H$("color=256"))return 2;if(D&&!D.isTTY&&O9!==!0)return 0;var $=O9?1:0;if(process.platform==="win32"){var X=G5D.release().split(".");if(Number(process.versions.node.split(".")[0])>=8&&Number(X[0])>=10&&Number(X[2])>=10586)return Number(X[2])>=14931?3:2;return 1}if("CI"in U1){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(function(J){return J in U1})||U1.CI_NAME==="codeship")return 1;return $}if("TEAMCITY_VERSION"in U1)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(U1.TEAMCITY_VERSION)?1:0;if("TERM_PROGRAM"in U1){var Y=parseInt((U1.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(U1.TERM_PROGRAM){case"iTerm.app":return Y>=3?3:2;case"Hyper":return 3;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(U1.TERM))return 2;if(/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(U1.TERM))return 1;if("COLORTERM"in U1)return 1;if(U1.TERM==="dumb")return $;return $}function WO(D){var $=U5D(D);return O5D($)}iE.exports={supportsColor:WO,stdout:WO(process.stdout),stderr:WO(process.stderr)}});var oE=T((EfD,rE)=>{rE.exports=function($,X){var Y="";$=$||"Run the trap, drop the bass",$=$.split("");var J={a:["@","Ą","Ⱥ","Ʌ","Δ","Λ","Д"],b:["ß","Ɓ","Ƀ","ɮ","β","฿"],c:["©","Ȼ","Ͼ"],d:["Ð","Ɗ","Ԁ","ԁ","Ԃ","ԃ"],e:["Ë","ĕ","Ǝ","ɘ","Σ","ξ","Ҽ","੬"],f:["Ӻ"],g:["ɢ"],h:["Ħ","ƕ","Ң","Һ","Ӈ","Ԋ"],i:["༏"],j:["Ĵ"],k:["ĸ","Ҡ","Ӄ","Ԟ"],l:["Ĺ"],m:["ʍ","Ӎ","ӎ","Ԡ","ԡ","൩"],n:["Ñ","ŋ","Ɲ","Ͷ","Π","Ҋ"],o:["Ø","õ","ø","Ǿ","ʘ","Ѻ","ם","۝","๏"],p:["Ƿ","Ҏ"],q:["্"],r:["®","Ʀ","Ȑ","Ɍ","ʀ","Я"],s:["§","Ϟ","ϟ","Ϩ"],t:["Ł","Ŧ","ͳ"],u:["Ʊ","Ս"],v:["ט"],w:["Ш","Ѡ","Ѽ","൰"],x:["Ҳ","Ӿ","Ӽ","ӽ"],y:["¥","Ұ","Ӌ"],z:["Ƶ","ɀ"]};return $.forEach(function(Q){Q=Q.toLowerCase();var F=J[Q]||[" "],w=Math.floor(Math.random()*F.length);if(typeof J[Q]<"u")Y+=J[Q][w];else Y+=Q}),Y}});var tE=T((TfD,aE)=>{aE.exports=function($,X){$=$||" he is here ";var Y={up:["̍","̎","̄","̅","̿","̑","̆","̐","͒","͗","͑","̇","̈","̊","͂","̓","̈","͊","͋","͌","̃","̂","̌","͐","̀","́","̋","̏","̒","̓","̔","̽","̉","ͣ","ͤ","ͥ","ͦ","ͧ","ͨ","ͩ","ͪ","ͫ","ͬ","ͭ","ͮ","ͯ","̾","͛","͆","̚"],down:["̖","̗","̘","̙","̜","̝","̞","̟","̠","̤","̥","̦","̩","̪","̫","̬","̭","̮","̯","̰","̱","̲","̳","̹","̺","̻","̼","ͅ","͇","͈","͉","͍","͎","͓","͔","͕","͖","͙","͚","̣"],mid:["̕","̛","̀","́","͘","̡","̢","̧","̨","̴","̵","̶","͜","͝","͞","͟","͠","͢","̸","̷","͡"," ҉"]},J=[].concat(Y.up,Y.down,Y.mid);function Q(Z){var G=Math.floor(Math.random()*Z);return G}function F(Z){var G=!1;return J.filter(function(O){G=O===Z}),G}function w(Z,G){var O="",U,z;G=G||{},G.up=typeof G.up<"u"?G.up:!0,G.mid=typeof G.mid<"u"?G.mid:!0,G.down=typeof G.down<"u"?G.down:!0,G.size=typeof G.size<"u"?G.size:"maxi",Z=Z.split("");for(z in Z){if(F(z))continue;switch(O=O+Z[z],U={up:0,down:0,mid:0},G.size){case"mini":U.up=Q(8),U.mid=Q(2),U.down=Q(8);break;case"maxi":U.up=Q(16)+3,U.mid=Q(4)+1,U.down=Q(64)+3;break;default:U.up=Q(8)+1,U.mid=Q(6)/2,U.down=Q(8)+1;break}var q=["up","mid","down"];for(var B in q){var K=q[B];for(var M=0;M<=U[K];M++)if(G[K])O=O+Y[K][Q(Y[K].length)]}}return O}return w($,X)}});var eE=T((CfD,sE)=>{sE.exports=function(D){return function($,X,Y){if($===" ")return $;switch(X%3){case 0:return D.red($);case 1:return D.white($);case 2:return D.blue($)}}}});var $T=T((PfD,DT)=>{DT.exports=function(D){return function($,X,Y){return X%2===0?$:D.inverse($)}}});var JT=T((xfD,XT)=>{XT.exports=function(D){var $=["red","yellow","green","blue","magenta"];return function(X,Y,J){if(X===" ")return X;else return D[$[Y++%$.length]](X)}}});var QT=T((SfD,YT)=>{YT.exports=function(D){var $=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta","brightYellow","brightRed","brightGreen","brightBlue","brightWhite","brightCyan","brightMagenta"];return function(X,Y,J){return X===" "?X:D[$[Math.round(Math.random()*($.length-2))]](X)}}});var OT=T((vfD,GT)=>{var _D={};GT.exports=_D;_D.themes={};var q5D=p("util"),h4=_D.styles=cE(),FT=Object.defineProperties,z5D=new RegExp(/[\r\n]+/g);_D.supportsColor=pE().supportsColor;if(typeof _D.enabled>"u")_D.enabled=_D.supportsColor()!==!1;_D.enable=function(){_D.enabled=!0};_D.disable=function(){_D.enabled=!1};_D.stripColors=_D.strip=function(D){return(""+D).replace(/\x1B\[\d+m/g,"")};var ufD=_D.stylize=function($,X){if(!_D.enabled)return $+"";var Y=h4[X];if(!Y&&X in _D)return _D[X]($);return Y.open+$+Y.close},B5D=/[|\\{}()[\]^$+*?.]/g,K5D=function(D){if(typeof D!=="string")throw TypeError("Expected a string");return D.replace(B5D,"\\$&")};function wT(D){var $=function X(){return H5D.apply(X,arguments)};return $._styles=D,$.__proto__=W5D,$}var ZT=function(){var D={};return h4.grey=h4.gray,Object.keys(h4).forEach(function($){h4[$].closeRe=new RegExp(K5D(h4[$].close),"g"),D[$]={get:function(){return wT(this._styles.concat($))}}}),D}(),W5D=FT(function(){},ZT);function H5D(){var D=Array.prototype.slice.call(arguments),$=D.map(function(F){if(F!=null&&F.constructor===String)return F;else return q5D.inspect(F)}).join(" ");if(!_D.enabled||!$)return $;var X=$.indexOf(`
112
+ ${L}`}});var fj=T((_j)=>{Object.defineProperty(_j,"__esModule",{value:!0});_j.WebAuthnUnknownError=_j.WebAuthnError=void 0;_j.isWebAuthnError=C8D;_j.identifyRegistrationError=P8D;_j.identifyAuthenticationError=x8D;var uj=FO();class E0 extends Error{constructor({message:D,code:$,cause:X,name:Y}){var J;super(D,{cause:X});this.__isWebAuthnError=!0,this.name=(J=Y!==null&&Y!==void 0?Y:X instanceof Error?X.name:void 0)!==null&&J!==void 0?J:"Unknown Error",this.code=$}}_j.WebAuthnError=E0;class vj extends E0{constructor(D,$){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:$,message:D});this.name="WebAuthnUnknownError",this.originalError=$}}_j.WebAuthnUnknownError=vj;function C8D(D){return typeof D==="object"&&D!==null&&"__isWebAuthnError"in D}function P8D({error:D,options:$}){var X,Y,J;let{publicKey:Q}=$;if(!Q)throw Error("options was missing required publicKey property");if(D.name==="AbortError"){if($.signal instanceof AbortSignal)return new E0({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:D})}else if(D.name==="ConstraintError"){if(((X=Q.authenticatorSelection)===null||X===void 0?void 0:X.requireResidentKey)===!0)return new E0({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:D});else if($.mediation==="conditional"&&((Y=Q.authenticatorSelection)===null||Y===void 0?void 0:Y.userVerification)==="required")return new E0({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:D});else if(((J=Q.authenticatorSelection)===null||J===void 0?void 0:J.userVerification)==="required")return new E0({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:D})}else if(D.name==="InvalidStateError")return new E0({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:D});else if(D.name==="NotAllowedError")return new E0({message:D.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:D});else if(D.name==="NotSupportedError"){if(Q.pubKeyCredParams.filter((w)=>w.type==="public-key").length===0)return new E0({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:D});return new E0({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:D})}else if(D.name==="SecurityError"){let F=window.location.hostname;if(!(0,uj.isValidDomain)(F))return new E0({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:D});else if(Q.rp.id!==F)return new E0({message:`The RP ID "${Q.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:D})}else if(D.name==="TypeError"){if(Q.user.id.byteLength<1||Q.user.id.byteLength>64)return new E0({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:D})}else if(D.name==="UnknownError")return new E0({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:D});return new E0({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:D})}function x8D({error:D,options:$}){let{publicKey:X}=$;if(!X)throw Error("options was missing required publicKey property");if(D.name==="AbortError"){if($.signal instanceof AbortSignal)return new E0({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:D})}else if(D.name==="NotAllowedError")return new E0({message:D.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:D});else if(D.name==="SecurityError"){let Y=window.location.hostname;if(!(0,uj.isValidDomain)(Y))return new E0({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:D});else if(X.rpId!==Y)return new E0({message:`The RP ID "${X.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:D})}else if(D.name==="UnknownError")return new E0({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:D});return new E0({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:D})}});var FO=T((Y9)=>{Object.defineProperty(Y9,"__esModule",{value:!0});Y9.WebAuthnApi=Y9.DEFAULT_REQUEST_OPTIONS=Y9.DEFAULT_CREATION_OPTIONS=Y9.webAuthnAbortService=Y9.WebAuthnAbortService=Y9.identifyAuthenticationError=Y9.identifyRegistrationError=Y9.isWebAuthnError=Y9.WebAuthnError=void 0;Y9.deserializeCredentialCreationOptions=f8D;Y9.deserializeCredentialRequestOptions=y8D;Y9.serializeCredentialCreationResponse=b8D;Y9.serializeCredentialRequestResponse=g8D;Y9.isValidDomain=h8D;Y9.createCredential=gj;Y9.getCredential=hj;Y9.mergeCredentialCreationOptions=mj;Y9.mergeCredentialRequestOptions=dj;var bj=lD(),W$=KJ(),E$=_4(),k8D=J9(),T$=fj();Object.defineProperty(Y9,"identifyAuthenticationError",{enumerable:!0,get:function(){return T$.identifyAuthenticationError}});Object.defineProperty(Y9,"identifyRegistrationError",{enumerable:!0,get:function(){return T$.identifyRegistrationError}});Object.defineProperty(Y9,"isWebAuthnError",{enumerable:!0,get:function(){return T$.isWebAuthnError}});Object.defineProperty(Y9,"WebAuthnError",{enumerable:!0,get:function(){return T$.WebAuthnError}});class wO{createNewAbortSignal(){if(this.controller){let $=Error("Cancelling existing WebAuthn API call for new one");$.name="AbortError",this.controller.abort($)}let D=new AbortController;return this.controller=D,D.signal}cancelCeremony(){if(this.controller){let D=Error("Manually cancelling existing WebAuthn API call");D.name="AbortError",this.controller.abort(D),this.controller=void 0}}}Y9.WebAuthnAbortService=wO;Y9.webAuthnAbortService=new wO;function f8D(D){if(!D)throw Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON==="function")return PublicKeyCredential.parseCreationOptionsFromJSON(D);let{challenge:$,user:X,excludeCredentials:Y}=D,J=bj.__rest(D,["challenge","user","excludeCredentials"]),Q=(0,W$.base64UrlToUint8Array)($).buffer,F=Object.assign(Object.assign({},X),{id:(0,W$.base64UrlToUint8Array)(X.id).buffer}),w=Object.assign(Object.assign({},J),{challenge:Q,user:F});if(Y&&Y.length>0){w.excludeCredentials=Array(Y.length);for(let Z=0;Z<Y.length;Z++){let G=Y[Z];w.excludeCredentials[Z]=Object.assign(Object.assign({},G),{id:(0,W$.base64UrlToUint8Array)(G.id).buffer,type:G.type||"public-key",transports:G.transports})}}return w}function y8D(D){if(!D)throw Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON==="function")return PublicKeyCredential.parseRequestOptionsFromJSON(D);let{challenge:$,allowCredentials:X}=D,Y=bj.__rest(D,["challenge","allowCredentials"]),J=(0,W$.base64UrlToUint8Array)($).buffer,Q=Object.assign(Object.assign({},Y),{challenge:J});if(X&&X.length>0){Q.allowCredentials=Array(X.length);for(let F=0;F<X.length;F++){let w=X[F];Q.allowCredentials[F]=Object.assign(Object.assign({},w),{id:(0,W$.base64UrlToUint8Array)(w.id).buffer,type:w.type||"public-key",transports:w.transports})}}return Q}function b8D(D){var $;if("toJSON"in D&&typeof D.toJSON==="function")return D.toJSON();let X=D;return{id:D.id,rawId:D.id,response:{attestationObject:(0,W$.bytesToBase64URL)(new Uint8Array(D.response.attestationObject)),clientDataJSON:(0,W$.bytesToBase64URL)(new Uint8Array(D.response.clientDataJSON))},type:"public-key",clientExtensionResults:D.getClientExtensionResults(),authenticatorAttachment:($=X.authenticatorAttachment)!==null&&$!==void 0?$:void 0}}function g8D(D){var $;if("toJSON"in D&&typeof D.toJSON==="function")return D.toJSON();let X=D,Y=D.getClientExtensionResults(),J=D.response;return{id:D.id,rawId:D.id,response:{authenticatorData:(0,W$.bytesToBase64URL)(new Uint8Array(J.authenticatorData)),clientDataJSON:(0,W$.bytesToBase64URL)(new Uint8Array(J.clientDataJSON)),signature:(0,W$.bytesToBase64URL)(new Uint8Array(J.signature)),userHandle:J.userHandle?(0,W$.bytesToBase64URL)(new Uint8Array(J.userHandle)):void 0},type:"public-key",clientExtensionResults:Y,authenticatorAttachment:($=X.authenticatorAttachment)!==null&&$!==void 0?$:void 0}}function h8D(D){return D==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(D)}function yj(){var D,$;return!!((0,k8D.isBrowser)()&&("PublicKeyCredential"in window)&&window.PublicKeyCredential&&("credentials"in navigator)&&typeof((D=navigator===null||navigator===void 0?void 0:navigator.credentials)===null||D===void 0?void 0:D.create)==="function"&&typeof(($=navigator===null||navigator===void 0?void 0:navigator.credentials)===null||$===void 0?void 0:$.get)==="function")}async function gj(D){try{let $=await navigator.credentials.create(D);if(!$)return{data:null,error:new T$.WebAuthnUnknownError("Empty credential response",$)};if(!($ instanceof PublicKeyCredential))return{data:null,error:new T$.WebAuthnUnknownError("Browser returned unexpected credential type",$)};return{data:$,error:null}}catch($){return{data:null,error:(0,T$.identifyRegistrationError)({error:$,options:D})}}}async function hj(D){try{let $=await navigator.credentials.get(D);if(!$)return{data:null,error:new T$.WebAuthnUnknownError("Empty credential response",$)};if(!($ instanceof PublicKeyCredential))return{data:null,error:new T$.WebAuthnUnknownError("Browser returned unexpected credential type",$)};return{data:$,error:null}}catch($){return{data:null,error:(0,T$.identifyAuthenticationError)({error:$,options:D})}}}Y9.DEFAULT_CREATION_OPTIONS={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"};Y9.DEFAULT_REQUEST_OPTIONS={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function MJ(...D){let $=(J)=>J!==null&&typeof J==="object"&&!Array.isArray(J),X=(J)=>J instanceof ArrayBuffer||ArrayBuffer.isView(J),Y={};for(let J of D){if(!J)continue;for(let Q in J){let F=J[Q];if(F===void 0)continue;if(Array.isArray(F))Y[Q]=F;else if(X(F))Y[Q]=F;else if($(F)){let w=Y[Q];if($(w))Y[Q]=MJ(w,F);else Y[Q]=MJ(F)}else Y[Q]=F}}return Y}function mj(D,$){return MJ(Y9.DEFAULT_CREATION_OPTIONS,D,$||{})}function dj(D,$){return MJ(Y9.DEFAULT_REQUEST_OPTIONS,D,$||{})}class cj{constructor(D){this.client=D,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(D){return this.client.mfa.enroll(Object.assign(Object.assign({},D),{factorType:"webauthn"}))}async _challenge({factorId:D,webauthn:$,friendlyName:X,signal:Y},J){var Q;try{let{data:F,error:w}=await this.client.mfa.challenge({factorId:D,webauthn:$});if(!F)return{data:null,error:w};let Z=Y!==null&&Y!==void 0?Y:Y9.webAuthnAbortService.createNewAbortSignal();if(F.webauthn.type==="create"){let{user:G}=F.webauthn.credential_options.publicKey;if(!G.name){let O=X;if(!O){let z=(await this.client.getUser()).data.user,q=((Q=z===null||z===void 0?void 0:z.user_metadata)===null||Q===void 0?void 0:Q.name)||(z===null||z===void 0?void 0:z.email)||(z===null||z===void 0?void 0:z.id)||"User";G.name=`${G.id}:${q}`}else G.name=`${G.id}:${O}`}if(!G.displayName)G.displayName=G.name}switch(F.webauthn.type){case"create":{let G=mj(F.webauthn.credential_options.publicKey,J===null||J===void 0?void 0:J.create),{data:O,error:U}=await gj({publicKey:G,signal:Z});if(O)return{data:{factorId:D,challengeId:F.id,webauthn:{type:F.webauthn.type,credential_response:O}},error:null};return{data:null,error:U}}case"request":{let G=dj(F.webauthn.credential_options.publicKey,J===null||J===void 0?void 0:J.request),{data:O,error:U}=await hj(Object.assign(Object.assign({},F.webauthn.credential_options),{publicKey:G,signal:Z}));if(O)return{data:{factorId:D,challengeId:F.id,webauthn:{type:F.webauthn.type,credential_response:O}},error:null};return{data:null,error:U}}}}catch(F){if((0,E$.isAuthError)(F))return{data:null,error:F};return{data:null,error:new E$.AuthUnknownError("Unexpected error in challenge",F)}}}async _verify({challengeId:D,factorId:$,webauthn:X}){return this.client.mfa.verify({factorId:$,challengeId:D,webauthn:X})}async _authenticate({factorId:D,webauthn:{rpId:$=typeof window<"u"?window.location.hostname:void 0,rpOrigins:X=typeof window<"u"?[window.location.origin]:void 0,signal:Y}={}},J){if(!$)return{data:null,error:new E$.AuthError("rpId is required for WebAuthn authentication")};try{if(!yj())return{data:null,error:new E$.AuthUnknownError("Browser does not support WebAuthn",null)};let{data:Q,error:F}=await this.challenge({factorId:D,webauthn:{rpId:$,rpOrigins:X},signal:Y},{request:J});if(!Q)return{data:null,error:F};let{webauthn:w}=Q;return this._verify({factorId:D,challengeId:Q.challengeId,webauthn:{type:w.type,rpId:$,rpOrigins:X,credential_response:w.credential_response}})}catch(Q){if((0,E$.isAuthError)(Q))return{data:null,error:Q};return{data:null,error:new E$.AuthUnknownError("Unexpected error in authenticate",Q)}}}async _register({friendlyName:D,webauthn:{rpId:$=typeof window<"u"?window.location.hostname:void 0,rpOrigins:X=typeof window<"u"?[window.location.origin]:void 0,signal:Y}={}},J){if(!$)return{data:null,error:new E$.AuthError("rpId is required for WebAuthn registration")};try{if(!yj())return{data:null,error:new E$.AuthUnknownError("Browser does not support WebAuthn",null)};let{data:Q,error:F}=await this._enroll({friendlyName:D});if(!Q)return await this.client.mfa.listFactors().then((G)=>{var O;return(O=G.data)===null||O===void 0?void 0:O.all.find((U)=>U.factor_type==="webauthn"&&U.friendly_name===D&&U.status!=="unverified")}).then((G)=>G?this.client.mfa.unenroll({factorId:G===null||G===void 0?void 0:G.id}):void 0),{data:null,error:F};let{data:w,error:Z}=await this._challenge({factorId:Q.id,friendlyName:Q.friendly_name,webauthn:{rpId:$,rpOrigins:X},signal:Y},{create:J});if(!w)return{data:null,error:Z};return this._verify({factorId:Q.id,challengeId:w.challengeId,webauthn:{rpId:$,rpOrigins:X,type:w.webauthn.type,credential_response:w.webauthn.credential_response}})}catch(Q){if((0,E$.isAuthError)(Q))return{data:null,error:Q};return{data:null,error:new E$.AuthUnknownError("Unexpected error in register",Q)}}}}Y9.WebAuthnApi=cj});var ZO=T((sj)=>{Object.defineProperty(sj,"__esModule",{value:!0});var t8D=lD(),s8D=t8D.__importDefault(VJ()),P1=zJ(),QD=_4(),MD=DO(),ZD=J9(),rj=Aj(),oj=QO(),e8D=Cj(),D9D=rG(),aj=KJ(),LJ=Sj(),f7=FO();(0,e8D.polyfillGlobalThis)();var $9D={url:P1.GOTRUE_URL,storageKey:P1.STORAGE_KEY,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:P1.DEFAULT_HEADERS,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:1e4};async function tj(D,$,X){return await X()}var Q9={};class y7{get jwks(){var D,$;return($=(D=Q9[this.storageKey])===null||D===void 0?void 0:D.jwks)!==null&&$!==void 0?$:{keys:[]}}set jwks(D){Q9[this.storageKey]=Object.assign(Object.assign({},Q9[this.storageKey]),{jwks:D})}get jwks_cached_at(){var D,$;return($=(D=Q9[this.storageKey])===null||D===void 0?void 0:D.cachedAt)!==null&&$!==void 0?$:Number.MIN_SAFE_INTEGER}set jwks_cached_at(D){Q9[this.storageKey]=Object.assign(Object.assign({},Q9[this.storageKey]),{cachedAt:D})}constructor(D){var $,X,Y;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;let J=Object.assign(Object.assign({},$9D),D);if(this.storageKey=J.storageKey,this.instanceID=($=y7.nextInstanceID[this.storageKey])!==null&&$!==void 0?$:0,y7.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!J.debug,typeof J.debug==="function")this.logger=J.debug;if(this.instanceID>0&&(0,ZD.isBrowser)()){let Q=`${this._logPrefix()} Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.`;if(console.warn(Q),this.logDebugMessages)console.trace(Q)}if(this.persistSession=J.persistSession,this.autoRefreshToken=J.autoRefreshToken,this.admin=new s8D.default({url:J.url,headers:J.headers,fetch:J.fetch}),this.url=J.url,this.headers=J.headers,this.fetch=(0,ZD.resolveFetch)(J.fetch),this.lock=J.lock||tj,this.detectSessionInUrl=J.detectSessionInUrl,this.flowType=J.flowType,this.hasCustomAuthorizationHeader=J.hasCustomAuthorizationHeader,this.throwOnError=J.throwOnError,this.lockAcquireTimeout=J.lockAcquireTimeout,J.lock)this.lock=J.lock;else if(this.persistSession&&(0,ZD.isBrowser)()&&((X=globalThis===null||globalThis===void 0?void 0:globalThis.navigator)===null||X===void 0?void 0:X.locks))this.lock=oj.navigatorLock;else this.lock=tj;if(!this.jwks)this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER;if(this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this),webauthn:new f7.WebAuthnApi(this)},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this),listGrants:this._listOAuthGrants.bind(this),revokeGrant:this._revokeOAuthGrant.bind(this)},this.persistSession){if(J.storage)this.storage=J.storage;else if((0,ZD.supportsLocalStorage)())this.storage=globalThis.localStorage;else this.memoryStorage={},this.storage=(0,rj.memoryLocalStorageAdapter)(this.memoryStorage);if(J.userStorage)this.userStorage=J.userStorage}else this.memoryStorage={},this.storage=(0,rj.memoryLocalStorageAdapter)(this.memoryStorage);if((0,ZD.isBrowser)()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(Q){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",Q)}(Y=this.broadcastChannel)===null||Y===void 0||Y.addEventListener("message",async(Q)=>{this._debug("received broadcast notification from other tab or client",Q);try{await this._notifyAllSubscribers(Q.data.event,Q.data.session,!1)}catch(F){this._debug("#broadcastChannel","error",F)}})}this.initialize().catch((Q)=>{this._debug("#initialize()","error",Q)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(D){if(this.throwOnError&&D&&D.error)throw D.error;return D}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${D9D.version}) ${new Date().toISOString()}`}_debug(...D){if(this.logDebugMessages)this.logger(this._logPrefix(),...D);return this}async initialize(){if(this.initializePromise)return await this.initializePromise;return this.initializePromise=(async()=>{return await this._acquireLock(this.lockAcquireTimeout,async()=>{return await this._initialize()})})(),await this.initializePromise}async _initialize(){var D;try{let $={},X="none";if((0,ZD.isBrowser)()){if($=(0,ZD.parseParametersFromURL)(window.location.href),this._isImplicitGrantCallback($))X="implicit";else if(await this._isPKCECallback($))X="pkce"}if((0,ZD.isBrowser)()&&this.detectSessionInUrl&&X!=="none"){let{data:Y,error:J}=await this._getSessionFromURL($,X);if(J){if(this._debug("#_initialize()","error detecting session from URL",J),(0,QD.isAuthImplicitGrantRedirectError)(J)){let w=(D=J.details)===null||D===void 0?void 0:D.code;if(w==="identity_already_exists"||w==="identity_not_found"||w==="single_identity_not_deletable")return{error:J}}return{error:J}}let{session:Q,redirectType:F}=Y;return this._debug("#_initialize()","detected session in URL",Q,"redirect type",F),await this._saveSession(Q),setTimeout(async()=>{if(F==="recovery")await this._notifyAllSubscribers("PASSWORD_RECOVERY",Q);else await this._notifyAllSubscribers("SIGNED_IN",Q)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch($){if((0,QD.isAuthError)($))return this._returnResult({error:$});return this._returnResult({error:new QD.AuthUnknownError("Unexpected error during initialization",$)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(D){var $,X,Y;try{let J=await(0,MD._request)(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(X=($=D===null||D===void 0?void 0:D.options)===null||$===void 0?void 0:$.data)!==null&&X!==void 0?X:{},gotrue_meta_security:{captcha_token:(Y=D===null||D===void 0?void 0:D.options)===null||Y===void 0?void 0:Y.captchaToken}},xform:MD._sessionResponse}),{data:Q,error:F}=J;if(F||!Q)return this._returnResult({data:{user:null,session:null},error:F});let{session:w,user:Z}=Q;if(Q.session)await this._saveSession(Q.session),await this._notifyAllSubscribers("SIGNED_IN",w);return this._returnResult({data:{user:Z,session:w},error:null})}catch(J){if((0,QD.isAuthError)(J))return this._returnResult({data:{user:null,session:null},error:J});throw J}}async signUp(D){var $,X,Y;try{let J;if("email"in D){let{email:G,password:O,options:U}=D,z=null,q=null;if(this.flowType==="pkce")[z,q]=await(0,ZD.getCodeChallengeAndMethod)(this.storage,this.storageKey);J=await(0,MD._request)(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:U===null||U===void 0?void 0:U.emailRedirectTo,body:{email:G,password:O,data:($=U===null||U===void 0?void 0:U.data)!==null&&$!==void 0?$:{},gotrue_meta_security:{captcha_token:U===null||U===void 0?void 0:U.captchaToken},code_challenge:z,code_challenge_method:q},xform:MD._sessionResponse})}else if("phone"in D){let{phone:G,password:O,options:U}=D;J=await(0,MD._request)(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:G,password:O,data:(X=U===null||U===void 0?void 0:U.data)!==null&&X!==void 0?X:{},channel:(Y=U===null||U===void 0?void 0:U.channel)!==null&&Y!==void 0?Y:"sms",gotrue_meta_security:{captcha_token:U===null||U===void 0?void 0:U.captchaToken}},xform:MD._sessionResponse})}else throw new QD.AuthInvalidCredentialsError("You must provide either an email or phone number and a password");let{data:Q,error:F}=J;if(F||!Q)return await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:F});let{session:w,user:Z}=Q;if(Q.session)await this._saveSession(Q.session),await this._notifyAllSubscribers("SIGNED_IN",w);return this._returnResult({data:{user:Z,session:w},error:null})}catch(J){if(await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,QD.isAuthError)(J))return this._returnResult({data:{user:null,session:null},error:J});throw J}}async signInWithPassword(D){try{let $;if("email"in D){let{email:J,password:Q,options:F}=D;$=await(0,MD._request)(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:J,password:Q,gotrue_meta_security:{captcha_token:F===null||F===void 0?void 0:F.captchaToken}},xform:MD._sessionResponsePassword})}else if("phone"in D){let{phone:J,password:Q,options:F}=D;$=await(0,MD._request)(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:J,password:Q,gotrue_meta_security:{captcha_token:F===null||F===void 0?void 0:F.captchaToken}},xform:MD._sessionResponsePassword})}else throw new QD.AuthInvalidCredentialsError("You must provide either an email or phone number and a password");let{data:X,error:Y}=$;if(Y)return this._returnResult({data:{user:null,session:null},error:Y});else if(!X||!X.session||!X.user){let J=new QD.AuthInvalidTokenResponseError;return this._returnResult({data:{user:null,session:null},error:J})}if(X.session)await this._saveSession(X.session),await this._notifyAllSubscribers("SIGNED_IN",X.session);return this._returnResult({data:Object.assign({user:X.user,session:X.session},X.weak_password?{weakPassword:X.weak_password}:null),error:Y})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:{user:null,session:null},error:$});throw $}}async signInWithOAuth(D){var $,X,Y,J;return await this._handleProviderSignIn(D.provider,{redirectTo:($=D.options)===null||$===void 0?void 0:$.redirectTo,scopes:(X=D.options)===null||X===void 0?void 0:X.scopes,queryParams:(Y=D.options)===null||Y===void 0?void 0:Y.queryParams,skipBrowserRedirect:(J=D.options)===null||J===void 0?void 0:J.skipBrowserRedirect})}async exchangeCodeForSession(D){return await this.initializePromise,this._acquireLock(this.lockAcquireTimeout,async()=>{return this._exchangeCodeForSession(D)})}async signInWithWeb3(D){let{chain:$}=D;switch($){case"ethereum":return await this.signInWithEthereum(D);case"solana":return await this.signInWithSolana(D);default:throw Error(`@supabase/auth-js: Unsupported chain "${$}"`)}}async signInWithEthereum(D){var $,X,Y,J,Q,F,w,Z,G,O,U;let z,q;if("message"in D)z=D.message,q=D.signature;else{let{chain:B,wallet:K,statement:M,options:L}=D,I;if(!(0,ZD.isBrowser)()){if(typeof K!=="object"||!(L===null||L===void 0?void 0:L.url))throw Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");I=K}else if(typeof K==="object")I=K;else{let A=window;if("ethereum"in A&&typeof A.ethereum==="object"&&"request"in A.ethereum&&typeof A.ethereum.request==="function")I=A.ethereum;else throw Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}let W=new URL(($=L===null||L===void 0?void 0:L.url)!==null&&$!==void 0?$:window.location.href),N=await I.request({method:"eth_requestAccounts"}).then((A)=>A).catch(()=>{throw Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!N||N.length===0)throw Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");let V=(0,LJ.getAddress)(N[0]),R=(X=L===null||L===void 0?void 0:L.signInWithEthereum)===null||X===void 0?void 0:X.chainId;if(!R){let A=await I.request({method:"eth_chainId"});R=(0,LJ.fromHex)(A)}let C={domain:W.host,address:V,statement:M,uri:W.href,version:"1",chainId:R,nonce:(Y=L===null||L===void 0?void 0:L.signInWithEthereum)===null||Y===void 0?void 0:Y.nonce,issuedAt:(Q=(J=L===null||L===void 0?void 0:L.signInWithEthereum)===null||J===void 0?void 0:J.issuedAt)!==null&&Q!==void 0?Q:new Date,expirationTime:(F=L===null||L===void 0?void 0:L.signInWithEthereum)===null||F===void 0?void 0:F.expirationTime,notBefore:(w=L===null||L===void 0?void 0:L.signInWithEthereum)===null||w===void 0?void 0:w.notBefore,requestId:(Z=L===null||L===void 0?void 0:L.signInWithEthereum)===null||Z===void 0?void 0:Z.requestId,resources:(G=L===null||L===void 0?void 0:L.signInWithEthereum)===null||G===void 0?void 0:G.resources};z=(0,LJ.createSiweMessage)(C),q=await I.request({method:"personal_sign",params:[(0,LJ.toHex)(z),V]})}try{let{data:B,error:K}=await(0,MD._request)(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:z,signature:q},((O=D.options)===null||O===void 0?void 0:O.captchaToken)?{gotrue_meta_security:{captcha_token:(U=D.options)===null||U===void 0?void 0:U.captchaToken}}:null),xform:MD._sessionResponse});if(K)throw K;if(!B||!B.session||!B.user){let M=new QD.AuthInvalidTokenResponseError;return this._returnResult({data:{user:null,session:null},error:M})}if(B.session)await this._saveSession(B.session),await this._notifyAllSubscribers("SIGNED_IN",B.session);return this._returnResult({data:Object.assign({},B),error:K})}catch(B){if((0,QD.isAuthError)(B))return this._returnResult({data:{user:null,session:null},error:B});throw B}}async signInWithSolana(D){var $,X,Y,J,Q,F,w,Z,G,O,U,z;let q,B;if("message"in D)q=D.message,B=D.signature;else{let{chain:K,wallet:M,statement:L,options:I}=D,W;if(!(0,ZD.isBrowser)()){if(typeof M!=="object"||!(I===null||I===void 0?void 0:I.url))throw Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");W=M}else if(typeof M==="object")W=M;else{let V=window;if("solana"in V&&typeof V.solana==="object"&&(("signIn"in V.solana)&&typeof V.solana.signIn==="function"||("signMessage"in V.solana)&&typeof V.solana.signMessage==="function"))W=V.solana;else throw Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}let N=new URL(($=I===null||I===void 0?void 0:I.url)!==null&&$!==void 0?$:window.location.href);if("signIn"in W&&W.signIn){let V=await W.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},I===null||I===void 0?void 0:I.signInWithSolana),{version:"1",domain:N.host,uri:N.href}),L?{statement:L}:null)),R;if(Array.isArray(V)&&V[0]&&typeof V[0]==="object")R=V[0];else if(V&&typeof V==="object"&&"signedMessage"in V&&"signature"in V)R=V;else throw Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in R&&"signature"in R&&(typeof R.signedMessage==="string"||R.signedMessage instanceof Uint8Array)&&R.signature instanceof Uint8Array)q=typeof R.signedMessage==="string"?R.signedMessage:new TextDecoder().decode(R.signedMessage),B=R.signature;else throw Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in W)||typeof W.signMessage!=="function"||!("publicKey"in W)||typeof W!=="object"||!W.publicKey||!("toBase58"in W.publicKey)||typeof W.publicKey.toBase58!=="function")throw Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");q=[`${N.host} wants you to sign in with your Solana account:`,W.publicKey.toBase58(),...L?["",L,""]:[""],"Version: 1",`URI: ${N.href}`,`Issued At: ${(Y=(X=I===null||I===void 0?void 0:I.signInWithSolana)===null||X===void 0?void 0:X.issuedAt)!==null&&Y!==void 0?Y:new Date().toISOString()}`,...((J=I===null||I===void 0?void 0:I.signInWithSolana)===null||J===void 0?void 0:J.notBefore)?[`Not Before: ${I.signInWithSolana.notBefore}`]:[],...((Q=I===null||I===void 0?void 0:I.signInWithSolana)===null||Q===void 0?void 0:Q.expirationTime)?[`Expiration Time: ${I.signInWithSolana.expirationTime}`]:[],...((F=I===null||I===void 0?void 0:I.signInWithSolana)===null||F===void 0?void 0:F.chainId)?[`Chain ID: ${I.signInWithSolana.chainId}`]:[],...((w=I===null||I===void 0?void 0:I.signInWithSolana)===null||w===void 0?void 0:w.nonce)?[`Nonce: ${I.signInWithSolana.nonce}`]:[],...((Z=I===null||I===void 0?void 0:I.signInWithSolana)===null||Z===void 0?void 0:Z.requestId)?[`Request ID: ${I.signInWithSolana.requestId}`]:[],...((O=(G=I===null||I===void 0?void 0:I.signInWithSolana)===null||G===void 0?void 0:G.resources)===null||O===void 0?void 0:O.length)?["Resources",...I.signInWithSolana.resources.map((R)=>`- ${R}`)]:[]].join(`
113
+ `);let V=await W.signMessage(new TextEncoder().encode(q),"utf8");if(!V||!(V instanceof Uint8Array))throw Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");B=V}}try{let{data:K,error:M}=await(0,MD._request)(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:q,signature:(0,aj.bytesToBase64URL)(B)},((U=D.options)===null||U===void 0?void 0:U.captchaToken)?{gotrue_meta_security:{captcha_token:(z=D.options)===null||z===void 0?void 0:z.captchaToken}}:null),xform:MD._sessionResponse});if(M)throw M;if(!K||!K.session||!K.user){let L=new QD.AuthInvalidTokenResponseError;return this._returnResult({data:{user:null,session:null},error:L})}if(K.session)await this._saveSession(K.session),await this._notifyAllSubscribers("SIGNED_IN",K.session);return this._returnResult({data:Object.assign({},K),error:M})}catch(K){if((0,QD.isAuthError)(K))return this._returnResult({data:{user:null,session:null},error:K});throw K}}async _exchangeCodeForSession(D){let $=await(0,ZD.getItemAsync)(this.storage,`${this.storageKey}-code-verifier`),[X,Y]=($!==null&&$!==void 0?$:"").split("/");try{if(!X&&this.flowType==="pkce")throw new QD.AuthPKCECodeVerifierMissingError;let{data:J,error:Q}=await(0,MD._request)(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:D,code_verifier:X},xform:MD._sessionResponse});if(await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),Q)throw Q;if(!J||!J.session||!J.user){let F=new QD.AuthInvalidTokenResponseError;return this._returnResult({data:{user:null,session:null,redirectType:null},error:F})}if(J.session)await this._saveSession(J.session),await this._notifyAllSubscribers("SIGNED_IN",J.session);return this._returnResult({data:Object.assign(Object.assign({},J),{redirectType:Y!==null&&Y!==void 0?Y:null}),error:Q})}catch(J){if(await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,QD.isAuthError)(J))return this._returnResult({data:{user:null,session:null,redirectType:null},error:J});throw J}}async signInWithIdToken(D){try{let{options:$,provider:X,token:Y,access_token:J,nonce:Q}=D,F=await(0,MD._request)(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:X,id_token:Y,access_token:J,nonce:Q,gotrue_meta_security:{captcha_token:$===null||$===void 0?void 0:$.captchaToken}},xform:MD._sessionResponse}),{data:w,error:Z}=F;if(Z)return this._returnResult({data:{user:null,session:null},error:Z});else if(!w||!w.session||!w.user){let G=new QD.AuthInvalidTokenResponseError;return this._returnResult({data:{user:null,session:null},error:G})}if(w.session)await this._saveSession(w.session),await this._notifyAllSubscribers("SIGNED_IN",w.session);return this._returnResult({data:w,error:Z})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:{user:null,session:null},error:$});throw $}}async signInWithOtp(D){var $,X,Y,J,Q;try{if("email"in D){let{email:F,options:w}=D,Z=null,G=null;if(this.flowType==="pkce")[Z,G]=await(0,ZD.getCodeChallengeAndMethod)(this.storage,this.storageKey);let{error:O}=await(0,MD._request)(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:F,data:($=w===null||w===void 0?void 0:w.data)!==null&&$!==void 0?$:{},create_user:(X=w===null||w===void 0?void 0:w.shouldCreateUser)!==null&&X!==void 0?X:!0,gotrue_meta_security:{captcha_token:w===null||w===void 0?void 0:w.captchaToken},code_challenge:Z,code_challenge_method:G},redirectTo:w===null||w===void 0?void 0:w.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:O})}if("phone"in D){let{phone:F,options:w}=D,{data:Z,error:G}=await(0,MD._request)(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:F,data:(Y=w===null||w===void 0?void 0:w.data)!==null&&Y!==void 0?Y:{},create_user:(J=w===null||w===void 0?void 0:w.shouldCreateUser)!==null&&J!==void 0?J:!0,gotrue_meta_security:{captcha_token:w===null||w===void 0?void 0:w.captchaToken},channel:(Q=w===null||w===void 0?void 0:w.channel)!==null&&Q!==void 0?Q:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:Z===null||Z===void 0?void 0:Z.message_id},error:G})}throw new QD.AuthInvalidCredentialsError("You must provide either an email or phone number.")}catch(F){if(await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,QD.isAuthError)(F))return this._returnResult({data:{user:null,session:null},error:F});throw F}}async verifyOtp(D){var $,X;try{let Y=void 0,J=void 0;if("options"in D)Y=($=D.options)===null||$===void 0?void 0:$.redirectTo,J=(X=D.options)===null||X===void 0?void 0:X.captchaToken;let{data:Q,error:F}=await(0,MD._request)(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},D),{gotrue_meta_security:{captcha_token:J}}),redirectTo:Y,xform:MD._sessionResponse});if(F)throw F;if(!Q)throw Error("An error occurred on token verification.");let{session:w,user:Z}=Q;if(w===null||w===void 0?void 0:w.access_token)await this._saveSession(w),await this._notifyAllSubscribers(D.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",w);return this._returnResult({data:{user:Z,session:w},error:null})}catch(Y){if((0,QD.isAuthError)(Y))return this._returnResult({data:{user:null,session:null},error:Y});throw Y}}async signInWithSSO(D){var $,X,Y,J,Q;try{let F=null,w=null;if(this.flowType==="pkce")[F,w]=await(0,ZD.getCodeChallengeAndMethod)(this.storage,this.storageKey);let Z=await(0,MD._request)(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in D?{provider_id:D.providerId}:null),"domain"in D?{domain:D.domain}:null),{redirect_to:(X=($=D.options)===null||$===void 0?void 0:$.redirectTo)!==null&&X!==void 0?X:void 0}),((Y=D===null||D===void 0?void 0:D.options)===null||Y===void 0?void 0:Y.captchaToken)?{gotrue_meta_security:{captcha_token:D.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:F,code_challenge_method:w}),headers:this.headers,xform:MD._ssoResponse});if(((J=Z.data)===null||J===void 0?void 0:J.url)&&(0,ZD.isBrowser)()&&!((Q=D.options)===null||Q===void 0?void 0:Q.skipBrowserRedirect))window.location.assign(Z.data.url);return this._returnResult(Z)}catch(F){if(await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,QD.isAuthError)(F))return this._returnResult({data:null,error:F});throw F}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{return await this._reauthenticate()})}async _reauthenticate(){try{return await this._useSession(async(D)=>{let{data:{session:$},error:X}=D;if(X)throw X;if(!$)throw new QD.AuthSessionMissingError;let{error:Y}=await(0,MD._request)(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:$.access_token});return this._returnResult({data:{user:null,session:null},error:Y})})}catch(D){if((0,QD.isAuthError)(D))return this._returnResult({data:{user:null,session:null},error:D});throw D}}async resend(D){try{let $=`${this.url}/resend`;if("email"in D){let{email:X,type:Y,options:J}=D,{error:Q}=await(0,MD._request)(this.fetch,"POST",$,{headers:this.headers,body:{email:X,type:Y,gotrue_meta_security:{captcha_token:J===null||J===void 0?void 0:J.captchaToken}},redirectTo:J===null||J===void 0?void 0:J.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:Q})}else if("phone"in D){let{phone:X,type:Y,options:J}=D,{data:Q,error:F}=await(0,MD._request)(this.fetch,"POST",$,{headers:this.headers,body:{phone:X,type:Y,gotrue_meta_security:{captcha_token:J===null||J===void 0?void 0:J.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:Q===null||Q===void 0?void 0:Q.message_id},error:F})}throw new QD.AuthInvalidCredentialsError("You must provide either an email or phone number and a type")}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:{user:null,session:null},error:$});throw $}}async getSession(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{return this._useSession(async($)=>{return $})})}async _acquireLock(D,$){this._debug("#_acquireLock","begin",D);try{if(this.lockAcquired){let X=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),Y=(async()=>{return await X,await $()})();return this.pendingInLock.push((async()=>{try{await Y}catch(J){}})()),Y}return await this.lock(`lock:${this.storageKey}`,D,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;let X=$();this.pendingInLock.push((async()=>{try{await X}catch(Y){}})()),await X;while(this.pendingInLock.length){let Y=[...this.pendingInLock];await Promise.all(Y),this.pendingInLock.splice(0,Y.length)}return await X}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(D){this._debug("#_useSession","begin");try{let $=await this.__loadSession();return await D($)}finally{this._debug("#_useSession","end")}}async __loadSession(){if(this._debug("#__loadSession()","begin"),!this.lockAcquired)this._debug("#__loadSession()","used outside of an acquired lock!",Error().stack);try{let D=null,$=await(0,ZD.getItemAsync)(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",$),$!==null)if(this._isValidSession($))D=$;else this._debug("#getSession()","session from storage is not valid"),await this._removeSession();if(!D)return{data:{session:null},error:null};let X=D.expires_at?D.expires_at*1000-Date.now()<P1.EXPIRY_MARGIN_MS:!1;if(this._debug("#__loadSession()",`session has${X?"":" not"} expired`,"expires_at",D.expires_at),!X){if(this.userStorage){let Q=await(0,ZD.getItemAsync)(this.userStorage,this.storageKey+"-user");if(Q===null||Q===void 0?void 0:Q.user)D.user=Q.user;else D.user=(0,ZD.userNotAvailableProxy)()}if(this.storage.isServer&&D.user&&!D.user.__isUserNotAvailableProxy){let Q={value:this.suppressGetSessionWarning};if(D.user=(0,ZD.insecureUserWarningProxy)(D.user,Q),Q.value)this.suppressGetSessionWarning=!0}return{data:{session:D},error:null}}let{data:Y,error:J}=await this._callRefreshToken(D.refresh_token);if(J)return this._returnResult({data:{session:null},error:J});return this._returnResult({data:{session:Y},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(D){if(D)return await this._getUser(D);await this.initializePromise;let $=await this._acquireLock(this.lockAcquireTimeout,async()=>{return await this._getUser()});if($.data.user)this.suppressGetSessionWarning=!0;return $}async _getUser(D){try{if(D)return await(0,MD._request)(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:D,xform:MD._userResponse});return await this._useSession(async($)=>{var X,Y,J;let{data:Q,error:F}=$;if(F)throw F;if(!((X=Q.session)===null||X===void 0?void 0:X.access_token)&&!this.hasCustomAuthorizationHeader)return{data:{user:null},error:new QD.AuthSessionMissingError};return await(0,MD._request)(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(J=(Y=Q.session)===null||Y===void 0?void 0:Y.access_token)!==null&&J!==void 0?J:void 0,xform:MD._userResponse})})}catch($){if((0,QD.isAuthError)($)){if((0,QD.isAuthSessionMissingError)($))await this._removeSession(),await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`);return this._returnResult({data:{user:null},error:$})}throw $}}async updateUser(D,$={}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{return await this._updateUser(D,$)})}async _updateUser(D,$={}){try{return await this._useSession(async(X)=>{let{data:Y,error:J}=X;if(J)throw J;if(!Y.session)throw new QD.AuthSessionMissingError;let Q=Y.session,F=null,w=null;if(this.flowType==="pkce"&&D.email!=null)[F,w]=await(0,ZD.getCodeChallengeAndMethod)(this.storage,this.storageKey);let{data:Z,error:G}=await(0,MD._request)(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:$===null||$===void 0?void 0:$.emailRedirectTo,body:Object.assign(Object.assign({},D),{code_challenge:F,code_challenge_method:w}),jwt:Q.access_token,xform:MD._userResponse});if(G)throw G;return Q.user=Z.user,await this._saveSession(Q),await this._notifyAllSubscribers("USER_UPDATED",Q),this._returnResult({data:{user:Q.user},error:null})})}catch(X){if(await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,QD.isAuthError)(X))return this._returnResult({data:{user:null},error:X});throw X}}async setSession(D){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{return await this._setSession(D)})}async _setSession(D){try{if(!D.access_token||!D.refresh_token)throw new QD.AuthSessionMissingError;let $=Date.now()/1000,X=$,Y=!0,J=null,{payload:Q}=(0,ZD.decodeJWT)(D.access_token);if(Q.exp)X=Q.exp,Y=X<=$;if(Y){let{data:F,error:w}=await this._callRefreshToken(D.refresh_token);if(w)return this._returnResult({data:{user:null,session:null},error:w});if(!F)return{data:{user:null,session:null},error:null};J=F}else{let{data:F,error:w}=await this._getUser(D.access_token);if(w)return this._returnResult({data:{user:null,session:null},error:w});J={access_token:D.access_token,refresh_token:D.refresh_token,user:F.user,token_type:"bearer",expires_in:X-$,expires_at:X},await this._saveSession(J),await this._notifyAllSubscribers("SIGNED_IN",J)}return this._returnResult({data:{user:J.user,session:J},error:null})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:{session:null,user:null},error:$});throw $}}async refreshSession(D){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{return await this._refreshSession(D)})}async _refreshSession(D){try{return await this._useSession(async($)=>{var X;if(!D){let{data:Q,error:F}=$;if(F)throw F;D=(X=Q.session)!==null&&X!==void 0?X:void 0}if(!(D===null||D===void 0?void 0:D.refresh_token))throw new QD.AuthSessionMissingError;let{data:Y,error:J}=await this._callRefreshToken(D.refresh_token);if(J)return this._returnResult({data:{user:null,session:null},error:J});if(!Y)return this._returnResult({data:{user:null,session:null},error:null});return this._returnResult({data:{user:Y.user,session:Y},error:null})})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:{user:null,session:null},error:$});throw $}}async _getSessionFromURL(D,$){try{if(!(0,ZD.isBrowser)())throw new QD.AuthImplicitGrantRedirectError("No browser detected.");if(D.error||D.error_description||D.error_code)throw new QD.AuthImplicitGrantRedirectError(D.error_description||"Error in URL with unspecified error_description",{error:D.error||"unspecified_error",code:D.error_code||"unspecified_code"});switch($){case"implicit":if(this.flowType==="pkce")throw new QD.AuthPKCEGrantCodeExchangeError("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new QD.AuthImplicitGrantRedirectError("Not a valid implicit grant flow url.");break;default:}if($==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!D.code)throw new QD.AuthPKCEGrantCodeExchangeError("No code detected.");let{data:L,error:I}=await this._exchangeCodeForSession(D.code);if(I)throw I;let W=new URL(window.location.href);return W.searchParams.delete("code"),window.history.replaceState(window.history.state,"",W.toString()),{data:{session:L.session,redirectType:null},error:null}}let{provider_token:X,provider_refresh_token:Y,access_token:J,refresh_token:Q,expires_in:F,expires_at:w,token_type:Z}=D;if(!J||!F||!Q||!Z)throw new QD.AuthImplicitGrantRedirectError("No session defined in URL");let G=Math.round(Date.now()/1000),O=parseInt(F),U=G+O;if(w)U=parseInt(w);let z=U-G;if(z*1000<=P1.AUTO_REFRESH_TICK_DURATION_MS)console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${z}s, should have been closer to ${O}s`);let q=U-O;if(G-q>=120)console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",q,U,G);else if(G-q<0)console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",q,U,G);let{data:B,error:K}=await this._getUser(J);if(K)throw K;let M={provider_token:X,provider_refresh_token:Y,access_token:J,expires_in:O,expires_at:U,refresh_token:Q,token_type:Z,user:B.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:M,redirectType:D.type},error:null})}catch(X){if((0,QD.isAuthError)(X))return this._returnResult({data:{session:null,redirectType:null},error:X});throw X}}_isImplicitGrantCallback(D){if(typeof this.detectSessionInUrl==="function")return this.detectSessionInUrl(new URL(window.location.href),D);return Boolean(D.access_token||D.error_description)}async _isPKCECallback(D){let $=await(0,ZD.getItemAsync)(this.storage,`${this.storageKey}-code-verifier`);return!!(D.code&&$)}async signOut(D={scope:"global"}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{return await this._signOut(D)})}async _signOut({scope:D}={scope:"global"}){return await this._useSession(async($)=>{var X;let{data:Y,error:J}=$;if(J&&!(0,QD.isAuthSessionMissingError)(J))return this._returnResult({error:J});let Q=(X=Y.session)===null||X===void 0?void 0:X.access_token;if(Q){let{error:F}=await this.admin.signOut(Q,D);if(F){if(!((0,QD.isAuthApiError)(F)&&(F.status===404||F.status===401||F.status===403)||(0,QD.isAuthSessionMissingError)(F)))return this._returnResult({error:F})}}if(D!=="others")await this._removeSession(),await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`);return this._returnResult({error:null})})}onAuthStateChange(D){let $=(0,ZD.generateCallbackId)(),X={id:$,callback:D,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",$),this.stateChangeEmitters.delete($)}};return this._debug("#onAuthStateChange()","registered callback with id",$),this.stateChangeEmitters.set($,X),(async()=>{await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession($)})})(),{data:{subscription:X}}}async _emitInitialSession(D){return await this._useSession(async($)=>{var X,Y;try{let{data:{session:J},error:Q}=$;if(Q)throw Q;await((X=this.stateChangeEmitters.get(D))===null||X===void 0?void 0:X.callback("INITIAL_SESSION",J)),this._debug("INITIAL_SESSION","callback id",D,"session",J)}catch(J){await((Y=this.stateChangeEmitters.get(D))===null||Y===void 0?void 0:Y.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",D,"error",J),console.error(J)}})}async resetPasswordForEmail(D,$={}){let X=null,Y=null;if(this.flowType==="pkce")[X,Y]=await(0,ZD.getCodeChallengeAndMethod)(this.storage,this.storageKey,!0);try{return await(0,MD._request)(this.fetch,"POST",`${this.url}/recover`,{body:{email:D,code_challenge:X,code_challenge_method:Y,gotrue_meta_security:{captcha_token:$.captchaToken}},headers:this.headers,redirectTo:$.redirectTo})}catch(J){if(await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,QD.isAuthError)(J))return this._returnResult({data:null,error:J});throw J}}async getUserIdentities(){var D;try{let{data:$,error:X}=await this.getUser();if(X)throw X;return this._returnResult({data:{identities:(D=$.user.identities)!==null&&D!==void 0?D:[]},error:null})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:null,error:$});throw $}}async linkIdentity(D){if("token"in D)return this.linkIdentityIdToken(D);return this.linkIdentityOAuth(D)}async linkIdentityOAuth(D){var $;try{let{data:X,error:Y}=await this._useSession(async(J)=>{var Q,F,w,Z,G;let{data:O,error:U}=J;if(U)throw U;let z=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,D.provider,{redirectTo:(Q=D.options)===null||Q===void 0?void 0:Q.redirectTo,scopes:(F=D.options)===null||F===void 0?void 0:F.scopes,queryParams:(w=D.options)===null||w===void 0?void 0:w.queryParams,skipBrowserRedirect:!0});return await(0,MD._request)(this.fetch,"GET",z,{headers:this.headers,jwt:(G=(Z=O.session)===null||Z===void 0?void 0:Z.access_token)!==null&&G!==void 0?G:void 0})});if(Y)throw Y;if((0,ZD.isBrowser)()&&!(($=D.options)===null||$===void 0?void 0:$.skipBrowserRedirect))window.location.assign(X===null||X===void 0?void 0:X.url);return this._returnResult({data:{provider:D.provider,url:X===null||X===void 0?void 0:X.url},error:null})}catch(X){if((0,QD.isAuthError)(X))return this._returnResult({data:{provider:D.provider,url:null},error:X});throw X}}async linkIdentityIdToken(D){return await this._useSession(async($)=>{var X;try{let{error:Y,data:{session:J}}=$;if(Y)throw Y;let{options:Q,provider:F,token:w,access_token:Z,nonce:G}=D,O=await(0,MD._request)(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(X=J===null||J===void 0?void 0:J.access_token)!==null&&X!==void 0?X:void 0,body:{provider:F,id_token:w,access_token:Z,nonce:G,link_identity:!0,gotrue_meta_security:{captcha_token:Q===null||Q===void 0?void 0:Q.captchaToken}},xform:MD._sessionResponse}),{data:U,error:z}=O;if(z)return this._returnResult({data:{user:null,session:null},error:z});else if(!U||!U.session||!U.user)return this._returnResult({data:{user:null,session:null},error:new QD.AuthInvalidTokenResponseError});if(U.session)await this._saveSession(U.session),await this._notifyAllSubscribers("USER_UPDATED",U.session);return this._returnResult({data:U,error:z})}catch(Y){if(await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,QD.isAuthError)(Y))return this._returnResult({data:{user:null,session:null},error:Y});throw Y}})}async unlinkIdentity(D){try{return await this._useSession(async($)=>{var X,Y;let{data:J,error:Q}=$;if(Q)throw Q;return await(0,MD._request)(this.fetch,"DELETE",`${this.url}/user/identities/${D.identity_id}`,{headers:this.headers,jwt:(Y=(X=J.session)===null||X===void 0?void 0:X.access_token)!==null&&Y!==void 0?Y:void 0})})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:null,error:$});throw $}}async _refreshAccessToken(D){let $=`#_refreshAccessToken(${D.substring(0,5)}...)`;this._debug($,"begin");try{let X=Date.now();return await(0,ZD.retryable)(async(Y)=>{if(Y>0)await(0,ZD.sleep)(200*Math.pow(2,Y-1));return this._debug($,"refreshing attempt",Y),await(0,MD._request)(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:D},headers:this.headers,xform:MD._sessionResponse})},(Y,J)=>{let Q=200*Math.pow(2,Y);return J&&(0,QD.isAuthRetryableFetchError)(J)&&Date.now()+Q-X<P1.AUTO_REFRESH_TICK_DURATION_MS})}catch(X){if(this._debug($,"error",X),(0,QD.isAuthError)(X))return this._returnResult({data:{session:null,user:null},error:X});throw X}finally{this._debug($,"end")}}_isValidSession(D){return typeof D==="object"&&D!==null&&"access_token"in D&&"refresh_token"in D&&"expires_at"in D}async _handleProviderSignIn(D,$){let X=await this._getUrlForProvider(`${this.url}/authorize`,D,{redirectTo:$.redirectTo,scopes:$.scopes,queryParams:$.queryParams});if(this._debug("#_handleProviderSignIn()","provider",D,"options",$,"url",X),(0,ZD.isBrowser)()&&!$.skipBrowserRedirect)window.location.assign(X);return{data:{provider:D,url:X},error:null}}async _recoverAndRefresh(){var D,$;let X="#_recoverAndRefresh()";this._debug("#_recoverAndRefresh()","begin");try{let Y=await(0,ZD.getItemAsync)(this.storage,this.storageKey);if(Y&&this.userStorage){let Q=await(0,ZD.getItemAsync)(this.userStorage,this.storageKey+"-user");if(!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!Q)Q={user:Y.user},await(0,ZD.setItemAsync)(this.userStorage,this.storageKey+"-user",Q);Y.user=(D=Q===null||Q===void 0?void 0:Q.user)!==null&&D!==void 0?D:(0,ZD.userNotAvailableProxy)()}else if(Y&&!Y.user){if(!Y.user){let Q=await(0,ZD.getItemAsync)(this.storage,this.storageKey+"-user");if(Q&&(Q===null||Q===void 0?void 0:Q.user))Y.user=Q.user,await(0,ZD.removeItemAsync)(this.storage,this.storageKey+"-user"),await(0,ZD.setItemAsync)(this.storage,this.storageKey,Y);else Y.user=(0,ZD.userNotAvailableProxy)()}}if(this._debug("#_recoverAndRefresh()","session from storage",Y),!this._isValidSession(Y)){if(this._debug("#_recoverAndRefresh()","session is not valid"),Y!==null)await this._removeSession();return}let J=(($=Y.expires_at)!==null&&$!==void 0?$:1/0)*1000-Date.now()<P1.EXPIRY_MARGIN_MS;if(this._debug("#_recoverAndRefresh()",`session has${J?"":" not"} expired with margin of ${P1.EXPIRY_MARGIN_MS}s`),J){if(this.autoRefreshToken&&Y.refresh_token){let{error:Q}=await this._callRefreshToken(Y.refresh_token);if(Q){if(console.error(Q),!(0,QD.isAuthRetryableFetchError)(Q))this._debug("#_recoverAndRefresh()","refresh failed with a non-retryable error, removing the session",Q),await this._removeSession()}}}else if(Y.user&&Y.user.__isUserNotAvailableProxy===!0)try{let{data:Q,error:F}=await this._getUser(Y.access_token);if(!F&&(Q===null||Q===void 0?void 0:Q.user))Y.user=Q.user,await this._saveSession(Y),await this._notifyAllSubscribers("SIGNED_IN",Y);else this._debug("#_recoverAndRefresh()","could not get user data, skipping SIGNED_IN notification")}catch(Q){console.error("Error getting user data:",Q),this._debug("#_recoverAndRefresh()","error getting user data, skipping SIGNED_IN notification",Q)}else await this._notifyAllSubscribers("SIGNED_IN",Y)}catch(Y){this._debug("#_recoverAndRefresh()","error",Y),console.error(Y);return}finally{this._debug("#_recoverAndRefresh()","end")}}async _callRefreshToken(D){var $,X;if(!D)throw new QD.AuthSessionMissingError;if(this.refreshingDeferred)return this.refreshingDeferred.promise;let Y=`#_callRefreshToken(${D.substring(0,5)}...)`;this._debug(Y,"begin");try{this.refreshingDeferred=new ZD.Deferred;let{data:J,error:Q}=await this._refreshAccessToken(D);if(Q)throw Q;if(!J.session)throw new QD.AuthSessionMissingError;await this._saveSession(J.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",J.session);let F={data:J.session,error:null};return this.refreshingDeferred.resolve(F),F}catch(J){if(this._debug(Y,"error",J),(0,QD.isAuthError)(J)){let Q={data:null,error:J};if(!(0,QD.isAuthRetryableFetchError)(J))await this._removeSession();return($=this.refreshingDeferred)===null||$===void 0||$.resolve(Q),Q}throw(X=this.refreshingDeferred)===null||X===void 0||X.reject(J),J}finally{this.refreshingDeferred=null,this._debug(Y,"end")}}async _notifyAllSubscribers(D,$,X=!0){let Y=`#_notifyAllSubscribers(${D})`;this._debug(Y,"begin",$,`broadcast = ${X}`);try{if(this.broadcastChannel&&X)this.broadcastChannel.postMessage({event:D,session:$});let J=[],Q=Array.from(this.stateChangeEmitters.values()).map(async(F)=>{try{await F.callback(D,$)}catch(w){J.push(w)}});if(await Promise.all(Q),J.length>0){for(let F=0;F<J.length;F+=1)console.error(J[F]);throw J[0]}}finally{this._debug(Y,"end")}}async _saveSession(D){this._debug("#_saveSession()",D),this.suppressGetSessionWarning=!0,await(0,ZD.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`);let $=Object.assign({},D),X=$.user&&$.user.__isUserNotAvailableProxy===!0;if(this.userStorage){if(!X&&$.user)await(0,ZD.setItemAsync)(this.userStorage,this.storageKey+"-user",{user:$.user});let Y=Object.assign({},$);delete Y.user;let J=(0,ZD.deepClone)(Y);await(0,ZD.setItemAsync)(this.storage,this.storageKey,J)}else{let Y=(0,ZD.deepClone)($);await(0,ZD.setItemAsync)(this.storage,this.storageKey,Y)}}async _removeSession(){if(this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await(0,ZD.removeItemAsync)(this.storage,this.storageKey),await(0,ZD.removeItemAsync)(this.storage,this.storageKey+"-code-verifier"),await(0,ZD.removeItemAsync)(this.storage,this.storageKey+"-user"),this.userStorage)await(0,ZD.removeItemAsync)(this.userStorage,this.storageKey+"-user");await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");let D=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{if(D&&(0,ZD.isBrowser)()&&(window===null||window===void 0?void 0:window.removeEventListener))window.removeEventListener("visibilitychange",D)}catch($){console.error("removing visibilitychange callback failed",$)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");let D=setInterval(()=>this._autoRefreshTokenTick(),P1.AUTO_REFRESH_TICK_DURATION_MS);if(this.autoRefreshTicker=D,D&&typeof D==="object"&&typeof D.unref==="function")D.unref();else if(typeof Deno<"u"&&typeof Deno.unrefTimer==="function")Deno.unrefTimer(D);let $=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);if(this.autoRefreshTickTimeout=$,$&&typeof $==="object"&&typeof $.unref==="function")$.unref();else if(typeof Deno<"u"&&typeof Deno.unrefTimer==="function")Deno.unrefTimer($)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");let D=this.autoRefreshTicker;if(this.autoRefreshTicker=null,D)clearInterval(D);let $=this.autoRefreshTickTimeout;if(this.autoRefreshTickTimeout=null,$)clearTimeout($)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{let D=Date.now();try{return await this._useSession(async($)=>{let{data:{session:X}}=$;if(!X||!X.refresh_token||!X.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}let Y=Math.floor((X.expires_at*1000-D)/P1.AUTO_REFRESH_TICK_DURATION_MS);if(this._debug("#_autoRefreshTokenTick()",`access token expires in ${Y} ticks, a tick lasts ${P1.AUTO_REFRESH_TICK_DURATION_MS}ms, refresh threshold is ${P1.AUTO_REFRESH_TICK_THRESHOLD} ticks`),Y<=P1.AUTO_REFRESH_TICK_THRESHOLD)await this._callRefreshToken(X.refresh_token)})}catch($){console.error("Auto refresh tick failed with error. This is likely a transient error.",$)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(D){if(D.isAcquireTimeout||D instanceof oj.LockAcquireTimeoutError)this._debug("auto refresh token tick lock not available");else throw D}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!(0,ZD.isBrowser)()||!(window===null||window===void 0?void 0:window.addEventListener)){if(this.autoRefreshToken)this.startAutoRefresh();return!1}try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(D){this._debug("#visibilityChangedCallback","error",D)}},window===null||window===void 0||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(D){console.error("_handleVisibilityChange",D)}}async _onVisibilityChanged(D){let $=`#_onVisibilityChanged(${D})`;if(this._debug($,"visibilityState",document.visibilityState),document.visibilityState==="visible"){if(this.autoRefreshToken)this._startAutoRefresh();if(!D)await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{if(document.visibilityState!=="visible"){this._debug($,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()})}else if(document.visibilityState==="hidden"){if(this.autoRefreshToken)this._stopAutoRefresh()}}async _getUrlForProvider(D,$,X){let Y=[`provider=${encodeURIComponent($)}`];if(X===null||X===void 0?void 0:X.redirectTo)Y.push(`redirect_to=${encodeURIComponent(X.redirectTo)}`);if(X===null||X===void 0?void 0:X.scopes)Y.push(`scopes=${encodeURIComponent(X.scopes)}`);if(this.flowType==="pkce"){let[J,Q]=await(0,ZD.getCodeChallengeAndMethod)(this.storage,this.storageKey),F=new URLSearchParams({code_challenge:`${encodeURIComponent(J)}`,code_challenge_method:`${encodeURIComponent(Q)}`});Y.push(F.toString())}if(X===null||X===void 0?void 0:X.queryParams){let J=new URLSearchParams(X.queryParams);Y.push(J.toString())}if(X===null||X===void 0?void 0:X.skipBrowserRedirect)Y.push(`skip_http_redirect=${X.skipBrowserRedirect}`);return`${D}?${Y.join("&")}`}async _unenroll(D){try{return await this._useSession(async($)=>{var X;let{data:Y,error:J}=$;if(J)return this._returnResult({data:null,error:J});return await(0,MD._request)(this.fetch,"DELETE",`${this.url}/factors/${D.factorId}`,{headers:this.headers,jwt:(X=Y===null||Y===void 0?void 0:Y.session)===null||X===void 0?void 0:X.access_token})})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:null,error:$});throw $}}async _enroll(D){try{return await this._useSession(async($)=>{var X,Y;let{data:J,error:Q}=$;if(Q)return this._returnResult({data:null,error:Q});let F=Object.assign({friendly_name:D.friendlyName,factor_type:D.factorType},D.factorType==="phone"?{phone:D.phone}:D.factorType==="totp"?{issuer:D.issuer}:{}),{data:w,error:Z}=await(0,MD._request)(this.fetch,"POST",`${this.url}/factors`,{body:F,headers:this.headers,jwt:(X=J===null||J===void 0?void 0:J.session)===null||X===void 0?void 0:X.access_token});if(Z)return this._returnResult({data:null,error:Z});if(D.factorType==="totp"&&w.type==="totp"&&((Y=w===null||w===void 0?void 0:w.totp)===null||Y===void 0?void 0:Y.qr_code))w.totp.qr_code=`data:image/svg+xml;utf-8,${w.totp.qr_code}`;return this._returnResult({data:w,error:null})})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:null,error:$});throw $}}async _verify(D){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async($)=>{var X;let{data:Y,error:J}=$;if(J)return this._returnResult({data:null,error:J});let Q=Object.assign({challenge_id:D.challengeId},"webauthn"in D?{webauthn:Object.assign(Object.assign({},D.webauthn),{credential_response:D.webauthn.type==="create"?(0,f7.serializeCredentialCreationResponse)(D.webauthn.credential_response):(0,f7.serializeCredentialRequestResponse)(D.webauthn.credential_response)})}:{code:D.code}),{data:F,error:w}=await(0,MD._request)(this.fetch,"POST",`${this.url}/factors/${D.factorId}/verify`,{body:Q,headers:this.headers,jwt:(X=Y===null||Y===void 0?void 0:Y.session)===null||X===void 0?void 0:X.access_token});if(w)return this._returnResult({data:null,error:w});return await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1000)+F.expires_in},F)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",F),this._returnResult({data:F,error:w})})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:null,error:$});throw $}})}async _challenge(D){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async($)=>{var X;let{data:Y,error:J}=$;if(J)return this._returnResult({data:null,error:J});let Q=await(0,MD._request)(this.fetch,"POST",`${this.url}/factors/${D.factorId}/challenge`,{body:D,headers:this.headers,jwt:(X=Y===null||Y===void 0?void 0:Y.session)===null||X===void 0?void 0:X.access_token});if(Q.error)return Q;let{data:F}=Q;if(F.type!=="webauthn")return{data:F,error:null};switch(F.webauthn.type){case"create":return{data:Object.assign(Object.assign({},F),{webauthn:Object.assign(Object.assign({},F.webauthn),{credential_options:Object.assign(Object.assign({},F.webauthn.credential_options),{publicKey:(0,f7.deserializeCredentialCreationOptions)(F.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},F),{webauthn:Object.assign(Object.assign({},F.webauthn),{credential_options:Object.assign(Object.assign({},F.webauthn.credential_options),{publicKey:(0,f7.deserializeCredentialRequestOptions)(F.webauthn.credential_options.publicKey)})})}),error:null}}})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:null,error:$});throw $}})}async _challengeAndVerify(D){let{data:$,error:X}=await this._challenge({factorId:D.factorId});if(X)return this._returnResult({data:null,error:X});return await this._verify({factorId:D.factorId,challengeId:$.id,code:D.code})}async _listFactors(){var D;let{data:{user:$},error:X}=await this.getUser();if(X)return{data:null,error:X};let Y={all:[],phone:[],totp:[],webauthn:[]};for(let J of(D=$===null||$===void 0?void 0:$.factors)!==null&&D!==void 0?D:[])if(Y.all.push(J),J.status==="verified")Y[J.factor_type].push(J);return{data:Y,error:null}}async _getAuthenticatorAssuranceLevel(D){var $,X,Y,J;if(D)try{let{payload:z}=(0,ZD.decodeJWT)(D),q=null;if(z.aal)q=z.aal;let B=q,{data:{user:K},error:M}=await this.getUser(D);if(M)return this._returnResult({data:null,error:M});if(((X=($=K===null||K===void 0?void 0:K.factors)===null||$===void 0?void 0:$.filter((W)=>W.status==="verified"))!==null&&X!==void 0?X:[]).length>0)B="aal2";let I=z.amr||[];return{data:{currentLevel:q,nextLevel:B,currentAuthenticationMethods:I},error:null}}catch(z){if((0,QD.isAuthError)(z))return this._returnResult({data:null,error:z});throw z}let{data:{session:Q},error:F}=await this.getSession();if(F)return this._returnResult({data:null,error:F});if(!Q)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};let{payload:w}=(0,ZD.decodeJWT)(Q.access_token),Z=null;if(w.aal)Z=w.aal;let G=Z;if(((J=(Y=Q.user.factors)===null||Y===void 0?void 0:Y.filter((z)=>z.status==="verified"))!==null&&J!==void 0?J:[]).length>0)G="aal2";let U=w.amr||[];return{data:{currentLevel:Z,nextLevel:G,currentAuthenticationMethods:U},error:null}}async _getAuthorizationDetails(D){try{return await this._useSession(async($)=>{let{data:{session:X},error:Y}=$;if(Y)return this._returnResult({data:null,error:Y});if(!X)return this._returnResult({data:null,error:new QD.AuthSessionMissingError});return await(0,MD._request)(this.fetch,"GET",`${this.url}/oauth/authorizations/${D}`,{headers:this.headers,jwt:X.access_token,xform:(J)=>({data:J,error:null})})})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:null,error:$});throw $}}async _approveAuthorization(D,$){try{return await this._useSession(async(X)=>{let{data:{session:Y},error:J}=X;if(J)return this._returnResult({data:null,error:J});if(!Y)return this._returnResult({data:null,error:new QD.AuthSessionMissingError});let Q=await(0,MD._request)(this.fetch,"POST",`${this.url}/oauth/authorizations/${D}/consent`,{headers:this.headers,jwt:Y.access_token,body:{action:"approve"},xform:(F)=>({data:F,error:null})});if(Q.data&&Q.data.redirect_url){if((0,ZD.isBrowser)()&&!($===null||$===void 0?void 0:$.skipBrowserRedirect))window.location.assign(Q.data.redirect_url)}return Q})}catch(X){if((0,QD.isAuthError)(X))return this._returnResult({data:null,error:X});throw X}}async _denyAuthorization(D,$){try{return await this._useSession(async(X)=>{let{data:{session:Y},error:J}=X;if(J)return this._returnResult({data:null,error:J});if(!Y)return this._returnResult({data:null,error:new QD.AuthSessionMissingError});let Q=await(0,MD._request)(this.fetch,"POST",`${this.url}/oauth/authorizations/${D}/consent`,{headers:this.headers,jwt:Y.access_token,body:{action:"deny"},xform:(F)=>({data:F,error:null})});if(Q.data&&Q.data.redirect_url){if((0,ZD.isBrowser)()&&!($===null||$===void 0?void 0:$.skipBrowserRedirect))window.location.assign(Q.data.redirect_url)}return Q})}catch(X){if((0,QD.isAuthError)(X))return this._returnResult({data:null,error:X});throw X}}async _listOAuthGrants(){try{return await this._useSession(async(D)=>{let{data:{session:$},error:X}=D;if(X)return this._returnResult({data:null,error:X});if(!$)return this._returnResult({data:null,error:new QD.AuthSessionMissingError});return await(0,MD._request)(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:$.access_token,xform:(Y)=>({data:Y,error:null})})})}catch(D){if((0,QD.isAuthError)(D))return this._returnResult({data:null,error:D});throw D}}async _revokeOAuthGrant(D){try{return await this._useSession(async($)=>{let{data:{session:X},error:Y}=$;if(Y)return this._returnResult({data:null,error:Y});if(!X)return this._returnResult({data:null,error:new QD.AuthSessionMissingError});return await(0,MD._request)(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:X.access_token,query:{client_id:D.clientId},noResolveJson:!0}),{data:{},error:null}})}catch($){if((0,QD.isAuthError)($))return this._returnResult({data:null,error:$});throw $}}async fetchJwk(D,$={keys:[]}){let X=$.keys.find((F)=>F.kid===D);if(X)return X;let Y=Date.now();if(X=this.jwks.keys.find((F)=>F.kid===D),X&&this.jwks_cached_at+P1.JWKS_TTL>Y)return X;let{data:J,error:Q}=await(0,MD._request)(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(Q)throw Q;if(!J.keys||J.keys.length===0)return null;if(this.jwks=J,this.jwks_cached_at=Y,X=J.keys.find((F)=>F.kid===D),!X)return null;return X}async getClaims(D,$={}){try{let X=D;if(!X){let{data:z,error:q}=await this.getSession();if(q||!z.session)return this._returnResult({data:null,error:q});X=z.session.access_token}let{header:Y,payload:J,signature:Q,raw:{header:F,payload:w}}=(0,ZD.decodeJWT)(X);if(!($===null||$===void 0?void 0:$.allowExpired))(0,ZD.validateExp)(J.exp);let Z=!Y.alg||Y.alg.startsWith("HS")||!Y.kid||!(("crypto"in globalThis)&&("subtle"in globalThis.crypto))?null:await this.fetchJwk(Y.kid,($===null||$===void 0?void 0:$.keys)?{keys:$.keys}:$===null||$===void 0?void 0:$.jwks);if(!Z){let{error:z}=await this.getUser(X);if(z)throw z;return{data:{claims:J,header:Y,signature:Q},error:null}}let G=(0,ZD.getAlgorithm)(Y.alg),O=await crypto.subtle.importKey("jwk",Z,G,!0,["verify"]);if(!await crypto.subtle.verify(G,O,Q,(0,aj.stringToUint8Array)(`${F}.${w}`)))throw new QD.AuthInvalidJwtError("Invalid JWT signature");return{data:{claims:J,header:Y,signature:Q},error:null}}catch(X){if((0,QD.isAuthError)(X))return this._returnResult({data:null,error:X});throw X}}}y7.nextInstanceID={};sj.default=y7});var DE=T((ej)=>{Object.defineProperty(ej,"__esModule",{value:!0});var J9D=lD(),Y9D=J9D.__importDefault(VJ()),Q9D=Y9D.default;ej.default=Q9D});var XE=T(($E)=>{Object.defineProperty($E,"__esModule",{value:!0});var w9D=lD(),Z9D=w9D.__importDefault(ZO()),G9D=Z9D.default;$E.default=G9D});var GO=T((g6)=>{Object.defineProperty(g6,"__esModule",{value:!0});g6.processLock=g6.lockInternals=g6.NavigatorLockAcquireTimeoutError=g6.navigatorLock=g6.AuthClient=g6.AuthAdminApi=g6.GoTrueClient=g6.GoTrueAdminApi=void 0;var F9=lD(),U9D=F9.__importDefault(VJ());g6.GoTrueAdminApi=U9D.default;var q9D=F9.__importDefault(ZO());g6.GoTrueClient=q9D.default;var z9D=F9.__importDefault(DE());g6.AuthAdminApi=z9D.default;var B9D=F9.__importDefault(XE());g6.AuthClient=B9D.default;F9.__exportStar($O(),g6);F9.__exportStar(_4(),g6);var IJ=QO();Object.defineProperty(g6,"navigatorLock",{enumerable:!0,get:function(){return IJ.navigatorLock}});Object.defineProperty(g6,"NavigatorLockAcquireTimeoutError",{enumerable:!0,get:function(){return IJ.NavigatorLockAcquireTimeoutError}});Object.defineProperty(g6,"lockInternals",{enumerable:!0,get:function(){return IJ.internals}});Object.defineProperty(g6,"processLock",{enumerable:!0,get:function(){return IJ.processLock}})});var GD={};a1(GD,{createClient:()=>OO,SupabaseClient:()=>FE,PostgrestError:()=>_G,FunctionsRelayError:()=>X1.FunctionsRelayError,FunctionsHttpError:()=>X1.FunctionsHttpError,FunctionsFetchError:()=>X1.FunctionsFetchError,FunctionsError:()=>X1.FunctionsError,FunctionRegion:()=>X1.FunctionRegion});function g7(D){return g7=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},g7(D)}function E9D(D,$){if(g7(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(g7(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}function T9D(D){var $=E9D(D,"string");return g7($)=="symbol"?$:$+""}function C9D(D,$,X){return($=T9D($))in D?Object.defineProperty(D,$,{value:X,enumerable:!0,configurable:!0,writable:!0}):D[$]=X,D}function JE(D,$){var X=Object.keys(D);if(Object.getOwnPropertySymbols){var Y=Object.getOwnPropertySymbols(D);$&&(Y=Y.filter(function(J){return Object.getOwnPropertyDescriptor(D,J).enumerable})),X.push.apply(X,Y)}return X}function T0(D){for(var $=1;$<arguments.length;$++){var X=arguments[$]!=null?arguments[$]:{};$%2?JE(Object(X),!0).forEach(function(Y){C9D(D,Y,X[Y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(D,Object.getOwnPropertyDescriptors(X)):JE(Object(X)).forEach(function(Y){Object.defineProperty(D,Y,Object.getOwnPropertyDescriptor(X,Y))})}return D}function u9D(D){return D.endsWith("/")?D:D+"/"}function v9D(D,$){var X,Y;let{db:J,auth:Q,realtime:F,global:w}=D,{db:Z,auth:G,realtime:O,global:U}=$,z={db:T0(T0({},Z),J),auth:T0(T0({},G),Q),realtime:T0(T0({},O),F),storage:{},global:T0(T0(T0({},U),w),{},{headers:T0(T0({},(X=U===null||U===void 0?void 0:U.headers)!==null&&X!==void 0?X:{}),(Y=w===null||w===void 0?void 0:w.headers)!==null&&Y!==void 0?Y:{})}),accessToken:async()=>""};if(D.accessToken)z.accessToken=D.accessToken;else delete z.accessToken;return z}function _9D(D){let $=D===null||D===void 0?void 0:D.trim();if(!$)throw Error("supabaseUrl is required.");if(!$.match(/^https?:\/\//i))throw Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(u9D($))}catch(X){throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}function f9D(){if(typeof window<"u")return!1;let D=globalThis.process;if(!D)return!1;let $=D.version;if($===void 0||$===null)return!1;let X=$.match(/^v(\d+)\./);if(!X)return!1;return parseInt(X[1],10)<=18}var X1,YE,QE,M9D="2.95.3",b7="",L9D,I9D,A9D,R9D,j9D,P9D=(D)=>{if(D)return(...$)=>D(...$);return(...$)=>fetch(...$)},x9D=()=>{return Headers},S9D=(D,$,X)=>{let Y=P9D(X),J=x9D();return async(Q,F)=>{var w;let Z=(w=await $())!==null&&w!==void 0?w:D,G=new J(F===null||F===void 0?void 0:F.headers);if(!G.has("apikey"))G.set("apikey",D);if(!G.has("Authorization"))G.set("Authorization",`Bearer ${Z}`);return Y(Q,T0(T0({},F),{},{headers:G}))}},k9D,FE=class{constructor(D,$,X){var Y,J;this.supabaseUrl=D,this.supabaseKey=$;let Q=_9D(D);if(!$)throw Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",Q),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",Q),this.storageUrl=new URL("storage/v1",Q),this.functionsUrl=new URL("functions/v1",Q);let F=`sb-${Q.hostname.split(".")[0]}-auth-token`,w={db:A9D,realtime:j9D,auth:T0(T0({},R9D),{},{storageKey:F}),global:I9D},Z=v9D(X!==null&&X!==void 0?X:{},w);if(this.storageKey=(Y=Z.auth.storageKey)!==null&&Y!==void 0?Y:"",this.headers=(J=Z.global.headers)!==null&&J!==void 0?J:{},!Z.accessToken){var G;this.auth=this._initSupabaseAuthClient((G=Z.auth)!==null&&G!==void 0?G:{},this.headers,Z.global.fetch)}else this.accessToken=Z.accessToken,this.auth=new Proxy({},{get:(O,U)=>{throw Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(U)} is not possible`)}});if(this.fetch=S9D($,this._getAccessToken.bind(this),Z.global.fetch),this.realtime=this._initRealtimeClient(T0({headers:this.headers,accessToken:this._getAccessToken.bind(this)},Z.realtime)),this.accessToken)Promise.resolve(this.accessToken()).then((O)=>this.realtime.setAuth(O)).catch((O)=>console.warn("Failed to set initial Realtime auth token:",O));if(this.rest=new gA(new URL("rest/v1",Q).href,{headers:this.headers,schema:Z.db.schema,fetch:this.fetch,timeout:Z.db.timeout,urlLengthLimit:Z.db.urlLengthLimit}),this.storage=new yR(this.storageUrl.href,this.headers,this.fetch,X===null||X===void 0?void 0:X.storage),!Z.accessToken)this._listenForAuthEvents()}get functions(){return new X1.FunctionsClient(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(D){return this.rest.from(D)}schema(D){return this.rest.schema(D)}rpc(D,$={},X={head:!1,get:!1,count:void 0}){return this.rest.rpc(D,$,X)}channel(D,$={config:{}}){return this.realtime.channel(D,$)}getChannels(){return this.realtime.getChannels()}removeChannel(D){return this.realtime.removeChannel(D)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var D=this,$,X;if(D.accessToken)return await D.accessToken();let{data:Y}=await D.auth.getSession();return($=(X=Y.session)===null||X===void 0?void 0:X.access_token)!==null&&$!==void 0?$:D.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:D,persistSession:$,detectSessionInUrl:X,storage:Y,userStorage:J,storageKey:Q,flowType:F,lock:w,debug:Z,throwOnError:G},O,U){let z={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new k9D({url:this.authUrl.href,headers:T0(T0({},z),O),storageKey:Q,autoRefreshToken:D,persistSession:$,detectSessionInUrl:X,storage:Y,userStorage:J,flowType:F,lock:w,debug:Z,throwOnError:G,fetch:U,hasCustomAuthorizationHeader:Object.keys(this.headers).some((q)=>q.toLowerCase()==="authorization")})}_initRealtimeClient(D){return new YE.RealtimeClient(this.realtimeUrl.href,T0(T0({},D),{},{params:T0(T0({},{apikey:this.supabaseKey}),D===null||D===void 0?void 0:D.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((D,$)=>{this._handleTokenChanged(D,"CLIENT",$===null||$===void 0?void 0:$.access_token)})}_handleTokenChanged(D,$,X){if((D==="TOKEN_REFRESHED"||D==="SIGNED_IN")&&this.changedAccessToken!==X)this.changedAccessToken=X,this.realtime.setAuth(X);else if(D==="SIGNED_OUT"){if(this.realtime.setAuth(),$=="STORAGE")this.auth.signOut();this.changedAccessToken=void 0}}},OO=(D,$,X)=>{return new FE(D,$,X)};var wE=o(()=>{hA();bR();X1=V0(fA(),1),YE=V0(lG(),1),QE=V0(GO(),1);OD(GD,V0(lG(),1));OD(GD,V0(GO(),1));if(typeof Deno<"u")b7="deno";else if(typeof document<"u")b7="web";else if(typeof navigator<"u"&&navigator.product==="ReactNative")b7="react-native";else b7="node";L9D={"X-Client-Info":`supabase-js-${b7}/${M9D}`},I9D={headers:L9D},A9D={schema:"public"},R9D={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},j9D={};k9D=class extends QE.AuthClient{constructor(D){super(D)}};if(f9D())console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217")});var UO=T((wfD,ZE)=>{ZE.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var AJ=T((OE)=>{var GE={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function y9D(D){return function(...$){if($.length)D=D.replace(/\{(\d)\}/g,(X,Y)=>$[Y]||"");return Error("ADM-ZIP: "+D)}}for(let D of Object.keys(GE))OE[D]=y9D(GE[D])});var KE=T((GfD,BE)=>{var b9D=p("fs"),h0=p("path"),UE=UO(),g9D=AJ(),h9D=typeof process==="object"&&process.platform==="win32",qE=(D)=>typeof D==="object"&&D!==null,zE=new Uint32Array(256).map((D,$)=>{for(let X=0;X<8;X++)if(($&1)!==0)$=3988292384^$>>>1;else $>>>=1;return $>>>0});function C0(D){if(this.sep=h0.sep,this.fs=b9D,qE(D)){if(qE(D.fs)&&typeof D.fs.statSync==="function")this.fs=D.fs}}BE.exports=C0;C0.prototype.makeDir=function(D){let $=this;function X(Y){let J=Y.split($.sep)[0];Y.split($.sep).forEach(function(Q){if(!Q||Q.substr(-1,1)===":")return;J+=$.sep+Q;var F;try{F=$.fs.statSync(J)}catch(w){$.fs.mkdirSync(J)}if(F&&F.isFile())throw g9D.FILE_IN_THE_WAY(`"${J}"`)})}X(D)};C0.prototype.writeFileTo=function(D,$,X,Y){let J=this;if(J.fs.existsSync(D)){if(!X)return!1;var Q=J.fs.statSync(D);if(Q.isDirectory())return!1}var F=h0.dirname(D);if(!J.fs.existsSync(F))J.makeDir(F);var w;try{w=J.fs.openSync(D,"w",438)}catch(Z){J.fs.chmodSync(D,438),w=J.fs.openSync(D,"w",438)}if(w)try{J.fs.writeSync(w,$,0,$.length,0)}finally{J.fs.closeSync(w)}return J.fs.chmodSync(D,Y||438),!0};C0.prototype.writeFileToAsync=function(D,$,X,Y,J){if(typeof Y==="function")J=Y,Y=void 0;let Q=this;Q.fs.exists(D,function(F){if(F&&!X)return J(!1);Q.fs.stat(D,function(w,Z){if(F&&Z.isDirectory())return J(!1);var G=h0.dirname(D);Q.fs.exists(G,function(O){if(!O)Q.makeDir(G);Q.fs.open(D,"w",438,function(U,z){if(U)Q.fs.chmod(D,438,function(){Q.fs.open(D,"w",438,function(q,B){Q.fs.write(B,$,0,$.length,0,function(){Q.fs.close(B,function(){Q.fs.chmod(D,Y||438,function(){J(!0)})})})})});else if(z)Q.fs.write(z,$,0,$.length,0,function(){Q.fs.close(z,function(){Q.fs.chmod(D,Y||438,function(){J(!0)})})});else Q.fs.chmod(D,Y||438,function(){J(!0)})})})})})};C0.prototype.findFiles=function(D){let $=this;function X(Y,J,Q){if(typeof J==="boolean")Q=J,J=void 0;let F=[];return $.fs.readdirSync(Y).forEach(function(w){let Z=h0.join(Y,w),G=$.fs.statSync(Z);if(!J||J.test(Z))F.push(h0.normalize(Z)+(G.isDirectory()?$.sep:""));if(G.isDirectory()&&Q)F=F.concat(X(Z,J,Q))}),F}return X(D,void 0,!0)};C0.prototype.findFilesAsync=function(D,$){let X=this,Y=[];X.fs.readdir(D,function(J,Q){if(J)return $(J);let F=Q.length;if(!F)return $(null,Y);Q.forEach(function(w){w=h0.join(D,w),X.fs.stat(w,function(Z,G){if(Z)return $(Z);if(G){if(Y.push(h0.normalize(w)+(G.isDirectory()?X.sep:"")),G.isDirectory())X.findFilesAsync(w,function(O,U){if(O)return $(O);if(Y=Y.concat(U),!--F)$(null,Y)});else if(!--F)$(null,Y)}})})})};C0.prototype.getAttributes=function(){};C0.prototype.setAttributes=function(){};C0.crc32update=function(D,$){return zE[(D^$)&255]^D>>>8};C0.crc32=function(D){if(typeof D==="string")D=Buffer.from(D,"utf8");let $=D.length,X=-1;for(let Y=0;Y<$;)X=C0.crc32update(X,D[Y++]);return~X>>>0};C0.methodToString=function(D){switch(D){case UE.STORED:return"STORED ("+D+")";case UE.DEFLATED:return"DEFLATED ("+D+")";default:return"UNSUPPORTED ("+D+")"}};C0.canonical=function(D){if(!D)return"";let $=h0.posix.normalize("/"+D.split("\\").join("/"));return h0.join(".",$)};C0.zipnamefix=function(D){if(!D)return"";let $=h0.posix.normalize("/"+D.split("\\").join("/"));return h0.posix.join(".",$)};C0.findLast=function(D,$){if(!Array.isArray(D))throw TypeError("arr is not array");let X=D.length>>>0;for(let Y=X-1;Y>=0;Y--)if($(D[Y],Y,D))return D[Y];return};C0.sanitize=function(D,$){D=h0.resolve(h0.normalize(D));var X=$.split("/");for(var Y=0,J=X.length;Y<J;Y++){var Q=h0.normalize(h0.join(D,X.slice(Y,J).join(h0.sep)));if(Q.indexOf(D)===0)return Q}return h0.normalize(h0.join(D,h0.basename($)))};C0.toBuffer=function($,X){if(Buffer.isBuffer($))return $;else if($ instanceof Uint8Array)return Buffer.from($);else return typeof $==="string"?X($):Buffer.alloc(0)};C0.readBigUInt64LE=function(D,$){var X=Buffer.from(D.slice($,$+8));return X.swap64(),parseInt(`0x${X.toString("hex")}`)};C0.fromDOS2Date=function(D){return new Date((D>>25&127)+1980,Math.max((D>>21&15)-1,0),Math.max(D>>16&31,1),D>>11&31,D>>5&63,(D&31)<<1)};C0.fromDate2DOS=function(D){let $=0,X=0;if(D.getFullYear()>1979)$=(D.getFullYear()-1980&127)<<9|D.getMonth()+1<<5|D.getDate(),X=D.getHours()<<11|D.getMinutes()<<5|D.getSeconds()>>1;return $<<16|X};C0.isWin=h9D;C0.crcTable=zE});var HE=T((OfD,WE)=>{var m9D=p("path");WE.exports=function(D,{fs:$}){var X=D||"",Y=Q(),J=null;function Q(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}if(X&&$.existsSync(X))J=$.statSync(X),Y.directory=J.isDirectory(),Y.mtime=J.mtime,Y.atime=J.atime,Y.executable=(73&J.mode)!==0,Y.readonly=(128&J.mode)===0,Y.hidden=m9D.basename(X)[0]===".";else console.warn("Invalid path: "+X);return{get directory(){return Y.directory},get readOnly(){return Y.readonly},get hidden(){return Y.hidden},get mtime(){return Y.mtime},get atime(){return Y.atime},get executable(){return Y.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:X,isDirectory:Y.directory,isReadOnly:Y.readonly,isHidden:Y.hidden,isExecutable:Y.executable,mTime:Y.mtime,aTime:Y.atime}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var NE=T((UfD,VE)=>{VE.exports={efs:!0,encode:(D)=>Buffer.from(D,"utf8"),decode:(D)=>D.toString("utf8")}});var Z9=T((qfD,w9)=>{w9.exports=KE();w9.exports.Constants=UO();w9.exports.Errors=AJ();w9.exports.FileAttr=HE();w9.exports.decoder=NE()});var LE=T((zfD,ME)=>{var h6=Z9(),wD=h6.Constants;ME.exports=function(){var D=20,$=10,X=0,Y=0,J=0,Q=0,F=0,w=0,Z=0,G=0,O=0,U=0,z=0,q=0,B=0;D|=h6.isWin?2560:768,X|=wD.FLG_EFS;let K={extraLen:0},M=(W)=>Math.max(0,W)>>>0,L=(W)=>Math.max(0,W)&65535,I=(W)=>Math.max(0,W)&255;return J=h6.fromDate2DOS(new Date),{get made(){return D},set made(W){D=W},get version(){return $},set version(W){$=W},get flags(){return X},set flags(W){X=W},get flags_efs(){return(X&wD.FLG_EFS)>0},set flags_efs(W){if(W)X|=wD.FLG_EFS;else X&=~wD.FLG_EFS},get flags_desc(){return(X&wD.FLG_DESC)>0},set flags_desc(W){if(W)X|=wD.FLG_DESC;else X&=~wD.FLG_DESC},get method(){return Y},set method(W){switch(W){case wD.STORED:this.version=10;case wD.DEFLATED:default:this.version=20}Y=W},get time(){return h6.fromDOS2Date(this.timeval)},set time(W){this.timeval=h6.fromDate2DOS(W)},get timeval(){return J},set timeval(W){J=M(W)},get timeHighByte(){return I(J>>>8)},get crc(){return Q},set crc(W){Q=M(W)},get compressedSize(){return F},set compressedSize(W){F=M(W)},get size(){return w},set size(W){w=M(W)},get fileNameLength(){return Z},set fileNameLength(W){Z=W},get extraLength(){return G},set extraLength(W){G=W},get extraLocalLength(){return K.extraLen},set extraLocalLength(W){K.extraLen=W},get commentLength(){return O},set commentLength(W){O=W},get diskNumStart(){return U},set diskNumStart(W){U=M(W)},get inAttr(){return z},set inAttr(W){z=M(W)},get attr(){return q},set attr(W){q=M(W)},get fileAttr(){return(q||0)>>16&4095},get offset(){return B},set offset(W){B=M(W)},get encrypted(){return(X&wD.FLG_ENC)===wD.FLG_ENC},get centralHeaderSize(){return wD.CENHDR+Z+G+O},get realDataOffset(){return B+wD.LOCHDR+K.fnameLen+K.extraLen},get localHeader(){return K},loadLocalHeaderFromBinary:function(W){var N=W.slice(B,B+wD.LOCHDR);if(N.readUInt32LE(0)!==wD.LOCSIG)throw h6.Errors.INVALID_LOC();K.version=N.readUInt16LE(wD.LOCVER),K.flags=N.readUInt16LE(wD.LOCFLG),K.method=N.readUInt16LE(wD.LOCHOW),K.time=N.readUInt32LE(wD.LOCTIM),K.crc=N.readUInt32LE(wD.LOCCRC),K.compressedSize=N.readUInt32LE(wD.LOCSIZ),K.size=N.readUInt32LE(wD.LOCLEN),K.fnameLen=N.readUInt16LE(wD.LOCNAM),K.extraLen=N.readUInt16LE(wD.LOCEXT);let V=B+wD.LOCHDR+K.fnameLen,R=V+K.extraLen;return W.slice(V,R)},loadFromBinary:function(W){if(W.length!==wD.CENHDR||W.readUInt32LE(0)!==wD.CENSIG)throw h6.Errors.INVALID_CEN();D=W.readUInt16LE(wD.CENVEM),$=W.readUInt16LE(wD.CENVER),X=W.readUInt16LE(wD.CENFLG),Y=W.readUInt16LE(wD.CENHOW),J=W.readUInt32LE(wD.CENTIM),Q=W.readUInt32LE(wD.CENCRC),F=W.readUInt32LE(wD.CENSIZ),w=W.readUInt32LE(wD.CENLEN),Z=W.readUInt16LE(wD.CENNAM),G=W.readUInt16LE(wD.CENEXT),O=W.readUInt16LE(wD.CENCOM),U=W.readUInt16LE(wD.CENDSK),z=W.readUInt16LE(wD.CENATT),q=W.readUInt32LE(wD.CENATX),B=W.readUInt32LE(wD.CENOFF)},localHeaderToBinary:function(){var W=Buffer.alloc(wD.LOCHDR);return W.writeUInt32LE(wD.LOCSIG,0),W.writeUInt16LE($,wD.LOCVER),W.writeUInt16LE(X,wD.LOCFLG),W.writeUInt16LE(Y,wD.LOCHOW),W.writeUInt32LE(J,wD.LOCTIM),W.writeUInt32LE(Q,wD.LOCCRC),W.writeUInt32LE(F,wD.LOCSIZ),W.writeUInt32LE(w,wD.LOCLEN),W.writeUInt16LE(Z,wD.LOCNAM),W.writeUInt16LE(K.extraLen,wD.LOCEXT),W},centralHeaderToBinary:function(){var W=Buffer.alloc(wD.CENHDR+Z+G+O);return W.writeUInt32LE(wD.CENSIG,0),W.writeUInt16LE(D,wD.CENVEM),W.writeUInt16LE($,wD.CENVER),W.writeUInt16LE(X,wD.CENFLG),W.writeUInt16LE(Y,wD.CENHOW),W.writeUInt32LE(J,wD.CENTIM),W.writeUInt32LE(Q,wD.CENCRC),W.writeUInt32LE(F,wD.CENSIZ),W.writeUInt32LE(w,wD.CENLEN),W.writeUInt16LE(Z,wD.CENNAM),W.writeUInt16LE(G,wD.CENEXT),W.writeUInt16LE(O,wD.CENCOM),W.writeUInt16LE(U,wD.CENDSK),W.writeUInt16LE(z,wD.CENATT),W.writeUInt32LE(q,wD.CENATX),W.writeUInt32LE(B,wD.CENOFF),W},toJSON:function(){let W=function(N){return N+" bytes"};return{made:D,version:$,flags:X,method:h6.methodToString(Y),time:this.time,crc:"0x"+Q.toString(16).toUpperCase(),compressedSize:W(F),size:W(w),fileNameLength:W(Z),extraLength:W(G),commentLength:W(O),diskNumStart:U,inAttr:z,attr:q,offset:B,centralHeaderSize:W(wD.CENHDR+Z+G+O)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var AE=T((BfD,IE)=>{var G9=Z9(),N0=G9.Constants;IE.exports=function(){var D=0,$=0,X=0,Y=0,J=0;return{get diskEntries(){return D},set diskEntries(Q){D=$=Q},get totalEntries(){return $},set totalEntries(Q){$=D=Q},get size(){return X},set size(Q){X=Q},get offset(){return Y},set offset(Q){Y=Q},get commentLength(){return J},set commentLength(Q){J=Q},get mainHeaderSize(){return N0.ENDHDR+J},loadFromBinary:function(Q){if((Q.length!==N0.ENDHDR||Q.readUInt32LE(0)!==N0.ENDSIG)&&(Q.length<N0.ZIP64HDR||Q.readUInt32LE(0)!==N0.ZIP64SIG))throw G9.Errors.INVALID_END();if(Q.readUInt32LE(0)===N0.ENDSIG)D=Q.readUInt16LE(N0.ENDSUB),$=Q.readUInt16LE(N0.ENDTOT),X=Q.readUInt32LE(N0.ENDSIZ),Y=Q.readUInt32LE(N0.ENDOFF),J=Q.readUInt16LE(N0.ENDCOM);else D=G9.readBigUInt64LE(Q,N0.ZIP64SUB),$=G9.readBigUInt64LE(Q,N0.ZIP64TOT),X=G9.readBigUInt64LE(Q,N0.ZIP64SIZE),Y=G9.readBigUInt64LE(Q,N0.ZIP64OFF),J=0},toBinary:function(){var Q=Buffer.alloc(N0.ENDHDR+J);return Q.writeUInt32LE(N0.ENDSIG,0),Q.writeUInt32LE(0,4),Q.writeUInt16LE(D,N0.ENDSUB),Q.writeUInt16LE($,N0.ENDTOT),Q.writeUInt32LE(X,N0.ENDSIZ),Q.writeUInt32LE(Y,N0.ENDOFF),Q.writeUInt16LE(J,N0.ENDCOM),Q.fill(" ",N0.ENDHDR),Q},toJSON:function(){let Q=function(F,w){let Z=F.toString(16).toUpperCase();while(Z.length<w)Z="0"+Z;return"0x"+Z};return{diskEntries:D,totalEntries:$,size:X+" bytes",offset:Q(Y,4),commentLength:J}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var qO=T((d9D)=>{d9D.EntryHeader=LE();d9D.MainHeader=AE()});var jE=T((WfD,RE)=>{RE.exports=function(D){var $=p("zlib"),X={chunkSize:(parseInt(D.length/1024)+1)*1024};return{deflate:function(){return $.deflateRawSync(D,X)},deflateAsync:function(Y){var J=$.createDeflateRaw(X),Q=[],F=0;J.on("data",function(w){Q.push(w),F+=w.length}),J.on("end",function(){var w=Buffer.alloc(F),Z=0;w.fill(0);for(var G=0;G<Q.length;G++){var O=Q[G];O.copy(w,Z),Z+=O.length}Y&&Y(w)}),J.end(D)}}}});var TE=T((HfD,EE)=>{var n9D=+(process.versions?process.versions.node:"").split(".")[0]||0;EE.exports=function(D,$){var X=p("zlib");let Y=n9D>=15&&$>0?{maxOutputLength:$}:{};return{inflate:function(){return X.inflateRawSync(D,Y)},inflateAsync:function(J){var Q=X.createInflateRaw(Y),F=[],w=0;Q.on("data",function(Z){F.push(Z),w+=Z.length}),Q.on("end",function(){var Z=Buffer.alloc(w),G=0;Z.fill(0);for(var O=0;O<F.length;O++){var U=F[O];U.copy(Z,G),G+=U.length}J&&J(Z)}),Q.end(D)}}}});var uE=T((VfD,SE)=>{var{randomFillSync:CE}=p("crypto"),i9D=AJ(),p9D=new Uint32Array(256).map((D,$)=>{for(let X=0;X<8;X++)if(($&1)!==0)$=$>>>1^3988292384;else $>>>=1;return $>>>0}),xE=(D,$)=>Math.imul(D,$)>>>0,PE=(D,$)=>{return p9D[(D^$)&255]^D>>>8},h7=()=>{if(typeof CE==="function")return CE(Buffer.alloc(12));else return h7.node()};h7.node=()=>{let D=Buffer.alloc(12),$=D.length;for(let X=0;X<$;X++)D[X]=Math.random()*256&255;return D};var RJ={genSalt:h7};function jJ(D){let $=Buffer.isBuffer(D)?D:Buffer.from(D);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let X=0;X<$.length;X++)this.updateKeys($[X])}jJ.prototype.updateKeys=function(D){let $=this.keys;return $[0]=PE($[0],D),$[1]+=$[0]&255,$[1]=xE($[1],134775813)+1,$[2]=PE($[2],$[1]>>>24),D};jJ.prototype.next=function(){let D=(this.keys[2]|2)>>>0;return xE(D,D^1)>>8&255};function r9D(D){let $=new jJ(D);return function(X){let Y=Buffer.alloc(X.length),J=0;for(let Q of X)Y[J++]=$.updateKeys(Q^$.next());return Y}}function o9D(D){let $=new jJ(D);return function(X,Y,J=0){if(!Y)Y=Buffer.alloc(X.length);for(let Q of X){let F=$.next();Y[J++]=Q^F,$.updateKeys(Q)}return Y}}function a9D(D,$,X){if(!D||!Buffer.isBuffer(D)||D.length<12)return Buffer.alloc(0);let Y=r9D(X),J=Y(D.slice(0,12)),Q=($.flags&8)===8?$.timeHighByte:$.crc>>>24;if(J[11]!==Q)throw i9D.WRONG_PASSWORD();return Y(D.slice(12))}function t9D(D){if(Buffer.isBuffer(D)&&D.length>=12)RJ.genSalt=function(){return D.slice(0,12)};else if(D==="node")RJ.genSalt=h7.node;else RJ.genSalt=h7}function s9D(D,$,X,Y=!1){if(D==null)D=Buffer.alloc(0);if(!Buffer.isBuffer(D))D=Buffer.from(D.toString());let J=o9D(X),Q=RJ.genSalt();if(Q[11]=$.crc>>>24&255,Y)Q[10]=$.crc>>>16&255;let F=Buffer.alloc(D.length+12);return J(Q,F),J(D,F,12)}SE.exports={decrypt:a9D,encrypt:s9D,_salter:t9D}});var vE=T((e9D)=>{e9D.Deflater=jE();e9D.Inflater=TE();e9D.ZipCrypto=uE()});var BO=T((MfD,_E)=>{var nD=Z9(),J5D=qO(),P0=nD.Constants,zO=vE();_E.exports=function(D,$){var X=new J5D.EntryHeader,Y=Buffer.alloc(0),J=Buffer.alloc(0),Q=!1,F=null,w=Buffer.alloc(0),Z=Buffer.alloc(0),G=!0;let O=D,U=typeof O.decoder==="object"?O.decoder:nD.decoder;G=U.hasOwnProperty("efs")?U.efs:!1;function z(){if(!$||!($ instanceof Uint8Array))return Buffer.alloc(0);return Z=X.loadLocalHeaderFromBinary($),$.slice(X.realDataOffset,X.realDataOffset+X.compressedSize)}function q(W){if(!X.flags_desc){if(nD.crc32(W)!==X.localHeader.crc)return!1}else{let N={},V=X.realDataOffset+X.compressedSize;if($.readUInt32LE(V)==P0.LOCSIG||$.readUInt32LE(V)==P0.CENSIG)throw nD.Errors.DESCRIPTOR_NOT_EXIST();if($.readUInt32LE(V)==P0.EXTSIG)N.crc=$.readUInt32LE(V+P0.EXTCRC),N.compressedSize=$.readUInt32LE(V+P0.EXTSIZ),N.size=$.readUInt32LE(V+P0.EXTLEN);else if($.readUInt16LE(V+12)===19280)N.crc=$.readUInt32LE(V+P0.EXTCRC-4),N.compressedSize=$.readUInt32LE(V+P0.EXTSIZ-4),N.size=$.readUInt32LE(V+P0.EXTLEN-4);else throw nD.Errors.DESCRIPTOR_UNKNOWN();if(N.compressedSize!==X.compressedSize||N.size!==X.size||N.crc!==X.crc)throw nD.Errors.DESCRIPTOR_FAULTY();if(nD.crc32(W)!==N.crc)return!1}return!0}function B(W,N,V){if(typeof N>"u"&&typeof W==="string")V=W,W=void 0;if(Q){if(W&&N)N(Buffer.alloc(0),nD.Errors.DIRECTORY_CONTENT_ERROR());return Buffer.alloc(0)}var R=z();if(R.length===0){if(W&&N)N(R);return R}if(X.encrypted){if(typeof V!=="string"&&!Buffer.isBuffer(V))throw nD.Errors.INVALID_PASS_PARAM();R=zO.ZipCrypto.decrypt(R,X,V)}var C=Buffer.alloc(X.size);switch(X.method){case nD.Constants.STORED:if(R.copy(C),!q(C)){if(W&&N)N(C,nD.Errors.BAD_CRC());throw nD.Errors.BAD_CRC()}else{if(W&&N)N(C);return C}case nD.Constants.DEFLATED:var A=new zO.Inflater(R,X.size);if(!W){if(A.inflate(C).copy(C,0),!q(C))throw nD.Errors.BAD_CRC(`"${U.decode(Y)}"`);return C}else A.inflateAsync(function(_){if(_.copy(_,0),N)if(!q(_))N(_,nD.Errors.BAD_CRC());else N(_)});break;default:if(W&&N)N(Buffer.alloc(0),nD.Errors.UNKNOWN_METHOD());throw nD.Errors.UNKNOWN_METHOD()}}function K(W,N){if((!F||!F.length)&&Buffer.isBuffer($)){if(W&&N)N(z());return z()}if(F.length&&!Q){var V;switch(X.method){case nD.Constants.STORED:if(X.compressedSize=X.size,V=Buffer.alloc(F.length),F.copy(V),W&&N)N(V);return V;default:case nD.Constants.DEFLATED:var R=new zO.Deflater(F);if(!W){var C=R.deflate();return X.compressedSize=C.length,C}else R.deflateAsync(function(A){V=Buffer.alloc(A.length),X.compressedSize=A.length,A.copy(V),N&&N(V)});R=null;break}}else if(W&&N)N(Buffer.alloc(0));else return Buffer.alloc(0)}function M(W,N){return(W.readUInt32LE(N+4)<<4)+W.readUInt32LE(N)}function L(W){try{var N=0,V,R,C;while(N+4<W.length)if(V=W.readUInt16LE(N),N+=2,R=W.readUInt16LE(N),N+=2,C=W.slice(N,N+R),N+=R,P0.ID_ZIP64===V)I(C)}catch(A){throw nD.Errors.EXTRA_FIELD_PARSE_ERROR()}}function I(W){var N,V,R,C;if(W.length>=P0.EF_ZIP64_SCOMP){if(N=M(W,P0.EF_ZIP64_SUNCOMP),X.size===P0.EF_ZIP64_OR_32)X.size=N}if(W.length>=P0.EF_ZIP64_RHO){if(V=M(W,P0.EF_ZIP64_SCOMP),X.compressedSize===P0.EF_ZIP64_OR_32)X.compressedSize=V}if(W.length>=P0.EF_ZIP64_DSN){if(R=M(W,P0.EF_ZIP64_RHO),X.offset===P0.EF_ZIP64_OR_32)X.offset=R}if(W.length>=P0.EF_ZIP64_DSN+4){if(C=W.readUInt32LE(P0.EF_ZIP64_DSN),X.diskNumStart===P0.EF_ZIP64_OR_16)X.diskNumStart=C}}return{get entryName(){return U.decode(Y)},get rawEntryName(){return Y},set entryName(W){Y=nD.toBuffer(W,U.encode);var N=Y[Y.length-1];Q=N===47||N===92,X.fileNameLength=Y.length},get efs(){if(typeof G==="function")return G(this.entryName);else return G},get extra(){return w},set extra(W){w=W,X.extraLength=W.length,L(W)},get comment(){return U.decode(J)},set comment(W){if(J=nD.toBuffer(W,U.encode),X.commentLength=J.length,J.length>65535)throw nD.Errors.COMMENT_TOO_LONG()},get name(){var W=U.decode(Y);return Q?W.substr(W.length-1).split("/").pop():W.split("/").pop()},get isDirectory(){return Q},getCompressedData:function(){return K(!1,null)},getCompressedDataAsync:function(W){K(!0,W)},setData:function(W){if(F=nD.toBuffer(W,nD.decoder.encode),!Q&&F.length)X.size=F.length,X.method=nD.Constants.DEFLATED,X.crc=nD.crc32(W),X.changed=!0;else X.method=nD.Constants.STORED},getData:function(W){if(X.changed)return F;else return B(!1,null,W)},getDataAsync:function(W,N){if(X.changed)W(F);else B(!0,W,N)},set attr(W){X.attr=W},get attr(){return X.attr},set header(W){X.loadFromBinary(W)},get header(){return X},packCentralHeader:function(){X.flags_efs=this.efs,X.extraLength=w.length;var W=X.centralHeaderToBinary(),N=nD.Constants.CENHDR;return Y.copy(W,N),N+=Y.length,w.copy(W,N),N+=X.extraLength,J.copy(W,N),W},packLocalHeader:function(){let W=0;X.flags_efs=this.efs,X.extraLocalLength=Z.length;let N=X.localHeaderToBinary(),V=Buffer.alloc(N.length+Y.length+X.extraLocalLength);return N.copy(V,W),W+=N.length,Y.copy(V,W),W+=Y.length,Z.copy(V,W),W+=Z.length,V},toJSON:function(){let W=function(N){return"<"+(N&&N.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:X.toJSON(),compressedData:W($),data:W(F)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var yE=T((LfD,fE)=>{var kE=BO(),Y5D=qO(),p0=Z9();fE.exports=function(D,$){var X=[],Y={},J=Buffer.alloc(0),Q=new Y5D.MainHeader,F=!1,w=null;let Z=new Set,G=$,{noSort:O,decoder:U}=G;if(D)B(G.readEntries);else F=!0;function z(){let M=new Set;for(let L of Object.keys(Y)){let I=L.split("/");if(I.pop(),!I.length)continue;for(let W=0;W<I.length;W++){let N=I.slice(0,W+1).join("/")+"/";M.add(N)}}for(let L of M)if(!(L in Y)){let I=new kE(G);I.entryName=L,I.attr=16,I.temporary=!0,X.push(I),Y[I.entryName]=I,Z.add(I)}}function q(){if(F=!0,Y={},Q.diskEntries>(D.length-Q.offset)/p0.Constants.CENHDR)throw p0.Errors.DISK_ENTRY_TOO_LARGE();X=Array(Q.diskEntries);var M=Q.offset;for(var L=0;L<X.length;L++){var I=M,W=new kE(G,D);if(W.header=D.slice(I,I+=p0.Constants.CENHDR),W.entryName=D.slice(I,I+=W.header.fileNameLength),W.header.extraLength)W.extra=D.slice(I,I+=W.header.extraLength);if(W.header.commentLength)W.comment=D.slice(I,I+W.header.commentLength);M+=W.header.centralHeaderSize,X[L]=W,Y[W.entryName]=W}Z.clear(),z()}function B(M){var L=D.length-p0.Constants.ENDHDR,I=Math.max(0,L-65535),W=I,N=D.length,V=-1,R=0;if(typeof G.trailingSpace==="boolean"?G.trailingSpace:!1)I=0;for(L;L>=W;L--){if(D[L]!==80)continue;if(D.readUInt32LE(L)===p0.Constants.ENDSIG){V=L,R=L,N=L+p0.Constants.ENDHDR,W=L-p0.Constants.END64HDR;continue}if(D.readUInt32LE(L)===p0.Constants.END64SIG){W=I;continue}if(D.readUInt32LE(L)===p0.Constants.ZIP64SIG){V=L,N=L+p0.readBigUInt64LE(D,L+p0.Constants.ZIP64SIZE)+p0.Constants.ZIP64LEAD;break}}if(V==-1)throw p0.Errors.INVALID_FORMAT();if(Q.loadFromBinary(D.slice(V,N)),Q.commentLength)J=D.slice(R+p0.Constants.ENDHDR);if(M)q()}function K(){if(X.length>1&&!O)X.sort((M,L)=>M.entryName.toLowerCase().localeCompare(L.entryName.toLowerCase()))}return{get entries(){if(!F)q();return X.filter((M)=>!Z.has(M))},get comment(){return U.decode(J)},set comment(M){J=p0.toBuffer(M,U.encode),Q.commentLength=J.length},getEntryCount:function(){if(!F)return Q.diskEntries;return X.length},forEach:function(M){this.entries.forEach(M)},getEntry:function(M){if(!F)q();return Y[M]||null},setEntry:function(M){if(!F)q();X.push(M),Y[M.entryName]=M,Q.totalEntries=X.length},deleteFile:function(M,L=!0){if(!F)q();let I=Y[M];this.getEntryChildren(I,L).map((N)=>N.entryName).forEach(this.deleteEntry)},deleteEntry:function(M){if(!F)q();let L=Y[M],I=X.indexOf(L);if(I>=0)X.splice(I,1),delete Y[M],Q.totalEntries=X.length},getEntryChildren:function(M,L=!0){if(!F)q();if(typeof M==="object")if(M.isDirectory&&L){let I=[],W=M.entryName;for(let N of X)if(N.entryName.startsWith(W))I.push(N);return I}else return[M];return[]},getChildCount:function(M){if(M&&M.isDirectory){let L=this.getEntryChildren(M);return L.includes(M)?L.length-1:L.length}return 0},compressToBuffer:function(){if(!F)q();K();let M=[],L=[],I=0,W=0;Q.size=0,Q.offset=0;let N=0;for(let C of this.entries){let A=C.getCompressedData();C.header.offset=W;let _=C.packLocalHeader(),v=_.length+A.length;W+=v,M.push(_),M.push(A);let S=C.packCentralHeader();L.push(S),Q.size+=S.length,I+=v+S.length,N++}I+=Q.mainHeaderSize,Q.offset=W,Q.totalEntries=N,W=0;let V=Buffer.alloc(I);for(let C of M)C.copy(V,W),W+=C.length;for(let C of L)C.copy(V,W),W+=C.length;let R=Q.toBinary();if(J)J.copy(R,p0.Constants.ENDHDR);return R.copy(V,W),D=V,F=!1,V},toAsyncBuffer:function(M,L,I,W){try{if(!F)q();K();let N=[],V=[],R=0,C=0,A=0;Q.size=0,Q.offset=0;let _=function(v){if(v.length>0){let S=v.shift(),h=S.entryName+S.extra.toString();if(I)I(h);S.getCompressedDataAsync(function(g){if(W)W(h);S.header.offset=C;let l=S.packLocalHeader(),f=l.length+g.length;C+=f,N.push(l),N.push(g);let j=S.packCentralHeader();V.push(j),Q.size+=j.length,R+=f+j.length,A++,_(v)})}else{R+=Q.mainHeaderSize,Q.offset=C,Q.totalEntries=A,C=0;let S=Buffer.alloc(R);N.forEach(function(g){g.copy(S,C),C+=g.length}),V.forEach(function(g){g.copy(S,C),C+=g.length});let h=Q.toBinary();if(J)J.copy(h,p0.Constants.ENDHDR);h.copy(S,C),D=S,F=!1,M(S)}};_(Array.from(this.entries))}catch(N){L(N)}}}}});var KO=T((IfD,gE)=>{var M0=Z9(),x0=p("path"),Q5D=BO(),F5D=yE(),g4=(...D)=>M0.findLast(D,($)=>typeof $==="boolean"),bE=(...D)=>M0.findLast(D,($)=>typeof $==="string"),w5D=(...D)=>M0.findLast(D,($)=>typeof $==="function"),Z5D={noSort:!1,readEntries:!1,method:M0.Constants.NONE,fs:null};gE.exports=function(D,$){let X=null,Y=Object.assign(Object.create(null),Z5D);if(D&&typeof D==="object"){if(!(D instanceof Uint8Array)){if(Object.assign(Y,D),D=Y.input?Y.input:void 0,Y.input)delete Y.input}if(Buffer.isBuffer(D))X=D,Y.method=M0.Constants.BUFFER,D=void 0}Object.assign(Y,$);let J=new M0(Y);if(typeof Y.decoder!=="object"||typeof Y.decoder.encode!=="function"||typeof Y.decoder.decode!=="function")Y.decoder=M0.decoder;if(D&&typeof D==="string")if(J.fs.existsSync(D))Y.method=M0.Constants.FILE,Y.filename=D,X=J.fs.readFileSync(D);else throw M0.Errors.INVALID_FILENAME();let Q=new F5D(X,Y),{canonical:F,sanitize:w,zipnamefix:Z}=M0;function G(q){if(q&&Q){var B;if(typeof q==="string")B=Q.getEntry(x0.posix.normalize(q));if(typeof q==="object"&&typeof q.entryName<"u"&&typeof q.header<"u")B=Q.getEntry(q.entryName);if(B)return B}return null}function O(q){let{join:B,normalize:K,sep:M}=x0.posix;return B(".",K(M+q.split("\\").join(M)+M))}function U(q){if(q instanceof RegExp)return function(B){return function(K){return B.test(K)}}(q);else if(typeof q!=="function")return()=>!0;return q}let z=(q,B)=>{let K=B.slice(-1);return K=K===J.sep?J.sep:"",x0.relative(q,B)+K};return{readFile:function(q,B){var K=G(q);return K&&K.getData(B)||null},childCount:function(q){let B=G(q);if(B)return Q.getChildCount(B)},readFileAsync:function(q,B){var K=G(q);if(K)K.getDataAsync(B);else B(null,"getEntry failed for:"+q)},readAsText:function(q,B){var K=G(q);if(K){var M=K.getData();if(M&&M.length)return M.toString(B||"utf8")}return""},readAsTextAsync:function(q,B,K){var M=G(q);if(M)M.getDataAsync(function(L,I){if(I){B(L,I);return}if(L&&L.length)B(L.toString(K||"utf8"));else B("")});else B("")},deleteFile:function(q,B=!0){var K=G(q);if(K)Q.deleteFile(K.entryName,B)},deleteEntry:function(q){var B=G(q);if(B)Q.deleteEntry(B.entryName)},addZipComment:function(q){Q.comment=q},getZipComment:function(){return Q.comment||""},addZipEntryComment:function(q,B){var K=G(q);if(K)K.comment=B},getZipEntryComment:function(q){var B=G(q);if(B)return B.comment||"";return""},updateFile:function(q,B){var K=G(q);if(K)K.setData(B)},addLocalFile:function(q,B,K,M){if(J.fs.existsSync(q)){B=B?O(B):"";let L=x0.win32.basename(x0.win32.normalize(q));B+=K?K:L;let I=J.fs.statSync(q),W=I.isFile()?J.fs.readFileSync(q):Buffer.alloc(0);if(I.isDirectory())B+=J.sep;this.addFile(B,W,M,I)}else throw M0.Errors.FILE_NOT_FOUND(q)},addLocalFileAsync:function(q,B){q=typeof q==="object"?q:{localPath:q};let K=x0.resolve(q.localPath),{comment:M}=q,{zipPath:L,zipName:I}=q,W=this;J.fs.stat(K,function(N,V){if(N)return B(N,!1);L=L?O(L):"";let R=x0.win32.basename(x0.win32.normalize(K));if(L+=I?I:R,V.isFile())J.fs.readFile(K,function(C,A){if(C)return B(C,!1);return W.addFile(L,A,M,V),setImmediate(B,void 0,!0)});else if(V.isDirectory())return L+=J.sep,W.addFile(L,Buffer.alloc(0),M,V),setImmediate(B,void 0,!0)})},addLocalFolder:function(q,B,K){if(K=U(K),B=B?O(B):"",q=x0.normalize(q),J.fs.existsSync(q)){let M=J.findFiles(q),L=this;if(M.length)for(let I of M){let W=x0.join(B,z(q,I));if(K(W))L.addLocalFile(I,x0.dirname(W))}}else throw M0.Errors.FILE_NOT_FOUND(q)},addLocalFolderAsync:function(q,B,K,M){M=U(M),K=K?O(K):"",q=x0.normalize(q);var L=this;J.fs.open(q,"r",function(I){if(I&&I.code==="ENOENT")B(void 0,M0.Errors.FILE_NOT_FOUND(q));else if(I)B(void 0,I);else{var W=J.findFiles(q),N=-1,V=function(){if(N+=1,N<W.length){var R=W[N],C=z(q,R).split("\\").join("/");if(C=C.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),M(C))J.fs.stat(R,function(A,_){if(A)B(void 0,A);if(_.isFile())J.fs.readFile(R,function(v,S){if(v)B(void 0,v);else L.addFile(K+C,S,"",_),V()});else L.addFile(K+C+"/",Buffer.alloc(0),"",_),V()});else process.nextTick(()=>{V()})}else B(!0,void 0)};V()}})},addLocalFolderAsync2:function(q,B){let K=this;q=typeof q==="object"?q:{localPath:q},localPath=x0.resolve(O(q.localPath));let{zipPath:M,filter:L,namefix:I}=q;if(L instanceof RegExp)L=function(V){return function(R){return V.test(R)}}(L);else if(typeof L!=="function")L=function(){return!0};if(M=M?O(M):"",I=="latin1")I=(V)=>V.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"");if(typeof I!=="function")I=(V)=>V;let W=(V)=>x0.join(M,I(z(localPath,V))),N=(V)=>x0.win32.basename(x0.win32.normalize(I(V)));J.fs.open(localPath,"r",function(V){if(V&&V.code==="ENOENT")B(void 0,M0.Errors.FILE_NOT_FOUND(localPath));else if(V)B(void 0,V);else J.findFilesAsync(localPath,function(R,C){if(R)return B(R);if(C=C.filter((A)=>L(W(A))),!C.length)B(void 0,!1);setImmediate(C.reverse().reduce(function(A,_){return function(v,S){if(v||S===!1)return setImmediate(A,v,!1);K.addLocalFileAsync({localPath:_,zipPath:x0.dirname(W(_)),zipName:N(_)},A)}},B))})})},addLocalFolderPromise:function(q,B){return new Promise((K,M)=>{this.addLocalFolderAsync2(Object.assign({localPath:q},B),(L,I)=>{if(L)M(L);if(I)K(this)})})},addFile:function(q,B,K,M){q=Z(q);let L=G(q),I=L!=null;if(!I)L=new Q5D(Y),L.entryName=q;L.comment=K||"";let W=typeof M==="object"&&M instanceof J.fs.Stats;if(W)L.header.time=M.mtime;var N=L.isDirectory?16:0;let V=L.isDirectory?16384:32768;if(W)V|=4095&M.mode;else if(typeof M==="number")V|=4095&M;else V|=L.isDirectory?493:420;if(N=(N|V<<16)>>>0,L.attr=N,L.setData(B),!I)Q.setEntry(L);return L},getEntries:function(q){return Q.password=q,Q?Q.entries:[]},getEntry:function(q){return G(q)},getEntryCount:function(){return Q.getEntryCount()},forEach:function(q){return Q.forEach(q)},extractEntryTo:function(q,B,K,M,L,I){M=g4(!1,M),L=g4(!1,L),K=g4(!0,K),I=bE(L,I);var W=G(q);if(!W)throw M0.Errors.NO_ENTRY();var N=F(W.entryName),V=w(B,I&&!W.isDirectory?I:K?N:x0.basename(N));if(W.isDirectory){var R=Q.getEntryChildren(W);return R.forEach(function(_){if(_.isDirectory)return;var v=_.getData();if(!v)throw M0.Errors.CANT_EXTRACT_FILE();var S=F(_.entryName),h=w(B,K?S:x0.basename(S));let g=L?_.header.fileAttr:void 0;J.writeFileTo(h,v,M,g)}),!0}var C=W.getData(Q.password);if(!C)throw M0.Errors.CANT_EXTRACT_FILE();if(J.fs.existsSync(V)&&!M)throw M0.Errors.CANT_OVERRIDE();let A=L?q.header.fileAttr:void 0;return J.writeFileTo(V,C,M,A),!0},test:function(q){if(!Q)return!1;for(var B in Q.entries)try{if(B.isDirectory)continue;var K=Q.entries[B].getData(q);if(!K)return!1}catch(M){return!1}return!0},extractAllTo:function(q,B,K,M){if(K=g4(!1,K),M=bE(K,M),B=g4(!1,B),!Q)throw M0.Errors.NO_ZIP();Q.entries.forEach(function(L){var I=w(q,F(L.entryName));if(L.isDirectory){J.makeDir(I);return}var W=L.getData(M);if(!W)throw M0.Errors.CANT_EXTRACT_FILE();let N=K?L.header.fileAttr:void 0;J.writeFileTo(I,W,B,N);try{J.fs.utimesSync(I,L.header.time,L.header.time)}catch(V){throw M0.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(q,B,K,M){if(M=w5D(B,K,M),K=g4(!1,K),B=g4(!1,B),!M)return new Promise((V,R)=>{this.extractAllToAsync(q,B,K,function(C){if(C)R(C);else V(this)})});if(!Q){M(M0.Errors.NO_ZIP());return}q=x0.resolve(q);let L=(V)=>w(q,x0.normalize(F(V.entryName))),I=(V,R)=>Error(V+': "'+R+'"'),W=[],N=[];Q.entries.forEach((V)=>{if(V.isDirectory)W.push(V);else N.push(V)});for(let V of W){let R=L(V),C=K?V.header.fileAttr:void 0;try{if(J.makeDir(R),C)J.fs.chmodSync(R,C);J.fs.utimesSync(R,V.header.time,V.header.time)}catch(A){M(I("Unable to create folder",R))}}N.reverse().reduce(function(V,R){return function(C){if(C)V(C);else{let A=x0.normalize(F(R.entryName)),_=w(q,A);R.getDataAsync(function(v,S){if(S)V(S);else if(!v)V(M0.Errors.CANT_EXTRACT_FILE());else{let h=K?R.header.fileAttr:void 0;J.writeFileToAsync(_,v,B,h,function(g){if(!g)V(I("Unable to write file",_));J.fs.utimes(_,R.header.time,R.header.time,function(l){if(l)V(I("Unable to set times",_));else V()})})}})}}},M)()},writeZip:function(q,B){if(arguments.length===1){if(typeof q==="function")B=q,q=""}if(!q&&Y.filename)q=Y.filename;if(!q)return;var K=Q.compressToBuffer();if(K){var M=J.writeFileTo(q,K,!0);if(typeof B==="function")B(!M?Error("failed"):null,"")}},writeZipPromise:function(q,B){let{overwrite:K,perm:M}=Object.assign({overwrite:!0},B);return new Promise((L,I)=>{if(!q&&Y.filename)q=Y.filename;if(!q)I("ADM-ZIP: ZIP File Name Missing");this.toBufferPromise().then((W)=>{let N=(V)=>V?L(V):I("ADM-ZIP: Wasn't able to write zip file");J.writeFileToAsync(q,W,K,M,N)},I)})},toBufferPromise:function(){return new Promise((q,B)=>{Q.toAsyncBuffer(q,B)})},toBuffer:function(q,B,K,M){if(typeof q==="function")return Q.toAsyncBuffer(q,B,K,M),null;return Q.compressToBuffer()}}}});var cE=T((AfD,dE)=>{var mE={};dE.exports=mE;var hE={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],brightRed:[91,39],brightGreen:[92,39],brightYellow:[93,39],brightBlue:[94,39],brightMagenta:[95,39],brightCyan:[96,39],brightWhite:[97,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgGray:[100,49],bgGrey:[100,49],bgBrightRed:[101,49],bgBrightGreen:[102,49],bgBrightYellow:[103,49],bgBrightBlue:[104,49],bgBrightMagenta:[105,49],bgBrightCyan:[106,49],bgBrightWhite:[107,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(hE).forEach(function(D){var $=hE[D],X=mE[D]=[];X.open="\x1B["+$[0]+"m",X.close="\x1B["+$[1]+"m"})});var nE=T((RfD,lE)=>{lE.exports=function(D,$){$=$||process.argv;var X=$.indexOf("--"),Y=/^-{1,2}/.test(D)?"":"--",J=$.indexOf(Y+D);return J!==-1&&(X===-1?!0:J<X)}});var pE=T((jfD,iE)=>{var G5D=p("os"),H$=nE(),U1=process.env,O9=void 0;if(H$("no-color")||H$("no-colors")||H$("color=false"))O9=!1;else if(H$("color")||H$("colors")||H$("color=true")||H$("color=always"))O9=!0;if("FORCE_COLOR"in U1)O9=U1.FORCE_COLOR.length===0||parseInt(U1.FORCE_COLOR,10)!==0;function O5D(D){if(D===0)return!1;return{level:D,hasBasic:!0,has256:D>=2,has16m:D>=3}}function U5D(D){if(O9===!1)return 0;if(H$("color=16m")||H$("color=full")||H$("color=truecolor"))return 3;if(H$("color=256"))return 2;if(D&&!D.isTTY&&O9!==!0)return 0;var $=O9?1:0;if(process.platform==="win32"){var X=G5D.release().split(".");if(Number(process.versions.node.split(".")[0])>=8&&Number(X[0])>=10&&Number(X[2])>=10586)return Number(X[2])>=14931?3:2;return 1}if("CI"in U1){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(function(J){return J in U1})||U1.CI_NAME==="codeship")return 1;return $}if("TEAMCITY_VERSION"in U1)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(U1.TEAMCITY_VERSION)?1:0;if("TERM_PROGRAM"in U1){var Y=parseInt((U1.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(U1.TERM_PROGRAM){case"iTerm.app":return Y>=3?3:2;case"Hyper":return 3;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(U1.TERM))return 2;if(/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(U1.TERM))return 1;if("COLORTERM"in U1)return 1;if(U1.TERM==="dumb")return $;return $}function WO(D){var $=U5D(D);return O5D($)}iE.exports={supportsColor:WO,stdout:WO(process.stdout),stderr:WO(process.stderr)}});var oE=T((EfD,rE)=>{rE.exports=function($,X){var Y="";$=$||"Run the trap, drop the bass",$=$.split("");var J={a:["@","Ą","Ⱥ","Ʌ","Δ","Λ","Д"],b:["ß","Ɓ","Ƀ","ɮ","β","฿"],c:["©","Ȼ","Ͼ"],d:["Ð","Ɗ","Ԁ","ԁ","Ԃ","ԃ"],e:["Ë","ĕ","Ǝ","ɘ","Σ","ξ","Ҽ","੬"],f:["Ӻ"],g:["ɢ"],h:["Ħ","ƕ","Ң","Һ","Ӈ","Ԋ"],i:["༏"],j:["Ĵ"],k:["ĸ","Ҡ","Ӄ","Ԟ"],l:["Ĺ"],m:["ʍ","Ӎ","ӎ","Ԡ","ԡ","൩"],n:["Ñ","ŋ","Ɲ","Ͷ","Π","Ҋ"],o:["Ø","õ","ø","Ǿ","ʘ","Ѻ","ם","۝","๏"],p:["Ƿ","Ҏ"],q:["্"],r:["®","Ʀ","Ȑ","Ɍ","ʀ","Я"],s:["§","Ϟ","ϟ","Ϩ"],t:["Ł","Ŧ","ͳ"],u:["Ʊ","Ս"],v:["ט"],w:["Ш","Ѡ","Ѽ","൰"],x:["Ҳ","Ӿ","Ӽ","ӽ"],y:["¥","Ұ","Ӌ"],z:["Ƶ","ɀ"]};return $.forEach(function(Q){Q=Q.toLowerCase();var F=J[Q]||[" "],w=Math.floor(Math.random()*F.length);if(typeof J[Q]<"u")Y+=J[Q][w];else Y+=Q}),Y}});var tE=T((TfD,aE)=>{aE.exports=function($,X){$=$||" he is here ";var Y={up:["̍","̎","̄","̅","̿","̑","̆","̐","͒","͗","͑","̇","̈","̊","͂","̓","̈","͊","͋","͌","̃","̂","̌","͐","̀","́","̋","̏","̒","̓","̔","̽","̉","ͣ","ͤ","ͥ","ͦ","ͧ","ͨ","ͩ","ͪ","ͫ","ͬ","ͭ","ͮ","ͯ","̾","͛","͆","̚"],down:["̖","̗","̘","̙","̜","̝","̞","̟","̠","̤","̥","̦","̩","̪","̫","̬","̭","̮","̯","̰","̱","̲","̳","̹","̺","̻","̼","ͅ","͇","͈","͉","͍","͎","͓","͔","͕","͖","͙","͚","̣"],mid:["̕","̛","̀","́","͘","̡","̢","̧","̨","̴","̵","̶","͜","͝","͞","͟","͠","͢","̸","̷","͡"," ҉"]},J=[].concat(Y.up,Y.down,Y.mid);function Q(Z){var G=Math.floor(Math.random()*Z);return G}function F(Z){var G=!1;return J.filter(function(O){G=O===Z}),G}function w(Z,G){var O="",U,z;G=G||{},G.up=typeof G.up<"u"?G.up:!0,G.mid=typeof G.mid<"u"?G.mid:!0,G.down=typeof G.down<"u"?G.down:!0,G.size=typeof G.size<"u"?G.size:"maxi",Z=Z.split("");for(z in Z){if(F(z))continue;switch(O=O+Z[z],U={up:0,down:0,mid:0},G.size){case"mini":U.up=Q(8),U.mid=Q(2),U.down=Q(8);break;case"maxi":U.up=Q(16)+3,U.mid=Q(4)+1,U.down=Q(64)+3;break;default:U.up=Q(8)+1,U.mid=Q(6)/2,U.down=Q(8)+1;break}var q=["up","mid","down"];for(var B in q){var K=q[B];for(var M=0;M<=U[K];M++)if(G[K])O=O+Y[K][Q(Y[K].length)]}}return O}return w($,X)}});var eE=T((CfD,sE)=>{sE.exports=function(D){return function($,X,Y){if($===" ")return $;switch(X%3){case 0:return D.red($);case 1:return D.white($);case 2:return D.blue($)}}}});var $T=T((PfD,DT)=>{DT.exports=function(D){return function($,X,Y){return X%2===0?$:D.inverse($)}}});var JT=T((xfD,XT)=>{XT.exports=function(D){var $=["red","yellow","green","blue","magenta"];return function(X,Y,J){if(X===" ")return X;else return D[$[Y++%$.length]](X)}}});var QT=T((SfD,YT)=>{YT.exports=function(D){var $=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta","brightYellow","brightRed","brightGreen","brightBlue","brightWhite","brightCyan","brightMagenta"];return function(X,Y,J){return X===" "?X:D[$[Math.round(Math.random()*($.length-2))]](X)}}});var OT=T((vfD,GT)=>{var _D={};GT.exports=_D;_D.themes={};var q5D=p("util"),h4=_D.styles=cE(),FT=Object.defineProperties,z5D=new RegExp(/[\r\n]+/g);_D.supportsColor=pE().supportsColor;if(typeof _D.enabled>"u")_D.enabled=_D.supportsColor()!==!1;_D.enable=function(){_D.enabled=!0};_D.disable=function(){_D.enabled=!1};_D.stripColors=_D.strip=function(D){return(""+D).replace(/\x1B\[\d+m/g,"")};var ufD=_D.stylize=function($,X){if(!_D.enabled)return $+"";var Y=h4[X];if(!Y&&X in _D)return _D[X]($);return Y.open+$+Y.close},B5D=/[|\\{}()[\]^$+*?.]/g,K5D=function(D){if(typeof D!=="string")throw TypeError("Expected a string");return D.replace(B5D,"\\$&")};function wT(D){var $=function X(){return H5D.apply(X,arguments)};return $._styles=D,$.__proto__=W5D,$}var ZT=function(){var D={};return h4.grey=h4.gray,Object.keys(h4).forEach(function($){h4[$].closeRe=new RegExp(K5D(h4[$].close),"g"),D[$]={get:function(){return wT(this._styles.concat($))}}}),D}(),W5D=FT(function(){},ZT);function H5D(){var D=Array.prototype.slice.call(arguments),$=D.map(function(F){if(F!=null&&F.constructor===String)return F;else return q5D.inspect(F)}).join(" ");if(!_D.enabled||!$)return $;var X=$.indexOf(`
114
114
  `)!=-1,Y=this._styles,J=Y.length;while(J--){var Q=h4[Y[J]];if($=Q.open+$.replace(Q.closeRe,Q.open)+Q.close,X)$=$.replace(z5D,function(F){return Q.close+F+Q.open})}return $}_D.setTheme=function(D){if(typeof D==="string"){console.log("colors.setTheme now only accepts an object, not a string. If you are trying to set a theme from a file, it is now your (the caller's) responsibility to require the file. The old syntax looked like colors.setTheme(__dirname + '/../themes/generic-logging.js'); The new syntax looks like colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));");return}for(var $ in D)(function(X){_D[X]=function(Y){if(typeof D[X]==="object"){var J=Y;for(var Q in D[X])J=_D[D[X][Q]](J);return J}return _D[D[X]](Y)}})($)};function V5D(){var D={};return Object.keys(ZT).forEach(function($){D[$]={get:function(){return wT([$])}}}),D}var N5D=function($,X){var Y=X.split("");return Y=Y.map($),Y.join("")};_D.trap=oE();_D.zalgo=tE();_D.maps={};_D.maps.america=eE()(_D);_D.maps.zebra=$T()(_D);_D.maps.rainbow=JT()(_D);_D.maps.random=QT()(_D);for(HO in _D.maps)(function(D){_D[D]=function($){return N5D(_D.maps[D],$)}})(HO);var HO;FT(_D,V5D())});var qT=T((_fD,UT)=>{var M5D=OT();UT.exports=M5D});var zT=T((L5D)=>{L5D.indent=function($){return Array($+1).join(" ")};L5D.getMaxIndexLength=function(D){var $=0;return Object.getOwnPropertyNames(D).forEach(function(X){if(D[X]===void 0)return;$=Math.max($,X.length)}),$}});var BT=T((ffD,R5D)=>{R5D.exports={author:"Rafael de Oleza <rafeca@gmail.com> (https://github.com/rafeca)",name:"prettyjson",description:"Package for formatting JSON data in a coloured YAML-style, perfect for CLI output",version:"1.2.5",homepage:"http://rafeca.com/prettyjson",keywords:["json","cli","formatting","colors"],repository:{type:"git",url:"https://github.com/rafeca/prettyjson.git"},bugs:{url:"https://github.com/rafeca/prettyjson/issues"},main:"./lib/prettyjson",files:["bin/prettyjson","lib/*.js"],license:"MIT",scripts:{test:"npm run jshint && mocha --reporter spec",testwin:"node ./node_modules/mocha/bin/mocha --reporter spec",jshint:"jshint lib/*.js test/*.js",coverage:"istanbul cover _mocha --report lcovonly -- -R spec",coveralls:"npm run coverage && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage",changelog:"git log $(git describe --tags --abbrev=0)..HEAD --pretty='* %s' --first-parent"},bin:{prettyjson:"./bin/prettyjson"},dependencies:{colors:"1.4.0",minimist:"^1.2.0"},devDependencies:{coveralls:"^2.11.15",istanbul:"^0.4.5",jshint:"^2.9.4",mocha:"^3.1.2","mocha-lcov-reporter":"^1.2.0",should:"^11.1.1"}}});var WT=T((C5D)=>{var C$=qT(),m6=zT(),j5D=/[^\w\s\n\r\v\t\.,]/i;C5D.version=BT().version;var VO=function(D,$){return D!==void 0||$.renderUndefined},EJ=function(D,$,X){if(typeof D==="boolean"||typeof D==="number"||typeof D==="function"||D===null||D===void 0||D instanceof Date)return!0;if(typeof D==="string"&&D.indexOf(`
115
115
  `)===-1)return!0;if(X.inlineArrays&&!$){if(Array.isArray(D)&&EJ(D[0],!0,X))return!0}return!1},E5D=function(D,$){if($.noColor)return D;if(typeof D==="string")return $.stringColor?C$[$.stringColor](D):D;var X=D+"";if(D===!0)return C$.green(X);if(D===!1)return C$.red(X);if(D===null||D===void 0)return C$.grey(X);if(typeof D==="number")if(D>=0)return C$[$.positiveNumberColor](X);else return C$[$.negativeNumberColor](X);if(typeof D==="function")return"function() {}";if(Array.isArray(D))return D.join(", ");return X},NO=function(D,$){if(D.multilineStringColor===null||D.noColor)return $;else return C$[D.multilineStringColor]($)},T5D=function(D,$,X){var Y=D.split(`
116
116
  `);return Y=Y.map(function(J){return m6.indent($)+NO(X,J)}),Y.join(`
117
117
  `)},U9=function(D,$,X){if(typeof D==="string"&&D.match(j5D)&&$.escape)D=JSON.stringify(D);if(!VO(D,$))return[];if(EJ(D,!1,$))return[m6.indent(X)+E5D(D,$)];if(typeof D==="string")return[m6.indent(X)+NO($,'"""'),T5D(D,X+$.defaultIndentation,$),m6.indent(X)+NO($,'"""')];if(Array.isArray(D)){if(D.length===0)return[m6.indent(X)+$.emptyArrayMsg];var Y=[];return D.forEach(function(w){if(!VO(w,$))return;var Z="- ";if(!$.noColor)Z=C$[$.dashColor](Z);if(Z=m6.indent(X)+Z,EJ(w,!1,$))Z+=U9(w,$,0)[0],Y.push(Z);else Y.push(Z),Y.push.apply(Y,U9(w,$,X+$.defaultIndentation))}),Y}if(D instanceof Error)return U9({message:D.message,stack:D.stack.split(`
118
118
  `)},$,X);var J=$.noAlign?0:m6.getMaxIndexLength(D),Q,F=[];return Object.getOwnPropertyNames(D).forEach(function(w){if(!VO(D[w],$))return;if(Q=w+": ",!$.noColor)Q=C$[$.keysColor](Q);if(Q=m6.indent(X)+Q,EJ(D[w],!1,$)){var Z=$.noAlign?0:J-w.length;Q+=U9(D[w],$,Z)[0],F.push(Q)}else F.push(Q),F.push.apply(F,U9(D[w],$,X+$.defaultIndentation))}),F};C5D.render=function($,X,Y){return Y=Y||0,X=X||{},X.emptyArrayMsg=X.emptyArrayMsg||"(empty array)",X.keysColor=X.keysColor||"green",X.dashColor=X.dashColor||"green",X.numberColor=X.numberColor||"blue",X.positiveNumberColor=X.positiveNumberColor||X.numberColor,X.negativeNumberColor=X.negativeNumberColor||X.numberColor,X.defaultIndentation=X.defaultIndentation||2,X.noColor=!!X.noColor,X.noAlign=!!X.noAlign,X.escape=!!X.escape,X.renderUndefined=!!X.renderUndefined,X.stringColor=X.stringColor||null,X.multilineStringColor=X.multilineStringColor||null,U9($,X,Y).join(`
119
119
  `)};C5D.renderString=function($,X,Y){var J="",Q;if(typeof $!=="string"||$==="")return"";if($[0]!=="{"&&$[0]!=="["){var F;if($.indexOf("{")===-1)F=$.indexOf("[");else if($.indexOf("[")===-1)F=$.indexOf("{");else if($.indexOf("{")<$.indexOf("["))F=$.indexOf("{");else F=$.indexOf("[");J+=$.substr(0,F)+`
120
- `,$=$.substr(F)}try{Q=JSON.parse($)}catch(w){return C$.red("Error:")+" Not valid JSON!"}return J+=C5D.render(Q,X,Y),J}});var IO=T((VT)=>{Object.defineProperty(VT,"__esModule",{value:!0});VT.default=void 0;function q9(D){return q9=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},q9(D)}function HT(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,u5D(Y.key),Y)}}function S5D(D,$,X){if($)HT(D.prototype,$);if(X)HT(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function u5D(D){var $=v5D(D,"string");return q9($)=="symbol"?$:$+""}function v5D(D,$){if(q9(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(q9(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}function _5D(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function k5D(D,$,X){return $=d7($),f5D(D,LO()?Reflect.construct($,X||[],d7(D).constructor):$.apply(D,X))}function f5D(D,$){if($&&(q9($)==="object"||typeof $==="function"))return $;else if($!==void 0)throw TypeError("Derived constructors may only return object or undefined");return y5D(D)}function y5D(D){if(D===void 0)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return D}function b5D(D,$){if(typeof $!=="function"&&$!==null)throw TypeError("Super expression must either be null or a function");if(D.prototype=Object.create($&&$.prototype,{constructor:{value:D,writable:!0,configurable:!0}}),Object.defineProperty(D,"prototype",{writable:!1}),$)m7(D,$)}function MO(D){var $=typeof Map==="function"?new Map:void 0;return MO=function(Y){if(Y===null||!h5D(Y))return Y;if(typeof Y!=="function")throw TypeError("Super expression must either be null or a function");if(typeof $<"u"){if($.has(Y))return $.get(Y);$.set(Y,J)}function J(){return g5D(Y,arguments,d7(this).constructor)}return J.prototype=Object.create(Y.prototype,{constructor:{value:J,enumerable:!1,writable:!0,configurable:!0}}),m7(J,Y)},MO(D)}function g5D(D,$,X){if(LO())return Reflect.construct.apply(null,arguments);var Y=[null];Y.push.apply(Y,$);var J=new(D.bind.apply(D,Y));return X&&m7(J,X.prototype),J}function LO(){try{var D=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch($){}return(LO=function(){return!!D})()}function h5D(D){try{return Function.toString.call(D).indexOf("[native code]")!==-1}catch($){return typeof D==="function"}}function m7(D,$){return m7=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(Y,J){return Y.__proto__=J,Y},m7(D,$)}function d7(D){return d7=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(X){return X.__proto__||Object.getPrototypeOf(X)},d7(D)}var m5D=function(D){function $(X){var Y,J=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,Q=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,F=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;if(_5D(this,$),Y=k5D(this,$,[X]),Y.originalRequest=Q,Y.originalResponse=F,Y.causingError=J,J!=null)X+=", caused by ".concat(J.toString());if(Q!=null){var w=Q.getHeader("X-Request-ID")||"n/a",Z=Q.getMethod(),G=Q.getURL(),O=F?F.getStatus():"n/a",U=F?F.getBody()||"":"n/a";X+=", originated from request (method: ".concat(Z,", url: ").concat(G,", response code: ").concat(O,", response text: ").concat(U,", request id: ").concat(w,")")}return Y.message=X,Y}return b5D($,D),S5D($)}(MO(Error)),bfD=VT.default=m5D});var AO=T((LT)=>{Object.defineProperty(LT,"__esModule",{value:!0});LT.enableDebugLog=d5D;LT.log=c5D;var MT=!1;function d5D(){MT=!0}function c5D(D){if(!MT)return;console.log(D)}});var jT=T((AT)=>{Object.defineProperty(AT,"__esModule",{value:!0});AT.default=void 0;function c7(D){return c7=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},c7(D)}function i5D(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function IT(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,r5D(Y.key),Y)}}function p5D(D,$,X){if($)IT(D.prototype,$);if(X)IT(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function r5D(D){var $=o5D(D,"string");return c7($)=="symbol"?$:$+""}function o5D(D,$){if(c7(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(c7(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var mfD=AT.default=function(){function D(){i5D(this,D)}return p5D(D,[{key:"listAllUploads",value:function(){return Promise.resolve([])}},{key:"findUploadsByFingerprint",value:function(X){return Promise.resolve([])}},{key:"removeUpload",value:function(X){return Promise.resolve()}},{key:"addUpload",value:function(X,Y){return Promise.resolve(null)}}])}()});var ET=T((RO,jO)=>{(function(D,$){typeof RO==="object"&&typeof jO<"u"?jO.exports=$():typeof define==="function"&&define.amd?define($):function(){var X=D.Base64,Y=$();if(Y.noConflict=function(){return D.Base64=X,Y},D.Meteor)Base64=Y;D.Base64=Y}()})(typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:RO,function(){var D="3.7.8",$=D,X=typeof Buffer==="function",Y=typeof TextDecoder==="function"?new TextDecoder:void 0,J=typeof TextEncoder==="function"?new TextEncoder:void 0,Q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",F=Array.prototype.slice.call(Q),w=function(c){var n={};return c.forEach(function(YD,C){return n[YD]=C}),n}(F),Z=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,G=String.fromCharCode.bind(String),O=typeof Uint8Array.from==="function"?Uint8Array.from.bind(Uint8Array):function(c){return new Uint8Array(Array.prototype.slice.call(c,0))},U=function(c){return c.replace(/=/g,"").replace(/[+\/]/g,function(n){return n=="+"?"-":"_"})},z=function(c){return c.replace(/[^A-Za-z0-9\+\/]/g,"")},q=function(c){var n,YD,C,E,r="",k=c.length%3;for(var zD=0;zD<c.length;){if((YD=c.charCodeAt(zD++))>255||(C=c.charCodeAt(zD++))>255||(E=c.charCodeAt(zD++))>255)throw TypeError("invalid character found");n=YD<<16|C<<8|E,r+=F[n>>18&63]+F[n>>12&63]+F[n>>6&63]+F[n&63]}return k?r.slice(0,k-3)+"===".substring(k):r},B=typeof btoa==="function"?function(c){return btoa(c)}:X?function(c){return Buffer.from(c,"binary").toString("base64")}:q,K=X?function(c){return Buffer.from(c).toString("base64")}:function(c){var n=4096,YD=[];for(var C=0,E=c.length;C<E;C+=n)YD.push(G.apply(null,c.subarray(C,C+n)));return B(YD.join(""))},M=function(c,n){if(n===void 0)n=!1;return n?U(K(c)):K(c)},L=function(c){if(c.length<2){var n=c.charCodeAt(0);return n<128?c:n<2048?G(192|n>>>6)+G(128|n&63):G(224|n>>>12&15)+G(128|n>>>6&63)+G(128|n&63)}else{var n=65536+(c.charCodeAt(0)-55296)*1024+(c.charCodeAt(1)-56320);return G(240|n>>>18&7)+G(128|n>>>12&63)+G(128|n>>>6&63)+G(128|n&63)}},I=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,W=function(c){return c.replace(I,L)},N=X?function(c){return Buffer.from(c,"utf8").toString("base64")}:J?function(c){return K(J.encode(c))}:function(c){return B(W(c))},V=function(c,n){if(n===void 0)n=!1;return n?U(N(c)):N(c)},R=function(c){return V(c,!0)},P=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,A=function(c){switch(c.length){case 4:var n=(7&c.charCodeAt(0))<<18|(63&c.charCodeAt(1))<<12|(63&c.charCodeAt(2))<<6|63&c.charCodeAt(3),YD=n-65536;return G((YD>>>10)+55296)+G((YD&1023)+56320);case 3:return G((15&c.charCodeAt(0))<<12|(63&c.charCodeAt(1))<<6|63&c.charCodeAt(2));default:return G((31&c.charCodeAt(0))<<6|63&c.charCodeAt(1))}},_=function(c){return c.replace(P,A)},v=function(c){if(c=c.replace(/\s+/g,""),!Z.test(c))throw TypeError("malformed base64.");c+="==".slice(2-(c.length&3));var n,YD,C,E=[];for(var r=0;r<c.length;)if(n=w[c.charAt(r++)]<<18|w[c.charAt(r++)]<<12|(YD=w[c.charAt(r++)])<<6|(C=w[c.charAt(r++)]),YD===64)E.push(G(n>>16&255));else if(C===64)E.push(G(n>>16&255,n>>8&255));else E.push(G(n>>16&255,n>>8&255,n&255));return E.join("")},S=typeof atob==="function"?function(c){return atob(z(c))}:X?function(c){return Buffer.from(c,"base64").toString("binary")}:v,h=X?function(c){return O(Buffer.from(c,"base64"))}:function(c){return O(S(c).split("").map(function(n){return n.charCodeAt(0)}))},g=function(c){return h(f(c))},l=X?function(c){return Buffer.from(c,"base64").toString("utf8")}:Y?function(c){return Y.decode(h(c))}:function(c){return _(S(c))},f=function(c){return z(c.replace(/[-_]/g,function(n){return n=="-"?"+":"/"}))},j=function(c){return l(f(c))},x=function(c){if(typeof c!=="string")return!1;var n=c.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(n)||!/[^\s0-9a-zA-Z\-_]/.test(n)},u=function(c){return{value:c,enumerable:!1,writable:!0,configurable:!0}},y=function(){var c=function(n,YD){return Object.defineProperty(String.prototype,n,u(YD))};c("fromBase64",function(){return j(this)}),c("toBase64",function(n){return V(this,n)}),c("toBase64URI",function(){return V(this,!0)}),c("toBase64URL",function(){return V(this,!0)}),c("toUint8Array",function(){return g(this)})},d=function(){var c=function(n,YD){return Object.defineProperty(Uint8Array.prototype,n,u(YD))};c("toBase64",function(n){return M(this,n)}),c("toBase64URI",function(){return M(this,!0)}),c("toBase64URL",function(){return M(this,!0)})},b=function(){y(),d()},a={version:D,VERSION:$,atob:S,atobPolyfill:v,btoa:B,btoaPolyfill:q,fromBase64:j,toBase64:V,encode:V,encodeURI:R,encodeURL:R,utob:W,btou:_,decode:j,isValid:x,fromUint8Array:M,toUint8Array:g,extendString:y,extendUint8Array:d,extendBuiltins:b};return a.Base64={},Object.keys(a).forEach(function(c){return a.Base64[c]=a[c]}),a})});var CT=T((cfD,TT)=>{TT.exports=function($,X){if(X=X.split(":")[0],$=+$,!$)return!1;switch(X){case"http":case"ws":return $!==80;case"https":case"wss":return $!==443;case"ftp":return $!==21;case"gopher":return $!==70;case"file":return!1}return $!==0}});var ST=T((D7D)=>{var a5D=Object.prototype.hasOwnProperty,t5D;function PT(D){try{return decodeURIComponent(D.replace(/\+/g," "))}catch($){return null}}function xT(D){try{return encodeURIComponent(D)}catch($){return null}}function s5D(D){var $=/([^=?#&]+)=?([^&]*)/g,X={},Y;while(Y=$.exec(D)){var J=PT(Y[1]),Q=PT(Y[2]);if(J===null||Q===null||J in X)continue;X[J]=Q}return X}function e5D(D,$){$=$||"";var X=[],Y,J;if(typeof $!=="string")$="?";for(J in D)if(a5D.call(D,J)){if(Y=D[J],!Y&&(Y===null||Y===t5D||isNaN(Y)))Y="";if(J=xT(J),Y=xT(Y),J===null||Y===null)continue;X.push(J+"="+Y)}return X.length?$+X.join("&"):""}D7D.stringify=e5D;D7D.parse=s5D});var gT=T((nfD,bT)=>{var vT=CT(),TJ=ST(),J7D=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,_T=/[\n\r\t]/g,Y7D=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,kT=/:\d+$/,Q7D=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,F7D=/^[a-zA-Z]:/;function TO(D){return(D?D:"").toString().replace(J7D,"")}var EO=[["#","hash"],["?","query"],function($,X){return P$(X.protocol)?$.replace(/\\/g,"/"):$},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],uT={hash:1,query:1};function fT(D){var $;if(typeof window<"u")$=window;else if(typeof global<"u")$=global;else if(typeof self<"u")$=self;else $={};var X=$.location||{};D=D||X;var Y={},J=typeof D,Q;if(D.protocol==="blob:")Y=new x$(unescape(D.pathname),{});else if(J==="string"){Y=new x$(D,{});for(Q in uT)delete Y[Q]}else if(J==="object"){for(Q in D){if(Q in uT)continue;Y[Q]=D[Q]}if(Y.slashes===void 0)Y.slashes=Y7D.test(D.href)}return Y}function P$(D){return D==="file:"||D==="ftp:"||D==="http:"||D==="https:"||D==="ws:"||D==="wss:"}function yT(D,$){D=TO(D),D=D.replace(_T,""),$=$||{};var X=Q7D.exec(D),Y=X[1]?X[1].toLowerCase():"",J=!!X[2],Q=!!X[3],F=0,w;if(J)if(Q)w=X[2]+X[3]+X[4],F=X[2].length+X[3].length;else w=X[2]+X[4],F=X[2].length;else if(Q)w=X[3]+X[4],F=X[3].length;else w=X[4];if(Y==="file:"){if(F>=2)w=w.slice(2)}else if(P$(Y))w=X[4];else if(Y){if(J)w=w.slice(2)}else if(F>=2&&P$($.protocol))w=X[4];return{protocol:Y,slashes:J||P$(Y),slashesCount:F,rest:w}}function w7D(D,$){if(D==="")return $;var X=($||"/").split("/").slice(0,-1).concat(D.split("/")),Y=X.length,J=X[Y-1],Q=!1,F=0;while(Y--)if(X[Y]===".")X.splice(Y,1);else if(X[Y]==="..")X.splice(Y,1),F++;else if(F){if(Y===0)Q=!0;X.splice(Y,1),F--}if(Q)X.unshift("");if(J==="."||J==="..")X.push("");return X.join("/")}function x$(D,$,X){if(D=TO(D),D=D.replace(_T,""),!(this instanceof x$))return new x$(D,$,X);var Y,J,Q,F,w,Z,G=EO.slice(),O=typeof $,U=this,z=0;if(O!=="object"&&O!=="string")X=$,$=null;if(X&&typeof X!=="function")X=TJ.parse;if($=fT($),J=yT(D||"",$),Y=!J.protocol&&!J.slashes,U.slashes=J.slashes||Y&&$.slashes,U.protocol=J.protocol||$.protocol||"",D=J.rest,J.protocol==="file:"&&(J.slashesCount!==2||F7D.test(D))||!J.slashes&&(J.protocol||J.slashesCount<2||!P$(U.protocol)))G[3]=[/(.*)/,"pathname"];for(;z<G.length;z++){if(F=G[z],typeof F==="function"){D=F(D,U);continue}if(Q=F[0],Z=F[1],Q!==Q)U[Z]=D;else if(typeof Q==="string"){if(w=Q==="@"?D.lastIndexOf(Q):D.indexOf(Q),~w)if(typeof F[2]==="number")U[Z]=D.slice(0,w),D=D.slice(w+F[2]);else U[Z]=D.slice(w),D=D.slice(0,w)}else if(w=Q.exec(D))U[Z]=w[1],D=D.slice(0,w.index);if(U[Z]=U[Z]||(Y&&F[3]?$[Z]||"":""),F[4])U[Z]=U[Z].toLowerCase()}if(X)U.query=X(U.query);if(Y&&$.slashes&&U.pathname.charAt(0)!=="/"&&(U.pathname!==""||$.pathname!==""))U.pathname=w7D(U.pathname,$.pathname);if(U.pathname.charAt(0)!=="/"&&P$(U.protocol))U.pathname="/"+U.pathname;if(!vT(U.port,U.protocol))U.host=U.hostname,U.port="";if(U.username=U.password="",U.auth){if(w=U.auth.indexOf(":"),~w)U.username=U.auth.slice(0,w),U.username=encodeURIComponent(decodeURIComponent(U.username)),U.password=U.auth.slice(w+1),U.password=encodeURIComponent(decodeURIComponent(U.password));else U.username=encodeURIComponent(decodeURIComponent(U.auth));U.auth=U.password?U.username+":"+U.password:U.username}U.origin=U.protocol!=="file:"&&P$(U.protocol)&&U.host?U.protocol+"//"+U.host:"null",U.href=U.toString()}function Z7D(D,$,X){var Y=this;switch(D){case"query":if(typeof $==="string"&&$.length)$=(X||TJ.parse)($);Y[D]=$;break;case"port":if(Y[D]=$,!vT($,Y.protocol))Y.host=Y.hostname,Y[D]="";else if($)Y.host=Y.hostname+":"+$;break;case"hostname":if(Y[D]=$,Y.port)$+=":"+Y.port;Y.host=$;break;case"host":if(Y[D]=$,kT.test($))$=$.split(":"),Y.port=$.pop(),Y.hostname=$.join(":");else Y.hostname=$,Y.port="";break;case"protocol":Y.protocol=$.toLowerCase(),Y.slashes=!X;break;case"pathname":case"hash":if($){var J=D==="pathname"?"/":"#";Y[D]=$.charAt(0)!==J?J+$:$}else Y[D]=$;break;case"username":case"password":Y[D]=encodeURIComponent($);break;case"auth":var Q=$.indexOf(":");if(~Q)Y.username=$.slice(0,Q),Y.username=encodeURIComponent(decodeURIComponent(Y.username)),Y.password=$.slice(Q+1),Y.password=encodeURIComponent(decodeURIComponent(Y.password));else Y.username=encodeURIComponent(decodeURIComponent($))}for(var F=0;F<EO.length;F++){var w=EO[F];if(w[4])Y[w[1]]=Y[w[1]].toLowerCase()}return Y.auth=Y.password?Y.username+":"+Y.password:Y.username,Y.origin=Y.protocol!=="file:"&&P$(Y.protocol)&&Y.host?Y.protocol+"//"+Y.host:"null",Y.href=Y.toString(),Y}function G7D(D){if(!D||typeof D!=="function")D=TJ.stringify;var $,X=this,Y=X.host,J=X.protocol;if(J&&J.charAt(J.length-1)!==":")J+=":";var Q=J+(X.protocol&&X.slashes||P$(X.protocol)?"//":"");if(X.username){if(Q+=X.username,X.password)Q+=":"+X.password;Q+="@"}else if(X.password)Q+=":"+X.password,Q+="@";else if(X.protocol!=="file:"&&P$(X.protocol)&&!Y&&X.pathname!=="/")Q+="@";if(Y[Y.length-1]===":"||kT.test(X.hostname)&&!X.port)Y+=":";if(Q+=Y+X.pathname,$=typeof X.query==="object"?D(X.query):X.query,$)Q+=$.charAt(0)!=="?"?"?"+$:$;if(X.hash)Q+=X.hash;return Q}x$.prototype={set:Z7D,toString:G7D};x$.extractProtocol=yT;x$.location=fT;x$.trimLeft=TO;x$.qs=TJ;bT.exports=x$});var mT=T((hT)=>{Object.defineProperty(hT,"__esModule",{value:!0});hT.default=O7D;function O7D(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(D){var $=Math.random()*16|0,X=D==="x"?$:$&3|8;return X.toString(16)})}});var YC=T((XC)=>{Object.defineProperty(XC,"__esModule",{value:!0});XC.default=void 0;var q7D=ET(),z7D=xO(gT()),CJ=xO(IO()),m4=AO(),B7D=xO(mT());function xO(D){return D&&D.__esModule?D:{default:D}}function CO(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */CO=function(){return $};var D,$={},X=Object.prototype,Y=X.hasOwnProperty,J=Object.defineProperty||function(j,x,u){j[x]=u.value},Q=typeof Symbol=="function"?Symbol:{},F=Q.iterator||"@@iterator",w=Q.asyncIterator||"@@asyncIterator",Z=Q.toStringTag||"@@toStringTag";function G(j,x,u){return Object.defineProperty(j,x,{value:u,enumerable:!0,configurable:!0,writable:!0}),j[x]}try{G({},"")}catch(j){G=function(u,y,d){return u[y]=d}}function O(j,x,u,y){var d=x&&x.prototype instanceof L?x:L,b=Object.create(d.prototype),a=new l(y||[]);return J(b,"_invoke",{value:v(j,u,a)}),b}function U(j,x,u){try{return{type:"normal",arg:j.call(x,u)}}catch(y){return{type:"throw",arg:y}}}$.wrap=O;var z="suspendedStart",q="suspendedYield",B="executing",K="completed",M={};function L(){}function I(){}function W(){}var N={};G(N,F,function(){return this});var V=Object.getPrototypeOf,R=V&&V(V(f([])));R&&R!==X&&Y.call(R,F)&&(N=R);var P=W.prototype=L.prototype=Object.create(N);function A(j){["next","throw","return"].forEach(function(x){G(j,x,function(u){return this._invoke(x,u)})})}function _(j,x){function u(d,b,a,c){var n=U(j[d],j,b);if(n.type!=="throw"){var YD=n.arg,C=YD.value;return C&&d4(C)=="object"&&Y.call(C,"__await")?x.resolve(C.__await).then(function(E){u("next",E,a,c)},function(E){u("throw",E,a,c)}):x.resolve(C).then(function(E){YD.value=E,a(YD)},function(E){return u("throw",E,a,c)})}c(n.arg)}var y;J(this,"_invoke",{value:function(b,a){function c(){return new x(function(n,YD){u(b,a,n,YD)})}return y=y?y.then(c,c):c()}})}function v(j,x,u){var y=z;return function(d,b){if(y===B)throw Error("Generator is already running");if(y===K){if(d==="throw")throw b;return{value:D,done:!0}}for(u.method=d,u.arg=b;;){var a=u.delegate;if(a){var c=S(a,u);if(c){if(c===M)continue;return c}}if(u.method==="next")u.sent=u._sent=u.arg;else if(u.method==="throw"){if(y===z)throw y=K,u.arg;u.dispatchException(u.arg)}else u.method==="return"&&u.abrupt("return",u.arg);y=B;var n=U(j,x,u);if(n.type==="normal"){if(y=u.done?K:q,n.arg===M)continue;return{value:n.arg,done:u.done}}n.type==="throw"&&(y=K,u.method="throw",u.arg=n.arg)}}}function S(j,x){var u=x.method,y=j.iterator[u];if(y===D)return x.delegate=null,u==="throw"&&j.iterator.return&&(x.method="return",x.arg=D,S(j,x),x.method==="throw")||u!=="return"&&(x.method="throw",x.arg=TypeError("The iterator does not provide a '"+u+"' method")),M;var d=U(y,j.iterator,x.arg);if(d.type==="throw")return x.method="throw",x.arg=d.arg,x.delegate=null,M;var b=d.arg;return b?b.done?(x[j.resultName]=b.value,x.next=j.nextLoc,x.method!=="return"&&(x.method="next",x.arg=D),x.delegate=null,M):b:(x.method="throw",x.arg=TypeError("iterator result is not an object"),x.delegate=null,M)}function h(j){var x={tryLoc:j[0]};1 in j&&(x.catchLoc=j[1]),2 in j&&(x.finallyLoc=j[2],x.afterLoc=j[3]),this.tryEntries.push(x)}function g(j){var x=j.completion||{};x.type="normal",delete x.arg,j.completion=x}function l(j){this.tryEntries=[{tryLoc:"root"}],j.forEach(h,this),this.reset(!0)}function f(j){if(j||j===""){var x=j[F];if(x)return x.call(j);if(typeof j.next=="function")return j;if(!isNaN(j.length)){var u=-1,y=function d(){for(;++u<j.length;)if(Y.call(j,u))return d.value=j[u],d.done=!1,d;return d.value=D,d.done=!0,d};return y.next=y}}throw TypeError(d4(j)+" is not iterable")}return I.prototype=W,J(P,"constructor",{value:W,configurable:!0}),J(W,"constructor",{value:I,configurable:!0}),I.displayName=G(W,Z,"GeneratorFunction"),$.isGeneratorFunction=function(j){var x=typeof j=="function"&&j.constructor;return!!x&&(x===I||(x.displayName||x.name)==="GeneratorFunction")},$.mark=function(j){return Object.setPrototypeOf?Object.setPrototypeOf(j,W):(j.__proto__=W,G(j,Z,"GeneratorFunction")),j.prototype=Object.create(P),j},$.awrap=function(j){return{__await:j}},A(_.prototype),G(_.prototype,w,function(){return this}),$.AsyncIterator=_,$.async=function(j,x,u,y,d){d===void 0&&(d=Promise);var b=new _(O(j,x,u,y),d);return $.isGeneratorFunction(x)?b:b.next().then(function(a){return a.done?a.value:b.next()})},A(P),G(P,Z,"Generator"),G(P,F,function(){return this}),G(P,"toString",function(){return"[object Generator]"}),$.keys=function(j){var x=Object(j),u=[];for(var y in x)u.push(y);return u.reverse(),function d(){for(;u.length;){var b=u.pop();if(b in x)return d.value=b,d.done=!1,d}return d.done=!0,d}},$.values=f,l.prototype={constructor:l,reset:function(x){if(this.prev=0,this.next=0,this.sent=this._sent=D,this.done=!1,this.delegate=null,this.method="next",this.arg=D,this.tryEntries.forEach(g),!x)for(var u in this)u.charAt(0)==="t"&&Y.call(this,u)&&!isNaN(+u.slice(1))&&(this[u]=D)},stop:function(){this.done=!0;var x=this.tryEntries[0].completion;if(x.type==="throw")throw x.arg;return this.rval},dispatchException:function(x){if(this.done)throw x;var u=this;function y(YD,C){return a.type="throw",a.arg=x,u.next=YD,C&&(u.method="next",u.arg=D),!!C}for(var d=this.tryEntries.length-1;d>=0;--d){var b=this.tryEntries[d],a=b.completion;if(b.tryLoc==="root")return y("end");if(b.tryLoc<=this.prev){var c=Y.call(b,"catchLoc"),n=Y.call(b,"finallyLoc");if(c&&n){if(this.prev<b.catchLoc)return y(b.catchLoc,!0);if(this.prev<b.finallyLoc)return y(b.finallyLoc)}else if(c){if(this.prev<b.catchLoc)return y(b.catchLoc,!0)}else{if(!n)throw Error("try statement without catch or finally");if(this.prev<b.finallyLoc)return y(b.finallyLoc)}}}},abrupt:function(x,u){for(var y=this.tryEntries.length-1;y>=0;--y){var d=this.tryEntries[y];if(d.tryLoc<=this.prev&&Y.call(d,"finallyLoc")&&this.prev<d.finallyLoc){var b=d;break}}b&&(x==="break"||x==="continue")&&b.tryLoc<=u&&u<=b.finallyLoc&&(b=null);var a=b?b.completion:{};return a.type=x,a.arg=u,b?(this.method="next",this.next=b.finallyLoc,M):this.complete(a)},complete:function(x,u){if(x.type==="throw")throw x.arg;return x.type==="break"||x.type==="continue"?this.next=x.arg:x.type==="return"?(this.rval=this.arg=x.arg,this.method="return",this.next="end"):x.type==="normal"&&u&&(this.next=u),M},finish:function(x){for(var u=this.tryEntries.length-1;u>=0;--u){var y=this.tryEntries[u];if(y.finallyLoc===x)return this.complete(y.completion,y.afterLoc),g(y),M}},catch:function(x){for(var u=this.tryEntries.length-1;u>=0;--u){var y=this.tryEntries[u];if(y.tryLoc===x){var d=y.completion;if(d.type==="throw"){var b=d.arg;g(y)}return b}}throw Error("illegal catch attempt")},delegateYield:function(x,u,y){return this.delegate={iterator:f(x),resultName:u,nextLoc:y},this.method==="next"&&(this.arg=D),M}},$}function dT(D,$,X,Y,J,Q,F){try{var w=D[Q](F),Z=w.value}catch(G){X(G);return}if(w.done)$(Z);else Promise.resolve(Z).then(Y,J)}function K7D(D){return function(){var $=this,X=arguments;return new Promise(function(Y,J){var Q=D.apply($,X);function F(Z){dT(Q,Y,J,F,w,"next",Z)}function w(Z){dT(Q,Y,J,F,w,"throw",Z)}F(void 0)})}}function tT(D,$){return V7D(D)||H7D(D,$)||sT(D,$)||W7D()}function W7D(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
120
+ `,$=$.substr(F)}try{Q=JSON.parse($)}catch(w){return C$.red("Error:")+" Not valid JSON!"}return J+=C5D.render(Q,X,Y),J}});var IO=T((VT)=>{Object.defineProperty(VT,"__esModule",{value:!0});VT.default=void 0;function q9(D){return q9=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},q9(D)}function HT(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,u5D(Y.key),Y)}}function S5D(D,$,X){if($)HT(D.prototype,$);if(X)HT(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function u5D(D){var $=v5D(D,"string");return q9($)=="symbol"?$:$+""}function v5D(D,$){if(q9(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(q9(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}function _5D(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function k5D(D,$,X){return $=d7($),f5D(D,LO()?Reflect.construct($,X||[],d7(D).constructor):$.apply(D,X))}function f5D(D,$){if($&&(q9($)==="object"||typeof $==="function"))return $;else if($!==void 0)throw TypeError("Derived constructors may only return object or undefined");return y5D(D)}function y5D(D){if(D===void 0)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return D}function b5D(D,$){if(typeof $!=="function"&&$!==null)throw TypeError("Super expression must either be null or a function");if(D.prototype=Object.create($&&$.prototype,{constructor:{value:D,writable:!0,configurable:!0}}),Object.defineProperty(D,"prototype",{writable:!1}),$)m7(D,$)}function MO(D){var $=typeof Map==="function"?new Map:void 0;return MO=function(Y){if(Y===null||!h5D(Y))return Y;if(typeof Y!=="function")throw TypeError("Super expression must either be null or a function");if(typeof $<"u"){if($.has(Y))return $.get(Y);$.set(Y,J)}function J(){return g5D(Y,arguments,d7(this).constructor)}return J.prototype=Object.create(Y.prototype,{constructor:{value:J,enumerable:!1,writable:!0,configurable:!0}}),m7(J,Y)},MO(D)}function g5D(D,$,X){if(LO())return Reflect.construct.apply(null,arguments);var Y=[null];Y.push.apply(Y,$);var J=new(D.bind.apply(D,Y));return X&&m7(J,X.prototype),J}function LO(){try{var D=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch($){}return(LO=function(){return!!D})()}function h5D(D){try{return Function.toString.call(D).indexOf("[native code]")!==-1}catch($){return typeof D==="function"}}function m7(D,$){return m7=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(Y,J){return Y.__proto__=J,Y},m7(D,$)}function d7(D){return d7=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(X){return X.__proto__||Object.getPrototypeOf(X)},d7(D)}var m5D=function(D){function $(X){var Y,J=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,Q=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,F=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;if(_5D(this,$),Y=k5D(this,$,[X]),Y.originalRequest=Q,Y.originalResponse=F,Y.causingError=J,J!=null)X+=", caused by ".concat(J.toString());if(Q!=null){var w=Q.getHeader("X-Request-ID")||"n/a",Z=Q.getMethod(),G=Q.getURL(),O=F?F.getStatus():"n/a",U=F?F.getBody()||"":"n/a";X+=", originated from request (method: ".concat(Z,", url: ").concat(G,", response code: ").concat(O,", response text: ").concat(U,", request id: ").concat(w,")")}return Y.message=X,Y}return b5D($,D),S5D($)}(MO(Error)),bfD=VT.default=m5D});var AO=T((LT)=>{Object.defineProperty(LT,"__esModule",{value:!0});LT.enableDebugLog=d5D;LT.log=c5D;var MT=!1;function d5D(){MT=!0}function c5D(D){if(!MT)return;console.log(D)}});var jT=T((AT)=>{Object.defineProperty(AT,"__esModule",{value:!0});AT.default=void 0;function c7(D){return c7=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},c7(D)}function i5D(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function IT(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,r5D(Y.key),Y)}}function p5D(D,$,X){if($)IT(D.prototype,$);if(X)IT(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function r5D(D){var $=o5D(D,"string");return c7($)=="symbol"?$:$+""}function o5D(D,$){if(c7(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(c7(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var mfD=AT.default=function(){function D(){i5D(this,D)}return p5D(D,[{key:"listAllUploads",value:function(){return Promise.resolve([])}},{key:"findUploadsByFingerprint",value:function(X){return Promise.resolve([])}},{key:"removeUpload",value:function(X){return Promise.resolve()}},{key:"addUpload",value:function(X,Y){return Promise.resolve(null)}}])}()});var ET=T((RO,jO)=>{(function(D,$){typeof RO==="object"&&typeof jO<"u"?jO.exports=$():typeof define==="function"&&define.amd?define($):function(){var X=D.Base64,Y=$();if(Y.noConflict=function(){return D.Base64=X,Y},D.Meteor)Base64=Y;D.Base64=Y}()})(typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:RO,function(){var D="3.7.8",$=D,X=typeof Buffer==="function",Y=typeof TextDecoder==="function"?new TextDecoder:void 0,J=typeof TextEncoder==="function"?new TextEncoder:void 0,Q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",F=Array.prototype.slice.call(Q),w=function(c){var n={};return c.forEach(function(YD,P){return n[YD]=P}),n}(F),Z=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,G=String.fromCharCode.bind(String),O=typeof Uint8Array.from==="function"?Uint8Array.from.bind(Uint8Array):function(c){return new Uint8Array(Array.prototype.slice.call(c,0))},U=function(c){return c.replace(/=/g,"").replace(/[+\/]/g,function(n){return n=="+"?"-":"_"})},z=function(c){return c.replace(/[^A-Za-z0-9\+\/]/g,"")},q=function(c){var n,YD,P,E,r="",k=c.length%3;for(var zD=0;zD<c.length;){if((YD=c.charCodeAt(zD++))>255||(P=c.charCodeAt(zD++))>255||(E=c.charCodeAt(zD++))>255)throw TypeError("invalid character found");n=YD<<16|P<<8|E,r+=F[n>>18&63]+F[n>>12&63]+F[n>>6&63]+F[n&63]}return k?r.slice(0,k-3)+"===".substring(k):r},B=typeof btoa==="function"?function(c){return btoa(c)}:X?function(c){return Buffer.from(c,"binary").toString("base64")}:q,K=X?function(c){return Buffer.from(c).toString("base64")}:function(c){var n=4096,YD=[];for(var P=0,E=c.length;P<E;P+=n)YD.push(G.apply(null,c.subarray(P,P+n)));return B(YD.join(""))},M=function(c,n){if(n===void 0)n=!1;return n?U(K(c)):K(c)},L=function(c){if(c.length<2){var n=c.charCodeAt(0);return n<128?c:n<2048?G(192|n>>>6)+G(128|n&63):G(224|n>>>12&15)+G(128|n>>>6&63)+G(128|n&63)}else{var n=65536+(c.charCodeAt(0)-55296)*1024+(c.charCodeAt(1)-56320);return G(240|n>>>18&7)+G(128|n>>>12&63)+G(128|n>>>6&63)+G(128|n&63)}},I=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,W=function(c){return c.replace(I,L)},N=X?function(c){return Buffer.from(c,"utf8").toString("base64")}:J?function(c){return K(J.encode(c))}:function(c){return B(W(c))},V=function(c,n){if(n===void 0)n=!1;return n?U(N(c)):N(c)},R=function(c){return V(c,!0)},C=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,A=function(c){switch(c.length){case 4:var n=(7&c.charCodeAt(0))<<18|(63&c.charCodeAt(1))<<12|(63&c.charCodeAt(2))<<6|63&c.charCodeAt(3),YD=n-65536;return G((YD>>>10)+55296)+G((YD&1023)+56320);case 3:return G((15&c.charCodeAt(0))<<12|(63&c.charCodeAt(1))<<6|63&c.charCodeAt(2));default:return G((31&c.charCodeAt(0))<<6|63&c.charCodeAt(1))}},_=function(c){return c.replace(C,A)},v=function(c){if(c=c.replace(/\s+/g,""),!Z.test(c))throw TypeError("malformed base64.");c+="==".slice(2-(c.length&3));var n,YD,P,E=[];for(var r=0;r<c.length;)if(n=w[c.charAt(r++)]<<18|w[c.charAt(r++)]<<12|(YD=w[c.charAt(r++)])<<6|(P=w[c.charAt(r++)]),YD===64)E.push(G(n>>16&255));else if(P===64)E.push(G(n>>16&255,n>>8&255));else E.push(G(n>>16&255,n>>8&255,n&255));return E.join("")},S=typeof atob==="function"?function(c){return atob(z(c))}:X?function(c){return Buffer.from(c,"base64").toString("binary")}:v,h=X?function(c){return O(Buffer.from(c,"base64"))}:function(c){return O(S(c).split("").map(function(n){return n.charCodeAt(0)}))},g=function(c){return h(f(c))},l=X?function(c){return Buffer.from(c,"base64").toString("utf8")}:Y?function(c){return Y.decode(h(c))}:function(c){return _(S(c))},f=function(c){return z(c.replace(/[-_]/g,function(n){return n=="-"?"+":"/"}))},j=function(c){return l(f(c))},x=function(c){if(typeof c!=="string")return!1;var n=c.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(n)||!/[^\s0-9a-zA-Z\-_]/.test(n)},u=function(c){return{value:c,enumerable:!1,writable:!0,configurable:!0}},y=function(){var c=function(n,YD){return Object.defineProperty(String.prototype,n,u(YD))};c("fromBase64",function(){return j(this)}),c("toBase64",function(n){return V(this,n)}),c("toBase64URI",function(){return V(this,!0)}),c("toBase64URL",function(){return V(this,!0)}),c("toUint8Array",function(){return g(this)})},d=function(){var c=function(n,YD){return Object.defineProperty(Uint8Array.prototype,n,u(YD))};c("toBase64",function(n){return M(this,n)}),c("toBase64URI",function(){return M(this,!0)}),c("toBase64URL",function(){return M(this,!0)})},b=function(){y(),d()},a={version:D,VERSION:$,atob:S,atobPolyfill:v,btoa:B,btoaPolyfill:q,fromBase64:j,toBase64:V,encode:V,encodeURI:R,encodeURL:R,utob:W,btou:_,decode:j,isValid:x,fromUint8Array:M,toUint8Array:g,extendString:y,extendUint8Array:d,extendBuiltins:b};return a.Base64={},Object.keys(a).forEach(function(c){return a.Base64[c]=a[c]}),a})});var CT=T((cfD,TT)=>{TT.exports=function($,X){if(X=X.split(":")[0],$=+$,!$)return!1;switch(X){case"http":case"ws":return $!==80;case"https":case"wss":return $!==443;case"ftp":return $!==21;case"gopher":return $!==70;case"file":return!1}return $!==0}});var ST=T((D7D)=>{var a5D=Object.prototype.hasOwnProperty,t5D;function PT(D){try{return decodeURIComponent(D.replace(/\+/g," "))}catch($){return null}}function xT(D){try{return encodeURIComponent(D)}catch($){return null}}function s5D(D){var $=/([^=?#&]+)=?([^&]*)/g,X={},Y;while(Y=$.exec(D)){var J=PT(Y[1]),Q=PT(Y[2]);if(J===null||Q===null||J in X)continue;X[J]=Q}return X}function e5D(D,$){$=$||"";var X=[],Y,J;if(typeof $!=="string")$="?";for(J in D)if(a5D.call(D,J)){if(Y=D[J],!Y&&(Y===null||Y===t5D||isNaN(Y)))Y="";if(J=xT(J),Y=xT(Y),J===null||Y===null)continue;X.push(J+"="+Y)}return X.length?$+X.join("&"):""}D7D.stringify=e5D;D7D.parse=s5D});var gT=T((nfD,bT)=>{var vT=CT(),TJ=ST(),J7D=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,_T=/[\n\r\t]/g,Y7D=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,kT=/:\d+$/,Q7D=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,F7D=/^[a-zA-Z]:/;function TO(D){return(D?D:"").toString().replace(J7D,"")}var EO=[["#","hash"],["?","query"],function($,X){return P$(X.protocol)?$.replace(/\\/g,"/"):$},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],uT={hash:1,query:1};function fT(D){var $;if(typeof window<"u")$=window;else if(typeof global<"u")$=global;else if(typeof self<"u")$=self;else $={};var X=$.location||{};D=D||X;var Y={},J=typeof D,Q;if(D.protocol==="blob:")Y=new x$(unescape(D.pathname),{});else if(J==="string"){Y=new x$(D,{});for(Q in uT)delete Y[Q]}else if(J==="object"){for(Q in D){if(Q in uT)continue;Y[Q]=D[Q]}if(Y.slashes===void 0)Y.slashes=Y7D.test(D.href)}return Y}function P$(D){return D==="file:"||D==="ftp:"||D==="http:"||D==="https:"||D==="ws:"||D==="wss:"}function yT(D,$){D=TO(D),D=D.replace(_T,""),$=$||{};var X=Q7D.exec(D),Y=X[1]?X[1].toLowerCase():"",J=!!X[2],Q=!!X[3],F=0,w;if(J)if(Q)w=X[2]+X[3]+X[4],F=X[2].length+X[3].length;else w=X[2]+X[4],F=X[2].length;else if(Q)w=X[3]+X[4],F=X[3].length;else w=X[4];if(Y==="file:"){if(F>=2)w=w.slice(2)}else if(P$(Y))w=X[4];else if(Y){if(J)w=w.slice(2)}else if(F>=2&&P$($.protocol))w=X[4];return{protocol:Y,slashes:J||P$(Y),slashesCount:F,rest:w}}function w7D(D,$){if(D==="")return $;var X=($||"/").split("/").slice(0,-1).concat(D.split("/")),Y=X.length,J=X[Y-1],Q=!1,F=0;while(Y--)if(X[Y]===".")X.splice(Y,1);else if(X[Y]==="..")X.splice(Y,1),F++;else if(F){if(Y===0)Q=!0;X.splice(Y,1),F--}if(Q)X.unshift("");if(J==="."||J==="..")X.push("");return X.join("/")}function x$(D,$,X){if(D=TO(D),D=D.replace(_T,""),!(this instanceof x$))return new x$(D,$,X);var Y,J,Q,F,w,Z,G=EO.slice(),O=typeof $,U=this,z=0;if(O!=="object"&&O!=="string")X=$,$=null;if(X&&typeof X!=="function")X=TJ.parse;if($=fT($),J=yT(D||"",$),Y=!J.protocol&&!J.slashes,U.slashes=J.slashes||Y&&$.slashes,U.protocol=J.protocol||$.protocol||"",D=J.rest,J.protocol==="file:"&&(J.slashesCount!==2||F7D.test(D))||!J.slashes&&(J.protocol||J.slashesCount<2||!P$(U.protocol)))G[3]=[/(.*)/,"pathname"];for(;z<G.length;z++){if(F=G[z],typeof F==="function"){D=F(D,U);continue}if(Q=F[0],Z=F[1],Q!==Q)U[Z]=D;else if(typeof Q==="string"){if(w=Q==="@"?D.lastIndexOf(Q):D.indexOf(Q),~w)if(typeof F[2]==="number")U[Z]=D.slice(0,w),D=D.slice(w+F[2]);else U[Z]=D.slice(w),D=D.slice(0,w)}else if(w=Q.exec(D))U[Z]=w[1],D=D.slice(0,w.index);if(U[Z]=U[Z]||(Y&&F[3]?$[Z]||"":""),F[4])U[Z]=U[Z].toLowerCase()}if(X)U.query=X(U.query);if(Y&&$.slashes&&U.pathname.charAt(0)!=="/"&&(U.pathname!==""||$.pathname!==""))U.pathname=w7D(U.pathname,$.pathname);if(U.pathname.charAt(0)!=="/"&&P$(U.protocol))U.pathname="/"+U.pathname;if(!vT(U.port,U.protocol))U.host=U.hostname,U.port="";if(U.username=U.password="",U.auth){if(w=U.auth.indexOf(":"),~w)U.username=U.auth.slice(0,w),U.username=encodeURIComponent(decodeURIComponent(U.username)),U.password=U.auth.slice(w+1),U.password=encodeURIComponent(decodeURIComponent(U.password));else U.username=encodeURIComponent(decodeURIComponent(U.auth));U.auth=U.password?U.username+":"+U.password:U.username}U.origin=U.protocol!=="file:"&&P$(U.protocol)&&U.host?U.protocol+"//"+U.host:"null",U.href=U.toString()}function Z7D(D,$,X){var Y=this;switch(D){case"query":if(typeof $==="string"&&$.length)$=(X||TJ.parse)($);Y[D]=$;break;case"port":if(Y[D]=$,!vT($,Y.protocol))Y.host=Y.hostname,Y[D]="";else if($)Y.host=Y.hostname+":"+$;break;case"hostname":if(Y[D]=$,Y.port)$+=":"+Y.port;Y.host=$;break;case"host":if(Y[D]=$,kT.test($))$=$.split(":"),Y.port=$.pop(),Y.hostname=$.join(":");else Y.hostname=$,Y.port="";break;case"protocol":Y.protocol=$.toLowerCase(),Y.slashes=!X;break;case"pathname":case"hash":if($){var J=D==="pathname"?"/":"#";Y[D]=$.charAt(0)!==J?J+$:$}else Y[D]=$;break;case"username":case"password":Y[D]=encodeURIComponent($);break;case"auth":var Q=$.indexOf(":");if(~Q)Y.username=$.slice(0,Q),Y.username=encodeURIComponent(decodeURIComponent(Y.username)),Y.password=$.slice(Q+1),Y.password=encodeURIComponent(decodeURIComponent(Y.password));else Y.username=encodeURIComponent(decodeURIComponent($))}for(var F=0;F<EO.length;F++){var w=EO[F];if(w[4])Y[w[1]]=Y[w[1]].toLowerCase()}return Y.auth=Y.password?Y.username+":"+Y.password:Y.username,Y.origin=Y.protocol!=="file:"&&P$(Y.protocol)&&Y.host?Y.protocol+"//"+Y.host:"null",Y.href=Y.toString(),Y}function G7D(D){if(!D||typeof D!=="function")D=TJ.stringify;var $,X=this,Y=X.host,J=X.protocol;if(J&&J.charAt(J.length-1)!==":")J+=":";var Q=J+(X.protocol&&X.slashes||P$(X.protocol)?"//":"");if(X.username){if(Q+=X.username,X.password)Q+=":"+X.password;Q+="@"}else if(X.password)Q+=":"+X.password,Q+="@";else if(X.protocol!=="file:"&&P$(X.protocol)&&!Y&&X.pathname!=="/")Q+="@";if(Y[Y.length-1]===":"||kT.test(X.hostname)&&!X.port)Y+=":";if(Q+=Y+X.pathname,$=typeof X.query==="object"?D(X.query):X.query,$)Q+=$.charAt(0)!=="?"?"?"+$:$;if(X.hash)Q+=X.hash;return Q}x$.prototype={set:Z7D,toString:G7D};x$.extractProtocol=yT;x$.location=fT;x$.trimLeft=TO;x$.qs=TJ;bT.exports=x$});var mT=T((hT)=>{Object.defineProperty(hT,"__esModule",{value:!0});hT.default=O7D;function O7D(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(D){var $=Math.random()*16|0,X=D==="x"?$:$&3|8;return X.toString(16)})}});var YC=T((XC)=>{Object.defineProperty(XC,"__esModule",{value:!0});XC.default=void 0;var q7D=ET(),z7D=xO(gT()),CJ=xO(IO()),m4=AO(),B7D=xO(mT());function xO(D){return D&&D.__esModule?D:{default:D}}function CO(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */CO=function(){return $};var D,$={},X=Object.prototype,Y=X.hasOwnProperty,J=Object.defineProperty||function(j,x,u){j[x]=u.value},Q=typeof Symbol=="function"?Symbol:{},F=Q.iterator||"@@iterator",w=Q.asyncIterator||"@@asyncIterator",Z=Q.toStringTag||"@@toStringTag";function G(j,x,u){return Object.defineProperty(j,x,{value:u,enumerable:!0,configurable:!0,writable:!0}),j[x]}try{G({},"")}catch(j){G=function(u,y,d){return u[y]=d}}function O(j,x,u,y){var d=x&&x.prototype instanceof L?x:L,b=Object.create(d.prototype),a=new l(y||[]);return J(b,"_invoke",{value:v(j,u,a)}),b}function U(j,x,u){try{return{type:"normal",arg:j.call(x,u)}}catch(y){return{type:"throw",arg:y}}}$.wrap=O;var z="suspendedStart",q="suspendedYield",B="executing",K="completed",M={};function L(){}function I(){}function W(){}var N={};G(N,F,function(){return this});var V=Object.getPrototypeOf,R=V&&V(V(f([])));R&&R!==X&&Y.call(R,F)&&(N=R);var C=W.prototype=L.prototype=Object.create(N);function A(j){["next","throw","return"].forEach(function(x){G(j,x,function(u){return this._invoke(x,u)})})}function _(j,x){function u(d,b,a,c){var n=U(j[d],j,b);if(n.type!=="throw"){var YD=n.arg,P=YD.value;return P&&d4(P)=="object"&&Y.call(P,"__await")?x.resolve(P.__await).then(function(E){u("next",E,a,c)},function(E){u("throw",E,a,c)}):x.resolve(P).then(function(E){YD.value=E,a(YD)},function(E){return u("throw",E,a,c)})}c(n.arg)}var y;J(this,"_invoke",{value:function(b,a){function c(){return new x(function(n,YD){u(b,a,n,YD)})}return y=y?y.then(c,c):c()}})}function v(j,x,u){var y=z;return function(d,b){if(y===B)throw Error("Generator is already running");if(y===K){if(d==="throw")throw b;return{value:D,done:!0}}for(u.method=d,u.arg=b;;){var a=u.delegate;if(a){var c=S(a,u);if(c){if(c===M)continue;return c}}if(u.method==="next")u.sent=u._sent=u.arg;else if(u.method==="throw"){if(y===z)throw y=K,u.arg;u.dispatchException(u.arg)}else u.method==="return"&&u.abrupt("return",u.arg);y=B;var n=U(j,x,u);if(n.type==="normal"){if(y=u.done?K:q,n.arg===M)continue;return{value:n.arg,done:u.done}}n.type==="throw"&&(y=K,u.method="throw",u.arg=n.arg)}}}function S(j,x){var u=x.method,y=j.iterator[u];if(y===D)return x.delegate=null,u==="throw"&&j.iterator.return&&(x.method="return",x.arg=D,S(j,x),x.method==="throw")||u!=="return"&&(x.method="throw",x.arg=TypeError("The iterator does not provide a '"+u+"' method")),M;var d=U(y,j.iterator,x.arg);if(d.type==="throw")return x.method="throw",x.arg=d.arg,x.delegate=null,M;var b=d.arg;return b?b.done?(x[j.resultName]=b.value,x.next=j.nextLoc,x.method!=="return"&&(x.method="next",x.arg=D),x.delegate=null,M):b:(x.method="throw",x.arg=TypeError("iterator result is not an object"),x.delegate=null,M)}function h(j){var x={tryLoc:j[0]};1 in j&&(x.catchLoc=j[1]),2 in j&&(x.finallyLoc=j[2],x.afterLoc=j[3]),this.tryEntries.push(x)}function g(j){var x=j.completion||{};x.type="normal",delete x.arg,j.completion=x}function l(j){this.tryEntries=[{tryLoc:"root"}],j.forEach(h,this),this.reset(!0)}function f(j){if(j||j===""){var x=j[F];if(x)return x.call(j);if(typeof j.next=="function")return j;if(!isNaN(j.length)){var u=-1,y=function d(){for(;++u<j.length;)if(Y.call(j,u))return d.value=j[u],d.done=!1,d;return d.value=D,d.done=!0,d};return y.next=y}}throw TypeError(d4(j)+" is not iterable")}return I.prototype=W,J(C,"constructor",{value:W,configurable:!0}),J(W,"constructor",{value:I,configurable:!0}),I.displayName=G(W,Z,"GeneratorFunction"),$.isGeneratorFunction=function(j){var x=typeof j=="function"&&j.constructor;return!!x&&(x===I||(x.displayName||x.name)==="GeneratorFunction")},$.mark=function(j){return Object.setPrototypeOf?Object.setPrototypeOf(j,W):(j.__proto__=W,G(j,Z,"GeneratorFunction")),j.prototype=Object.create(C),j},$.awrap=function(j){return{__await:j}},A(_.prototype),G(_.prototype,w,function(){return this}),$.AsyncIterator=_,$.async=function(j,x,u,y,d){d===void 0&&(d=Promise);var b=new _(O(j,x,u,y),d);return $.isGeneratorFunction(x)?b:b.next().then(function(a){return a.done?a.value:b.next()})},A(C),G(C,Z,"Generator"),G(C,F,function(){return this}),G(C,"toString",function(){return"[object Generator]"}),$.keys=function(j){var x=Object(j),u=[];for(var y in x)u.push(y);return u.reverse(),function d(){for(;u.length;){var b=u.pop();if(b in x)return d.value=b,d.done=!1,d}return d.done=!0,d}},$.values=f,l.prototype={constructor:l,reset:function(x){if(this.prev=0,this.next=0,this.sent=this._sent=D,this.done=!1,this.delegate=null,this.method="next",this.arg=D,this.tryEntries.forEach(g),!x)for(var u in this)u.charAt(0)==="t"&&Y.call(this,u)&&!isNaN(+u.slice(1))&&(this[u]=D)},stop:function(){this.done=!0;var x=this.tryEntries[0].completion;if(x.type==="throw")throw x.arg;return this.rval},dispatchException:function(x){if(this.done)throw x;var u=this;function y(YD,P){return a.type="throw",a.arg=x,u.next=YD,P&&(u.method="next",u.arg=D),!!P}for(var d=this.tryEntries.length-1;d>=0;--d){var b=this.tryEntries[d],a=b.completion;if(b.tryLoc==="root")return y("end");if(b.tryLoc<=this.prev){var c=Y.call(b,"catchLoc"),n=Y.call(b,"finallyLoc");if(c&&n){if(this.prev<b.catchLoc)return y(b.catchLoc,!0);if(this.prev<b.finallyLoc)return y(b.finallyLoc)}else if(c){if(this.prev<b.catchLoc)return y(b.catchLoc,!0)}else{if(!n)throw Error("try statement without catch or finally");if(this.prev<b.finallyLoc)return y(b.finallyLoc)}}}},abrupt:function(x,u){for(var y=this.tryEntries.length-1;y>=0;--y){var d=this.tryEntries[y];if(d.tryLoc<=this.prev&&Y.call(d,"finallyLoc")&&this.prev<d.finallyLoc){var b=d;break}}b&&(x==="break"||x==="continue")&&b.tryLoc<=u&&u<=b.finallyLoc&&(b=null);var a=b?b.completion:{};return a.type=x,a.arg=u,b?(this.method="next",this.next=b.finallyLoc,M):this.complete(a)},complete:function(x,u){if(x.type==="throw")throw x.arg;return x.type==="break"||x.type==="continue"?this.next=x.arg:x.type==="return"?(this.rval=this.arg=x.arg,this.method="return",this.next="end"):x.type==="normal"&&u&&(this.next=u),M},finish:function(x){for(var u=this.tryEntries.length-1;u>=0;--u){var y=this.tryEntries[u];if(y.finallyLoc===x)return this.complete(y.completion,y.afterLoc),g(y),M}},catch:function(x){for(var u=this.tryEntries.length-1;u>=0;--u){var y=this.tryEntries[u];if(y.tryLoc===x){var d=y.completion;if(d.type==="throw"){var b=d.arg;g(y)}return b}}throw Error("illegal catch attempt")},delegateYield:function(x,u,y){return this.delegate={iterator:f(x),resultName:u,nextLoc:y},this.method==="next"&&(this.arg=D),M}},$}function dT(D,$,X,Y,J,Q,F){try{var w=D[Q](F),Z=w.value}catch(G){X(G);return}if(w.done)$(Z);else Promise.resolve(Z).then(Y,J)}function K7D(D){return function(){var $=this,X=arguments;return new Promise(function(Y,J){var Q=D.apply($,X);function F(Z){dT(Q,Y,J,F,w,"next",Z)}function w(Z){dT(Q,Y,J,F,w,"throw",Z)}F(void 0)})}}function tT(D,$){return V7D(D)||H7D(D,$)||sT(D,$)||W7D()}function W7D(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
121
121
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function H7D(D,$){var X=D==null?null:typeof Symbol<"u"&&D[Symbol.iterator]||D["@@iterator"];if(X!=null){var Y,J,Q,F,w=[],Z=!0,G=!1;try{if(Q=(X=X.call(D)).next,$===0){if(Object(X)!==X)return;Z=!1}else for(;!(Z=(Y=Q.call(X)).done)&&(w.push(Y.value),w.length!==$);Z=!0);}catch(O){G=!0,J=O}finally{try{if(!Z&&X.return!=null&&(F=X.return(),Object(F)!==F))return}finally{if(G)throw J}}return w}}function V7D(D){if(Array.isArray(D))return D}function d4(D){return d4=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},d4(D)}function N7D(D,$){var X=typeof Symbol<"u"&&D[Symbol.iterator]||D["@@iterator"];if(!X){if(Array.isArray(D)||(X=sT(D))||$&&D&&typeof D.length==="number"){if(X)D=X;var Y=0,J=function(){};return{s:J,n:function(){if(Y>=D.length)return{done:!0};return{done:!1,value:D[Y++]}},e:function(G){throw G},f:J}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
122
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var Q=!0,F=!1,w;return{s:function(){X=X.call(D)},n:function(){var G=X.next();return Q=G.done,G},e:function(G){F=!0,w=G},f:function(){try{if(!Q&&X.return!=null)X.return()}finally{if(F)throw w}}}}function sT(D,$){if(!D)return;if(typeof D==="string")return cT(D,$);var X=Object.prototype.toString.call(D).slice(8,-1);if(X==="Object"&&D.constructor)X=D.constructor.name;if(X==="Map"||X==="Set")return Array.from(D);if(X==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(X))return cT(D,$)}function cT(D,$){if($==null||$>D.length)$=D.length;for(var X=0,Y=Array($);X<$;X++)Y[X]=D[X];return Y}function lT(D,$){var X=Object.keys(D);if(Object.getOwnPropertySymbols){var Y=Object.getOwnPropertySymbols(D);$&&(Y=Y.filter(function(J){return Object.getOwnPropertyDescriptor(D,J).enumerable})),X.push.apply(X,Y)}return X}function z9(D){for(var $=1;$<arguments.length;$++){var X=arguments[$]!=null?arguments[$]:{};$%2?lT(Object(X),!0).forEach(function(Y){M7D(D,Y,X[Y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(D,Object.getOwnPropertyDescriptors(X)):lT(Object(X)).forEach(function(Y){Object.defineProperty(D,Y,Object.getOwnPropertyDescriptor(X,Y))})}return D}function M7D(D,$,X){if($=eT($),$ in D)Object.defineProperty(D,$,{value:X,enumerable:!0,configurable:!0,writable:!0});else D[$]=X;return D}function L7D(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function nT(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,eT(Y.key),Y)}}function I7D(D,$,X){if($)nT(D.prototype,$);if(X)nT(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function eT(D){var $=A7D(D,"string");return d4($)=="symbol"?$:$+""}function A7D(D,$){if(d4(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(d4(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var PJ="tus-v1",xJ="ietf-draft-03",l7="ietf-draft-05",R7D={endpoint:null,uploadUrl:null,metadata:{},metadataForPartialUploads:{},fingerprint:null,uploadSize:null,onProgress:null,onChunkComplete:null,onSuccess:null,onError:null,onUploadUrlAvailable:null,overridePatchMethod:!1,headers:{},addRequestId:!1,onBeforeRequest:null,onAfterResponse:null,onShouldRetry:$C,chunkSize:Number.POSITIVE_INFINITY,retryDelays:[0,1000,3000,5000],parallelUploads:1,parallelUploadBoundaries:null,storeFingerprintForResuming:!0,removeFingerprintOnSuccess:!1,uploadLengthDeferred:!1,uploadDataDuringCreation:!1,urlStorage:null,fileReader:null,httpStack:null,protocol:PJ},DC=function(){function D($,X){if(L7D(this,D),"resume"in X)console.log("tus: The `resume` option has been removed in tus-js-client v2. Please use the URL storage API instead.");this.options=X,this.options.chunkSize=Number(this.options.chunkSize),this._urlStorage=this.options.urlStorage,this.file=$,this.url=null,this._req=null,this._fingerprint=null,this._urlStorageKey=null,this._offset=null,this._aborted=!1,this._size=null,this._source=null,this._retryAttempt=0,this._retryTimeout=null,this._offsetBeforeRetry=0,this._parallelUploads=null,this._parallelUploadUrls=null}return I7D(D,[{key:"findPreviousUploads",value:function(){var X=this;return this.options.fingerprint(this.file,this.options).then(function(Y){return X._urlStorage.findUploadsByFingerprint(Y)})}},{key:"resumeFromPreviousUpload",value:function(X){this.url=X.uploadUrl||null,this._parallelUploadUrls=X.parallelUploadUrls||null,this._urlStorageKey=X.urlStorageKey}},{key:"start",value:function(){var X=this,Y=this.file;if(!Y){this._emitError(Error("tus: no file or stream to upload provided"));return}if(![PJ,xJ,l7].includes(this.options.protocol)){this._emitError(Error("tus: unsupported protocol ".concat(this.options.protocol)));return}if(!this.options.endpoint&&!this.options.uploadUrl&&!this.url){this._emitError(Error("tus: neither an endpoint or an upload URL is provided"));return}var J=this.options.retryDelays;if(J!=null&&Object.prototype.toString.call(J)!=="[object Array]"){this._emitError(Error("tus: the `retryDelays` option must either be an array or null"));return}if(this.options.parallelUploads>1)for(var Q=0,F=["uploadUrl","uploadSize","uploadLengthDeferred"];Q<F.length;Q++){var w=F[Q];if(this.options[w]){this._emitError(Error("tus: cannot use the ".concat(w," option when parallelUploads is enabled")));return}}if(this.options.parallelUploadBoundaries){if(this.options.parallelUploads<=1){this._emitError(Error("tus: cannot use the `parallelUploadBoundaries` option when `parallelUploads` is disabled"));return}if(this.options.parallelUploads!==this.options.parallelUploadBoundaries.length){this._emitError(Error("tus: the `parallelUploadBoundaries` must have the same length as the value of `parallelUploads`"));return}}this.options.fingerprint(Y,this.options).then(function(Z){if(Z==null)(0,m4.log)("No fingerprint was calculated meaning that the upload cannot be stored in the URL storage.");else(0,m4.log)("Calculated fingerprint: ".concat(Z));if(X._fingerprint=Z,X._source)return X._source;return X.options.fileReader.openFile(Y,X.options.chunkSize)}).then(function(Z){if(X._source=Z,X.options.uploadLengthDeferred)X._size=null;else if(X.options.uploadSize!=null){if(X._size=Number(X.options.uploadSize),Number.isNaN(X._size)){X._emitError(Error("tus: cannot convert `uploadSize` option into a number"));return}}else if(X._size=X._source.size,X._size==null){X._emitError(Error("tus: cannot automatically derive upload's size from input. Specify it manually using the `uploadSize` option or use the `uploadLengthDeferred` option"));return}if(X.options.parallelUploads>1||X._parallelUploadUrls!=null)X._startParallelUpload();else X._startSingleUpload()}).catch(function(Z){X._emitError(Z)})}},{key:"_startParallelUpload",value:function(){var X,Y=this,J=this._size,Q=0;this._parallelUploads=[];var F=this._parallelUploadUrls!=null?this._parallelUploadUrls.length:this.options.parallelUploads,w=(X=this.options.parallelUploadBoundaries)!==null&&X!==void 0?X:E7D(this._source.size,F);if(this._parallelUploadUrls)w.forEach(function(O,U){O.uploadUrl=Y._parallelUploadUrls[U]||null});this._parallelUploadUrls=Array(w.length);var Z=w.map(function(O,U){var z=0;return Y._source.slice(O.start,O.end).then(function(q){var B=q.value;return new Promise(function(K,M){var L=z9(z9({},Y.options),{},{uploadUrl:O.uploadUrl||null,storeFingerprintForResuming:!1,removeFingerprintOnSuccess:!1,parallelUploads:1,parallelUploadBoundaries:null,metadata:Y.options.metadataForPartialUploads,headers:z9(z9({},Y.options.headers),{},{"Upload-Concat":"partial"}),onSuccess:K,onError:M,onProgress:function(N){Q=Q-z+N,z=N,Y._emitProgress(Q,J)},onUploadUrlAvailable:function(){if(Y._parallelUploadUrls[U]=I.url,Y._parallelUploadUrls.filter(function(N){return Boolean(N)}).length===w.length)Y._saveUploadInUrlStorage()}}),I=new D(B,L);I.start(),Y._parallelUploads.push(I)})})}),G;Promise.all(Z).then(function(){G=Y._openRequest("POST",Y.options.endpoint),G.setHeader("Upload-Concat","final;".concat(Y._parallelUploadUrls.join(" ")));var O=iT(Y.options.metadata);if(O!=="")G.setHeader("Upload-Metadata",O);return Y._sendRequest(G,null)}).then(function(O){if(!B9(O.getStatus(),200)){Y._emitHttpError(G,O,"tus: unexpected response while creating upload");return}var U=O.getHeader("Location");if(U==null){Y._emitHttpError(G,O,"tus: invalid or missing Location header");return}Y.url=aT(Y.options.endpoint,U),(0,m4.log)("Created upload at ".concat(Y.url)),Y._emitSuccess(O)}).catch(function(O){Y._emitError(O)})}},{key:"_startSingleUpload",value:function(){if(this._aborted=!1,this.url!=null){(0,m4.log)("Resuming upload from previous URL: ".concat(this.url)),this._resumeUpload();return}if(this.options.uploadUrl!=null){(0,m4.log)("Resuming upload from provided URL: ".concat(this.options.uploadUrl)),this.url=this.options.uploadUrl,this._resumeUpload();return}(0,m4.log)("Creating a new upload"),this._createUpload()}},{key:"abort",value:function(X){var Y=this;if(this._parallelUploads!=null){var J=N7D(this._parallelUploads),Q;try{for(J.s();!(Q=J.n()).done;){var F=Q.value;F.abort(X)}}catch(w){J.e(w)}finally{J.f()}}if(this._req!==null)this._req.abort();if(this._aborted=!0,this._retryTimeout!=null)clearTimeout(this._retryTimeout),this._retryTimeout=null;if(!X||this.url==null)return Promise.resolve();return D.terminate(this.url,this.options).then(function(){return Y._removeFromUrlStorage()})}},{key:"_emitHttpError",value:function(X,Y,J,Q){this._emitError(new CJ.default(J,Q,X,Y))}},{key:"_emitError",value:function(X){var Y=this;if(this._aborted)return;if(this.options.retryDelays!=null){var J=this._offset!=null&&this._offset>this._offsetBeforeRetry;if(J)this._retryAttempt=0;if(oT(X,this._retryAttempt,this.options)){var Q=this.options.retryDelays[this._retryAttempt++];this._offsetBeforeRetry=this._offset,this._retryTimeout=setTimeout(function(){Y.start()},Q);return}}if(typeof this.options.onError==="function")this.options.onError(X);else throw X}},{key:"_emitSuccess",value:function(X){if(this.options.removeFingerprintOnSuccess)this._removeFromUrlStorage();if(typeof this.options.onSuccess==="function")this.options.onSuccess({lastResponse:X})}},{key:"_emitProgress",value:function(X,Y){if(typeof this.options.onProgress==="function")this.options.onProgress(X,Y)}},{key:"_emitChunkComplete",value:function(X,Y,J){if(typeof this.options.onChunkComplete==="function")this.options.onChunkComplete(X,Y,J)}},{key:"_createUpload",value:function(){var X=this;if(!this.options.endpoint){this._emitError(Error("tus: unable to create upload because no endpoint is provided"));return}var Y=this._openRequest("POST",this.options.endpoint);if(this.options.uploadLengthDeferred)Y.setHeader("Upload-Defer-Length","1");else Y.setHeader("Upload-Length","".concat(this._size));var J=iT(this.options.metadata);if(J!=="")Y.setHeader("Upload-Metadata",J);var Q;if(this.options.uploadDataDuringCreation&&!this.options.uploadLengthDeferred)this._offset=0,Q=this._addChunkToRequest(Y);else{if(this.options.protocol===xJ||this.options.protocol===l7)Y.setHeader("Upload-Complete","?0");Q=this._sendRequest(Y,null)}Q.then(function(F){if(!B9(F.getStatus(),200)){X._emitHttpError(Y,F,"tus: unexpected response while creating upload");return}var w=F.getHeader("Location");if(w==null){X._emitHttpError(Y,F,"tus: invalid or missing Location header");return}if(X.url=aT(X.options.endpoint,w),(0,m4.log)("Created upload at ".concat(X.url)),typeof X.options.onUploadUrlAvailable==="function")X.options.onUploadUrlAvailable();if(X._size===0){X._emitSuccess(F),X._source.close();return}X._saveUploadInUrlStorage().then(function(){if(X.options.uploadDataDuringCreation)X._handleUploadResponse(Y,F);else X._offset=0,X._performUpload()})}).catch(function(F){X._emitHttpError(Y,null,"tus: failed to create upload",F)})}},{key:"_resumeUpload",value:function(){var X=this,Y=this._openRequest("HEAD",this.url),J=this._sendRequest(Y,null);J.then(function(Q){var F=Q.getStatus();if(!B9(F,200)){if(F===423){X._emitHttpError(Y,Q,"tus: upload is currently locked; retry later");return}if(B9(F,400))X._removeFromUrlStorage();if(!X.options.endpoint){X._emitHttpError(Y,Q,"tus: unable to resume upload (new upload cannot be created without an endpoint)");return}X.url=null,X._createUpload();return}var w=Number.parseInt(Q.getHeader("Upload-Offset"),10);if(Number.isNaN(w)){X._emitHttpError(Y,Q,"tus: invalid or missing offset value");return}var Z=Number.parseInt(Q.getHeader("Upload-Length"),10);if(Number.isNaN(Z)&&!X.options.uploadLengthDeferred&&X.options.protocol===PJ){X._emitHttpError(Y,Q,"tus: invalid or missing length value");return}if(typeof X.options.onUploadUrlAvailable==="function")X.options.onUploadUrlAvailable();X._saveUploadInUrlStorage().then(function(){if(w===Z){X._emitProgress(Z,Z),X._emitSuccess(Q);return}X._offset=w,X._performUpload()})}).catch(function(Q){X._emitHttpError(Y,null,"tus: failed to resume upload",Q)})}},{key:"_performUpload",value:function(){var X=this;if(this._aborted)return;var Y;if(this.options.overridePatchMethod)Y=this._openRequest("POST",this.url),Y.setHeader("X-HTTP-Method-Override","PATCH");else Y=this._openRequest("PATCH",this.url);Y.setHeader("Upload-Offset","".concat(this._offset));var J=this._addChunkToRequest(Y);J.then(function(Q){if(!B9(Q.getStatus(),200)){X._emitHttpError(Y,Q,"tus: unexpected response while uploading chunk");return}X._handleUploadResponse(Y,Q)}).catch(function(Q){if(X._aborted)return;X._emitHttpError(Y,null,"tus: failed to upload chunk at offset ".concat(X._offset),Q)})}},{key:"_addChunkToRequest",value:function(X){var Y=this,J=this._offset,Q=this._offset+this.options.chunkSize;if(X.setProgressHandler(function(F){Y._emitProgress(J+F,Y._size)}),this.options.protocol===PJ)X.setHeader("Content-Type","application/offset+octet-stream");else if(this.options.protocol===l7)X.setHeader("Content-Type","application/partial-upload");if((Q===Number.POSITIVE_INFINITY||Q>this._size)&&!this.options.uploadLengthDeferred)Q=this._size;return this._source.slice(J,Q).then(function(F){var{value:w,done:Z}=F,G=w!==null&&w!==void 0&&w.size?w.size:0;if(Y.options.uploadLengthDeferred&&Z)Y._size=Y._offset+G,X.setHeader("Upload-Length","".concat(Y._size));var O=Y._offset+G;if(!Y.options.uploadLengthDeferred&&Z&&O!==Y._size)return Promise.reject(Error("upload was configured with a size of ".concat(Y._size," bytes, but the source is done after ").concat(O," bytes")));if(w===null)return Y._sendRequest(X);if(Y.options.protocol===xJ||Y.options.protocol===l7)X.setHeader("Upload-Complete",Z?"?1":"?0");return Y._emitProgress(Y._offset,Y._size),Y._sendRequest(X,w)})}},{key:"_handleUploadResponse",value:function(X,Y){var J=Number.parseInt(Y.getHeader("Upload-Offset"),10);if(Number.isNaN(J)){this._emitHttpError(X,Y,"tus: invalid or missing offset value");return}if(this._emitProgress(J,this._size),this._emitChunkComplete(J-this._offset,J,this._size),this._offset=J,J===this._size){this._emitSuccess(Y),this._source.close();return}this._performUpload()}},{key:"_openRequest",value:function(X,Y){var J=pT(X,Y,this.options);return this._req=J,J}},{key:"_removeFromUrlStorage",value:function(){var X=this;if(!this._urlStorageKey)return;this._urlStorage.removeUpload(this._urlStorageKey).catch(function(Y){X._emitError(Y)}),this._urlStorageKey=null}},{key:"_saveUploadInUrlStorage",value:function(){var X=this;if(!this.options.storeFingerprintForResuming||!this._fingerprint||this._urlStorageKey!==null)return Promise.resolve();var Y={size:this._size,metadata:this.options.metadata,creationTime:new Date().toString()};if(this._parallelUploads)Y.parallelUploadUrls=this._parallelUploadUrls;else Y.uploadUrl=this.url;return this._urlStorage.addUpload(this._fingerprint,Y).then(function(J){X._urlStorageKey=J})}},{key:"_sendRequest",value:function(X){var Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;return rT(X,Y,this.options)}}],[{key:"terminate",value:function(X){var Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},J=pT("DELETE",X,Y);return rT(J,null,Y).then(function(Q){if(Q.getStatus()===204)return;throw new CJ.default("tus: unexpected response while terminating upload",null,J,Q)}).catch(function(Q){if(!(Q instanceof CJ.default))Q=new CJ.default("tus: failed to terminate upload",Q,J,null);if(!oT(Q,0,Y))throw Q;var F=Y.retryDelays[0],w=Y.retryDelays.slice(1),Z=z9(z9({},Y),{},{retryDelays:w});return new Promise(function(G){return setTimeout(G,F)}).then(function(){return D.terminate(X,Z)})})}}])}();function iT(D){return Object.entries(D).map(function($){var X=tT($,2),Y=X[0],J=X[1];return"".concat(Y," ").concat(q7D.Base64.encode(String(J)))}).join(",")}function B9(D,$){return D>=$&&D<$+100}function pT(D,$,X){var Y=X.httpStack.createRequest(D,$);if(X.protocol===xJ)Y.setHeader("Upload-Draft-Interop-Version","5");else if(X.protocol===l7)Y.setHeader("Upload-Draft-Interop-Version","6");else Y.setHeader("Tus-Resumable","1.0.0");var J=X.headers||{};for(var Q=0,F=Object.entries(J);Q<F.length;Q++){var w=tT(F[Q],2),Z=w[0],G=w[1];Y.setHeader(Z,G)}if(X.addRequestId){var O=(0,B7D.default)();Y.setHeader("X-Request-ID",O)}return Y}function rT(D,$,X){return PO.apply(this,arguments)}function PO(){return PO=K7D(CO().mark(function D($,X,Y){var J;return CO().wrap(function(F){while(!0)switch(F.prev=F.next){case 0:if(typeof Y.onBeforeRequest!=="function"){F.next=3;break}return F.next=3,Y.onBeforeRequest($);case 3:return F.next=5,$.send(X);case 5:if(J=F.sent,typeof Y.onAfterResponse!=="function"){F.next=9;break}return F.next=9,Y.onAfterResponse($,J);case 9:return F.abrupt("return",J);case 10:case"end":return F.stop()}},D)})),PO.apply(this,arguments)}function j7D(){var D=!0;if(typeof navigator<"u"&&navigator.onLine===!1)D=!1;return D}function oT(D,$,X){if(X.retryDelays==null||$>=X.retryDelays.length||D.originalRequest==null)return!1;if(X&&typeof X.onShouldRetry==="function")return X.onShouldRetry(D,$,X);return $C(D)}function $C(D){var $=D.originalResponse?D.originalResponse.getStatus():0;return(!B9($,400)||$===409||$===423)&&j7D()}function aT(D,$){return new z7D.default($,D).toString()}function E7D(D,$){var X=Math.floor(D/$),Y=[];for(var J=0;J<$;J++)Y.push({start:X*J,end:X*(J+1)});return Y[$-1].end=D,Y}DC.defaultOptions=R7D;var pfD=XC.default=DC});var FC=T((ofD,QC)=>{var S$=(D)=>D!==null&&typeof D==="object"&&typeof D.pipe==="function";S$.writable=(D)=>S$(D)&&D.writable!==!1&&typeof D._write==="function"&&typeof D._writableState==="object";S$.readable=(D)=>S$(D)&&D.readable!==!1&&typeof D._read==="function"&&typeof D._readableState==="object";S$.duplex=(D)=>S$.writable(D)&&S$.readable(D);S$.transform=(D)=>S$.duplex(D)&&typeof D._transform==="function";QC.exports=S$});var OC=T((ZC)=>{Object.defineProperty(ZC,"__esModule",{value:!0});ZC.default=void 0;function n7(D){return n7=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},n7(D)}function T7D(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function wC(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,P7D(Y.key),Y)}}function C7D(D,$,X){if($)wC(D.prototype,$);if(X)wC(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function P7D(D){var $=x7D(D,"string");return n7($)=="symbol"?$:$+""}function x7D(D,$){if(n7(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(n7(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var afD=ZC.default=function(){function D($){T7D(this,D),this._buffer=$,this.size=$.length}return C7D(D,[{key:"slice",value:function(X,Y){var J=this._buffer.slice(X,Y);J.size=J.length;var Q=Y>=this.size;return Promise.resolve({value:J,done:Q})}},{key:"close",value:function(){}}])}()});var KC=T((BC)=>{Object.defineProperty(BC,"__esModule",{value:!0});BC.default=f7D;var zC=p("fs");function c4(D){return c4=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},c4(D)}function SO(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */SO=function(){return $};var D,$={},X=Object.prototype,Y=X.hasOwnProperty,J=Object.defineProperty||function(j,x,u){j[x]=u.value},Q=typeof Symbol=="function"?Symbol:{},F=Q.iterator||"@@iterator",w=Q.asyncIterator||"@@asyncIterator",Z=Q.toStringTag||"@@toStringTag";function G(j,x,u){return Object.defineProperty(j,x,{value:u,enumerable:!0,configurable:!0,writable:!0}),j[x]}try{G({},"")}catch(j){G=function(u,y,d){return u[y]=d}}function O(j,x,u,y){var d=x&&x.prototype instanceof L?x:L,b=Object.create(d.prototype),a=new l(y||[]);return J(b,"_invoke",{value:v(j,u,a)}),b}function U(j,x,u){try{return{type:"normal",arg:j.call(x,u)}}catch(y){return{type:"throw",arg:y}}}$.wrap=O;var z="suspendedStart",q="suspendedYield",B="executing",K="completed",M={};function L(){}function I(){}function W(){}var N={};G(N,F,function(){return this});var V=Object.getPrototypeOf,R=V&&V(V(f([])));R&&R!==X&&Y.call(R,F)&&(N=R);var P=W.prototype=L.prototype=Object.create(N);function A(j){["next","throw","return"].forEach(function(x){G(j,x,function(u){return this._invoke(x,u)})})}function _(j,x){function u(d,b,a,c){var n=U(j[d],j,b);if(n.type!=="throw"){var YD=n.arg,C=YD.value;return C&&c4(C)=="object"&&Y.call(C,"__await")?x.resolve(C.__await).then(function(E){u("next",E,a,c)},function(E){u("throw",E,a,c)}):x.resolve(C).then(function(E){YD.value=E,a(YD)},function(E){return u("throw",E,a,c)})}c(n.arg)}var y;J(this,"_invoke",{value:function(b,a){function c(){return new x(function(n,YD){u(b,a,n,YD)})}return y=y?y.then(c,c):c()}})}function v(j,x,u){var y=z;return function(d,b){if(y===B)throw Error("Generator is already running");if(y===K){if(d==="throw")throw b;return{value:D,done:!0}}for(u.method=d,u.arg=b;;){var a=u.delegate;if(a){var c=S(a,u);if(c){if(c===M)continue;return c}}if(u.method==="next")u.sent=u._sent=u.arg;else if(u.method==="throw"){if(y===z)throw y=K,u.arg;u.dispatchException(u.arg)}else u.method==="return"&&u.abrupt("return",u.arg);y=B;var n=U(j,x,u);if(n.type==="normal"){if(y=u.done?K:q,n.arg===M)continue;return{value:n.arg,done:u.done}}n.type==="throw"&&(y=K,u.method="throw",u.arg=n.arg)}}}function S(j,x){var u=x.method,y=j.iterator[u];if(y===D)return x.delegate=null,u==="throw"&&j.iterator.return&&(x.method="return",x.arg=D,S(j,x),x.method==="throw")||u!=="return"&&(x.method="throw",x.arg=TypeError("The iterator does not provide a '"+u+"' method")),M;var d=U(y,j.iterator,x.arg);if(d.type==="throw")return x.method="throw",x.arg=d.arg,x.delegate=null,M;var b=d.arg;return b?b.done?(x[j.resultName]=b.value,x.next=j.nextLoc,x.method!=="return"&&(x.method="next",x.arg=D),x.delegate=null,M):b:(x.method="throw",x.arg=TypeError("iterator result is not an object"),x.delegate=null,M)}function h(j){var x={tryLoc:j[0]};1 in j&&(x.catchLoc=j[1]),2 in j&&(x.finallyLoc=j[2],x.afterLoc=j[3]),this.tryEntries.push(x)}function g(j){var x=j.completion||{};x.type="normal",delete x.arg,j.completion=x}function l(j){this.tryEntries=[{tryLoc:"root"}],j.forEach(h,this),this.reset(!0)}function f(j){if(j||j===""){var x=j[F];if(x)return x.call(j);if(typeof j.next=="function")return j;if(!isNaN(j.length)){var u=-1,y=function d(){for(;++u<j.length;)if(Y.call(j,u))return d.value=j[u],d.done=!1,d;return d.value=D,d.done=!0,d};return y.next=y}}throw TypeError(c4(j)+" is not iterable")}return I.prototype=W,J(P,"constructor",{value:W,configurable:!0}),J(W,"constructor",{value:I,configurable:!0}),I.displayName=G(W,Z,"GeneratorFunction"),$.isGeneratorFunction=function(j){var x=typeof j=="function"&&j.constructor;return!!x&&(x===I||(x.displayName||x.name)==="GeneratorFunction")},$.mark=function(j){return Object.setPrototypeOf?Object.setPrototypeOf(j,W):(j.__proto__=W,G(j,Z,"GeneratorFunction")),j.prototype=Object.create(P),j},$.awrap=function(j){return{__await:j}},A(_.prototype),G(_.prototype,w,function(){return this}),$.AsyncIterator=_,$.async=function(j,x,u,y,d){d===void 0&&(d=Promise);var b=new _(O(j,x,u,y),d);return $.isGeneratorFunction(x)?b:b.next().then(function(a){return a.done?a.value:b.next()})},A(P),G(P,Z,"Generator"),G(P,F,function(){return this}),G(P,"toString",function(){return"[object Generator]"}),$.keys=function(j){var x=Object(j),u=[];for(var y in x)u.push(y);return u.reverse(),function d(){for(;u.length;){var b=u.pop();if(b in x)return d.value=b,d.done=!1,d}return d.done=!0,d}},$.values=f,l.prototype={constructor:l,reset:function(x){if(this.prev=0,this.next=0,this.sent=this._sent=D,this.done=!1,this.delegate=null,this.method="next",this.arg=D,this.tryEntries.forEach(g),!x)for(var u in this)u.charAt(0)==="t"&&Y.call(this,u)&&!isNaN(+u.slice(1))&&(this[u]=D)},stop:function(){this.done=!0;var x=this.tryEntries[0].completion;if(x.type==="throw")throw x.arg;return this.rval},dispatchException:function(x){if(this.done)throw x;var u=this;function y(YD,C){return a.type="throw",a.arg=x,u.next=YD,C&&(u.method="next",u.arg=D),!!C}for(var d=this.tryEntries.length-1;d>=0;--d){var b=this.tryEntries[d],a=b.completion;if(b.tryLoc==="root")return y("end");if(b.tryLoc<=this.prev){var c=Y.call(b,"catchLoc"),n=Y.call(b,"finallyLoc");if(c&&n){if(this.prev<b.catchLoc)return y(b.catchLoc,!0);if(this.prev<b.finallyLoc)return y(b.finallyLoc)}else if(c){if(this.prev<b.catchLoc)return y(b.catchLoc,!0)}else{if(!n)throw Error("try statement without catch or finally");if(this.prev<b.finallyLoc)return y(b.finallyLoc)}}}},abrupt:function(x,u){for(var y=this.tryEntries.length-1;y>=0;--y){var d=this.tryEntries[y];if(d.tryLoc<=this.prev&&Y.call(d,"finallyLoc")&&this.prev<d.finallyLoc){var b=d;break}}b&&(x==="break"||x==="continue")&&b.tryLoc<=u&&u<=b.finallyLoc&&(b=null);var a=b?b.completion:{};return a.type=x,a.arg=u,b?(this.method="next",this.next=b.finallyLoc,M):this.complete(a)},complete:function(x,u){if(x.type==="throw")throw x.arg;return x.type==="break"||x.type==="continue"?this.next=x.arg:x.type==="return"?(this.rval=this.arg=x.arg,this.method="return",this.next="end"):x.type==="normal"&&u&&(this.next=u),M},finish:function(x){for(var u=this.tryEntries.length-1;u>=0;--u){var y=this.tryEntries[u];if(y.finallyLoc===x)return this.complete(y.completion,y.afterLoc),g(y),M}},catch:function(x){for(var u=this.tryEntries.length-1;u>=0;--u){var y=this.tryEntries[u];if(y.tryLoc===x){var d=y.completion;if(d.type==="throw"){var b=d.arg;g(y)}return b}}throw Error("illegal catch attempt")},delegateYield:function(x,u,y){return this.delegate={iterator:f(x),resultName:u,nextLoc:y},this.method==="next"&&(this.arg=D),M}},$}function S7D(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function UC(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,v7D(Y.key),Y)}}function u7D(D,$,X){if($)UC(D.prototype,$);if(X)UC(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function v7D(D){var $=_7D(D,"string");return c4($)=="symbol"?$:$+""}function _7D(D,$){if(c4(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(c4(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}function qC(D,$,X,Y,J,Q,F){try{var w=D[Q](F),Z=w.value}catch(G){X(G);return}if(w.done)$(Z);else Promise.resolve(Z).then(Y,J)}function k7D(D){return function(){var $=this,X=arguments;return new Promise(function(Y,J){var Q=D.apply($,X);function F(Z){qC(Q,Y,J,F,w,"next",Z)}function w(Z){qC(Q,Y,J,F,w,"throw",Z)}F(void 0)})}}function f7D(D){return uO.apply(this,arguments)}function uO(){return uO=k7D(SO().mark(function D($){var X,Y,J,Q,F,w,Z;return SO().wrap(function(O){while(!0)switch(O.prev=O.next){case 0:return Y=$.path.toString(),O.next=3,zC.promises.stat(Y);case 3:return J=O.sent,Q=J.size,F=(X=$.start)!==null&&X!==void 0?X:0,w=Number.isFinite($.end)?$.end+1:Q,Z=w-F,O.abrupt("return",new y7D($,Y,Z));case 9:case"end":return O.stop()}},D)})),uO.apply(this,arguments)}var y7D=function(){function D($,X,Y){S7D(this,D),this._stream=$,this._path=X,this.size=Y}return u7D(D,[{key:"slice",value:function(X,Y){var J,Q=(J=this._stream.start)!==null&&J!==void 0?J:0,F=(0,zC.createReadStream)(this._path,{start:Q+X,end:Q+Y-1,autoClose:!0});F.size=Math.min(Y-X,this.size);var w=F.size>=this.size;return Promise.resolve({value:F,done:w})}},{key:"close",value:function(){this._stream.destroy()}}])}()});var _O=T((NC)=>{Object.defineProperty(NC,"__esModule",{value:!0});NC.default=void 0;function l4(D){return l4=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},l4(D)}function i7(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */i7=function(){return $};var D,$={},X=Object.prototype,Y=X.hasOwnProperty,J=Object.defineProperty||function(j,x,u){j[x]=u.value},Q=typeof Symbol=="function"?Symbol:{},F=Q.iterator||"@@iterator",w=Q.asyncIterator||"@@asyncIterator",Z=Q.toStringTag||"@@toStringTag";function G(j,x,u){return Object.defineProperty(j,x,{value:u,enumerable:!0,configurable:!0,writable:!0}),j[x]}try{G({},"")}catch(j){G=function(u,y,d){return u[y]=d}}function O(j,x,u,y){var d=x&&x.prototype instanceof L?x:L,b=Object.create(d.prototype),a=new l(y||[]);return J(b,"_invoke",{value:v(j,u,a)}),b}function U(j,x,u){try{return{type:"normal",arg:j.call(x,u)}}catch(y){return{type:"throw",arg:y}}}$.wrap=O;var z="suspendedStart",q="suspendedYield",B="executing",K="completed",M={};function L(){}function I(){}function W(){}var N={};G(N,F,function(){return this});var V=Object.getPrototypeOf,R=V&&V(V(f([])));R&&R!==X&&Y.call(R,F)&&(N=R);var P=W.prototype=L.prototype=Object.create(N);function A(j){["next","throw","return"].forEach(function(x){G(j,x,function(u){return this._invoke(x,u)})})}function _(j,x){function u(d,b,a,c){var n=U(j[d],j,b);if(n.type!=="throw"){var YD=n.arg,C=YD.value;return C&&l4(C)=="object"&&Y.call(C,"__await")?x.resolve(C.__await).then(function(E){u("next",E,a,c)},function(E){u("throw",E,a,c)}):x.resolve(C).then(function(E){YD.value=E,a(YD)},function(E){return u("throw",E,a,c)})}c(n.arg)}var y;J(this,"_invoke",{value:function(b,a){function c(){return new x(function(n,YD){u(b,a,n,YD)})}return y=y?y.then(c,c):c()}})}function v(j,x,u){var y=z;return function(d,b){if(y===B)throw Error("Generator is already running");if(y===K){if(d==="throw")throw b;return{value:D,done:!0}}for(u.method=d,u.arg=b;;){var a=u.delegate;if(a){var c=S(a,u);if(c){if(c===M)continue;return c}}if(u.method==="next")u.sent=u._sent=u.arg;else if(u.method==="throw"){if(y===z)throw y=K,u.arg;u.dispatchException(u.arg)}else u.method==="return"&&u.abrupt("return",u.arg);y=B;var n=U(j,x,u);if(n.type==="normal"){if(y=u.done?K:q,n.arg===M)continue;return{value:n.arg,done:u.done}}n.type==="throw"&&(y=K,u.method="throw",u.arg=n.arg)}}}function S(j,x){var u=x.method,y=j.iterator[u];if(y===D)return x.delegate=null,u==="throw"&&j.iterator.return&&(x.method="return",x.arg=D,S(j,x),x.method==="throw")||u!=="return"&&(x.method="throw",x.arg=TypeError("The iterator does not provide a '"+u+"' method")),M;var d=U(y,j.iterator,x.arg);if(d.type==="throw")return x.method="throw",x.arg=d.arg,x.delegate=null,M;var b=d.arg;return b?b.done?(x[j.resultName]=b.value,x.next=j.nextLoc,x.method!=="return"&&(x.method="next",x.arg=D),x.delegate=null,M):b:(x.method="throw",x.arg=TypeError("iterator result is not an object"),x.delegate=null,M)}function h(j){var x={tryLoc:j[0]};1 in j&&(x.catchLoc=j[1]),2 in j&&(x.finallyLoc=j[2],x.afterLoc=j[3]),this.tryEntries.push(x)}function g(j){var x=j.completion||{};x.type="normal",delete x.arg,j.completion=x}function l(j){this.tryEntries=[{tryLoc:"root"}],j.forEach(h,this),this.reset(!0)}function f(j){if(j||j===""){var x=j[F];if(x)return x.call(j);if(typeof j.next=="function")return j;if(!isNaN(j.length)){var u=-1,y=function d(){for(;++u<j.length;)if(Y.call(j,u))return d.value=j[u],d.done=!1,d;return d.value=D,d.done=!0,d};return y.next=y}}throw TypeError(l4(j)+" is not iterable")}return I.prototype=W,J(P,"constructor",{value:W,configurable:!0}),J(W,"constructor",{value:I,configurable:!0}),I.displayName=G(W,Z,"GeneratorFunction"),$.isGeneratorFunction=function(j){var x=typeof j=="function"&&j.constructor;return!!x&&(x===I||(x.displayName||x.name)==="GeneratorFunction")},$.mark=function(j){return Object.setPrototypeOf?Object.setPrototypeOf(j,W):(j.__proto__=W,G(j,Z,"GeneratorFunction")),j.prototype=Object.create(P),j},$.awrap=function(j){return{__await:j}},A(_.prototype),G(_.prototype,w,function(){return this}),$.AsyncIterator=_,$.async=function(j,x,u,y,d){d===void 0&&(d=Promise);var b=new _(O(j,x,u,y),d);return $.isGeneratorFunction(x)?b:b.next().then(function(a){return a.done?a.value:b.next()})},A(P),G(P,Z,"Generator"),G(P,F,function(){return this}),G(P,"toString",function(){return"[object Generator]"}),$.keys=function(j){var x=Object(j),u=[];for(var y in x)u.push(y);return u.reverse(),function d(){for(;u.length;){var b=u.pop();if(b in x)return d.value=b,d.done=!1,d}return d.done=!0,d}},$.values=f,l.prototype={constructor:l,reset:function(x){if(this.prev=0,this.next=0,this.sent=this._sent=D,this.done=!1,this.delegate=null,this.method="next",this.arg=D,this.tryEntries.forEach(g),!x)for(var u in this)u.charAt(0)==="t"&&Y.call(this,u)&&!isNaN(+u.slice(1))&&(this[u]=D)},stop:function(){this.done=!0;var x=this.tryEntries[0].completion;if(x.type==="throw")throw x.arg;return this.rval},dispatchException:function(x){if(this.done)throw x;var u=this;function y(YD,C){return a.type="throw",a.arg=x,u.next=YD,C&&(u.method="next",u.arg=D),!!C}for(var d=this.tryEntries.length-1;d>=0;--d){var b=this.tryEntries[d],a=b.completion;if(b.tryLoc==="root")return y("end");if(b.tryLoc<=this.prev){var c=Y.call(b,"catchLoc"),n=Y.call(b,"finallyLoc");if(c&&n){if(this.prev<b.catchLoc)return y(b.catchLoc,!0);if(this.prev<b.finallyLoc)return y(b.finallyLoc)}else if(c){if(this.prev<b.catchLoc)return y(b.catchLoc,!0)}else{if(!n)throw Error("try statement without catch or finally");if(this.prev<b.finallyLoc)return y(b.finallyLoc)}}}},abrupt:function(x,u){for(var y=this.tryEntries.length-1;y>=0;--y){var d=this.tryEntries[y];if(d.tryLoc<=this.prev&&Y.call(d,"finallyLoc")&&this.prev<d.finallyLoc){var b=d;break}}b&&(x==="break"||x==="continue")&&b.tryLoc<=u&&u<=b.finallyLoc&&(b=null);var a=b?b.completion:{};return a.type=x,a.arg=u,b?(this.method="next",this.next=b.finallyLoc,M):this.complete(a)},complete:function(x,u){if(x.type==="throw")throw x.arg;return x.type==="break"||x.type==="continue"?this.next=x.arg:x.type==="return"?(this.rval=this.arg=x.arg,this.method="return",this.next="end"):x.type==="normal"&&u&&(this.next=u),M},finish:function(x){for(var u=this.tryEntries.length-1;u>=0;--u){var y=this.tryEntries[u];if(y.finallyLoc===x)return this.complete(y.completion,y.afterLoc),g(y),M}},catch:function(x){for(var u=this.tryEntries.length-1;u>=0;--u){var y=this.tryEntries[u];if(y.tryLoc===x){var d=y.completion;if(d.type==="throw"){var b=d.arg;g(y)}return b}}throw Error("illegal catch attempt")},delegateYield:function(x,u,y){return this.delegate={iterator:f(x),resultName:u,nextLoc:y},this.method==="next"&&(this.arg=D),M}},$}function g7D(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function WC(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,m7D(Y.key),Y)}}function h7D(D,$,X){if($)WC(D.prototype,$);if(X)WC(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function m7D(D){var $=d7D(D,"string");return l4($)=="symbol"?$:$+""}function d7D(D,$){if(l4(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(l4(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}function HC(D,$,X,Y,J,Q,F){try{var w=D[Q](F),Z=w.value}catch(G){X(G);return}if(w.done)$(Z);else Promise.resolve(Z).then(Y,J)}function VC(D){return function(){var $=this,X=arguments;return new Promise(function(Y,J){var Q=D.apply($,X);function F(Z){HC(Q,Y,J,F,w,"next",Z)}function w(Z){HC(Q,Y,J,F,w,"throw",Z)}F(void 0)})}}function c7D(D,$){return vO.apply(this,arguments)}function vO(){return vO=VC(i7().mark(function D($,X){return i7().wrap(function(J){while(!0)switch(J.prev=J.next){case 0:return J.abrupt("return",new Promise(function(Q,F){var w=function(O){$.off("readable",Z),F(O)},Z=function G(){var O=$.read(X);if(O!==null)$.off("error",w),$.off("readable",G),Q(O)};$.once("error",w),$.on("readable",Z)}));case 1:case"end":return J.stop()}},D)})),vO.apply(this,arguments)}var efD=NC.default=function(){function D($){var X=this;g7D(this,D),this._stream=$,this.size=null,this._buf=Buffer.alloc(0),this._bufPos=0,this._ended=!1,this._error=null,$.pause(),$.on("end",function(){X._ended=!0}),$.on("error",function(Y){X._error=Y})}return h7D(D,[{key:"slice",value:function(){var $=VC(i7().mark(function Y(J,Q){var F,w,Z,G,O;return i7().wrap(function(z){while(!0)switch(z.prev=z.next){case 0:if(!(J<this._bufPos)){z.next=2;break}throw Error("cannot slice from position which we already seeked away");case 2:if(!(J>this._bufPos+this._buf.length)){z.next=4;break}throw Error("slice start is outside of buffer (currently not implemented)");case 4:if(!this._error){z.next=6;break}throw this._error;case 6:if(J<this._bufPos+this._buf.length)w=J-this._bufPos,Z=Math.min(this._buf.length,Q-this._bufPos),F=this._buf.slice(w,Z);else F=Buffer.alloc(0);if(!this._ended){z.next=10;break}return F.size=F.length,z.abrupt("return",{value:F,done:!0});case 10:if(G=Q-J,!(G>F.length)){z.next=16;break}return z.next=14,c7D(this._stream,G-F.length);case 14:O=z.sent,F=Buffer.concat([F,O]);case 16:return this._buf=F,this._bufPos=J,F.size=F.length,z.abrupt("return",{value:F,done:this._ended});case 20:case"end":return z.stop()}},Y,this)}));function X(Y,J){return $.apply(this,arguments)}return X}()},{key:"close",value:function(){this._stream.destroy()}}])}()});var RC=T((IC)=>{Object.defineProperty(IC,"__esModule",{value:!0});IC.default=void 0;var l7D=p("fs"),n7D=SJ(FC()),i7D=SJ(OC()),p7D=SJ(KC()),r7D=SJ(_O());function SJ(D){return D&&D.__esModule?D:{default:D}}function p7(D){return p7=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},p7(D)}function o7D(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function LC(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,t7D(Y.key),Y)}}function a7D(D,$,X){if($)LC(D.prototype,$);if(X)LC(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function t7D(D){var $=s7D(D,"string");return p7($)=="symbol"?$:$+""}function s7D(D,$){if(p7(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(p7(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var $yD=IC.default=function(){function D(){o7D(this,D)}return a7D(D,[{key:"openFile",value:function(X,Y){if(Buffer.isBuffer(X))return Promise.resolve(new i7D.default(X));if(X instanceof l7D.ReadStream&&X.path!=null)return(0,p7D.default)(X);if(n7D.default.readable(X)){if(Y=Number(Y),!Number.isFinite(Y))return Promise.reject(Error("cannot create source for stream without a finite value for the `chunkSize` option; specify a chunkSize to control the memory consumption"));return Promise.resolve(new r7D.default(X))}return Promise.reject(Error("source object may only be an instance of Buffer or Readable in this environment"))}}])}()});var PC=T((CC)=>{Object.defineProperty(CC,"__esModule",{value:!0});CC.default=$3D;var e7D=p("crypto"),jC=TC(p("fs")),D3D=TC(p("path"));function EC(D){if(typeof WeakMap!="function")return null;var $=new WeakMap,X=new WeakMap;return(EC=function(Y){return Y?X:$})(D)}function TC(D,$){if(!$&&D&&D.__esModule)return D;if(D===null||typeof D!="object"&&typeof D!="function")return{default:D};var X=EC($);if(X&&X.has(D))return X.get(D);var Y={__proto__:null},J=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var Q in D)if(Q!=="default"&&{}.hasOwnProperty.call(D,Q)){var F=J?Object.getOwnPropertyDescriptor(D,Q):null;F&&(F.get||F.set)?Object.defineProperty(Y,Q,F):Y[Q]=D[Q]}return Y.default=D,X&&X.set(D,Y),Y}function $3D(D,$){if(Buffer.isBuffer(D)){var X=65536,Y=D.slice(0,Math.min(X,D.length)),J=(0,e7D.createHash)("md5").update(Y).digest("hex"),Q=["node-buffer",J,D.length,$.endpoint].join("-");return Promise.resolve(Q)}if(D instanceof jC.ReadStream&&D.path!=null)return new Promise(function(F,w){var Z=D3D.resolve(D.path);jC.stat(D.path,function(G,O){if(G){w(G);return}var U=["node-file",Z,O.size,O.mtime.getTime(),$.endpoint].join("-");F(U)})});return Promise.resolve(null)}});var _C=T((YyD,vC)=>{var uC="Expected a function",xC=NaN,J3D="[object Symbol]",Y3D=/^\s+|\s+$/g,Q3D=/^[-+]0x[0-9a-f]+$/i,F3D=/^0b[01]+$/i,w3D=/^0o[0-7]+$/i,Z3D=parseInt,G3D=typeof global=="object"&&global&&global.Object===Object&&global,O3D=typeof self=="object"&&self&&self.Object===Object&&self,U3D=G3D||O3D||Function("return this")(),q3D=Object.prototype,z3D=q3D.toString,B3D=Math.max,K3D=Math.min,kO=function(){return U3D.Date.now()};function W3D(D,$,X){var Y,J,Q,F,w,Z,G=0,O=!1,U=!1,z=!0;if(typeof D!="function")throw TypeError(uC);if($=SC($)||0,uJ(X))O=!!X.leading,U="maxWait"in X,Q=U?B3D(SC(X.maxWait)||0,$):Q,z="trailing"in X?!!X.trailing:z;function q(R){var P=Y,A=J;return Y=J=void 0,G=R,F=D.apply(A,P),F}function B(R){return G=R,w=setTimeout(L,$),O?q(R):F}function K(R){var P=R-Z,A=R-G,_=$-P;return U?K3D(_,Q-A):_}function M(R){var P=R-Z,A=R-G;return Z===void 0||P>=$||P<0||U&&A>=Q}function L(){var R=kO();if(M(R))return I(R);w=setTimeout(L,K(R))}function I(R){if(w=void 0,z&&Y)return q(R);return Y=J=void 0,F}function W(){if(w!==void 0)clearTimeout(w);G=0,Y=Z=J=w=void 0}function N(){return w===void 0?F:I(kO())}function V(){var R=kO(),P=M(R);if(Y=arguments,J=this,Z=R,P){if(w===void 0)return B(Z);if(U)return w=setTimeout(L,$),q(Z)}if(w===void 0)w=setTimeout(L,$);return F}return V.cancel=W,V.flush=N,V}function H3D(D,$,X){var Y=!0,J=!0;if(typeof D!="function")throw TypeError(uC);if(uJ(X))Y="leading"in X?!!X.leading:Y,J="trailing"in X?!!X.trailing:J;return W3D(D,$,{leading:Y,maxWait:$,trailing:J})}function uJ(D){var $=typeof D;return!!D&&($=="object"||$=="function")}function V3D(D){return!!D&&typeof D=="object"}function N3D(D){return typeof D=="symbol"||V3D(D)&&z3D.call(D)==J3D}function SC(D){if(typeof D=="number")return D;if(N3D(D))return xC;if(uJ(D)){var $=typeof D.valueOf=="function"?D.valueOf():D;D=uJ($)?$+"":$}if(typeof D!="string")return D===0?D:+D;D=D.replace(Y3D,"");var X=F3D.test(D);return X||w3D.test(D)?Z3D(D.slice(2),X?2:8):Q3D.test(D)?xC:+D}vC.exports=H3D});var nC=T((cC)=>{Object.defineProperty(cC,"__esModule",{value:!0});cC.default=void 0;var M3D=hC(p("http")),L3D=hC(p("https")),yC=p("stream"),I3D=p("url"),bC=A3D(_C());function A3D(D){return D&&D.__esModule?D:{default:D}}function gC(D){if(typeof WeakMap!="function")return null;var $=new WeakMap,X=new WeakMap;return(gC=function(Y){return Y?X:$})(D)}function hC(D,$){if(!$&&D&&D.__esModule)return D;if(D===null||typeof D!="object"&&typeof D!="function")return{default:D};var X=gC($);if(X&&X.has(D))return X.get(D);var Y={__proto__:null},J=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var Q in D)if(Q!=="default"&&{}.hasOwnProperty.call(D,Q)){var F=J?Object.getOwnPropertyDescriptor(D,Q):null;F&&(F.get||F.set)?Object.defineProperty(Y,Q,F):Y[Q]=D[Q]}return Y.default=D,X&&X.set(D,Y),Y}function R3D(D,$,X){return $=vJ($),j3D(D,mC()?Reflect.construct($,X||[],vJ(D).constructor):$.apply(D,X))}function j3D(D,$){if($&&(K9($)==="object"||typeof $==="function"))return $;else if($!==void 0)throw TypeError("Derived constructors may only return object or undefined");return E3D(D)}function E3D(D){if(D===void 0)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return D}function mC(){try{var D=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch($){}return(mC=function(){return!!D})()}function vJ(D){return vJ=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(X){return X.__proto__||Object.getPrototypeOf(X)},vJ(D)}function T3D(D,$){if(typeof $!=="function"&&$!==null)throw TypeError("Super expression must either be null or a function");if(D.prototype=Object.create($&&$.prototype,{constructor:{value:D,writable:!0,configurable:!0}}),Object.defineProperty(D,"prototype",{writable:!1}),$)fO(D,$)}function fO(D,$){return fO=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(Y,J){return Y.__proto__=J,Y},fO(D,$)}function kC(D,$){var X=Object.keys(D);if(Object.getOwnPropertySymbols){var Y=Object.getOwnPropertySymbols(D);$&&(Y=Y.filter(function(J){return Object.getOwnPropertyDescriptor(D,J).enumerable})),X.push.apply(X,Y)}return X}function r7(D){for(var $=1;$<arguments.length;$++){var X=arguments[$]!=null?arguments[$]:{};$%2?kC(Object(X),!0).forEach(function(Y){C3D(D,Y,X[Y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(D,Object.getOwnPropertyDescriptors(X)):kC(Object(X)).forEach(function(Y){Object.defineProperty(D,Y,Object.getOwnPropertyDescriptor(X,Y))})}return D}function C3D(D,$,X){if($=dC($),$ in D)Object.defineProperty(D,$,{value:X,enumerable:!0,configurable:!0,writable:!0});else D[$]=X;return D}function K9(D){return K9=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},K9(D)}function _J(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function fC(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,dC(Y.key),Y)}}function kJ(D,$,X){if($)fC(D.prototype,$);if(X)fC(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function dC(D){var $=P3D(D,"string");return K9($)=="symbol"?$:$+""}function P3D(D,$){if(K9(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(K9(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var QyD=cC.default=function(){function D(){var $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_J(this,D),this._requestOptions=$}return kJ(D,[{key:"createRequest",value:function(X,Y){return new x3D(X,Y,this._requestOptions)}},{key:"getName",value:function(){return"NodeHttpStack"}}])}(),x3D=function(){function D($,X,Y){_J(this,D),this._method=$,this._url=X,this._headers={},this._request=null,this._progressHandler=function(){},this._requestOptions=Y||{}}return kJ(D,[{key:"getMethod",value:function(){return this._method}},{key:"getURL",value:function(){return this._url}},{key:"setHeader",value:function(X,Y){this._headers[X]=Y}},{key:"getHeader",value:function(X){return this._headers[X]}},{key:"setProgressHandler",value:function(X){this._progressHandler=X}},{key:"send",value:function(){var X=this,Y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null;return new Promise(function(J,Q){var F=r7(r7(r7({},(0,I3D.parse)(X._url)),X._requestOptions),{},{method:X._method,headers:r7(r7({},X._requestOptions.headers||{}),X._headers)});if(Y!==null&&Y!==void 0&&Y.size)F.headers["Content-Length"]=Y.size;var w=F.protocol==="https:"?L3D:M3D;X._request=w.request(F);var Z=X._request;if(Z.on("response",function(G){var O=[];G.on("data",function(U){O.push(U)}),G.on("end",function(){var U=Buffer.concat(O).toString("utf8");J(new S3D(G,U))})}),Z.on("error",function(G){Q(G)}),Y instanceof yC.Readable)Y.pipe(new u3D(X._progressHandler)).pipe(Z);else if(Y instanceof Uint8Array)v3D(Z,Y,X._progressHandler);else Z.end(Y)})}},{key:"abort",value:function(){if(this._request!==null)this._request.abort();return Promise.resolve()}},{key:"getUnderlyingObject",value:function(){return this._request}}])}(),S3D=function(){function D($,X){_J(this,D),this._response=$,this._body=X}return kJ(D,[{key:"getStatus",value:function(){return this._response.statusCode}},{key:"getHeader",value:function(X){return this._response.headers[X.toLowerCase()]}},{key:"getBody",value:function(){return this._body}},{key:"getUnderlyingObject",value:function(){return this._response}}])}(),u3D=function(D){function $(X){var Y;return _J(this,$),Y=R3D(this,$),Y._onprogress=(0,bC.default)(X,100,{leading:!0,trailing:!1}),Y._position=0,Y}return T3D($,D),kJ($,[{key:"_transform",value:function(Y,J,Q){this._position+=Y.length,this._onprogress(this._position),Q(null,Y)}}])}(yC.Transform),v3D=function($,X,Y){Y=(0,bC.default)(Y,100,{leading:!0,trailing:!1});var J=0;function Q(){var F=Math.min($.writableHighWaterMark,X.length-J),w=X.subarray(J,J+F);J+=w.length;var Z=$.write(w);if(!Z)$.once("drain",Q),Y(J);else if(J<X.length)Q();else $.end()}Q()}});var iC=T((_3D)=>{_3D.expectReceive=function(D,$,X){var Y;if(X.root(D,$,X),Y=this.message,D.hasOwnProperty("expected"))Y+=" Expected "+D.expected+".";if(D.hasOwnProperty("received"))Y+=" Received: "+D.received+".";this.message=Y};_3D.root=function(D,$,X){var Y=this,J,Q={stackLength:Error.stackTraceLimit,rootOnly:!0},F="",w=Error.stackTraceLimit,Z;function G(){Z[0]=Y.toString(),Y.stack=Z.join(`
122
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var Q=!0,F=!1,w;return{s:function(){X=X.call(D)},n:function(){var G=X.next();return Q=G.done,G},e:function(G){F=!0,w=G},f:function(){try{if(!Q&&X.return!=null)X.return()}finally{if(F)throw w}}}}function sT(D,$){if(!D)return;if(typeof D==="string")return cT(D,$);var X=Object.prototype.toString.call(D).slice(8,-1);if(X==="Object"&&D.constructor)X=D.constructor.name;if(X==="Map"||X==="Set")return Array.from(D);if(X==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(X))return cT(D,$)}function cT(D,$){if($==null||$>D.length)$=D.length;for(var X=0,Y=Array($);X<$;X++)Y[X]=D[X];return Y}function lT(D,$){var X=Object.keys(D);if(Object.getOwnPropertySymbols){var Y=Object.getOwnPropertySymbols(D);$&&(Y=Y.filter(function(J){return Object.getOwnPropertyDescriptor(D,J).enumerable})),X.push.apply(X,Y)}return X}function z9(D){for(var $=1;$<arguments.length;$++){var X=arguments[$]!=null?arguments[$]:{};$%2?lT(Object(X),!0).forEach(function(Y){M7D(D,Y,X[Y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(D,Object.getOwnPropertyDescriptors(X)):lT(Object(X)).forEach(function(Y){Object.defineProperty(D,Y,Object.getOwnPropertyDescriptor(X,Y))})}return D}function M7D(D,$,X){if($=eT($),$ in D)Object.defineProperty(D,$,{value:X,enumerable:!0,configurable:!0,writable:!0});else D[$]=X;return D}function L7D(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function nT(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,eT(Y.key),Y)}}function I7D(D,$,X){if($)nT(D.prototype,$);if(X)nT(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function eT(D){var $=A7D(D,"string");return d4($)=="symbol"?$:$+""}function A7D(D,$){if(d4(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(d4(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var PJ="tus-v1",xJ="ietf-draft-03",l7="ietf-draft-05",R7D={endpoint:null,uploadUrl:null,metadata:{},metadataForPartialUploads:{},fingerprint:null,uploadSize:null,onProgress:null,onChunkComplete:null,onSuccess:null,onError:null,onUploadUrlAvailable:null,overridePatchMethod:!1,headers:{},addRequestId:!1,onBeforeRequest:null,onAfterResponse:null,onShouldRetry:$C,chunkSize:Number.POSITIVE_INFINITY,retryDelays:[0,1000,3000,5000],parallelUploads:1,parallelUploadBoundaries:null,storeFingerprintForResuming:!0,removeFingerprintOnSuccess:!1,uploadLengthDeferred:!1,uploadDataDuringCreation:!1,urlStorage:null,fileReader:null,httpStack:null,protocol:PJ},DC=function(){function D($,X){if(L7D(this,D),"resume"in X)console.log("tus: The `resume` option has been removed in tus-js-client v2. Please use the URL storage API instead.");this.options=X,this.options.chunkSize=Number(this.options.chunkSize),this._urlStorage=this.options.urlStorage,this.file=$,this.url=null,this._req=null,this._fingerprint=null,this._urlStorageKey=null,this._offset=null,this._aborted=!1,this._size=null,this._source=null,this._retryAttempt=0,this._retryTimeout=null,this._offsetBeforeRetry=0,this._parallelUploads=null,this._parallelUploadUrls=null}return I7D(D,[{key:"findPreviousUploads",value:function(){var X=this;return this.options.fingerprint(this.file,this.options).then(function(Y){return X._urlStorage.findUploadsByFingerprint(Y)})}},{key:"resumeFromPreviousUpload",value:function(X){this.url=X.uploadUrl||null,this._parallelUploadUrls=X.parallelUploadUrls||null,this._urlStorageKey=X.urlStorageKey}},{key:"start",value:function(){var X=this,Y=this.file;if(!Y){this._emitError(Error("tus: no file or stream to upload provided"));return}if(![PJ,xJ,l7].includes(this.options.protocol)){this._emitError(Error("tus: unsupported protocol ".concat(this.options.protocol)));return}if(!this.options.endpoint&&!this.options.uploadUrl&&!this.url){this._emitError(Error("tus: neither an endpoint or an upload URL is provided"));return}var J=this.options.retryDelays;if(J!=null&&Object.prototype.toString.call(J)!=="[object Array]"){this._emitError(Error("tus: the `retryDelays` option must either be an array or null"));return}if(this.options.parallelUploads>1)for(var Q=0,F=["uploadUrl","uploadSize","uploadLengthDeferred"];Q<F.length;Q++){var w=F[Q];if(this.options[w]){this._emitError(Error("tus: cannot use the ".concat(w," option when parallelUploads is enabled")));return}}if(this.options.parallelUploadBoundaries){if(this.options.parallelUploads<=1){this._emitError(Error("tus: cannot use the `parallelUploadBoundaries` option when `parallelUploads` is disabled"));return}if(this.options.parallelUploads!==this.options.parallelUploadBoundaries.length){this._emitError(Error("tus: the `parallelUploadBoundaries` must have the same length as the value of `parallelUploads`"));return}}this.options.fingerprint(Y,this.options).then(function(Z){if(Z==null)(0,m4.log)("No fingerprint was calculated meaning that the upload cannot be stored in the URL storage.");else(0,m4.log)("Calculated fingerprint: ".concat(Z));if(X._fingerprint=Z,X._source)return X._source;return X.options.fileReader.openFile(Y,X.options.chunkSize)}).then(function(Z){if(X._source=Z,X.options.uploadLengthDeferred)X._size=null;else if(X.options.uploadSize!=null){if(X._size=Number(X.options.uploadSize),Number.isNaN(X._size)){X._emitError(Error("tus: cannot convert `uploadSize` option into a number"));return}}else if(X._size=X._source.size,X._size==null){X._emitError(Error("tus: cannot automatically derive upload's size from input. Specify it manually using the `uploadSize` option or use the `uploadLengthDeferred` option"));return}if(X.options.parallelUploads>1||X._parallelUploadUrls!=null)X._startParallelUpload();else X._startSingleUpload()}).catch(function(Z){X._emitError(Z)})}},{key:"_startParallelUpload",value:function(){var X,Y=this,J=this._size,Q=0;this._parallelUploads=[];var F=this._parallelUploadUrls!=null?this._parallelUploadUrls.length:this.options.parallelUploads,w=(X=this.options.parallelUploadBoundaries)!==null&&X!==void 0?X:E7D(this._source.size,F);if(this._parallelUploadUrls)w.forEach(function(O,U){O.uploadUrl=Y._parallelUploadUrls[U]||null});this._parallelUploadUrls=Array(w.length);var Z=w.map(function(O,U){var z=0;return Y._source.slice(O.start,O.end).then(function(q){var B=q.value;return new Promise(function(K,M){var L=z9(z9({},Y.options),{},{uploadUrl:O.uploadUrl||null,storeFingerprintForResuming:!1,removeFingerprintOnSuccess:!1,parallelUploads:1,parallelUploadBoundaries:null,metadata:Y.options.metadataForPartialUploads,headers:z9(z9({},Y.options.headers),{},{"Upload-Concat":"partial"}),onSuccess:K,onError:M,onProgress:function(N){Q=Q-z+N,z=N,Y._emitProgress(Q,J)},onUploadUrlAvailable:function(){if(Y._parallelUploadUrls[U]=I.url,Y._parallelUploadUrls.filter(function(N){return Boolean(N)}).length===w.length)Y._saveUploadInUrlStorage()}}),I=new D(B,L);I.start(),Y._parallelUploads.push(I)})})}),G;Promise.all(Z).then(function(){G=Y._openRequest("POST",Y.options.endpoint),G.setHeader("Upload-Concat","final;".concat(Y._parallelUploadUrls.join(" ")));var O=iT(Y.options.metadata);if(O!=="")G.setHeader("Upload-Metadata",O);return Y._sendRequest(G,null)}).then(function(O){if(!B9(O.getStatus(),200)){Y._emitHttpError(G,O,"tus: unexpected response while creating upload");return}var U=O.getHeader("Location");if(U==null){Y._emitHttpError(G,O,"tus: invalid or missing Location header");return}Y.url=aT(Y.options.endpoint,U),(0,m4.log)("Created upload at ".concat(Y.url)),Y._emitSuccess(O)}).catch(function(O){Y._emitError(O)})}},{key:"_startSingleUpload",value:function(){if(this._aborted=!1,this.url!=null){(0,m4.log)("Resuming upload from previous URL: ".concat(this.url)),this._resumeUpload();return}if(this.options.uploadUrl!=null){(0,m4.log)("Resuming upload from provided URL: ".concat(this.options.uploadUrl)),this.url=this.options.uploadUrl,this._resumeUpload();return}(0,m4.log)("Creating a new upload"),this._createUpload()}},{key:"abort",value:function(X){var Y=this;if(this._parallelUploads!=null){var J=N7D(this._parallelUploads),Q;try{for(J.s();!(Q=J.n()).done;){var F=Q.value;F.abort(X)}}catch(w){J.e(w)}finally{J.f()}}if(this._req!==null)this._req.abort();if(this._aborted=!0,this._retryTimeout!=null)clearTimeout(this._retryTimeout),this._retryTimeout=null;if(!X||this.url==null)return Promise.resolve();return D.terminate(this.url,this.options).then(function(){return Y._removeFromUrlStorage()})}},{key:"_emitHttpError",value:function(X,Y,J,Q){this._emitError(new CJ.default(J,Q,X,Y))}},{key:"_emitError",value:function(X){var Y=this;if(this._aborted)return;if(this.options.retryDelays!=null){var J=this._offset!=null&&this._offset>this._offsetBeforeRetry;if(J)this._retryAttempt=0;if(oT(X,this._retryAttempt,this.options)){var Q=this.options.retryDelays[this._retryAttempt++];this._offsetBeforeRetry=this._offset,this._retryTimeout=setTimeout(function(){Y.start()},Q);return}}if(typeof this.options.onError==="function")this.options.onError(X);else throw X}},{key:"_emitSuccess",value:function(X){if(this.options.removeFingerprintOnSuccess)this._removeFromUrlStorage();if(typeof this.options.onSuccess==="function")this.options.onSuccess({lastResponse:X})}},{key:"_emitProgress",value:function(X,Y){if(typeof this.options.onProgress==="function")this.options.onProgress(X,Y)}},{key:"_emitChunkComplete",value:function(X,Y,J){if(typeof this.options.onChunkComplete==="function")this.options.onChunkComplete(X,Y,J)}},{key:"_createUpload",value:function(){var X=this;if(!this.options.endpoint){this._emitError(Error("tus: unable to create upload because no endpoint is provided"));return}var Y=this._openRequest("POST",this.options.endpoint);if(this.options.uploadLengthDeferred)Y.setHeader("Upload-Defer-Length","1");else Y.setHeader("Upload-Length","".concat(this._size));var J=iT(this.options.metadata);if(J!=="")Y.setHeader("Upload-Metadata",J);var Q;if(this.options.uploadDataDuringCreation&&!this.options.uploadLengthDeferred)this._offset=0,Q=this._addChunkToRequest(Y);else{if(this.options.protocol===xJ||this.options.protocol===l7)Y.setHeader("Upload-Complete","?0");Q=this._sendRequest(Y,null)}Q.then(function(F){if(!B9(F.getStatus(),200)){X._emitHttpError(Y,F,"tus: unexpected response while creating upload");return}var w=F.getHeader("Location");if(w==null){X._emitHttpError(Y,F,"tus: invalid or missing Location header");return}if(X.url=aT(X.options.endpoint,w),(0,m4.log)("Created upload at ".concat(X.url)),typeof X.options.onUploadUrlAvailable==="function")X.options.onUploadUrlAvailable();if(X._size===0){X._emitSuccess(F),X._source.close();return}X._saveUploadInUrlStorage().then(function(){if(X.options.uploadDataDuringCreation)X._handleUploadResponse(Y,F);else X._offset=0,X._performUpload()})}).catch(function(F){X._emitHttpError(Y,null,"tus: failed to create upload",F)})}},{key:"_resumeUpload",value:function(){var X=this,Y=this._openRequest("HEAD",this.url),J=this._sendRequest(Y,null);J.then(function(Q){var F=Q.getStatus();if(!B9(F,200)){if(F===423){X._emitHttpError(Y,Q,"tus: upload is currently locked; retry later");return}if(B9(F,400))X._removeFromUrlStorage();if(!X.options.endpoint){X._emitHttpError(Y,Q,"tus: unable to resume upload (new upload cannot be created without an endpoint)");return}X.url=null,X._createUpload();return}var w=Number.parseInt(Q.getHeader("Upload-Offset"),10);if(Number.isNaN(w)){X._emitHttpError(Y,Q,"tus: invalid or missing offset value");return}var Z=Number.parseInt(Q.getHeader("Upload-Length"),10);if(Number.isNaN(Z)&&!X.options.uploadLengthDeferred&&X.options.protocol===PJ){X._emitHttpError(Y,Q,"tus: invalid or missing length value");return}if(typeof X.options.onUploadUrlAvailable==="function")X.options.onUploadUrlAvailable();X._saveUploadInUrlStorage().then(function(){if(w===Z){X._emitProgress(Z,Z),X._emitSuccess(Q);return}X._offset=w,X._performUpload()})}).catch(function(Q){X._emitHttpError(Y,null,"tus: failed to resume upload",Q)})}},{key:"_performUpload",value:function(){var X=this;if(this._aborted)return;var Y;if(this.options.overridePatchMethod)Y=this._openRequest("POST",this.url),Y.setHeader("X-HTTP-Method-Override","PATCH");else Y=this._openRequest("PATCH",this.url);Y.setHeader("Upload-Offset","".concat(this._offset));var J=this._addChunkToRequest(Y);J.then(function(Q){if(!B9(Q.getStatus(),200)){X._emitHttpError(Y,Q,"tus: unexpected response while uploading chunk");return}X._handleUploadResponse(Y,Q)}).catch(function(Q){if(X._aborted)return;X._emitHttpError(Y,null,"tus: failed to upload chunk at offset ".concat(X._offset),Q)})}},{key:"_addChunkToRequest",value:function(X){var Y=this,J=this._offset,Q=this._offset+this.options.chunkSize;if(X.setProgressHandler(function(F){Y._emitProgress(J+F,Y._size)}),this.options.protocol===PJ)X.setHeader("Content-Type","application/offset+octet-stream");else if(this.options.protocol===l7)X.setHeader("Content-Type","application/partial-upload");if((Q===Number.POSITIVE_INFINITY||Q>this._size)&&!this.options.uploadLengthDeferred)Q=this._size;return this._source.slice(J,Q).then(function(F){var{value:w,done:Z}=F,G=w!==null&&w!==void 0&&w.size?w.size:0;if(Y.options.uploadLengthDeferred&&Z)Y._size=Y._offset+G,X.setHeader("Upload-Length","".concat(Y._size));var O=Y._offset+G;if(!Y.options.uploadLengthDeferred&&Z&&O!==Y._size)return Promise.reject(Error("upload was configured with a size of ".concat(Y._size," bytes, but the source is done after ").concat(O," bytes")));if(w===null)return Y._sendRequest(X);if(Y.options.protocol===xJ||Y.options.protocol===l7)X.setHeader("Upload-Complete",Z?"?1":"?0");return Y._emitProgress(Y._offset,Y._size),Y._sendRequest(X,w)})}},{key:"_handleUploadResponse",value:function(X,Y){var J=Number.parseInt(Y.getHeader("Upload-Offset"),10);if(Number.isNaN(J)){this._emitHttpError(X,Y,"tus: invalid or missing offset value");return}if(this._emitProgress(J,this._size),this._emitChunkComplete(J-this._offset,J,this._size),this._offset=J,J===this._size){this._emitSuccess(Y),this._source.close();return}this._performUpload()}},{key:"_openRequest",value:function(X,Y){var J=pT(X,Y,this.options);return this._req=J,J}},{key:"_removeFromUrlStorage",value:function(){var X=this;if(!this._urlStorageKey)return;this._urlStorage.removeUpload(this._urlStorageKey).catch(function(Y){X._emitError(Y)}),this._urlStorageKey=null}},{key:"_saveUploadInUrlStorage",value:function(){var X=this;if(!this.options.storeFingerprintForResuming||!this._fingerprint||this._urlStorageKey!==null)return Promise.resolve();var Y={size:this._size,metadata:this.options.metadata,creationTime:new Date().toString()};if(this._parallelUploads)Y.parallelUploadUrls=this._parallelUploadUrls;else Y.uploadUrl=this.url;return this._urlStorage.addUpload(this._fingerprint,Y).then(function(J){X._urlStorageKey=J})}},{key:"_sendRequest",value:function(X){var Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;return rT(X,Y,this.options)}}],[{key:"terminate",value:function(X){var Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},J=pT("DELETE",X,Y);return rT(J,null,Y).then(function(Q){if(Q.getStatus()===204)return;throw new CJ.default("tus: unexpected response while terminating upload",null,J,Q)}).catch(function(Q){if(!(Q instanceof CJ.default))Q=new CJ.default("tus: failed to terminate upload",Q,J,null);if(!oT(Q,0,Y))throw Q;var F=Y.retryDelays[0],w=Y.retryDelays.slice(1),Z=z9(z9({},Y),{},{retryDelays:w});return new Promise(function(G){return setTimeout(G,F)}).then(function(){return D.terminate(X,Z)})})}}])}();function iT(D){return Object.entries(D).map(function($){var X=tT($,2),Y=X[0],J=X[1];return"".concat(Y," ").concat(q7D.Base64.encode(String(J)))}).join(",")}function B9(D,$){return D>=$&&D<$+100}function pT(D,$,X){var Y=X.httpStack.createRequest(D,$);if(X.protocol===xJ)Y.setHeader("Upload-Draft-Interop-Version","5");else if(X.protocol===l7)Y.setHeader("Upload-Draft-Interop-Version","6");else Y.setHeader("Tus-Resumable","1.0.0");var J=X.headers||{};for(var Q=0,F=Object.entries(J);Q<F.length;Q++){var w=tT(F[Q],2),Z=w[0],G=w[1];Y.setHeader(Z,G)}if(X.addRequestId){var O=(0,B7D.default)();Y.setHeader("X-Request-ID",O)}return Y}function rT(D,$,X){return PO.apply(this,arguments)}function PO(){return PO=K7D(CO().mark(function D($,X,Y){var J;return CO().wrap(function(F){while(!0)switch(F.prev=F.next){case 0:if(typeof Y.onBeforeRequest!=="function"){F.next=3;break}return F.next=3,Y.onBeforeRequest($);case 3:return F.next=5,$.send(X);case 5:if(J=F.sent,typeof Y.onAfterResponse!=="function"){F.next=9;break}return F.next=9,Y.onAfterResponse($,J);case 9:return F.abrupt("return",J);case 10:case"end":return F.stop()}},D)})),PO.apply(this,arguments)}function j7D(){var D=!0;if(typeof navigator<"u"&&navigator.onLine===!1)D=!1;return D}function oT(D,$,X){if(X.retryDelays==null||$>=X.retryDelays.length||D.originalRequest==null)return!1;if(X&&typeof X.onShouldRetry==="function")return X.onShouldRetry(D,$,X);return $C(D)}function $C(D){var $=D.originalResponse?D.originalResponse.getStatus():0;return(!B9($,400)||$===409||$===423)&&j7D()}function aT(D,$){return new z7D.default($,D).toString()}function E7D(D,$){var X=Math.floor(D/$),Y=[];for(var J=0;J<$;J++)Y.push({start:X*J,end:X*(J+1)});return Y[$-1].end=D,Y}DC.defaultOptions=R7D;var pfD=XC.default=DC});var FC=T((ofD,QC)=>{var S$=(D)=>D!==null&&typeof D==="object"&&typeof D.pipe==="function";S$.writable=(D)=>S$(D)&&D.writable!==!1&&typeof D._write==="function"&&typeof D._writableState==="object";S$.readable=(D)=>S$(D)&&D.readable!==!1&&typeof D._read==="function"&&typeof D._readableState==="object";S$.duplex=(D)=>S$.writable(D)&&S$.readable(D);S$.transform=(D)=>S$.duplex(D)&&typeof D._transform==="function";QC.exports=S$});var OC=T((ZC)=>{Object.defineProperty(ZC,"__esModule",{value:!0});ZC.default=void 0;function n7(D){return n7=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},n7(D)}function T7D(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function wC(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,P7D(Y.key),Y)}}function C7D(D,$,X){if($)wC(D.prototype,$);if(X)wC(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function P7D(D){var $=x7D(D,"string");return n7($)=="symbol"?$:$+""}function x7D(D,$){if(n7(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(n7(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var afD=ZC.default=function(){function D($){T7D(this,D),this._buffer=$,this.size=$.length}return C7D(D,[{key:"slice",value:function(X,Y){var J=this._buffer.slice(X,Y);J.size=J.length;var Q=Y>=this.size;return Promise.resolve({value:J,done:Q})}},{key:"close",value:function(){}}])}()});var KC=T((BC)=>{Object.defineProperty(BC,"__esModule",{value:!0});BC.default=f7D;var zC=p("fs");function c4(D){return c4=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},c4(D)}function SO(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */SO=function(){return $};var D,$={},X=Object.prototype,Y=X.hasOwnProperty,J=Object.defineProperty||function(j,x,u){j[x]=u.value},Q=typeof Symbol=="function"?Symbol:{},F=Q.iterator||"@@iterator",w=Q.asyncIterator||"@@asyncIterator",Z=Q.toStringTag||"@@toStringTag";function G(j,x,u){return Object.defineProperty(j,x,{value:u,enumerable:!0,configurable:!0,writable:!0}),j[x]}try{G({},"")}catch(j){G=function(u,y,d){return u[y]=d}}function O(j,x,u,y){var d=x&&x.prototype instanceof L?x:L,b=Object.create(d.prototype),a=new l(y||[]);return J(b,"_invoke",{value:v(j,u,a)}),b}function U(j,x,u){try{return{type:"normal",arg:j.call(x,u)}}catch(y){return{type:"throw",arg:y}}}$.wrap=O;var z="suspendedStart",q="suspendedYield",B="executing",K="completed",M={};function L(){}function I(){}function W(){}var N={};G(N,F,function(){return this});var V=Object.getPrototypeOf,R=V&&V(V(f([])));R&&R!==X&&Y.call(R,F)&&(N=R);var C=W.prototype=L.prototype=Object.create(N);function A(j){["next","throw","return"].forEach(function(x){G(j,x,function(u){return this._invoke(x,u)})})}function _(j,x){function u(d,b,a,c){var n=U(j[d],j,b);if(n.type!=="throw"){var YD=n.arg,P=YD.value;return P&&c4(P)=="object"&&Y.call(P,"__await")?x.resolve(P.__await).then(function(E){u("next",E,a,c)},function(E){u("throw",E,a,c)}):x.resolve(P).then(function(E){YD.value=E,a(YD)},function(E){return u("throw",E,a,c)})}c(n.arg)}var y;J(this,"_invoke",{value:function(b,a){function c(){return new x(function(n,YD){u(b,a,n,YD)})}return y=y?y.then(c,c):c()}})}function v(j,x,u){var y=z;return function(d,b){if(y===B)throw Error("Generator is already running");if(y===K){if(d==="throw")throw b;return{value:D,done:!0}}for(u.method=d,u.arg=b;;){var a=u.delegate;if(a){var c=S(a,u);if(c){if(c===M)continue;return c}}if(u.method==="next")u.sent=u._sent=u.arg;else if(u.method==="throw"){if(y===z)throw y=K,u.arg;u.dispatchException(u.arg)}else u.method==="return"&&u.abrupt("return",u.arg);y=B;var n=U(j,x,u);if(n.type==="normal"){if(y=u.done?K:q,n.arg===M)continue;return{value:n.arg,done:u.done}}n.type==="throw"&&(y=K,u.method="throw",u.arg=n.arg)}}}function S(j,x){var u=x.method,y=j.iterator[u];if(y===D)return x.delegate=null,u==="throw"&&j.iterator.return&&(x.method="return",x.arg=D,S(j,x),x.method==="throw")||u!=="return"&&(x.method="throw",x.arg=TypeError("The iterator does not provide a '"+u+"' method")),M;var d=U(y,j.iterator,x.arg);if(d.type==="throw")return x.method="throw",x.arg=d.arg,x.delegate=null,M;var b=d.arg;return b?b.done?(x[j.resultName]=b.value,x.next=j.nextLoc,x.method!=="return"&&(x.method="next",x.arg=D),x.delegate=null,M):b:(x.method="throw",x.arg=TypeError("iterator result is not an object"),x.delegate=null,M)}function h(j){var x={tryLoc:j[0]};1 in j&&(x.catchLoc=j[1]),2 in j&&(x.finallyLoc=j[2],x.afterLoc=j[3]),this.tryEntries.push(x)}function g(j){var x=j.completion||{};x.type="normal",delete x.arg,j.completion=x}function l(j){this.tryEntries=[{tryLoc:"root"}],j.forEach(h,this),this.reset(!0)}function f(j){if(j||j===""){var x=j[F];if(x)return x.call(j);if(typeof j.next=="function")return j;if(!isNaN(j.length)){var u=-1,y=function d(){for(;++u<j.length;)if(Y.call(j,u))return d.value=j[u],d.done=!1,d;return d.value=D,d.done=!0,d};return y.next=y}}throw TypeError(c4(j)+" is not iterable")}return I.prototype=W,J(C,"constructor",{value:W,configurable:!0}),J(W,"constructor",{value:I,configurable:!0}),I.displayName=G(W,Z,"GeneratorFunction"),$.isGeneratorFunction=function(j){var x=typeof j=="function"&&j.constructor;return!!x&&(x===I||(x.displayName||x.name)==="GeneratorFunction")},$.mark=function(j){return Object.setPrototypeOf?Object.setPrototypeOf(j,W):(j.__proto__=W,G(j,Z,"GeneratorFunction")),j.prototype=Object.create(C),j},$.awrap=function(j){return{__await:j}},A(_.prototype),G(_.prototype,w,function(){return this}),$.AsyncIterator=_,$.async=function(j,x,u,y,d){d===void 0&&(d=Promise);var b=new _(O(j,x,u,y),d);return $.isGeneratorFunction(x)?b:b.next().then(function(a){return a.done?a.value:b.next()})},A(C),G(C,Z,"Generator"),G(C,F,function(){return this}),G(C,"toString",function(){return"[object Generator]"}),$.keys=function(j){var x=Object(j),u=[];for(var y in x)u.push(y);return u.reverse(),function d(){for(;u.length;){var b=u.pop();if(b in x)return d.value=b,d.done=!1,d}return d.done=!0,d}},$.values=f,l.prototype={constructor:l,reset:function(x){if(this.prev=0,this.next=0,this.sent=this._sent=D,this.done=!1,this.delegate=null,this.method="next",this.arg=D,this.tryEntries.forEach(g),!x)for(var u in this)u.charAt(0)==="t"&&Y.call(this,u)&&!isNaN(+u.slice(1))&&(this[u]=D)},stop:function(){this.done=!0;var x=this.tryEntries[0].completion;if(x.type==="throw")throw x.arg;return this.rval},dispatchException:function(x){if(this.done)throw x;var u=this;function y(YD,P){return a.type="throw",a.arg=x,u.next=YD,P&&(u.method="next",u.arg=D),!!P}for(var d=this.tryEntries.length-1;d>=0;--d){var b=this.tryEntries[d],a=b.completion;if(b.tryLoc==="root")return y("end");if(b.tryLoc<=this.prev){var c=Y.call(b,"catchLoc"),n=Y.call(b,"finallyLoc");if(c&&n){if(this.prev<b.catchLoc)return y(b.catchLoc,!0);if(this.prev<b.finallyLoc)return y(b.finallyLoc)}else if(c){if(this.prev<b.catchLoc)return y(b.catchLoc,!0)}else{if(!n)throw Error("try statement without catch or finally");if(this.prev<b.finallyLoc)return y(b.finallyLoc)}}}},abrupt:function(x,u){for(var y=this.tryEntries.length-1;y>=0;--y){var d=this.tryEntries[y];if(d.tryLoc<=this.prev&&Y.call(d,"finallyLoc")&&this.prev<d.finallyLoc){var b=d;break}}b&&(x==="break"||x==="continue")&&b.tryLoc<=u&&u<=b.finallyLoc&&(b=null);var a=b?b.completion:{};return a.type=x,a.arg=u,b?(this.method="next",this.next=b.finallyLoc,M):this.complete(a)},complete:function(x,u){if(x.type==="throw")throw x.arg;return x.type==="break"||x.type==="continue"?this.next=x.arg:x.type==="return"?(this.rval=this.arg=x.arg,this.method="return",this.next="end"):x.type==="normal"&&u&&(this.next=u),M},finish:function(x){for(var u=this.tryEntries.length-1;u>=0;--u){var y=this.tryEntries[u];if(y.finallyLoc===x)return this.complete(y.completion,y.afterLoc),g(y),M}},catch:function(x){for(var u=this.tryEntries.length-1;u>=0;--u){var y=this.tryEntries[u];if(y.tryLoc===x){var d=y.completion;if(d.type==="throw"){var b=d.arg;g(y)}return b}}throw Error("illegal catch attempt")},delegateYield:function(x,u,y){return this.delegate={iterator:f(x),resultName:u,nextLoc:y},this.method==="next"&&(this.arg=D),M}},$}function S7D(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function UC(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,v7D(Y.key),Y)}}function u7D(D,$,X){if($)UC(D.prototype,$);if(X)UC(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function v7D(D){var $=_7D(D,"string");return c4($)=="symbol"?$:$+""}function _7D(D,$){if(c4(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(c4(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}function qC(D,$,X,Y,J,Q,F){try{var w=D[Q](F),Z=w.value}catch(G){X(G);return}if(w.done)$(Z);else Promise.resolve(Z).then(Y,J)}function k7D(D){return function(){var $=this,X=arguments;return new Promise(function(Y,J){var Q=D.apply($,X);function F(Z){qC(Q,Y,J,F,w,"next",Z)}function w(Z){qC(Q,Y,J,F,w,"throw",Z)}F(void 0)})}}function f7D(D){return uO.apply(this,arguments)}function uO(){return uO=k7D(SO().mark(function D($){var X,Y,J,Q,F,w,Z;return SO().wrap(function(O){while(!0)switch(O.prev=O.next){case 0:return Y=$.path.toString(),O.next=3,zC.promises.stat(Y);case 3:return J=O.sent,Q=J.size,F=(X=$.start)!==null&&X!==void 0?X:0,w=Number.isFinite($.end)?$.end+1:Q,Z=w-F,O.abrupt("return",new y7D($,Y,Z));case 9:case"end":return O.stop()}},D)})),uO.apply(this,arguments)}var y7D=function(){function D($,X,Y){S7D(this,D),this._stream=$,this._path=X,this.size=Y}return u7D(D,[{key:"slice",value:function(X,Y){var J,Q=(J=this._stream.start)!==null&&J!==void 0?J:0,F=(0,zC.createReadStream)(this._path,{start:Q+X,end:Q+Y-1,autoClose:!0});F.size=Math.min(Y-X,this.size);var w=F.size>=this.size;return Promise.resolve({value:F,done:w})}},{key:"close",value:function(){this._stream.destroy()}}])}()});var _O=T((NC)=>{Object.defineProperty(NC,"__esModule",{value:!0});NC.default=void 0;function l4(D){return l4=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},l4(D)}function i7(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */i7=function(){return $};var D,$={},X=Object.prototype,Y=X.hasOwnProperty,J=Object.defineProperty||function(j,x,u){j[x]=u.value},Q=typeof Symbol=="function"?Symbol:{},F=Q.iterator||"@@iterator",w=Q.asyncIterator||"@@asyncIterator",Z=Q.toStringTag||"@@toStringTag";function G(j,x,u){return Object.defineProperty(j,x,{value:u,enumerable:!0,configurable:!0,writable:!0}),j[x]}try{G({},"")}catch(j){G=function(u,y,d){return u[y]=d}}function O(j,x,u,y){var d=x&&x.prototype instanceof L?x:L,b=Object.create(d.prototype),a=new l(y||[]);return J(b,"_invoke",{value:v(j,u,a)}),b}function U(j,x,u){try{return{type:"normal",arg:j.call(x,u)}}catch(y){return{type:"throw",arg:y}}}$.wrap=O;var z="suspendedStart",q="suspendedYield",B="executing",K="completed",M={};function L(){}function I(){}function W(){}var N={};G(N,F,function(){return this});var V=Object.getPrototypeOf,R=V&&V(V(f([])));R&&R!==X&&Y.call(R,F)&&(N=R);var C=W.prototype=L.prototype=Object.create(N);function A(j){["next","throw","return"].forEach(function(x){G(j,x,function(u){return this._invoke(x,u)})})}function _(j,x){function u(d,b,a,c){var n=U(j[d],j,b);if(n.type!=="throw"){var YD=n.arg,P=YD.value;return P&&l4(P)=="object"&&Y.call(P,"__await")?x.resolve(P.__await).then(function(E){u("next",E,a,c)},function(E){u("throw",E,a,c)}):x.resolve(P).then(function(E){YD.value=E,a(YD)},function(E){return u("throw",E,a,c)})}c(n.arg)}var y;J(this,"_invoke",{value:function(b,a){function c(){return new x(function(n,YD){u(b,a,n,YD)})}return y=y?y.then(c,c):c()}})}function v(j,x,u){var y=z;return function(d,b){if(y===B)throw Error("Generator is already running");if(y===K){if(d==="throw")throw b;return{value:D,done:!0}}for(u.method=d,u.arg=b;;){var a=u.delegate;if(a){var c=S(a,u);if(c){if(c===M)continue;return c}}if(u.method==="next")u.sent=u._sent=u.arg;else if(u.method==="throw"){if(y===z)throw y=K,u.arg;u.dispatchException(u.arg)}else u.method==="return"&&u.abrupt("return",u.arg);y=B;var n=U(j,x,u);if(n.type==="normal"){if(y=u.done?K:q,n.arg===M)continue;return{value:n.arg,done:u.done}}n.type==="throw"&&(y=K,u.method="throw",u.arg=n.arg)}}}function S(j,x){var u=x.method,y=j.iterator[u];if(y===D)return x.delegate=null,u==="throw"&&j.iterator.return&&(x.method="return",x.arg=D,S(j,x),x.method==="throw")||u!=="return"&&(x.method="throw",x.arg=TypeError("The iterator does not provide a '"+u+"' method")),M;var d=U(y,j.iterator,x.arg);if(d.type==="throw")return x.method="throw",x.arg=d.arg,x.delegate=null,M;var b=d.arg;return b?b.done?(x[j.resultName]=b.value,x.next=j.nextLoc,x.method!=="return"&&(x.method="next",x.arg=D),x.delegate=null,M):b:(x.method="throw",x.arg=TypeError("iterator result is not an object"),x.delegate=null,M)}function h(j){var x={tryLoc:j[0]};1 in j&&(x.catchLoc=j[1]),2 in j&&(x.finallyLoc=j[2],x.afterLoc=j[3]),this.tryEntries.push(x)}function g(j){var x=j.completion||{};x.type="normal",delete x.arg,j.completion=x}function l(j){this.tryEntries=[{tryLoc:"root"}],j.forEach(h,this),this.reset(!0)}function f(j){if(j||j===""){var x=j[F];if(x)return x.call(j);if(typeof j.next=="function")return j;if(!isNaN(j.length)){var u=-1,y=function d(){for(;++u<j.length;)if(Y.call(j,u))return d.value=j[u],d.done=!1,d;return d.value=D,d.done=!0,d};return y.next=y}}throw TypeError(l4(j)+" is not iterable")}return I.prototype=W,J(C,"constructor",{value:W,configurable:!0}),J(W,"constructor",{value:I,configurable:!0}),I.displayName=G(W,Z,"GeneratorFunction"),$.isGeneratorFunction=function(j){var x=typeof j=="function"&&j.constructor;return!!x&&(x===I||(x.displayName||x.name)==="GeneratorFunction")},$.mark=function(j){return Object.setPrototypeOf?Object.setPrototypeOf(j,W):(j.__proto__=W,G(j,Z,"GeneratorFunction")),j.prototype=Object.create(C),j},$.awrap=function(j){return{__await:j}},A(_.prototype),G(_.prototype,w,function(){return this}),$.AsyncIterator=_,$.async=function(j,x,u,y,d){d===void 0&&(d=Promise);var b=new _(O(j,x,u,y),d);return $.isGeneratorFunction(x)?b:b.next().then(function(a){return a.done?a.value:b.next()})},A(C),G(C,Z,"Generator"),G(C,F,function(){return this}),G(C,"toString",function(){return"[object Generator]"}),$.keys=function(j){var x=Object(j),u=[];for(var y in x)u.push(y);return u.reverse(),function d(){for(;u.length;){var b=u.pop();if(b in x)return d.value=b,d.done=!1,d}return d.done=!0,d}},$.values=f,l.prototype={constructor:l,reset:function(x){if(this.prev=0,this.next=0,this.sent=this._sent=D,this.done=!1,this.delegate=null,this.method="next",this.arg=D,this.tryEntries.forEach(g),!x)for(var u in this)u.charAt(0)==="t"&&Y.call(this,u)&&!isNaN(+u.slice(1))&&(this[u]=D)},stop:function(){this.done=!0;var x=this.tryEntries[0].completion;if(x.type==="throw")throw x.arg;return this.rval},dispatchException:function(x){if(this.done)throw x;var u=this;function y(YD,P){return a.type="throw",a.arg=x,u.next=YD,P&&(u.method="next",u.arg=D),!!P}for(var d=this.tryEntries.length-1;d>=0;--d){var b=this.tryEntries[d],a=b.completion;if(b.tryLoc==="root")return y("end");if(b.tryLoc<=this.prev){var c=Y.call(b,"catchLoc"),n=Y.call(b,"finallyLoc");if(c&&n){if(this.prev<b.catchLoc)return y(b.catchLoc,!0);if(this.prev<b.finallyLoc)return y(b.finallyLoc)}else if(c){if(this.prev<b.catchLoc)return y(b.catchLoc,!0)}else{if(!n)throw Error("try statement without catch or finally");if(this.prev<b.finallyLoc)return y(b.finallyLoc)}}}},abrupt:function(x,u){for(var y=this.tryEntries.length-1;y>=0;--y){var d=this.tryEntries[y];if(d.tryLoc<=this.prev&&Y.call(d,"finallyLoc")&&this.prev<d.finallyLoc){var b=d;break}}b&&(x==="break"||x==="continue")&&b.tryLoc<=u&&u<=b.finallyLoc&&(b=null);var a=b?b.completion:{};return a.type=x,a.arg=u,b?(this.method="next",this.next=b.finallyLoc,M):this.complete(a)},complete:function(x,u){if(x.type==="throw")throw x.arg;return x.type==="break"||x.type==="continue"?this.next=x.arg:x.type==="return"?(this.rval=this.arg=x.arg,this.method="return",this.next="end"):x.type==="normal"&&u&&(this.next=u),M},finish:function(x){for(var u=this.tryEntries.length-1;u>=0;--u){var y=this.tryEntries[u];if(y.finallyLoc===x)return this.complete(y.completion,y.afterLoc),g(y),M}},catch:function(x){for(var u=this.tryEntries.length-1;u>=0;--u){var y=this.tryEntries[u];if(y.tryLoc===x){var d=y.completion;if(d.type==="throw"){var b=d.arg;g(y)}return b}}throw Error("illegal catch attempt")},delegateYield:function(x,u,y){return this.delegate={iterator:f(x),resultName:u,nextLoc:y},this.method==="next"&&(this.arg=D),M}},$}function g7D(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function WC(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,m7D(Y.key),Y)}}function h7D(D,$,X){if($)WC(D.prototype,$);if(X)WC(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function m7D(D){var $=d7D(D,"string");return l4($)=="symbol"?$:$+""}function d7D(D,$){if(l4(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(l4(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}function HC(D,$,X,Y,J,Q,F){try{var w=D[Q](F),Z=w.value}catch(G){X(G);return}if(w.done)$(Z);else Promise.resolve(Z).then(Y,J)}function VC(D){return function(){var $=this,X=arguments;return new Promise(function(Y,J){var Q=D.apply($,X);function F(Z){HC(Q,Y,J,F,w,"next",Z)}function w(Z){HC(Q,Y,J,F,w,"throw",Z)}F(void 0)})}}function c7D(D,$){return vO.apply(this,arguments)}function vO(){return vO=VC(i7().mark(function D($,X){return i7().wrap(function(J){while(!0)switch(J.prev=J.next){case 0:return J.abrupt("return",new Promise(function(Q,F){var w=function(O){$.off("readable",Z),F(O)},Z=function G(){var O=$.read(X);if(O!==null)$.off("error",w),$.off("readable",G),Q(O)};$.once("error",w),$.on("readable",Z)}));case 1:case"end":return J.stop()}},D)})),vO.apply(this,arguments)}var efD=NC.default=function(){function D($){var X=this;g7D(this,D),this._stream=$,this.size=null,this._buf=Buffer.alloc(0),this._bufPos=0,this._ended=!1,this._error=null,$.pause(),$.on("end",function(){X._ended=!0}),$.on("error",function(Y){X._error=Y})}return h7D(D,[{key:"slice",value:function(){var $=VC(i7().mark(function Y(J,Q){var F,w,Z,G,O;return i7().wrap(function(z){while(!0)switch(z.prev=z.next){case 0:if(!(J<this._bufPos)){z.next=2;break}throw Error("cannot slice from position which we already seeked away");case 2:if(!(J>this._bufPos+this._buf.length)){z.next=4;break}throw Error("slice start is outside of buffer (currently not implemented)");case 4:if(!this._error){z.next=6;break}throw this._error;case 6:if(J<this._bufPos+this._buf.length)w=J-this._bufPos,Z=Math.min(this._buf.length,Q-this._bufPos),F=this._buf.slice(w,Z);else F=Buffer.alloc(0);if(!this._ended){z.next=10;break}return F.size=F.length,z.abrupt("return",{value:F,done:!0});case 10:if(G=Q-J,!(G>F.length)){z.next=16;break}return z.next=14,c7D(this._stream,G-F.length);case 14:O=z.sent,F=Buffer.concat([F,O]);case 16:return this._buf=F,this._bufPos=J,F.size=F.length,z.abrupt("return",{value:F,done:this._ended});case 20:case"end":return z.stop()}},Y,this)}));function X(Y,J){return $.apply(this,arguments)}return X}()},{key:"close",value:function(){this._stream.destroy()}}])}()});var RC=T((IC)=>{Object.defineProperty(IC,"__esModule",{value:!0});IC.default=void 0;var l7D=p("fs"),n7D=SJ(FC()),i7D=SJ(OC()),p7D=SJ(KC()),r7D=SJ(_O());function SJ(D){return D&&D.__esModule?D:{default:D}}function p7(D){return p7=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},p7(D)}function o7D(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function LC(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,t7D(Y.key),Y)}}function a7D(D,$,X){if($)LC(D.prototype,$);if(X)LC(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function t7D(D){var $=s7D(D,"string");return p7($)=="symbol"?$:$+""}function s7D(D,$){if(p7(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(p7(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var $yD=IC.default=function(){function D(){o7D(this,D)}return a7D(D,[{key:"openFile",value:function(X,Y){if(Buffer.isBuffer(X))return Promise.resolve(new i7D.default(X));if(X instanceof l7D.ReadStream&&X.path!=null)return(0,p7D.default)(X);if(n7D.default.readable(X)){if(Y=Number(Y),!Number.isFinite(Y))return Promise.reject(Error("cannot create source for stream without a finite value for the `chunkSize` option; specify a chunkSize to control the memory consumption"));return Promise.resolve(new r7D.default(X))}return Promise.reject(Error("source object may only be an instance of Buffer or Readable in this environment"))}}])}()});var PC=T((CC)=>{Object.defineProperty(CC,"__esModule",{value:!0});CC.default=$3D;var e7D=p("crypto"),jC=TC(p("fs")),D3D=TC(p("path"));function EC(D){if(typeof WeakMap!="function")return null;var $=new WeakMap,X=new WeakMap;return(EC=function(Y){return Y?X:$})(D)}function TC(D,$){if(!$&&D&&D.__esModule)return D;if(D===null||typeof D!="object"&&typeof D!="function")return{default:D};var X=EC($);if(X&&X.has(D))return X.get(D);var Y={__proto__:null},J=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var Q in D)if(Q!=="default"&&{}.hasOwnProperty.call(D,Q)){var F=J?Object.getOwnPropertyDescriptor(D,Q):null;F&&(F.get||F.set)?Object.defineProperty(Y,Q,F):Y[Q]=D[Q]}return Y.default=D,X&&X.set(D,Y),Y}function $3D(D,$){if(Buffer.isBuffer(D)){var X=65536,Y=D.slice(0,Math.min(X,D.length)),J=(0,e7D.createHash)("md5").update(Y).digest("hex"),Q=["node-buffer",J,D.length,$.endpoint].join("-");return Promise.resolve(Q)}if(D instanceof jC.ReadStream&&D.path!=null)return new Promise(function(F,w){var Z=D3D.resolve(D.path);jC.stat(D.path,function(G,O){if(G){w(G);return}var U=["node-file",Z,O.size,O.mtime.getTime(),$.endpoint].join("-");F(U)})});return Promise.resolve(null)}});var _C=T((YyD,vC)=>{var uC="Expected a function",xC=NaN,J3D="[object Symbol]",Y3D=/^\s+|\s+$/g,Q3D=/^[-+]0x[0-9a-f]+$/i,F3D=/^0b[01]+$/i,w3D=/^0o[0-7]+$/i,Z3D=parseInt,G3D=typeof global=="object"&&global&&global.Object===Object&&global,O3D=typeof self=="object"&&self&&self.Object===Object&&self,U3D=G3D||O3D||Function("return this")(),q3D=Object.prototype,z3D=q3D.toString,B3D=Math.max,K3D=Math.min,kO=function(){return U3D.Date.now()};function W3D(D,$,X){var Y,J,Q,F,w,Z,G=0,O=!1,U=!1,z=!0;if(typeof D!="function")throw TypeError(uC);if($=SC($)||0,uJ(X))O=!!X.leading,U="maxWait"in X,Q=U?B3D(SC(X.maxWait)||0,$):Q,z="trailing"in X?!!X.trailing:z;function q(R){var C=Y,A=J;return Y=J=void 0,G=R,F=D.apply(A,C),F}function B(R){return G=R,w=setTimeout(L,$),O?q(R):F}function K(R){var C=R-Z,A=R-G,_=$-C;return U?K3D(_,Q-A):_}function M(R){var C=R-Z,A=R-G;return Z===void 0||C>=$||C<0||U&&A>=Q}function L(){var R=kO();if(M(R))return I(R);w=setTimeout(L,K(R))}function I(R){if(w=void 0,z&&Y)return q(R);return Y=J=void 0,F}function W(){if(w!==void 0)clearTimeout(w);G=0,Y=Z=J=w=void 0}function N(){return w===void 0?F:I(kO())}function V(){var R=kO(),C=M(R);if(Y=arguments,J=this,Z=R,C){if(w===void 0)return B(Z);if(U)return w=setTimeout(L,$),q(Z)}if(w===void 0)w=setTimeout(L,$);return F}return V.cancel=W,V.flush=N,V}function H3D(D,$,X){var Y=!0,J=!0;if(typeof D!="function")throw TypeError(uC);if(uJ(X))Y="leading"in X?!!X.leading:Y,J="trailing"in X?!!X.trailing:J;return W3D(D,$,{leading:Y,maxWait:$,trailing:J})}function uJ(D){var $=typeof D;return!!D&&($=="object"||$=="function")}function V3D(D){return!!D&&typeof D=="object"}function N3D(D){return typeof D=="symbol"||V3D(D)&&z3D.call(D)==J3D}function SC(D){if(typeof D=="number")return D;if(N3D(D))return xC;if(uJ(D)){var $=typeof D.valueOf=="function"?D.valueOf():D;D=uJ($)?$+"":$}if(typeof D!="string")return D===0?D:+D;D=D.replace(Y3D,"");var X=F3D.test(D);return X||w3D.test(D)?Z3D(D.slice(2),X?2:8):Q3D.test(D)?xC:+D}vC.exports=H3D});var nC=T((cC)=>{Object.defineProperty(cC,"__esModule",{value:!0});cC.default=void 0;var M3D=hC(p("http")),L3D=hC(p("https")),yC=p("stream"),I3D=p("url"),bC=A3D(_C());function A3D(D){return D&&D.__esModule?D:{default:D}}function gC(D){if(typeof WeakMap!="function")return null;var $=new WeakMap,X=new WeakMap;return(gC=function(Y){return Y?X:$})(D)}function hC(D,$){if(!$&&D&&D.__esModule)return D;if(D===null||typeof D!="object"&&typeof D!="function")return{default:D};var X=gC($);if(X&&X.has(D))return X.get(D);var Y={__proto__:null},J=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var Q in D)if(Q!=="default"&&{}.hasOwnProperty.call(D,Q)){var F=J?Object.getOwnPropertyDescriptor(D,Q):null;F&&(F.get||F.set)?Object.defineProperty(Y,Q,F):Y[Q]=D[Q]}return Y.default=D,X&&X.set(D,Y),Y}function R3D(D,$,X){return $=vJ($),j3D(D,mC()?Reflect.construct($,X||[],vJ(D).constructor):$.apply(D,X))}function j3D(D,$){if($&&(K9($)==="object"||typeof $==="function"))return $;else if($!==void 0)throw TypeError("Derived constructors may only return object or undefined");return E3D(D)}function E3D(D){if(D===void 0)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return D}function mC(){try{var D=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch($){}return(mC=function(){return!!D})()}function vJ(D){return vJ=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(X){return X.__proto__||Object.getPrototypeOf(X)},vJ(D)}function T3D(D,$){if(typeof $!=="function"&&$!==null)throw TypeError("Super expression must either be null or a function");if(D.prototype=Object.create($&&$.prototype,{constructor:{value:D,writable:!0,configurable:!0}}),Object.defineProperty(D,"prototype",{writable:!1}),$)fO(D,$)}function fO(D,$){return fO=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(Y,J){return Y.__proto__=J,Y},fO(D,$)}function kC(D,$){var X=Object.keys(D);if(Object.getOwnPropertySymbols){var Y=Object.getOwnPropertySymbols(D);$&&(Y=Y.filter(function(J){return Object.getOwnPropertyDescriptor(D,J).enumerable})),X.push.apply(X,Y)}return X}function r7(D){for(var $=1;$<arguments.length;$++){var X=arguments[$]!=null?arguments[$]:{};$%2?kC(Object(X),!0).forEach(function(Y){C3D(D,Y,X[Y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(D,Object.getOwnPropertyDescriptors(X)):kC(Object(X)).forEach(function(Y){Object.defineProperty(D,Y,Object.getOwnPropertyDescriptor(X,Y))})}return D}function C3D(D,$,X){if($=dC($),$ in D)Object.defineProperty(D,$,{value:X,enumerable:!0,configurable:!0,writable:!0});else D[$]=X;return D}function K9(D){return K9=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},K9(D)}function _J(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function fC(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,dC(Y.key),Y)}}function kJ(D,$,X){if($)fC(D.prototype,$);if(X)fC(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function dC(D){var $=P3D(D,"string");return K9($)=="symbol"?$:$+""}function P3D(D,$){if(K9(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(K9(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var QyD=cC.default=function(){function D(){var $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_J(this,D),this._requestOptions=$}return kJ(D,[{key:"createRequest",value:function(X,Y){return new x3D(X,Y,this._requestOptions)}},{key:"getName",value:function(){return"NodeHttpStack"}}])}(),x3D=function(){function D($,X,Y){_J(this,D),this._method=$,this._url=X,this._headers={},this._request=null,this._progressHandler=function(){},this._requestOptions=Y||{}}return kJ(D,[{key:"getMethod",value:function(){return this._method}},{key:"getURL",value:function(){return this._url}},{key:"setHeader",value:function(X,Y){this._headers[X]=Y}},{key:"getHeader",value:function(X){return this._headers[X]}},{key:"setProgressHandler",value:function(X){this._progressHandler=X}},{key:"send",value:function(){var X=this,Y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null;return new Promise(function(J,Q){var F=r7(r7(r7({},(0,I3D.parse)(X._url)),X._requestOptions),{},{method:X._method,headers:r7(r7({},X._requestOptions.headers||{}),X._headers)});if(Y!==null&&Y!==void 0&&Y.size)F.headers["Content-Length"]=Y.size;var w=F.protocol==="https:"?L3D:M3D;X._request=w.request(F);var Z=X._request;if(Z.on("response",function(G){var O=[];G.on("data",function(U){O.push(U)}),G.on("end",function(){var U=Buffer.concat(O).toString("utf8");J(new S3D(G,U))})}),Z.on("error",function(G){Q(G)}),Y instanceof yC.Readable)Y.pipe(new u3D(X._progressHandler)).pipe(Z);else if(Y instanceof Uint8Array)v3D(Z,Y,X._progressHandler);else Z.end(Y)})}},{key:"abort",value:function(){if(this._request!==null)this._request.abort();return Promise.resolve()}},{key:"getUnderlyingObject",value:function(){return this._request}}])}(),S3D=function(){function D($,X){_J(this,D),this._response=$,this._body=X}return kJ(D,[{key:"getStatus",value:function(){return this._response.statusCode}},{key:"getHeader",value:function(X){return this._response.headers[X.toLowerCase()]}},{key:"getBody",value:function(){return this._body}},{key:"getUnderlyingObject",value:function(){return this._response}}])}(),u3D=function(D){function $(X){var Y;return _J(this,$),Y=R3D(this,$),Y._onprogress=(0,bC.default)(X,100,{leading:!0,trailing:!1}),Y._position=0,Y}return T3D($,D),kJ($,[{key:"_transform",value:function(Y,J,Q){this._position+=Y.length,this._onprogress(this._position),Q(null,Y)}}])}(yC.Transform),v3D=function($,X,Y){Y=(0,bC.default)(Y,100,{leading:!0,trailing:!1});var J=0;function Q(){var F=Math.min($.writableHighWaterMark,X.length-J),w=X.subarray(J,J+F);J+=w.length;var Z=$.write(w);if(!Z)$.once("drain",Q),Y(J);else if(J<X.length)Q();else $.end()}Q()}});var iC=T((_3D)=>{_3D.expectReceive=function(D,$,X){var Y;if(X.root(D,$,X),Y=this.message,D.hasOwnProperty("expected"))Y+=" Expected "+D.expected+".";if(D.hasOwnProperty("received"))Y+=" Received: "+D.received+".";this.message=Y};_3D.root=function(D,$,X){var Y=this,J,Q={stackLength:Error.stackTraceLimit,rootOnly:!0},F="",w=Error.stackTraceLimit,Z;function G(){Z[0]=Y.toString(),Y.stack=Z.join(`
123
123
  `)}if(!$||typeof $!=="object")$={};if($.hasOwnProperty("stackLength")&&typeof $.stackLength==="number"&&!isNaN($.stackLength)&&$.stackLength>=0)Q.stackLength=$.stackLength;if(!$.hasOwnProperty("rootOnly"))Q.rootOnly=$.rootOnly;if(!Q.rootOnly||this.CustomError.parent===Error)Object.keys(D).forEach(function(O){switch(O){case"code":J=D.code||void 0;break;case"message":F=D.message||"";break;default:Y[O]=D[O]}}),Error.stackTraceLimit=Q.stackLength+2,Z=Error().stack.split(`
124
124
  `),Z.splice(0,3),Z.unshift(""),Error.stackTraceLimit=w,this.stack=Z.join(`
125
125
  `),Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,get:function(){return J},set:function(O){J=O,G()}}),Object.defineProperty(this,"message",{configurable:!0,enumerable:!0,get:function(){return F},set:function(O){F=O,G()}}),G()}});var oC=T((ZyD,rC)=>{rC.exports=n4;n4.factory=iC();var gO=n4("CustomError");gO.order=n4(gO,{message:"Arguments out of order.",code:"EOARG"});function n4(D,$,X,Y){var J,Q;if($=fJ(arguments,1,Error,pC,[yO,yJ]),X=fJ(arguments,2,{},yO,[yJ]),Y=fJ(arguments,3,bO,yJ,[]),D=fJ(arguments,0,$===Error?"Error":$.prototype.CustomError.name,y3D,[pC,yO,yJ]),Q=$===Error,Q&&Y===bO)Y=n4.factory.root;return J=function(F,w){var Z,G,O,U,z,q;if(!(this instanceof J))return new J(F,w);if(delete this.constructor.name,Object.defineProperty(this.constructor,"name",{enumerable:!1,configurable:!0,value:D,writable:!1}),typeof F==="string")F={message:F};if(!F)F={};G=this.CustomError.chain.slice(0).reverse().map(function(B){return B.properties}),G.push(F),G.unshift({}),q=Object.assign.apply(Object,G),Z=this,O={},Object.keys(n4.factory).forEach(function(B){O[B]=function(K,M){n4.factory[B].call(Z,K,M,O)}});for(U=this.CustomError.chain.length-1;U>=0;U--)if(z=this.CustomError.chain[U],z.factory!==bO)z.factory.call(this,q,w,O)},J.prototype=Object.create($.prototype),J.prototype.constructor=J,J.prototype.name=D,J.prototype.CustomError={chain:Q?[]:$.prototype.CustomError.chain.slice(0),factory:Y,name:D,parent:$,properties:X},J.prototype.CustomError.chain.unshift(J.prototype.CustomError),J.prototype.toString=function(){var F=this.CustomError.chain[this.CustomError.chain.length-1].name;if(this.code)F+=" "+this.code;if(this.message)F+=": "+this.message;return F},J}function fJ(D,$,X,Y,J){var Q=-1,F=-1,w,Z,G=$<D.length?$:D.length,O;for(w=0;w<=G;w++){if(O=D[w],Q===-1){for(Z=0;Z<J.length;Z++)if(J[Z](O))Q=w}if(F===-1&&Y(O))F=w}if(F!==-1&&Q!==-1&&Q<F)throw new gO.order;return F!==-1?D[F]:X}function yJ(D){return typeof D==="function"&&D!==Error&&!D.prototype.CustomError}function y3D(D){return typeof D==="string"}function pC(D){return typeof D==="function"&&(D===Error||D.prototype.CustomError)}function yO(D){return D&&typeof D==="object"}function bO(){}});var DP=T((H9,W9)=>{var b3D=1/0,g3D="[object Symbol]",o7={function:!0,object:!0},h3D=o7[typeof H9]&&H9&&!H9.nodeType?H9:void 0,m3D=o7[typeof W9]&&W9&&!W9.nodeType?W9:void 0,d3D=bJ(h3D&&m3D&&typeof global=="object"&&global),c3D=bJ(o7[typeof self]&&self),aC=bJ(o7[typeof window]&&window),hO=bJ(o7[typeof H9]&&H9),l3D=d3D||aC!==(hO&&hO.window)&&aC||c3D||hO||Function("return this")();function bJ(D){return D&&D.Object===Object?D:null}var n3D=Object.prototype,i3D=n3D.toString,tC=l3D.Symbol,sC=tC?tC.prototype:void 0,eC=sC?sC.toString:void 0;function p3D(D){if(typeof D=="string")return D;if(o3D(D))return eC?eC.call(D):"";var $=D+"";return $=="0"&&1/D==-b3D?"-0":$}function r3D(D){return!!D&&typeof D=="object"}function o3D(D){return typeof D=="symbol"||r3D(D)&&i3D.call(D)==g3D}W9.exports=p3D});var wP=T((N9,V9)=>{var a3D=DP(),t3D="Expected a function",XP="__lodash_hash_undefined__",s3D="[object Function]",e3D="[object GeneratorFunction]",DXD=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g,$XD=/[\\^$.*+?()[\]{}|]/g,XXD=/\\(\\)?/g,JXD=/^\[object .+?Constructor\]$/,t7={function:!0,object:!0},YXD=t7[typeof N9]&&N9&&!N9.nodeType?N9:void 0,QXD=t7[typeof V9]&&V9&&!V9.nodeType?V9:void 0,FXD=gJ(YXD&&QXD&&typeof global=="object"&&global),wXD=gJ(t7[typeof self]&&self),$P=gJ(t7[typeof window]&&window),mO=gJ(t7[typeof N9]&&N9),ZXD=FXD||$P!==(mO&&mO.window)&&$P||wXD||mO||Function("return this")();function gJ(D){return D&&D.Object===Object?D:null}function GXD(D){var $=!1;if(D!=null&&typeof D.toString!="function")try{$=!!(D+"")}catch(X){}return $}var OXD=Array.prototype,JP=Object.prototype,YP=Function.prototype.toString,dO=JP.hasOwnProperty,UXD=JP.toString,qXD=RegExp("^"+YP.call(dO).replace($XD,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),zXD=OXD.splice,BXD=QP(ZXD,"Map"),a7=QP(Object,"create");function i4(D){var $=-1,X=D?D.length:0;this.clear();while(++$<X){var Y=D[$];this.set(Y[0],Y[1])}}function KXD(){this.__data__=a7?a7(null):{}}function WXD(D){return this.has(D)&&delete this.__data__[D]}function HXD(D){var $=this.__data__;if(a7){var X=$[D];return X===XP?void 0:X}return dO.call($,D)?$[D]:void 0}function VXD(D){var $=this.__data__;return a7?$[D]!==void 0:dO.call($,D)}function NXD(D,$){var X=this.__data__;return X[D]=a7&&$===void 0?XP:$,this}i4.prototype.clear=KXD;i4.prototype.delete=WXD;i4.prototype.get=HXD;i4.prototype.has=VXD;i4.prototype.set=NXD;function M9(D){var $=-1,X=D?D.length:0;this.clear();while(++$<X){var Y=D[$];this.set(Y[0],Y[1])}}function MXD(){this.__data__=[]}function LXD(D){var $=this.__data__,X=hJ($,D);if(X<0)return!1;var Y=$.length-1;if(X==Y)$.pop();else zXD.call($,X,1);return!0}function IXD(D){var $=this.__data__,X=hJ($,D);return X<0?void 0:$[X][1]}function AXD(D){return hJ(this.__data__,D)>-1}function RXD(D,$){var X=this.__data__,Y=hJ(X,D);if(Y<0)X.push([D,$]);else X[Y][1]=$;return this}M9.prototype.clear=MXD;M9.prototype.delete=LXD;M9.prototype.get=IXD;M9.prototype.has=AXD;M9.prototype.set=RXD;function p4(D){var $=-1,X=D?D.length:0;this.clear();while(++$<X){var Y=D[$];this.set(Y[0],Y[1])}}function jXD(){this.__data__={hash:new i4,map:new(BXD||M9),string:new i4}}function EXD(D){return mJ(this,D).delete(D)}function TXD(D){return mJ(this,D).get(D)}function CXD(D){return mJ(this,D).has(D)}function PXD(D,$){return mJ(this,D).set(D,$),this}p4.prototype.clear=jXD;p4.prototype.delete=EXD;p4.prototype.get=TXD;p4.prototype.has=CXD;p4.prototype.set=PXD;function hJ(D,$){var X=D.length;while(X--)if(vXD(D[X][0],$))return X;return-1}function mJ(D,$){var X=D.__data__;return xXD($)?X[typeof $=="string"?"string":"hash"]:X.map}function QP(D,$){var X=D[$];return kXD(X)?X:void 0}function xXD(D){var $=typeof D;return $=="string"||$=="number"||$=="symbol"||$=="boolean"?D!=="__proto__":D===null}var SXD=cO(function(D){var $=[];return fXD(D).replace(DXD,function(X,Y,J,Q){$.push(J?Q.replace(XXD,"$1"):Y||X)}),$});function uXD(D){if(D!=null){try{return YP.call(D)}catch($){}try{return D+""}catch($){}}return""}function cO(D,$){if(typeof D!="function"||$&&typeof $!="function")throw TypeError(t3D);var X=function(){var Y=arguments,J=$?$.apply(this,Y):Y[0],Q=X.cache;if(Q.has(J))return Q.get(J);var F=D.apply(this,Y);return X.cache=Q.set(J,F),F};return X.cache=new(cO.Cache||p4),X}cO.Cache=p4;function vXD(D,$){return D===$||D!==D&&$!==$}function _XD(D){var $=FP(D)?UXD.call(D):"";return $==s3D||$==e3D}function FP(D){var $=typeof D;return!!D&&($=="object"||$=="function")}function kXD(D){if(!FP(D))return!1;var $=_XD(D)||GXD(D)?qXD:JXD;return $.test(uXD(D))}function fXD(D){return D==null?"":a3D(D)}V9.exports=SXD});var yP=T((A9,I9)=>{var yXD=wP(),bXD=200,DU="__lodash_hash_undefined__",iJ=1,R9=2,gXD=1/0,zP=9007199254740991,dJ="[object Arguments]",iO="[object Array]",BP="[object Boolean]",KP="[object Date]",WP="[object Error]",HP="[object Function]",hXD="[object GeneratorFunction]",s7="[object Map]",VP="[object Number]",L9="[object Object]",ZP="[object Promise]",NP="[object RegExp]",e7="[object Set]",$U="[object String]",MP="[object Symbol]",pO="[object WeakMap]",LP="[object ArrayBuffer]",cJ="[object DataView]",mXD="[object Float32Array]",dXD="[object Float64Array]",cXD="[object Int8Array]",lXD="[object Int16Array]",nXD="[object Int32Array]",iXD="[object Uint8Array]",pXD="[object Uint8ClampedArray]",rXD="[object Uint16Array]",oXD="[object Uint32Array]",aXD=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,tXD=/^\w*$/,sXD=/[\\^$.*+?()[\]{}|]/g,eXD=/^\[object .+?Constructor\]$/,D2D=/^(?:0|[1-9]\d*)$/,U0={};U0[mXD]=U0[dXD]=U0[cXD]=U0[lXD]=U0[nXD]=U0[iXD]=U0[pXD]=U0[rXD]=U0[oXD]=!0;U0[dJ]=U0[iO]=U0[LP]=U0[BP]=U0[cJ]=U0[KP]=U0[WP]=U0[HP]=U0[s7]=U0[VP]=U0[L9]=U0[NP]=U0[e7]=U0[$U]=U0[pO]=!1;var $3={function:!0,object:!0},$2D=$3[typeof A9]&&A9&&!A9.nodeType?A9:void 0,X2D=$3[typeof I9]&&I9&&!I9.nodeType?I9:void 0,J2D=pJ($2D&&X2D&&typeof global=="object"&&global),Y2D=pJ($3[typeof self]&&self),GP=pJ($3[typeof window]&&window),lO=pJ($3[typeof A9]&&A9),a4=J2D||GP!==(lO&&lO.window)&&GP||Y2D||lO||Function("return this")();function Q2D(D,$){var X=-1,Y=D.length,J=Array(Y);while(++X<Y)J[X]=$(D[X],X,D);return J}function F2D(D,$){var X=-1,Y=D.length;while(++X<Y)if($(D[X],X,D))return!0;return!1}function w2D(D,$){var X=-1,Y=Array(D);while(++X<D)Y[X]=$(X);return Y}function Z2D(D,$){return Q2D($,function(X){return[X,D[X]]})}function pJ(D){return D&&D.Object===Object?D:null}function rO(D){var $=!1;if(D!=null&&typeof D.toString!="function")try{$=!!(D+"")}catch(X){}return $}function IP(D){var $=-1,X=Array(D.size);return D.forEach(function(Y,J){X[++$]=[J,Y]}),X}function G2D(D){var $=-1,X=Array(D.size);return D.forEach(function(Y){X[++$]=Y}),X}function O2D(D){var $=-1,X=Array(D.size);return D.forEach(function(Y){X[++$]=[Y,Y]}),X}var U2D=Array.prototype,rJ=Object.prototype,AP=Function.prototype.toString,r4=rJ.hasOwnProperty,t4=rJ.toString,q2D=RegExp("^"+AP.call(r4).replace(sXD,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),OP=a4.Symbol,UP=a4.Uint8Array,z2D=rJ.propertyIsEnumerable,B2D=U2D.splice,K2D=Object.getPrototypeOf,W2D=Object.keys,oO=j9(a4,"DataView"),lJ=j9(a4,"Map"),aO=j9(a4,"Promise"),tO=j9(a4,"Set"),sO=j9(a4,"WeakMap"),D3=j9(Object,"create"),H2D=e4(oO),V2D=e4(lJ),N2D=e4(aO),M2D=e4(tO),L2D=e4(sO),qP=OP?OP.prototype:void 0,nO=qP?qP.valueOf:void 0;function o4(D){var $=-1,X=D?D.length:0;this.clear();while(++$<X){var Y=D[$];this.set(Y[0],Y[1])}}function I2D(){this.__data__=D3?D3(null):{}}function A2D(D){return this.has(D)&&delete this.__data__[D]}function R2D(D){var $=this.__data__;if(D3){var X=$[D];return X===DU?void 0:X}return r4.call($,D)?$[D]:void 0}function j2D(D){var $=this.__data__;return D3?$[D]!==void 0:r4.call($,D)}function E2D(D,$){var X=this.__data__;return X[D]=D3&&$===void 0?DU:$,this}o4.prototype.clear=I2D;o4.prototype.delete=A2D;o4.prototype.get=R2D;o4.prototype.has=j2D;o4.prototype.set=E2D;function Y6(D){var $=-1,X=D?D.length:0;this.clear();while(++$<X){var Y=D[$];this.set(Y[0],Y[1])}}function T2D(){this.__data__=[]}function C2D(D){var $=this.__data__,X=oJ($,D);if(X<0)return!1;var Y=$.length-1;if(X==Y)$.pop();else B2D.call($,X,1);return!0}function P2D(D){var $=this.__data__,X=oJ($,D);return X<0?void 0:$[X][1]}function x2D(D){return oJ(this.__data__,D)>-1}function S2D(D,$){var X=this.__data__,Y=oJ(X,D);if(Y<0)X.push([D,$]);else X[Y][1]=$;return this}Y6.prototype.clear=T2D;Y6.prototype.delete=C2D;Y6.prototype.get=P2D;Y6.prototype.has=x2D;Y6.prototype.set=S2D;function s4(D){var $=-1,X=D?D.length:0;this.clear();while(++$<X){var Y=D[$];this.set(Y[0],Y[1])}}function u2D(){this.__data__={hash:new o4,map:new(lJ||Y6),string:new o4}}function v2D(D){return aJ(this,D).delete(D)}function _2D(D){return aJ(this,D).get(D)}function k2D(D){return aJ(this,D).has(D)}function f2D(D,$){return aJ(this,D).set(D,$),this}s4.prototype.clear=u2D;s4.prototype.delete=v2D;s4.prototype.get=_2D;s4.prototype.has=k2D;s4.prototype.set=f2D;function nJ(D){var $=-1,X=D?D.length:0;this.__data__=new s4;while(++$<X)this.add(D[$])}function y2D(D){return this.__data__.set(D,DU),this}function b2D(D){return this.__data__.has(D)}nJ.prototype.add=nJ.prototype.push=y2D;nJ.prototype.has=b2D;function J6(D){this.__data__=new Y6(D)}function g2D(){this.__data__=new Y6}function h2D(D){return this.__data__.delete(D)}function m2D(D){return this.__data__.get(D)}function d2D(D){return this.__data__.has(D)}function c2D(D,$){var X=this.__data__;if(X instanceof Y6&&X.__data__.length==bXD)X=this.__data__=new s4(X.__data__);return X.set(D,$),this}J6.prototype.clear=g2D;J6.prototype.delete=h2D;J6.prototype.get=m2D;J6.prototype.has=d2D;J6.prototype.set=c2D;function oJ(D,$){var X=D.length;while(X--)if(ZJD(D[X][0],$))return X;return-1}function RP(D,$){$=tJ($,D)?[$]:TP($);var X=0,Y=$.length;while(D!=null&&X<Y)D=D[sJ($[X++])];return X&&X==Y?D:void 0}function jP(D,$){return r4.call(D,$)||typeof D=="object"&&$ in D&&JJD(D)===null}function l2D(D,$){return $ in Object(D)}function XU(D,$,X,Y,J){if(D===$)return!0;if(D==null||$==null||!DY(D)&&!X3($))return D!==D&&$!==$;return n2D(D,$,XU,X,Y,J)}function n2D(D,$,X,Y,J,Q){var F=d6(D),w=d6($),Z=iO,G=iO;if(!F)Z=X6(D),Z=Z==dJ?L9:Z;if(!w)G=X6($),G=G==dJ?L9:G;var O=Z==L9&&!rO(D),U=G==L9&&!rO($),z=Z==G;if(z&&!O)return Q||(Q=new J6),F||UJD(D)?CP(D,$,X,Y,J,Q):e2D(D,$,Z,X,Y,J,Q);if(!(J&R9)){var q=O&&r4.call(D,"__wrapped__"),B=U&&r4.call($,"__wrapped__");if(q||B){var K=q?D.value():D,M=B?$.value():$;return Q||(Q=new J6),X(K,M,Y,J,Q)}}if(!z)return!1;return Q||(Q=new J6),DJD(D,$,X,Y,J,Q)}function i2D(D,$,X,Y){var J=X.length,Q=J,F=!Y;if(D==null)return!Q;D=Object(D);while(J--){var w=X[J];if(F&&w[2]?w[1]!==D[w[0]]:!(w[0]in D))return!1}while(++J<Q){w=X[J];var Z=w[0],G=D[Z],O=w[1];if(F&&w[2]){if(G===void 0&&!(Z in D))return!1}else{var U=new J6;if(Y)var z=Y(G,O,Z,D,$,U);if(!(z===void 0?XU(O,G,Y,iJ|R9,U):z))return!1}}return!0}function p2D(D){if(typeof D=="function")return D;if(D==null)return KJD;if(typeof D=="object")return d6(D)?a2D(D[0],D[1]):o2D(D);return WJD(D)}function r2D(D){return W2D(Object(D))}function o2D(D){var $=XJD(D);if($.length==1&&$[0][2])return SP($[0][0],$[0][1]);return function(X){return X===D||i2D(X,D,$)}}function a2D(D,$){if(tJ(D)&&xP($))return SP(sJ(D),$);return function(X){var Y=qJD(X,D);return Y===void 0&&Y===$?zJD(X,D):XU($,Y,void 0,iJ|R9)}}function EP(D){return function($){return $==null?void 0:$[D]}}function t2D(D){return function($){return RP($,D)}}function TP(D){return d6(D)?D:yXD(D)}function s2D(D){return function($){var X=X6($);if(X==s7)return IP($);if(X==e7)return O2D($);return Z2D($,D($))}}function CP(D,$,X,Y,J,Q){var F=J&R9,w=D.length,Z=$.length;if(w!=Z&&!(F&&Z>w))return!1;var G=Q.get(D);if(G)return G==$;var O=-1,U=!0,z=J&iJ?new nJ:void 0;Q.set(D,$);while(++O<w){var q=D[O],B=$[O];if(Y)var K=F?Y(B,q,O,$,D,Q):Y(q,B,O,D,$,Q);if(K!==void 0){if(K)continue;U=!1;break}if(z){if(!F2D($,function(M,L){if(!z.has(L)&&(q===M||X(q,M,Y,J,Q)))return z.add(L)})){U=!1;break}}else if(!(q===B||X(q,B,Y,J,Q))){U=!1;break}}return Q.delete(D),U}function e2D(D,$,X,Y,J,Q,F){switch(X){case cJ:if(D.byteLength!=$.byteLength||D.byteOffset!=$.byteOffset)return!1;D=D.buffer,$=$.buffer;case LP:if(D.byteLength!=$.byteLength||!Y(new UP(D),new UP($)))return!1;return!0;case BP:case KP:return+D==+$;case WP:return D.name==$.name&&D.message==$.message;case VP:return D!=+D?$!=+$:D==+$;case NP:case $U:return D==$+"";case s7:var w=IP;case e7:var Z=Q&R9;if(w||(w=G2D),D.size!=$.size&&!Z)return!1;var G=F.get(D);if(G)return G==$;return Q|=iJ,F.set(D,$),CP(w(D),w($),Y,J,Q,F);case MP:if(nO)return nO.call(D)==nO.call($)}return!1}function DJD(D,$,X,Y,J,Q){var F=J&R9,w=eO(D),Z=w.length,G=eO($),O=G.length;if(Z!=O&&!F)return!1;var U=Z;while(U--){var z=w[U];if(!(F?z in $:jP($,z)))return!1}var q=Q.get(D);if(q)return q==$;var B=!0;Q.set(D,$);var K=F;while(++U<Z){z=w[U];var M=D[z],L=$[z];if(Y)var I=F?Y(L,M,z,$,D,Q):Y(M,L,z,D,$,Q);if(!(I===void 0?M===L||X(M,L,Y,J,Q):I)){B=!1;break}K||(K=z=="constructor")}if(B&&!K){var W=D.constructor,N=$.constructor;if(W!=N&&(("constructor"in D)&&("constructor"in $))&&!(typeof W=="function"&&W instanceof W&&typeof N=="function"&&N instanceof N))B=!1}return Q.delete(D),B}var $JD=EP("length");function aJ(D,$){var X=D.__data__;return FJD($)?X[typeof $=="string"?"string":"hash"]:X.map}function XJD(D){var $=BJD(D),X=$.length;while(X--)$[X][2]=xP($[X][1]);return $}function j9(D,$){var X=D[$];return OJD(X)?X:void 0}function JJD(D){return K2D(Object(D))}function X6(D){return t4.call(D)}if(oO&&X6(new oO(new ArrayBuffer(1)))!=cJ||lJ&&X6(new lJ)!=s7||aO&&X6(aO.resolve())!=ZP||tO&&X6(new tO)!=e7||sO&&X6(new sO)!=pO)X6=function(D){var $=t4.call(D),X=$==L9?D.constructor:void 0,Y=X?e4(X):void 0;if(Y)switch(Y){case H2D:return cJ;case V2D:return s7;case N2D:return ZP;case M2D:return e7;case L2D:return pO}return $};function YJD(D,$,X){$=tJ($,D)?[$]:TP($);var Y,J=-1,F=$.length;while(++J<F){var Q=sJ($[J]);if(!(Y=D!=null&&X(D,Q)))break;D=D[Q]}if(Y)return Y;var F=D?D.length:0;return!!F&&eJ(F)&&PP(Q,F)&&(d6(D)||kP(D)||uP(D))}function QJD(D){var $=D?D.length:void 0;if(eJ($)&&(d6(D)||kP(D)||uP(D)))return w2D($,String);return null}function PP(D,$){return $=$==null?zP:$,!!$&&(typeof D=="number"||D2D.test(D))&&(D>-1&&D%1==0&&D<$)}function tJ(D,$){if(d6(D))return!1;var X=typeof D;if(X=="number"||X=="symbol"||X=="boolean"||D==null||fP(D))return!0;return tXD.test(D)||!aXD.test(D)||$!=null&&D in Object($)}function FJD(D){var $=typeof D;return $=="string"||$=="number"||$=="symbol"||$=="boolean"?D!=="__proto__":D===null}function wJD(D){var $=D&&D.constructor,X=typeof $=="function"&&$.prototype||rJ;return D===X}function xP(D){return D===D&&!DY(D)}function SP(D,$){return function(X){if(X==null)return!1;return X[D]===$&&($!==void 0||(D in Object(X)))}}function sJ(D){if(typeof D=="string"||fP(D))return D;var $=D+"";return $=="0"&&1/D==-gXD?"-0":$}function e4(D){if(D!=null){try{return AP.call(D)}catch($){}try{return D+""}catch($){}}return""}function ZJD(D,$){return D===$||D!==D&&$!==$}function uP(D){return GJD(D)&&r4.call(D,"callee")&&(!z2D.call(D,"callee")||t4.call(D)==dJ)}var d6=Array.isArray;function vP(D){return D!=null&&eJ($JD(D))&&!_P(D)}function GJD(D){return X3(D)&&vP(D)}function _P(D){var $=DY(D)?t4.call(D):"";return $==HP||$==hXD}function eJ(D){return typeof D=="number"&&D>-1&&D%1==0&&D<=zP}function DY(D){var $=typeof D;return!!D&&($=="object"||$=="function")}function X3(D){return!!D&&typeof D=="object"}function OJD(D){if(!DY(D))return!1;var $=_P(D)||rO(D)?q2D:eXD;return $.test(e4(D))}function kP(D){return typeof D=="string"||!d6(D)&&X3(D)&&t4.call(D)==$U}function fP(D){return typeof D=="symbol"||X3(D)&&t4.call(D)==MP}function UJD(D){return X3(D)&&eJ(D.length)&&!!U0[t4.call(D)]}function qJD(D,$,X){var Y=D==null?void 0:RP(D,$);return Y===void 0?X:Y}function zJD(D,$){return D!=null&&YJD(D,$,l2D)}function eO(D){var $=wJD(D);if(!($||vP(D)))return r2D(D);var X=QJD(D),Y=!!X,J=X||[],Q=J.length;for(var F in D)if(jP(D,F)&&!(Y&&(F=="length"||PP(F,Q)))&&!($&&F=="constructor"))J.push(F);return J}var BJD=s2D(eO);function KJD(D){return D}function WJD(D){return tJ(D)?EP(sJ(D)):t2D(D)}I9.exports=p2D});var dP=T((T9,E9)=>{var HJD=1/0,VJD="[object Function]",NJD="[object GeneratorFunction]",MJD=/[\\^$.*+?()[\]{}|]/g,LJD=/^\[object .+?Constructor\]$/,J3={function:!0,object:!0},IJD=J3[typeof T9]&&T9&&!T9.nodeType?T9:void 0,AJD=J3[typeof E9]&&E9&&!E9.nodeType?E9:void 0,RJD=$Y(IJD&&AJD&&typeof global=="object"&&global),jJD=$Y(J3[typeof self]&&self),bP=$Y(J3[typeof window]&&window),JU=$Y(J3[typeof T9]&&T9),EJD=RJD||bP!==(JU&&JU.window)&&bP||jJD||JU||Function("return this")();function $Y(D){return D&&D.Object===Object?D:null}function TJD(D){var $=!1;if(D!=null&&typeof D.toString!="function")try{$=!!(D+"")}catch(X){}return $}function CJD(D){var $=-1,X=Array(D.size);return D.forEach(function(Y){X[++$]=Y}),X}var gP=Object.prototype,hP=Function.prototype.toString,PJD=gP.hasOwnProperty,xJD=gP.toString,SJD=RegExp("^"+hP.call(PJD).replace(MJD,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),YU=vJD(EJD,"Set"),uJD=!(YU&&1/CJD(new YU([,-0]))[1]==HJD)?yJD:function(D){return new YU(D)};function vJD(D,$){var X=D[$];return fJD(X)?X:void 0}function _JD(D){if(D!=null){try{return hP.call(D)}catch($){}try{return D+""}catch($){}}return""}function kJD(D){var $=mP(D)?xJD.call(D):"";return $==VJD||$==NJD}function mP(D){var $=typeof D;return!!D&&($=="object"||$=="function")}function fJD(D){if(!mP(D))return!1;var $=kJD(D)||TJD(D)?SJD:LJD;return $.test(_JD(D))}function yJD(){}E9.exports=uJD});var lP=T((P9,C9)=>{var Y3={function:!0,object:!0},bJD=Y3[typeof P9]&&P9&&!P9.nodeType?P9:void 0,gJD=Y3[typeof C9]&&C9&&!C9.nodeType?C9:void 0,hJD=XY(bJD&&gJD&&typeof global=="object"&&global),mJD=XY(Y3[typeof self]&&self),cP=XY(Y3[typeof window]&&window),QU=XY(Y3[typeof P9]&&P9),dJD=hJD||cP!==(QU&&QU.window)&&cP||mJD||QU||Function("return this")();function XY(D){return D&&D.Object===Object?D:null}C9.exports=dJD});var aP=T((ByD,oP)=>{var cJD=dP(),lJD=lP(),nJD=200,FU="__lodash_hash_undefined__",iJD="[object Function]",pJD="[object GeneratorFunction]",rJD=/[\\^$.*+?()[\]{}|]/g,oJD=/^\[object .+?Constructor\]$/;function aJD(D,$){return!!D.length&&sJD(D,$,0)>-1}function tJD(D,$,X){var Y=-1,J=D.length;while(++Y<J)if(X($,D[Y]))return!0;return!1}function sJD(D,$,X){if($!==$)return DYD(D,X);var Y=X-1,J=D.length;while(++Y<J)if(D[Y]===$)return Y;return-1}function eJD(D,$){return D.has($)}function DYD(D,$,X){var Y=D.length,J=$+(X?0:-1);while(X?J--:++J<Y){var Q=D[J];if(Q!==Q)return J}return-1}function $YD(D){var $=!1;if(D!=null&&typeof D.toString!="function")try{$=!!(D+"")}catch(X){}return $}function XYD(D){var $=-1,X=Array(D.size);return D.forEach(function(Y){X[++$]=Y}),X}var JYD=Array.prototype,nP=Object.prototype,iP=Function.prototype.toString,wU=nP.hasOwnProperty,YYD=nP.toString,QYD=RegExp("^"+iP.call(wU).replace(rJD,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),FYD=JYD.splice,wYD=pP(lJD,"Map"),Q3=pP(Object,"create");function D8(D){var $=-1,X=D?D.length:0;this.clear();while(++$<X){var Y=D[$];this.set(Y[0],Y[1])}}function ZYD(){this.__data__=Q3?Q3(null):{}}function GYD(D){return this.has(D)&&delete this.__data__[D]}function OYD(D){var $=this.__data__;if(Q3){var X=$[D];return X===FU?void 0:X}return wU.call($,D)?$[D]:void 0}function UYD(D){var $=this.__data__;return Q3?$[D]!==void 0:wU.call($,D)}function qYD(D,$){var X=this.__data__;return X[D]=Q3&&$===void 0?FU:$,this}D8.prototype.clear=ZYD;D8.prototype.delete=GYD;D8.prototype.get=OYD;D8.prototype.has=UYD;D8.prototype.set=qYD;function x9(D){var $=-1,X=D?D.length:0;this.clear();while(++$<X){var Y=D[$];this.set(Y[0],Y[1])}}function zYD(){this.__data__=[]}function BYD(D){var $=this.__data__,X=YY($,D);if(X<0)return!1;var Y=$.length-1;if(X==Y)$.pop();else FYD.call($,X,1);return!0}function KYD(D){var $=this.__data__,X=YY($,D);return X<0?void 0:$[X][1]}function WYD(D){return YY(this.__data__,D)>-1}function HYD(D,$){var X=this.__data__,Y=YY(X,D);if(Y<0)X.push([D,$]);else X[Y][1]=$;return this}x9.prototype.clear=zYD;x9.prototype.delete=BYD;x9.prototype.get=KYD;x9.prototype.has=WYD;x9.prototype.set=HYD;function S9(D){var $=-1,X=D?D.length:0;this.clear();while(++$<X){var Y=D[$];this.set(Y[0],Y[1])}}function VYD(){this.__data__={hash:new D8,map:new(wYD||x9),string:new D8}}function NYD(D){return QY(this,D).delete(D)}function MYD(D){return QY(this,D).get(D)}function LYD(D){return QY(this,D).has(D)}function IYD(D,$){return QY(this,D).set(D,$),this}S9.prototype.clear=VYD;S9.prototype.delete=NYD;S9.prototype.get=MYD;S9.prototype.has=LYD;S9.prototype.set=IYD;function JY(D){var $=-1,X=D?D.length:0;this.__data__=new S9;while(++$<X)this.add(D[$])}function AYD(D){return this.__data__.set(D,FU),this}function RYD(D){return this.__data__.has(D)}JY.prototype.add=JY.prototype.push=AYD;JY.prototype.has=RYD;function YY(D,$){var X=D.length;while(X--)if(CYD(D[X][0],$))return X;return-1}function jYD(D,$,X){var Y=-1,J=aJD,Q=D.length,F=!0,w=[],Z=w;if(X)F=!1,J=tJD;else if(Q>=nJD){var G=$?null:cJD(D);if(G)return XYD(G);F=!1,J=eJD,Z=new JY}else Z=$?[]:w;D:while(++Y<Q){var O=D[Y],U=$?$(O):O;if(O=X||O!==0?O:0,F&&U===U){var z=Z.length;while(z--)if(Z[z]===U)continue D;if($)Z.push(U);w.push(O)}else if(!J(Z,U,X)){if(Z!==w)Z.push(U);w.push(O)}}return w}function QY(D,$){var X=D.__data__;return EYD($)?X[typeof $=="string"?"string":"hash"]:X.map}function pP(D,$){var X=D[$];return xYD(X)?X:void 0}function EYD(D){var $=typeof D;return $=="string"||$=="number"||$=="symbol"||$=="boolean"?D!=="__proto__":D===null}function TYD(D){if(D!=null){try{return iP.call(D)}catch($){}try{return D+""}catch($){}}return""}function CYD(D,$){return D===$||D!==D&&$!==$}function PYD(D){var $=rP(D)?YYD.call(D):"";return $==iJD||$==pJD}function rP(D){var $=typeof D;return!!D&&($=="object"||$=="function")}function xYD(D){if(!rP(D))return!1;var $=PYD(D)||$YD(D)?QYD:oJD;return $.test(TYD(D))}oP.exports=jYD});var sP=T((KyD,tP)=>{var SYD=yP(),uYD=aP();function vYD(D,$){return D&&D.length?uYD(D,SYD($)):[]}tP.exports=vYD});var Dx=T((WyD,eP)=>{var _YD=oC(),kYD=sP(),fYD=_YD("MultiError");eP.exports=ZU;function ZU(D){if(!(this instanceof ZU))return new ZU(D);if(D=Array.isArray(D)?D:[D],D=kYD(D,function(X){return X.stack}),D.length===1)return D[0];var $=new fYD({message:D.map(function(X){return X.message}).join("; "),errors:D.reduce(function(X,Y){return X.concat(Y.errors||Y)},[])});return $.__defineGetter__("stack",function(){return D.map(function(X){return X.stack}).join(`
@@ -127,8 +127,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
127
127
  `)}),$.__defineSetter__("stack",function(X){return[X].concat($.stack).join(`
128
128
 
129
129
  `)}),$}});var Xx=T((HyD,$x)=>{var c6=p("constants"),yYD=process.cwd,FY=null,bYD=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){if(!FY)FY=yYD.call(process);return FY};try{process.cwd()}catch(D){}if(typeof process.chdir==="function"){if(wY=process.chdir,process.chdir=function(D){FY=null,wY.call(process,D)},Object.setPrototypeOf)Object.setPrototypeOf(process.chdir,wY)}var wY;$x.exports=gYD;function gYD(D){if(c6.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./))$(D);if(!D.lutimes)X(D);if(D.chown=Q(D.chown),D.fchown=Q(D.fchown),D.lchown=Q(D.lchown),D.chmod=Y(D.chmod),D.fchmod=Y(D.fchmod),D.lchmod=Y(D.lchmod),D.chownSync=F(D.chownSync),D.fchownSync=F(D.fchownSync),D.lchownSync=F(D.lchownSync),D.chmodSync=J(D.chmodSync),D.fchmodSync=J(D.fchmodSync),D.lchmodSync=J(D.lchmodSync),D.stat=w(D.stat),D.fstat=w(D.fstat),D.lstat=w(D.lstat),D.statSync=Z(D.statSync),D.fstatSync=Z(D.fstatSync),D.lstatSync=Z(D.lstatSync),D.chmod&&!D.lchmod)D.lchmod=function(O,U,z){if(z)process.nextTick(z)},D.lchmodSync=function(){};if(D.chown&&!D.lchown)D.lchown=function(O,U,z,q){if(q)process.nextTick(q)},D.lchownSync=function(){};if(bYD==="win32")D.rename=typeof D.rename!=="function"?D.rename:function(O){function U(z,q,B){var K=Date.now(),M=0;O(z,q,function L(I){if(I&&(I.code==="EACCES"||I.code==="EPERM"||I.code==="EBUSY")&&Date.now()-K<60000){if(setTimeout(function(){D.stat(q,function(W,N){if(W&&W.code==="ENOENT")O(z,q,L);else B(I)})},M),M<100)M+=10;return}if(B)B(I)})}if(Object.setPrototypeOf)Object.setPrototypeOf(U,O);return U}(D.rename);D.read=typeof D.read!=="function"?D.read:function(O){function U(z,q,B,K,M,L){var I;if(L&&typeof L==="function"){var W=0;I=function(N,V,R){if(N&&N.code==="EAGAIN"&&W<10)return W++,O.call(D,z,q,B,K,M,I);L.apply(this,arguments)}}return O.call(D,z,q,B,K,M,I)}if(Object.setPrototypeOf)Object.setPrototypeOf(U,O);return U}(D.read),D.readSync=typeof D.readSync!=="function"?D.readSync:function(O){return function(U,z,q,B,K){var M=0;while(!0)try{return O.call(D,U,z,q,B,K)}catch(L){if(L.code==="EAGAIN"&&M<10){M++;continue}throw L}}}(D.readSync);function $(O){O.lchmod=function(U,z,q){O.open(U,c6.O_WRONLY|c6.O_SYMLINK,z,function(B,K){if(B){if(q)q(B);return}O.fchmod(K,z,function(M){O.close(K,function(L){if(q)q(M||L)})})})},O.lchmodSync=function(U,z){var q=O.openSync(U,c6.O_WRONLY|c6.O_SYMLINK,z),B=!0,K;try{K=O.fchmodSync(q,z),B=!1}finally{if(B)try{O.closeSync(q)}catch(M){}else O.closeSync(q)}return K}}function X(O){if(c6.hasOwnProperty("O_SYMLINK")&&O.futimes)O.lutimes=function(U,z,q,B){O.open(U,c6.O_SYMLINK,function(K,M){if(K){if(B)B(K);return}O.futimes(M,z,q,function(L){O.close(M,function(I){if(B)B(L||I)})})})},O.lutimesSync=function(U,z,q){var B=O.openSync(U,c6.O_SYMLINK),K,M=!0;try{K=O.futimesSync(B,z,q),M=!1}finally{if(M)try{O.closeSync(B)}catch(L){}else O.closeSync(B)}return K};else if(O.futimes)O.lutimes=function(U,z,q,B){if(B)process.nextTick(B)},O.lutimesSync=function(){}}function Y(O){if(!O)return O;return function(U,z,q){return O.call(D,U,z,function(B){if(G(B))B=null;if(q)q.apply(this,arguments)})}}function J(O){if(!O)return O;return function(U,z){try{return O.call(D,U,z)}catch(q){if(!G(q))throw q}}}function Q(O){if(!O)return O;return function(U,z,q,B){return O.call(D,U,z,q,function(K){if(G(K))K=null;if(B)B.apply(this,arguments)})}}function F(O){if(!O)return O;return function(U,z,q){try{return O.call(D,U,z,q)}catch(B){if(!G(B))throw B}}}function w(O){if(!O)return O;return function(U,z,q){if(typeof z==="function")q=z,z=null;function B(K,M){if(M){if(M.uid<0)M.uid+=4294967296;if(M.gid<0)M.gid+=4294967296}if(q)q.apply(this,arguments)}return z?O.call(D,U,z,B):O.call(D,U,B)}}function Z(O){if(!O)return O;return function(U,z){var q=z?O.call(D,U,z):O.call(D,U);if(q){if(q.uid<0)q.uid+=4294967296;if(q.gid<0)q.gid+=4294967296}return q}}function G(O){if(!O)return!0;if(O.code==="ENOSYS")return!0;var U=!process.getuid||process.getuid()!==0;if(U){if(O.code==="EINVAL"||O.code==="EPERM")return!0}return!1}}});var Qx=T((VyD,Yx)=>{var Jx=p("stream").Stream;Yx.exports=hYD;function hYD(D){return{ReadStream:$,WriteStream:X};function $(Y,J){if(!(this instanceof $))return new $(Y,J);Jx.call(this);var Q=this;this.path=Y,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,J=J||{};var F=Object.keys(J);for(var w=0,Z=F.length;w<Z;w++){var G=F[w];this[G]=J[G]}if(this.encoding)this.setEncoding(this.encoding);if(this.start!==void 0){if(typeof this.start!=="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!=="number")throw TypeError("end must be a Number");if(this.start>this.end)throw Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){Q._read()});return}D.open(this.path,this.flags,this.mode,function(O,U){if(O){Q.emit("error",O),Q.readable=!1;return}Q.fd=U,Q.emit("open",U),Q._read()})}function X(Y,J){if(!(this instanceof X))return new X(Y,J);Jx.call(this),this.path=Y,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,J=J||{};var Q=Object.keys(J);for(var F=0,w=Q.length;F<w;F++){var Z=Q[F];this[Z]=J[Z]}if(this.start!==void 0){if(typeof this.start!=="number")throw TypeError("start must be a Number");if(this.start<0)throw Error("start must be >= zero");this.pos=this.start}if(this.busy=!1,this._queue=[],this.fd===null)this._open=D.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush()}}});var wx=T((NyD,Fx)=>{Fx.exports=dYD;var mYD=Object.getPrototypeOf||function(D){return D.__proto__};function dYD(D){if(D===null||typeof D!=="object")return D;if(D instanceof Object)var $={__proto__:mYD(D)};else var $=Object.create(null);return Object.getOwnPropertyNames(D).forEach(function(X){Object.defineProperty($,X,Object.getOwnPropertyDescriptor(D,X))}),$}});var S0=T((MyD,qU)=>{var L0=p("fs"),cYD=Xx(),lYD=Qx(),nYD=wx(),ZY=p("util"),r0,OY;if(typeof Symbol==="function"&&typeof Symbol.for==="function")r0=Symbol.for("graceful-fs.queue"),OY=Symbol.for("graceful-fs.previous");else r0="___graceful-fs.queue",OY="___graceful-fs.previous";function iYD(){}function Gx(D,$){Object.defineProperty(D,r0,{get:function(){return $}})}var $8=iYD;if(ZY.debuglog)$8=ZY.debuglog("gfs4");else if(/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))$8=function(){var D=ZY.format.apply(ZY,arguments);D="GFS4: "+D.split(/\n/).join(`
130
- GFS4: `),console.error(D)};if(!L0[r0]){if(GU=global[r0]||[],Gx(L0,GU),L0.close=function(D){function $(X,Y){return D.call(L0,X,function(J){if(!J)Zx();if(typeof Y==="function")Y.apply(this,arguments)})}return Object.defineProperty($,OY,{value:D}),$}(L0.close),L0.closeSync=function(D){function $(X){D.apply(L0,arguments),Zx()}return Object.defineProperty($,OY,{value:D}),$}(L0.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))process.on("exit",function(){$8(L0[r0]),p("assert").equal(L0[r0].length,0)})}var GU;if(!global[r0])Gx(global,L0[r0]);qU.exports=OU(nYD(L0));if(process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!L0.__patched)qU.exports=OU(L0),L0.__patched=!0;function OU(D){cYD(D),D.gracefulify=OU,D.createReadStream=V,D.createWriteStream=R;var $=D.readFile;D.readFile=X;function X(_,v,S){if(typeof v==="function")S=v,v=null;return h(_,v,S);function h(g,l,f,j){return $(g,l,function(x){if(x&&(x.code==="EMFILE"||x.code==="ENFILE"))u9([h,[g,l,f],x,j||Date.now(),Date.now()]);else if(typeof f==="function")f.apply(this,arguments)})}}var Y=D.writeFile;D.writeFile=J;function J(_,v,S,h){if(typeof S==="function")h=S,S=null;return g(_,v,S,h);function g(l,f,j,x,u){return Y(l,f,j,function(y){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))u9([g,[l,f,j,x],y,u||Date.now(),Date.now()]);else if(typeof x==="function")x.apply(this,arguments)})}}var Q=D.appendFile;if(Q)D.appendFile=F;function F(_,v,S,h){if(typeof S==="function")h=S,S=null;return g(_,v,S,h);function g(l,f,j,x,u){return Q(l,f,j,function(y){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))u9([g,[l,f,j,x],y,u||Date.now(),Date.now()]);else if(typeof x==="function")x.apply(this,arguments)})}}var w=D.copyFile;if(w)D.copyFile=Z;function Z(_,v,S,h){if(typeof S==="function")h=S,S=0;return g(_,v,S,h);function g(l,f,j,x,u){return w(l,f,j,function(y){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))u9([g,[l,f,j,x],y,u||Date.now(),Date.now()]);else if(typeof x==="function")x.apply(this,arguments)})}}var G=D.readdir;D.readdir=U;var O=/^v[0-5]\./;function U(_,v,S){if(typeof v==="function")S=v,v=null;var h=O.test(process.version)?function(f,j,x,u){return G(f,g(f,j,x,u))}:function(f,j,x,u){return G(f,j,g(f,j,x,u))};return h(_,v,S);function g(l,f,j,x){return function(u,y){if(u&&(u.code==="EMFILE"||u.code==="ENFILE"))u9([h,[l,f,j],u,x||Date.now(),Date.now()]);else{if(y&&y.sort)y.sort();if(typeof j==="function")j.call(this,u,y)}}}}if(process.version.substr(0,4)==="v0.8"){var z=lYD(D);L=z.ReadStream,W=z.WriteStream}var q=D.ReadStream;if(q)L.prototype=Object.create(q.prototype),L.prototype.open=I;var B=D.WriteStream;if(B)W.prototype=Object.create(B.prototype),W.prototype.open=N;Object.defineProperty(D,"ReadStream",{get:function(){return L},set:function(_){L=_},enumerable:!0,configurable:!0}),Object.defineProperty(D,"WriteStream",{get:function(){return W},set:function(_){W=_},enumerable:!0,configurable:!0});var K=L;Object.defineProperty(D,"FileReadStream",{get:function(){return K},set:function(_){K=_},enumerable:!0,configurable:!0});var M=W;Object.defineProperty(D,"FileWriteStream",{get:function(){return M},set:function(_){M=_},enumerable:!0,configurable:!0});function L(_,v){if(this instanceof L)return q.apply(this,arguments),this;else return L.apply(Object.create(L.prototype),arguments)}function I(){var _=this;A(_.path,_.flags,_.mode,function(v,S){if(v){if(_.autoClose)_.destroy();_.emit("error",v)}else _.fd=S,_.emit("open",S),_.read()})}function W(_,v){if(this instanceof W)return B.apply(this,arguments),this;else return W.apply(Object.create(W.prototype),arguments)}function N(){var _=this;A(_.path,_.flags,_.mode,function(v,S){if(v)_.destroy(),_.emit("error",v);else _.fd=S,_.emit("open",S)})}function V(_,v){return new D.ReadStream(_,v)}function R(_,v){return new D.WriteStream(_,v)}var P=D.open;D.open=A;function A(_,v,S,h){if(typeof S==="function")h=S,S=null;return g(_,v,S,h);function g(l,f,j,x,u){return P(l,f,j,function(y,d){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))u9([g,[l,f,j,x],y,u||Date.now(),Date.now()]);else if(typeof x==="function")x.apply(this,arguments)})}}return D}function u9(D){$8("ENQUEUE",D[0].name,D[1]),L0[r0].push(D),UU()}var GY;function Zx(){var D=Date.now();for(var $=0;$<L0[r0].length;++$)if(L0[r0][$].length>2)L0[r0][$][3]=D,L0[r0][$][4]=D;UU()}function UU(){if(clearTimeout(GY),GY=void 0,L0[r0].length===0)return;var D=L0[r0].shift(),$=D[0],X=D[1],Y=D[2],J=D[3],Q=D[4];if(J===void 0)$8("RETRY",$.name,X),$.apply(null,X);else if(Date.now()-J>=60000){$8("TIMEOUT",$.name,X);var F=X.pop();if(typeof F==="function")F.call(null,Y)}else{var w=Date.now()-Q,Z=Math.max(Q-J,1),G=Math.min(Z*1.2,100);if(w>=G)$8("RETRY",$.name,X),$.apply(null,X.concat([J]));else L0[r0].push(D)}if(GY===void 0)GY=setTimeout(UU,0)}});var Ux=T((LyD,Ox)=>{function e1(D,$){if(typeof $==="boolean")$={forever:$};if(this._originalTimeouts=JSON.parse(JSON.stringify(D)),this._timeouts=D,this._options=$||{},this._maxRetryTime=$&&$.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever)this._cachedTimeouts=this._timeouts.slice(0)}Ox.exports=e1;e1.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};e1.prototype.stop=function(){if(this._timeout)clearTimeout(this._timeout);this._timeouts=[],this._cachedTimeouts=null};e1.prototype.retry=function(D){if(this._timeout)clearTimeout(this._timeout);if(!D)return!1;var $=new Date().getTime();if(D&&$-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error("RetryOperation timeout occurred")),!1;this._errors.push(D);var X=this._timeouts.shift();if(X===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),X=this._timeouts.shift();else return!1;var Y=this,J=setTimeout(function(){if(Y._attempts++,Y._operationTimeoutCb){if(Y._timeout=setTimeout(function(){Y._operationTimeoutCb(Y._attempts)},Y._operationTimeout),Y._options.unref)Y._timeout.unref()}Y._fn(Y._attempts)},X);if(this._options.unref)J.unref();return!0};e1.prototype.attempt=function(D,$){if(this._fn=D,$){if($.timeout)this._operationTimeout=$.timeout;if($.cb)this._operationTimeoutCb=$.cb}var X=this;if(this._operationTimeoutCb)this._timeout=setTimeout(function(){X._operationTimeoutCb()},X._operationTimeout);this._operationStart=new Date().getTime(),this._fn(this._attempts)};e1.prototype.try=function(D){console.log("Using RetryOperation.try() is deprecated"),this.attempt(D)};e1.prototype.start=function(D){console.log("Using RetryOperation.start() is deprecated"),this.attempt(D)};e1.prototype.start=e1.prototype.try;e1.prototype.errors=function(){return this._errors};e1.prototype.attempts=function(){return this._attempts};e1.prototype.mainError=function(){if(this._errors.length===0)return null;var D={},$=null,X=0;for(var Y=0;Y<this._errors.length;Y++){var J=this._errors[Y],Q=J.message,F=(D[Q]||0)+1;if(D[Q]=F,F>=X)$=J,X=F}return $}});var zx=T((rYD)=>{var pYD=Ux();rYD.operation=function(D){var $=rYD.timeouts(D);return new pYD($,{forever:D&&D.forever,unref:D&&D.unref,maxRetryTime:D&&D.maxRetryTime})};rYD.timeouts=function(D){if(D instanceof Array)return[].concat(D);var $={retries:10,factor:2,minTimeout:1000,maxTimeout:1/0,randomize:!1};for(var X in D)$[X]=D[X];if($.minTimeout>$.maxTimeout)throw Error("minTimeout is greater than maxTimeout");var Y=[];for(var J=0;J<$.retries;J++)Y.push(this.createTimeout(J,$));if(D&&D.forever&&!Y.length)Y.push(this.createTimeout(J,$));return Y.sort(function(Q,F){return Q-F}),Y};rYD.createTimeout=function(D,$){var X=$.randomize?Math.random()+1:1,Y=Math.round(X*$.minTimeout*Math.pow($.factor,D));return Y=Math.min(Y,$.maxTimeout),Y};rYD.wrap=function(D,$,X){if($ instanceof Array)X=$,$=null;if(!X){X=[];for(var Y in D)if(typeof D[Y]==="function")X.push(Y)}for(var J=0;J<X.length;J++){var Q=X[J],F=D[Q];D[Q]=function(Z){var G=rYD.operation($),O=Array.prototype.slice.call(arguments,1),U=O.pop();O.push(function(z){if(G.retry(z))return;if(z)arguments[0]=G.mainError();U.apply(this,arguments)}),G.attempt(function(){Z.apply(D,O)})}.bind(D,F),D[Q].options=$}}});var Bx=T((AyD,UY)=>{UY.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];if(process.platform!=="win32")UY.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")UY.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var BY=T((RyD,_9)=>{var K0=global.process,X8=function(D){return 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"};if(!X8(K0))_9.exports=function(){return function(){}};else{if(zU=p("assert"),J8=Bx(),BU=/^win/i.test(K0.platform),v9=p("events"),typeof v9!=="function")v9=v9.EventEmitter;if(K0.__signal_exit_emitter__)h0=K0.__signal_exit_emitter__;else h0=K0.__signal_exit_emitter__=new v9,h0.count=0,h0.emitted={};if(!h0.infinite)h0.setMaxListeners(1/0),h0.infinite=!0;_9.exports=function(D,$){if(!X8(global.process))return function(){};if(zU.equal(typeof D,"function","a callback must be provided for exit handler"),Y8===!1)qY();var X="exit";if($&&$.alwaysLast)X="afterexit";var Y=function(){if(h0.removeListener(X,D),h0.listeners("exit").length===0&&h0.listeners("afterexit").length===0)F3()};return h0.on(X,D),Y},F3=function(){if(!Y8||!X8(global.process))return;Y8=!1,J8.forEach(function($){try{K0.removeListener($,w3[$])}catch(X){}}),K0.emit=Z3,K0.reallyExit=zY,h0.count-=1},_9.exports.unload=F3,l6=function($,X,Y){if(h0.emitted[$])return;h0.emitted[$]=!0,h0.emit($,X,Y)},w3={},J8.forEach(function(D){w3[D]=function(){if(!X8(global.process))return;var X=K0.listeners(D);if(X.length===h0.count){if(F3(),l6("exit",null,D),l6("afterexit",null,D),BU&&D==="SIGHUP")D="SIGINT";K0.kill(K0.pid,D)}}}),_9.exports.signals=function(){return J8},Y8=!1,qY=function(){if(Y8||!X8(global.process))return;Y8=!0,h0.count+=1,J8=J8.filter(function($){try{return K0.on($,w3[$]),!0}catch(X){return!1}}),K0.emit=WU,K0.reallyExit=KU},_9.exports.load=qY,zY=K0.reallyExit,KU=function($){if(!X8(global.process))return;K0.exitCode=$||0,l6("exit",K0.exitCode,null),l6("afterexit",K0.exitCode,null),zY.call(K0,K0.exitCode)},Z3=K0.emit,WU=function($,X){if($==="exit"&&X8(global.process)){if(X!==void 0)K0.exitCode=X;var Y=Z3.apply(this,arguments);return l6("exit",K0.exitCode,null),l6("afterexit",K0.exitCode,null),Y}else return Z3.apply(this,arguments)}}var zU,J8,BU,v9,h0,F3,l6,w3,Y8,qY,zY,KU,Z3,WU});var Wx=T((DQD,HU)=>{var Kx=Symbol();function sYD(D,$,X){let Y=$[Kx];if(Y)return $.stat(D,(Q,F)=>{if(Q)return X(Q);X(null,F.mtime,Y)});let J=new Date(Math.ceil(Date.now()/1000)*1000+5);$.utimes(D,J,J,(Q)=>{if(Q)return X(Q);$.stat(D,(F,w)=>{if(F)return X(F);let Z=w.mtime.getTime()%1000===0?"s":"ms";Object.defineProperty($,Kx,{value:Z}),X(null,w.mtime,Z)})})}function eYD(D){let $=Date.now();if(D==="s")$=Math.ceil($/1000)*1000;return new Date($)}DQD.probe=sYD;DQD.getMtime=eYD});var Lx=T((GQD,O3)=>{var JQD=p("path"),MU=S0(),YQD=zx(),QQD=BY(),Hx=Wx(),Q6={};function G3(D,$){return $.lockfilePath||`${D}.lock`}function LU(D,$,X){if(!$.realpath)return X(null,JQD.resolve(D));$.fs.realpath(D,X)}function NU(D,$,X){let Y=G3(D,$);$.fs.mkdir(Y,(J)=>{if(!J)return Hx.probe(Y,$.fs,(Q,F,w)=>{if(Q)return $.fs.rmdir(Y,()=>{}),X(Q);X(null,F,w)});if(J.code!=="EEXIST")return X(J);if($.stale<=0)return X(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:D}));$.fs.stat(Y,(Q,F)=>{if(Q){if(Q.code==="ENOENT")return NU(D,{...$,stale:0},X);return X(Q)}if(!Vx(F,$))return X(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:D}));Nx(D,$,(w)=>{if(w)return X(w);NU(D,{...$,stale:0},X)})})})}function Vx(D,$){return D.mtime.getTime()<Date.now()-$.stale}function Nx(D,$,X){$.fs.rmdir(G3(D,$),(Y)=>{if(Y&&Y.code!=="ENOENT")return X(Y);X()})}function KY(D,$){let X=Q6[D];if(X.updateTimeout)return;if(X.updateDelay=X.updateDelay||$.update,X.updateTimeout=setTimeout(()=>{X.updateTimeout=null,$.fs.stat(X.lockfilePath,(Y,J)=>{let Q=X.lastUpdate+$.stale<Date.now();if(Y){if(Y.code==="ENOENT"||Q)return VU(D,X,Object.assign(Y,{code:"ECOMPROMISED"}));return X.updateDelay=1000,KY(D,$)}if(X.mtime.getTime()!==J.mtime.getTime())return VU(D,X,Object.assign(Error("Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"}));let w=Hx.getMtime(X.mtimePrecision);$.fs.utimes(X.lockfilePath,w,w,(Z)=>{let G=X.lastUpdate+$.stale<Date.now();if(X.released)return;if(Z){if(Z.code==="ENOENT"||G)return VU(D,X,Object.assign(Z,{code:"ECOMPROMISED"}));return X.updateDelay=1000,KY(D,$)}X.mtime=w,X.lastUpdate=Date.now(),X.updateDelay=null,KY(D,$)})})},X.updateDelay),X.updateTimeout.unref)X.updateTimeout.unref()}function VU(D,$,X){if($.released=!0,$.updateTimeout)clearTimeout($.updateTimeout);if(Q6[D]===$)delete Q6[D];$.options.onCompromised(X)}function FQD(D,$,X){$={stale:1e4,update:null,realpath:!0,retries:0,fs:MU,onCompromised:(Y)=>{throw Y},...$},$.retries=$.retries||0,$.retries=typeof $.retries==="number"?{retries:$.retries}:$.retries,$.stale=Math.max($.stale||0,2000),$.update=$.update==null?$.stale/2:$.update||0,$.update=Math.max(Math.min($.update,$.stale/2),1000),LU(D,$,(Y,J)=>{if(Y)return X(Y);let Q=YQD.operation($.retries);Q.attempt(()=>{NU(J,$,(F,w,Z)=>{if(Q.retry(F))return;if(F)return X(Q.mainError());let G=Q6[J]={lockfilePath:G3(J,$),mtime:w,mtimePrecision:Z,options:$,lastUpdate:Date.now()};KY(J,$),X(null,(O)=>{if(G.released)return O&&O(Object.assign(Error("Lock is already released"),{code:"ERELEASED"}));Mx(J,{...$,realpath:!1},O)})})})})}function Mx(D,$,X){$={fs:MU,realpath:!0,...$},LU(D,$,(Y,J)=>{if(Y)return X(Y);let Q=Q6[J];if(!Q)return X(Object.assign(Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));Q.updateTimeout&&clearTimeout(Q.updateTimeout),Q.released=!0,delete Q6[J],Nx(J,$,X)})}function wQD(D,$,X){$={stale:1e4,realpath:!0,fs:MU,...$},$.stale=Math.max($.stale||0,2000),LU(D,$,(Y,J)=>{if(Y)return X(Y);$.fs.stat(G3(J,$),(Q,F)=>{if(Q)return Q.code==="ENOENT"?X(null,!1):X(Q);return X(null,!Vx(F,$))})})}function ZQD(){return Q6}QQD(()=>{for(let D in Q6){let $=Q6[D].options;try{$.fs.rmdirSync(G3(D,$))}catch(X){}}});GQD.lock=FQD;GQD.unlock=Mx;GQD.check=wQD;GQD.getLocks=ZQD});var Ax=T((jyD,Ix)=>{var BQD=S0();function KQD(D){let $=["mkdir","realpath","stat","rmdir","utimes"],X={...D};return $.forEach((Y)=>{X[Y]=(...J)=>{let Q=J.pop(),F;try{F=D[`${Y}Sync`](...J)}catch(w){return Q(w)}Q(null,F)}}),X}function WQD(D){return(...$)=>new Promise((X,Y)=>{$.push((J,Q)=>{if(J)Y(J);else X(Q)}),D(...$)})}function HQD(D){return(...$)=>{let X,Y;if($.push((J,Q)=>{X=J,Y=Q}),D(...$),X)throw X;return Y}}function VQD(D){if(D={...D},D.fs=KQD(D.fs||BQD),typeof D.retries==="number"&&D.retries>0||D.retries&&typeof D.retries.retries==="number"&&D.retries.retries>0)throw Object.assign(Error("Cannot use retries with the sync api"),{code:"ESYNC"});return D}Ix.exports={toPromise:WQD,toSync:HQD,toSyncOptions:VQD}});var jx=T((EyD,n6)=>{var k9=Lx(),{toPromise:WY,toSync:HY,toSyncOptions:IU}=Ax();async function Rx(D,$){let X=await WY(k9.lock)(D,$);return WY(X)}function NQD(D,$){let X=HY(k9.lock)(D,IU($));return HY(X)}function MQD(D,$){return WY(k9.unlock)(D,$)}function LQD(D,$){return HY(k9.unlock)(D,IU($))}function IQD(D,$){return WY(k9.check)(D,$)}function AQD(D,$){return HY(k9.check)(D,IU($))}n6.exports=Rx;n6.exports.lock=Rx;n6.exports.unlock=MQD;n6.exports.lockSync=NQD;n6.exports.unlockSync=LQD;n6.exports.check=IQD;n6.exports.checkSync=AQD});var ux=T((xx)=>{Object.defineProperty(xx,"__esModule",{value:!0});xx.canStoreURLs=xx.FileUrlStorage=void 0;var Ex=p("fs"),RQD=EQD(Dx()),Tx=jQD(jx());function Px(D){if(typeof WeakMap!="function")return null;var $=new WeakMap,X=new WeakMap;return(Px=function(Y){return Y?X:$})(D)}function jQD(D,$){if(!$&&D&&D.__esModule)return D;if(D===null||typeof D!="object"&&typeof D!="function")return{default:D};var X=Px($);if(X&&X.has(D))return X.get(D);var Y={__proto__:null},J=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var Q in D)if(Q!=="default"&&{}.hasOwnProperty.call(D,Q)){var F=J?Object.getOwnPropertyDescriptor(D,Q):null;F&&(F.get||F.set)?Object.defineProperty(Y,Q,F):Y[Q]=D[Q]}return Y.default=D,X&&X.set(D,Y),Y}function EQD(D){return D&&D.__esModule?D:{default:D}}function U3(D){return U3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},U3(D)}function TQD(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function Cx(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,PQD(Y.key),Y)}}function CQD(D,$,X){if($)Cx(D.prototype,$);if(X)Cx(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function PQD(D){var $=xQD(D,"string");return U3($)=="symbol"?$:$+""}function xQD(D,$){if(U3(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(U3(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var TyD=xx.canStoreURLs=!0,CyD=xx.FileUrlStorage=function(){function D($){TQD(this,D),this.path=$}return CQD(D,[{key:"findAllUploads",value:function(){var X=this;return new Promise(function(Y,J){X._getItems("tus::",function(Q,F){if(Q)J(Q);else Y(F)})})}},{key:"findUploadsByFingerprint",value:function(X){var Y=this;return new Promise(function(J,Q){Y._getItems("tus::".concat(X),function(F,w){if(F)Q(F);else J(w)})})}},{key:"removeUpload",value:function(X){var Y=this;return new Promise(function(J,Q){Y._removeItem(X,function(F){if(F)Q(F);else J()})})}},{key:"addUpload",value:function(X,Y){var J=this,Q=Math.round(Math.random()*1000000000000),F="tus::".concat(X,"::").concat(Q);return new Promise(function(w,Z){J._setItem(F,Y,function(G){if(G)Z(G);else w(F)})})}},{key:"_setItem",value:function(X,Y,J){var Q=this;Tx.lock(this.path,this._lockfileOptions()).then(function(F){J=Q._releaseAndCb(F,J),Q._getData(function(w,Z){if(w){J(w);return}Z[X]=Y,Q._writeData(Z,function(G){return J(G)})})}).catch(J)}},{key:"_getItems",value:function(X,Y){this._getData(function(J,Q){if(J){Y(J);return}var F=Object.keys(Q).filter(function(w){return w.startsWith(X)}).map(function(w){var Z=Q[w];return Z.urlStorageKey=w,Z});Y(null,F)})}},{key:"_removeItem",value:function(X,Y){var J=this;Tx.lock(this.path,this._lockfileOptions()).then(function(Q){Y=J._releaseAndCb(Q,Y),J._getData(function(F,w){if(F){Y(F);return}delete w[X],J._writeData(w,function(Z){return Y(Z)})})}).catch(Y)}},{key:"_lockfileOptions",value:function(){return{realpath:!1,retries:{retries:5,minTimeout:20}}}},{key:"_releaseAndCb",value:function(X,Y){return function(J){if(J){X().then(function(){return Y(J)}).catch(function(Q){return Y((0,RQD.default)([J,Q]))});return}X().then(Y).catch(Y)}}},{key:"_writeData",value:function(X,Y){var J={encoding:"utf8",mode:432,flag:"w"};(0,Ex.writeFile)(this.path,JSON.stringify(X),J,function(Q){return Y(Q)})}},{key:"_getData",value:function(X){(0,Ex.readFile)(this.path,"utf8",function(Y,J){if(Y){if(Y.code==="ENOENT")X(null,{});else X(Y);return}try{J=!J.trim().length?{}:JSON.parse(J)}catch(Q){X(Q);return}X(null,J)})}}])}()});var NY=T((i6)=>{Object.defineProperty(i6,"__esModule",{value:!0});Object.defineProperty(i6,"DefaultHttpStack",{enumerable:!0,get:function(){return fx.default}});Object.defineProperty(i6,"DetailedError",{enumerable:!0,get:function(){return uQD.default}});Object.defineProperty(i6,"FileUrlStorage",{enumerable:!0,get:function(){return yx.FileUrlStorage}});Object.defineProperty(i6,"StreamSource",{enumerable:!0,get:function(){return yQD.default}});i6.Upload=void 0;Object.defineProperty(i6,"canStoreURLs",{enumerable:!0,get:function(){return yx.canStoreURLs}});i6.defaultOptions=void 0;Object.defineProperty(i6,"enableDebugLog",{enumerable:!0,get:function(){return vQD.enableDebugLog}});i6.isSupported=void 0;var uQD=Q8(IO()),vQD=AO(),_QD=Q8(jT()),AU=Q8(YC()),kQD=Q8(RC()),fQD=Q8(PC()),fx=Q8(nC()),yQD=Q8(_O()),yx=ux();function Q8(D){return D&&D.__esModule?D:{default:D}}function y9(D){return y9=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},y9(D)}function bQD(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function vx(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,gx(Y.key),Y)}}function gQD(D,$,X){if($)vx(D.prototype,$);if(X)vx(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function hQD(D,$,X){return $=VY($),mQD(D,bx()?Reflect.construct($,X||[],VY(D).constructor):$.apply(D,X))}function mQD(D,$){if($&&(y9($)==="object"||typeof $==="function"))return $;else if($!==void 0)throw TypeError("Derived constructors may only return object or undefined");return dQD(D)}function dQD(D){if(D===void 0)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return D}function bx(){try{var D=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch($){}return(bx=function(){return!!D})()}function VY(D){return VY=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(X){return X.__proto__||Object.getPrototypeOf(X)},VY(D)}function cQD(D,$){if(typeof $!=="function"&&$!==null)throw TypeError("Super expression must either be null or a function");if(D.prototype=Object.create($&&$.prototype,{constructor:{value:D,writable:!0,configurable:!0}}),Object.defineProperty(D,"prototype",{writable:!1}),$)RU(D,$)}function RU(D,$){return RU=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(Y,J){return Y.__proto__=J,Y},RU(D,$)}function _x(D,$){var X=Object.keys(D);if(Object.getOwnPropertySymbols){var Y=Object.getOwnPropertySymbols(D);$&&(Y=Y.filter(function(J){return Object.getOwnPropertyDescriptor(D,J).enumerable})),X.push.apply(X,Y)}return X}function f9(D){for(var $=1;$<arguments.length;$++){var X=arguments[$]!=null?arguments[$]:{};$%2?_x(Object(X),!0).forEach(function(Y){lQD(D,Y,X[Y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(D,Object.getOwnPropertyDescriptors(X)):_x(Object(X)).forEach(function(Y){Object.defineProperty(D,Y,Object.getOwnPropertyDescriptor(X,Y))})}return D}function lQD(D,$,X){if($=gx($),$ in D)Object.defineProperty(D,$,{value:X,enumerable:!0,configurable:!0,writable:!0});else D[$]=X;return D}function gx(D){var $=nQD(D,"string");return y9($)=="symbol"?$:$+""}function nQD(D,$){if(y9(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(y9(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var kx=i6.defaultOptions=f9(f9({},AU.default.defaultOptions),{},{httpStack:new fx.default,fileReader:new kQD.default,urlStorage:new _QD.default,fingerprint:fQD.default}),xyD=i6.Upload=function(D){function $(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return bQD(this,$),Y=f9(f9({},kx),Y),hQD(this,$,[X,Y])}return cQD($,D),gQD($,null,[{key:"terminate",value:function(Y){var J=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return J=f9(f9({},kx),J),AU.default.terminate(Y,J)}}])}(AU.default),SyD=i6.isSupported=!0});var F6;var MY=o(()=>{F6={name:"@capgo/cli",type:"module",version:"7.81.2",description:"A CLI to upload to capgo servers",author:"Martin martin@capgo.app",license:"Apache 2.0",homepage:"https://github.com/Cap-go/CLI#readme",repository:{type:"git",url:"git+https://github.com/Cap-go/CLI.git"},bugs:{url:"https://github.com/Cap-go/CLI/issues"},keywords:["appflow alternative","ionic","capacitor","auto update","live update","capgo","cli","upload","capgo-cli","sdk"],exports:{".":{import:"./dist/index.js",require:"./dist/index.js"},"./sdk":{types:"./dist/src/sdk.d.ts",import:"./dist/src/sdk.js"}},main:"dist/index.js",types:"dist/src/index.d.ts",bin:{capgo:"dist/index.js"},engines:{npm:">=8.0.0",node:">=20.0.0"},scripts:{build:"tsc && bun build.mjs",dev:"NODE_ENV=development ncc build","no-debug":"node dist/index.js","dev-build":"SUPA_DB=development ncc build",pack:"pkg",types:"npx --yes supabase gen types typescript --project-id=xvwzpoazmxkqosrdewyv > src/types/supabase.types.ts",typecheck:"tsc --noEmit",lint:'eslint "src/**/*.ts" --fix',"check-posix-paths":"node test/check-posix-paths.js","generate-docs":"node dist/index.js generate-docs README.md","test:bundle":"bun test/test-bundle.mjs","test:functional":"bun test/test-functional.mjs","test:semver":"bun test/test-semver-validation.mjs","test:version-edge-cases":"bun test/test-version-validation.mjs","test:regex":"bun test/test-regex-validation.mjs","test:upload":"bun test/test-upload-validation.mjs","test:credentials":"bun test/test-credentials.mjs","test:credentials-validation":"bun test/test-credentials-validation.mjs","test:build-zip-filter":"bun test/test-build-zip-filter.mjs","test:checksum":"bun test/test-checksum-algorithm.mjs","test:esm-sdk":"node test/test-sdk-esm.mjs","test:mcp":"node test/test-mcp.mjs","test:version-detection":"node test/test-get-installed-version.mjs","test:version-detection:setup":"./test/fixtures/setup-test-projects.sh","test:platform-paths":"bun test/test-platform-paths.mjs",test:"bun run test:bundle && bun run test:functional && bun run test:semver && bun run test:version-edge-cases && bun run test:regex && bun run test:upload && bun run test:credentials && bun run test:credentials-validation && bun run test:build-zip-filter && bun run test:checksum && bun run test:esm-sdk && bun run test:mcp && bun run test:version-detection && bun run test:platform-paths"},devDependencies:{"@antfu/eslint-config":"^7.0.0","@bradenmacdonald/s3-lite-client":"npm:@jsr/bradenmacdonald__s3-lite-client@0.9.4","@capacitor/cli":"^8.0.0","@capgo/find-package-manager":"^0.0.18","@clack/prompts":"^1.0.0","@modelcontextprotocol/sdk":"^1.25.3","@sauber/table":"npm:@jsr/sauber__table","@std/semver":"npm:@jsr/std__semver@1.0.6","@supabase/supabase-js":"^2.79.0","@types/adm-zip":"^0.5.7","@types/node":"^25.0.0","@types/prettyjson":"^0.0.33","@types/tmp":"^0.2.6","@vercel/ncc":"^0.38.4","adm-zip":"^0.5.16","ci-info":"^4.3.1",commander:"^14.0.2",eslint:"^9.38.0","git-format-staged":"4.0.1",husky:"^9.1.7","is-wsl":"^3.1.0",micromatch:"^4.0.8",open:"^11.0.0",prettyjson:"^1.2.5",tmp:"^0.2.5","tus-js-client":"^4.3.1",typescript:"^5.9.3",partysocket:"^1.1.11",ws:"^8.18.3",zod:"^4.3.6"}}});async function LY(D){try{let X=`https://registry.npmjs.org/${encodeURIComponent(D.toLowerCase())}`,Y=await fetch(X,{headers:{accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"}});if(!Y.ok)return null;return(await Y.json())["dist-tags"]?.latest||null}catch{return null}}async function F0(){let D=await LY("@capgo/cli")??"",$=D?.split(".")[0];if(D!==F6.version)H.warning(`\uD83D\uDEA8 You are using @capgo/cli@${F6.version} it's not the latest version.
131
- Please use @capgo/cli@${D}" or @capgo/cli@${$} to keep up to date with the latest features and bug fixes.`)}var q1=o(()=>{vD();MY()});async function cx(D,$,X,Y,J,Q="✅"){await RD(X,{channel:D,event:Y,icon:Q,user_id:$,...J?{tags:{"app-id":J}}:{},notify:!1})}var lx=o(()=>{vD();s$();q1();fD()});import{Buffer as nx}from"node:buffer";import{createHash as pQD}from"node:crypto";function oQD(D){let $=4294967295;for(let X=0;X<D.length;X++){let Y=D[X];$=rQD[($^Y)&255]^$>>>8}return $=$^4294967295,($>>>0).toString(16).padStart(8,"0")}async function p6(D,$="sha256"){let X=nx.isBuffer(D)?D:nx.from(D);if($==="crc32")return oQD(X);let Y=pQD($);return Y.update(X),Y.digest("hex")}var rQD;var q3=o(()=>{rQD=(()=>{let D=[];for(let $=0;$<256;$++){let X=$;for(let Y=0;Y<8;Y++)X=X&1?3988292384^X>>>1:X>>>1;D[$]=X}return D})()});var px=T((pyD,ix)=>{var b9=1000,g9=b9*60,h9=g9*60,F8=h9*24,aQD=F8*7,tQD=F8*365.25;ix.exports=function(D,$){$=$||{};var X=typeof D;if(X==="string"&&D.length>0)return sQD(D);else if(X==="number"&&isFinite(D))return $.long?DFD(D):eQD(D);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(D))};function sQD(D){if(D=String(D),D.length>100)return;var $=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(D);if(!$)return;var X=parseFloat($[1]),Y=($[2]||"ms").toLowerCase();switch(Y){case"years":case"year":case"yrs":case"yr":case"y":return X*tQD;case"weeks":case"week":case"w":return X*aQD;case"days":case"day":case"d":return X*F8;case"hours":case"hour":case"hrs":case"hr":case"h":return X*h9;case"minutes":case"minute":case"mins":case"min":case"m":return X*g9;case"seconds":case"second":case"secs":case"sec":case"s":return X*b9;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return X;default:return}}function eQD(D){var $=Math.abs(D);if($>=F8)return Math.round(D/F8)+"d";if($>=h9)return Math.round(D/h9)+"h";if($>=g9)return Math.round(D/g9)+"m";if($>=b9)return Math.round(D/b9)+"s";return D+"ms"}function DFD(D){var $=Math.abs(D);if($>=F8)return IY(D,$,F8,"day");if($>=h9)return IY(D,$,h9,"hour");if($>=g9)return IY(D,$,g9,"minute");if($>=b9)return IY(D,$,b9,"second");return D+" ms"}function IY(D,$,X,Y){var J=$>=X*1.5;return Math.round(D/X)+" "+Y+(J?"s":"")}});var jU=T((ryD,rx)=>{function $FD(D){X.debug=X,X.default=X,X.coerce=Z,X.disable=F,X.enable=J,X.enabled=w,X.humanize=px(),X.destroy=G,Object.keys(D).forEach((O)=>{X[O]=D[O]}),X.names=[],X.skips=[],X.formatters={};function $(O){let U=0;for(let z=0;z<O.length;z++)U=(U<<5)-U+O.charCodeAt(z),U|=0;return X.colors[Math.abs(U)%X.colors.length]}X.selectColor=$;function X(O){let U,z=null,q,B;function K(...M){if(!K.enabled)return;let L=K,I=Number(new Date),W=I-(U||I);if(L.diff=W,L.prev=U,L.curr=I,U=I,M[0]=X.coerce(M[0]),typeof M[0]!=="string")M.unshift("%O");let N=0;M[0]=M[0].replace(/%([a-zA-Z%])/g,(R,P)=>{if(R==="%%")return"%";N++;let A=X.formatters[P];if(typeof A==="function"){let _=M[N];R=A.call(L,_),M.splice(N,1),N--}return R}),X.formatArgs.call(L,M),(L.log||X.log).apply(L,M)}if(K.namespace=O,K.useColors=X.useColors(),K.color=X.selectColor(O),K.extend=Y,K.destroy=X.destroy,Object.defineProperty(K,"enabled",{enumerable:!0,configurable:!1,get:()=>{if(z!==null)return z;if(q!==X.namespaces)q=X.namespaces,B=X.enabled(O);return B},set:(M)=>{z=M}}),typeof X.init==="function")X.init(K);return K}function Y(O,U){let z=X(this.namespace+(typeof U>"u"?":":U)+O);return z.log=this.log,z}function J(O){X.save(O),X.namespaces=O,X.names=[],X.skips=[];let U=(typeof O==="string"?O:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let z of U)if(z[0]==="-")X.skips.push(z.slice(1));else X.names.push(z)}function Q(O,U){let z=0,q=0,B=-1,K=0;while(z<O.length)if(q<U.length&&(U[q]===O[z]||U[q]==="*"))if(U[q]==="*")B=q,K=z,q++;else z++,q++;else if(B!==-1)q=B+1,K++,z=K;else return!1;while(q<U.length&&U[q]==="*")q++;return q===U.length}function F(){let O=[...X.names,...X.skips.map((U)=>"-"+U)].join(",");return X.enable(""),O}function w(O){for(let U of X.skips)if(Q(O,U))return!1;for(let U of X.names)if(Q(O,U))return!0;return!1}function Z(O){if(O instanceof Error)return O.stack||O.message;return O}function G(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return X.enable(X.load()),X}rx.exports=$FD});var ax=T((ox,AY)=>{ox.formatArgs=JFD;ox.save=YFD;ox.load=QFD;ox.useColors=XFD;ox.storage=FFD();ox.destroy=(()=>{let D=!1;return()=>{if(!D)D=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}})();ox.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function XFD(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let D;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(D=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(D[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function JFD(D){if(D[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+D[0]+(this.useColors?"%c ":" ")+"+"+AY.exports.humanize(this.diff),!this.useColors)return;let $="color: "+this.color;D.splice(1,0,$,"color: inherit");let X=0,Y=0;D[0].replace(/%[a-zA-Z%]/g,(J)=>{if(J==="%%")return;if(X++,J==="%c")Y=X}),D.splice(Y,0,$)}ox.log=console.debug||console.log||(()=>{});function YFD(D){try{if(D)ox.storage.setItem("debug",D);else ox.storage.removeItem("debug")}catch($){}}function QFD(){let D;try{D=ox.storage.getItem("debug")||ox.storage.getItem("DEBUG")}catch($){}if(!D&&typeof process<"u"&&"env"in process)D=process.env.DEBUG;return D}function FFD(){try{return localStorage}catch(D){}}AY.exports=jU()(ox);var{formatters:wFD}=AY.exports;wFD.j=function(D){try{return JSON.stringify(D)}catch($){return"[UnexpectedJSONParseError]: "+$.message}}});var sx=T((ayD,tx)=>{tx.exports=(D,$=process.argv)=>{let X=D.startsWith("-")?"":D.length===1?"-":"--",Y=$.indexOf(X+D),J=$.indexOf("--");return Y!==-1&&(J===-1||Y<J)}});var $S=T((tyD,DS)=>{var KFD=p("os"),ex=p("tty"),D$=sx(),{env:l0}=process,r6;if(D$("no-color")||D$("no-colors")||D$("color=false")||D$("color=never"))r6=0;else if(D$("color")||D$("colors")||D$("color=true")||D$("color=always"))r6=1;if("FORCE_COLOR"in l0)if(l0.FORCE_COLOR==="true")r6=1;else if(l0.FORCE_COLOR==="false")r6=0;else r6=l0.FORCE_COLOR.length===0?1:Math.min(parseInt(l0.FORCE_COLOR,10),3);function EU(D){if(D===0)return!1;return{level:D,hasBasic:!0,has256:D>=2,has16m:D>=3}}function TU(D,$){if(r6===0)return 0;if(D$("color=16m")||D$("color=full")||D$("color=truecolor"))return 3;if(D$("color=256"))return 2;if(D&&!$&&r6===void 0)return 0;let X=r6||0;if(l0.TERM==="dumb")return X;if(process.platform==="win32"){let Y=KFD.release().split(".");if(Number(Y[0])>=10&&Number(Y[2])>=10586)return Number(Y[2])>=14931?3:2;return 1}if("CI"in l0){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((Y)=>(Y in l0))||l0.CI_NAME==="codeship")return 1;return X}if("TEAMCITY_VERSION"in l0)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(l0.TEAMCITY_VERSION)?1:0;if(l0.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in l0){let Y=parseInt((l0.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(l0.TERM_PROGRAM){case"iTerm.app":return Y>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(l0.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(l0.TERM))return 1;if("COLORTERM"in l0)return 1;return X}function WFD(D){let $=TU(D,D&&D.isTTY);return EU($)}DS.exports={supportsColor:WFD,stdout:EU(TU(!0,ex.isatty(1))),stderr:EU(TU(!0,ex.isatty(2)))}});var QS=T((JS,jY)=>{var HFD=p("tty"),RY=p("util");JS.init=RFD;JS.log=LFD;JS.formatArgs=NFD;JS.save=IFD;JS.load=AFD;JS.useColors=VFD;JS.destroy=RY.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");JS.colors=[6,2,3,4,5,1];try{let D=$S();if(D&&(D.stderr||D).level>=2)JS.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221]}catch(D){}JS.inspectOpts=Object.keys(process.env).filter((D)=>{return/^debug_/i.test(D)}).reduce((D,$)=>{let X=$.substring(6).toLowerCase().replace(/_([a-z])/g,(J,Q)=>{return Q.toUpperCase()}),Y=process.env[$];if(/^(yes|on|true|enabled)$/i.test(Y))Y=!0;else if(/^(no|off|false|disabled)$/i.test(Y))Y=!1;else if(Y==="null")Y=null;else Y=Number(Y);return D[X]=Y,D},{});function VFD(){return"colors"in JS.inspectOpts?Boolean(JS.inspectOpts.colors):HFD.isatty(process.stderr.fd)}function NFD(D){let{namespace:$,useColors:X}=this;if(X){let Y=this.color,J="\x1B[3"+(Y<8?Y:"8;5;"+Y),Q=` ${J};1m${$} \x1B[0m`;D[0]=Q+D[0].split(`
130
+ GFS4: `),console.error(D)};if(!L0[r0]){if(GU=global[r0]||[],Gx(L0,GU),L0.close=function(D){function $(X,Y){return D.call(L0,X,function(J){if(!J)Zx();if(typeof Y==="function")Y.apply(this,arguments)})}return Object.defineProperty($,OY,{value:D}),$}(L0.close),L0.closeSync=function(D){function $(X){D.apply(L0,arguments),Zx()}return Object.defineProperty($,OY,{value:D}),$}(L0.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))process.on("exit",function(){$8(L0[r0]),p("assert").equal(L0[r0].length,0)})}var GU;if(!global[r0])Gx(global,L0[r0]);qU.exports=OU(nYD(L0));if(process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!L0.__patched)qU.exports=OU(L0),L0.__patched=!0;function OU(D){cYD(D),D.gracefulify=OU,D.createReadStream=V,D.createWriteStream=R;var $=D.readFile;D.readFile=X;function X(_,v,S){if(typeof v==="function")S=v,v=null;return h(_,v,S);function h(g,l,f,j){return $(g,l,function(x){if(x&&(x.code==="EMFILE"||x.code==="ENFILE"))u9([h,[g,l,f],x,j||Date.now(),Date.now()]);else if(typeof f==="function")f.apply(this,arguments)})}}var Y=D.writeFile;D.writeFile=J;function J(_,v,S,h){if(typeof S==="function")h=S,S=null;return g(_,v,S,h);function g(l,f,j,x,u){return Y(l,f,j,function(y){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))u9([g,[l,f,j,x],y,u||Date.now(),Date.now()]);else if(typeof x==="function")x.apply(this,arguments)})}}var Q=D.appendFile;if(Q)D.appendFile=F;function F(_,v,S,h){if(typeof S==="function")h=S,S=null;return g(_,v,S,h);function g(l,f,j,x,u){return Q(l,f,j,function(y){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))u9([g,[l,f,j,x],y,u||Date.now(),Date.now()]);else if(typeof x==="function")x.apply(this,arguments)})}}var w=D.copyFile;if(w)D.copyFile=Z;function Z(_,v,S,h){if(typeof S==="function")h=S,S=0;return g(_,v,S,h);function g(l,f,j,x,u){return w(l,f,j,function(y){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))u9([g,[l,f,j,x],y,u||Date.now(),Date.now()]);else if(typeof x==="function")x.apply(this,arguments)})}}var G=D.readdir;D.readdir=U;var O=/^v[0-5]\./;function U(_,v,S){if(typeof v==="function")S=v,v=null;var h=O.test(process.version)?function(f,j,x,u){return G(f,g(f,j,x,u))}:function(f,j,x,u){return G(f,j,g(f,j,x,u))};return h(_,v,S);function g(l,f,j,x){return function(u,y){if(u&&(u.code==="EMFILE"||u.code==="ENFILE"))u9([h,[l,f,j],u,x||Date.now(),Date.now()]);else{if(y&&y.sort)y.sort();if(typeof j==="function")j.call(this,u,y)}}}}if(process.version.substr(0,4)==="v0.8"){var z=lYD(D);L=z.ReadStream,W=z.WriteStream}var q=D.ReadStream;if(q)L.prototype=Object.create(q.prototype),L.prototype.open=I;var B=D.WriteStream;if(B)W.prototype=Object.create(B.prototype),W.prototype.open=N;Object.defineProperty(D,"ReadStream",{get:function(){return L},set:function(_){L=_},enumerable:!0,configurable:!0}),Object.defineProperty(D,"WriteStream",{get:function(){return W},set:function(_){W=_},enumerable:!0,configurable:!0});var K=L;Object.defineProperty(D,"FileReadStream",{get:function(){return K},set:function(_){K=_},enumerable:!0,configurable:!0});var M=W;Object.defineProperty(D,"FileWriteStream",{get:function(){return M},set:function(_){M=_},enumerable:!0,configurable:!0});function L(_,v){if(this instanceof L)return q.apply(this,arguments),this;else return L.apply(Object.create(L.prototype),arguments)}function I(){var _=this;A(_.path,_.flags,_.mode,function(v,S){if(v){if(_.autoClose)_.destroy();_.emit("error",v)}else _.fd=S,_.emit("open",S),_.read()})}function W(_,v){if(this instanceof W)return B.apply(this,arguments),this;else return W.apply(Object.create(W.prototype),arguments)}function N(){var _=this;A(_.path,_.flags,_.mode,function(v,S){if(v)_.destroy(),_.emit("error",v);else _.fd=S,_.emit("open",S)})}function V(_,v){return new D.ReadStream(_,v)}function R(_,v){return new D.WriteStream(_,v)}var C=D.open;D.open=A;function A(_,v,S,h){if(typeof S==="function")h=S,S=null;return g(_,v,S,h);function g(l,f,j,x,u){return C(l,f,j,function(y,d){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))u9([g,[l,f,j,x],y,u||Date.now(),Date.now()]);else if(typeof x==="function")x.apply(this,arguments)})}}return D}function u9(D){$8("ENQUEUE",D[0].name,D[1]),L0[r0].push(D),UU()}var GY;function Zx(){var D=Date.now();for(var $=0;$<L0[r0].length;++$)if(L0[r0][$].length>2)L0[r0][$][3]=D,L0[r0][$][4]=D;UU()}function UU(){if(clearTimeout(GY),GY=void 0,L0[r0].length===0)return;var D=L0[r0].shift(),$=D[0],X=D[1],Y=D[2],J=D[3],Q=D[4];if(J===void 0)$8("RETRY",$.name,X),$.apply(null,X);else if(Date.now()-J>=60000){$8("TIMEOUT",$.name,X);var F=X.pop();if(typeof F==="function")F.call(null,Y)}else{var w=Date.now()-Q,Z=Math.max(Q-J,1),G=Math.min(Z*1.2,100);if(w>=G)$8("RETRY",$.name,X),$.apply(null,X.concat([J]));else L0[r0].push(D)}if(GY===void 0)GY=setTimeout(UU,0)}});var Ux=T((LyD,Ox)=>{function e1(D,$){if(typeof $==="boolean")$={forever:$};if(this._originalTimeouts=JSON.parse(JSON.stringify(D)),this._timeouts=D,this._options=$||{},this._maxRetryTime=$&&$.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever)this._cachedTimeouts=this._timeouts.slice(0)}Ox.exports=e1;e1.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};e1.prototype.stop=function(){if(this._timeout)clearTimeout(this._timeout);this._timeouts=[],this._cachedTimeouts=null};e1.prototype.retry=function(D){if(this._timeout)clearTimeout(this._timeout);if(!D)return!1;var $=new Date().getTime();if(D&&$-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error("RetryOperation timeout occurred")),!1;this._errors.push(D);var X=this._timeouts.shift();if(X===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),X=this._timeouts.shift();else return!1;var Y=this,J=setTimeout(function(){if(Y._attempts++,Y._operationTimeoutCb){if(Y._timeout=setTimeout(function(){Y._operationTimeoutCb(Y._attempts)},Y._operationTimeout),Y._options.unref)Y._timeout.unref()}Y._fn(Y._attempts)},X);if(this._options.unref)J.unref();return!0};e1.prototype.attempt=function(D,$){if(this._fn=D,$){if($.timeout)this._operationTimeout=$.timeout;if($.cb)this._operationTimeoutCb=$.cb}var X=this;if(this._operationTimeoutCb)this._timeout=setTimeout(function(){X._operationTimeoutCb()},X._operationTimeout);this._operationStart=new Date().getTime(),this._fn(this._attempts)};e1.prototype.try=function(D){console.log("Using RetryOperation.try() is deprecated"),this.attempt(D)};e1.prototype.start=function(D){console.log("Using RetryOperation.start() is deprecated"),this.attempt(D)};e1.prototype.start=e1.prototype.try;e1.prototype.errors=function(){return this._errors};e1.prototype.attempts=function(){return this._attempts};e1.prototype.mainError=function(){if(this._errors.length===0)return null;var D={},$=null,X=0;for(var Y=0;Y<this._errors.length;Y++){var J=this._errors[Y],Q=J.message,F=(D[Q]||0)+1;if(D[Q]=F,F>=X)$=J,X=F}return $}});var zx=T((rYD)=>{var pYD=Ux();rYD.operation=function(D){var $=rYD.timeouts(D);return new pYD($,{forever:D&&D.forever,unref:D&&D.unref,maxRetryTime:D&&D.maxRetryTime})};rYD.timeouts=function(D){if(D instanceof Array)return[].concat(D);var $={retries:10,factor:2,minTimeout:1000,maxTimeout:1/0,randomize:!1};for(var X in D)$[X]=D[X];if($.minTimeout>$.maxTimeout)throw Error("minTimeout is greater than maxTimeout");var Y=[];for(var J=0;J<$.retries;J++)Y.push(this.createTimeout(J,$));if(D&&D.forever&&!Y.length)Y.push(this.createTimeout(J,$));return Y.sort(function(Q,F){return Q-F}),Y};rYD.createTimeout=function(D,$){var X=$.randomize?Math.random()+1:1,Y=Math.round(X*$.minTimeout*Math.pow($.factor,D));return Y=Math.min(Y,$.maxTimeout),Y};rYD.wrap=function(D,$,X){if($ instanceof Array)X=$,$=null;if(!X){X=[];for(var Y in D)if(typeof D[Y]==="function")X.push(Y)}for(var J=0;J<X.length;J++){var Q=X[J],F=D[Q];D[Q]=function(Z){var G=rYD.operation($),O=Array.prototype.slice.call(arguments,1),U=O.pop();O.push(function(z){if(G.retry(z))return;if(z)arguments[0]=G.mainError();U.apply(this,arguments)}),G.attempt(function(){Z.apply(D,O)})}.bind(D,F),D[Q].options=$}}});var Bx=T((AyD,UY)=>{UY.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];if(process.platform!=="win32")UY.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")UY.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var BY=T((RyD,_9)=>{var K0=global.process,X8=function(D){return 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"};if(!X8(K0))_9.exports=function(){return function(){}};else{if(zU=p("assert"),J8=Bx(),BU=/^win/i.test(K0.platform),v9=p("events"),typeof v9!=="function")v9=v9.EventEmitter;if(K0.__signal_exit_emitter__)m0=K0.__signal_exit_emitter__;else m0=K0.__signal_exit_emitter__=new v9,m0.count=0,m0.emitted={};if(!m0.infinite)m0.setMaxListeners(1/0),m0.infinite=!0;_9.exports=function(D,$){if(!X8(global.process))return function(){};if(zU.equal(typeof D,"function","a callback must be provided for exit handler"),Y8===!1)qY();var X="exit";if($&&$.alwaysLast)X="afterexit";var Y=function(){if(m0.removeListener(X,D),m0.listeners("exit").length===0&&m0.listeners("afterexit").length===0)F3()};return m0.on(X,D),Y},F3=function(){if(!Y8||!X8(global.process))return;Y8=!1,J8.forEach(function($){try{K0.removeListener($,w3[$])}catch(X){}}),K0.emit=Z3,K0.reallyExit=zY,m0.count-=1},_9.exports.unload=F3,l6=function($,X,Y){if(m0.emitted[$])return;m0.emitted[$]=!0,m0.emit($,X,Y)},w3={},J8.forEach(function(D){w3[D]=function(){if(!X8(global.process))return;var X=K0.listeners(D);if(X.length===m0.count){if(F3(),l6("exit",null,D),l6("afterexit",null,D),BU&&D==="SIGHUP")D="SIGINT";K0.kill(K0.pid,D)}}}),_9.exports.signals=function(){return J8},Y8=!1,qY=function(){if(Y8||!X8(global.process))return;Y8=!0,m0.count+=1,J8=J8.filter(function($){try{return K0.on($,w3[$]),!0}catch(X){return!1}}),K0.emit=WU,K0.reallyExit=KU},_9.exports.load=qY,zY=K0.reallyExit,KU=function($){if(!X8(global.process))return;K0.exitCode=$||0,l6("exit",K0.exitCode,null),l6("afterexit",K0.exitCode,null),zY.call(K0,K0.exitCode)},Z3=K0.emit,WU=function($,X){if($==="exit"&&X8(global.process)){if(X!==void 0)K0.exitCode=X;var Y=Z3.apply(this,arguments);return l6("exit",K0.exitCode,null),l6("afterexit",K0.exitCode,null),Y}else return Z3.apply(this,arguments)}}var zU,J8,BU,v9,m0,F3,l6,w3,Y8,qY,zY,KU,Z3,WU});var Wx=T((DQD,HU)=>{var Kx=Symbol();function sYD(D,$,X){let Y=$[Kx];if(Y)return $.stat(D,(Q,F)=>{if(Q)return X(Q);X(null,F.mtime,Y)});let J=new Date(Math.ceil(Date.now()/1000)*1000+5);$.utimes(D,J,J,(Q)=>{if(Q)return X(Q);$.stat(D,(F,w)=>{if(F)return X(F);let Z=w.mtime.getTime()%1000===0?"s":"ms";Object.defineProperty($,Kx,{value:Z}),X(null,w.mtime,Z)})})}function eYD(D){let $=Date.now();if(D==="s")$=Math.ceil($/1000)*1000;return new Date($)}DQD.probe=sYD;DQD.getMtime=eYD});var Lx=T((GQD,O3)=>{var JQD=p("path"),MU=S0(),YQD=zx(),QQD=BY(),Hx=Wx(),Q6={};function G3(D,$){return $.lockfilePath||`${D}.lock`}function LU(D,$,X){if(!$.realpath)return X(null,JQD.resolve(D));$.fs.realpath(D,X)}function NU(D,$,X){let Y=G3(D,$);$.fs.mkdir(Y,(J)=>{if(!J)return Hx.probe(Y,$.fs,(Q,F,w)=>{if(Q)return $.fs.rmdir(Y,()=>{}),X(Q);X(null,F,w)});if(J.code!=="EEXIST")return X(J);if($.stale<=0)return X(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:D}));$.fs.stat(Y,(Q,F)=>{if(Q){if(Q.code==="ENOENT")return NU(D,{...$,stale:0},X);return X(Q)}if(!Vx(F,$))return X(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:D}));Nx(D,$,(w)=>{if(w)return X(w);NU(D,{...$,stale:0},X)})})})}function Vx(D,$){return D.mtime.getTime()<Date.now()-$.stale}function Nx(D,$,X){$.fs.rmdir(G3(D,$),(Y)=>{if(Y&&Y.code!=="ENOENT")return X(Y);X()})}function KY(D,$){let X=Q6[D];if(X.updateTimeout)return;if(X.updateDelay=X.updateDelay||$.update,X.updateTimeout=setTimeout(()=>{X.updateTimeout=null,$.fs.stat(X.lockfilePath,(Y,J)=>{let Q=X.lastUpdate+$.stale<Date.now();if(Y){if(Y.code==="ENOENT"||Q)return VU(D,X,Object.assign(Y,{code:"ECOMPROMISED"}));return X.updateDelay=1000,KY(D,$)}if(X.mtime.getTime()!==J.mtime.getTime())return VU(D,X,Object.assign(Error("Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"}));let w=Hx.getMtime(X.mtimePrecision);$.fs.utimes(X.lockfilePath,w,w,(Z)=>{let G=X.lastUpdate+$.stale<Date.now();if(X.released)return;if(Z){if(Z.code==="ENOENT"||G)return VU(D,X,Object.assign(Z,{code:"ECOMPROMISED"}));return X.updateDelay=1000,KY(D,$)}X.mtime=w,X.lastUpdate=Date.now(),X.updateDelay=null,KY(D,$)})})},X.updateDelay),X.updateTimeout.unref)X.updateTimeout.unref()}function VU(D,$,X){if($.released=!0,$.updateTimeout)clearTimeout($.updateTimeout);if(Q6[D]===$)delete Q6[D];$.options.onCompromised(X)}function FQD(D,$,X){$={stale:1e4,update:null,realpath:!0,retries:0,fs:MU,onCompromised:(Y)=>{throw Y},...$},$.retries=$.retries||0,$.retries=typeof $.retries==="number"?{retries:$.retries}:$.retries,$.stale=Math.max($.stale||0,2000),$.update=$.update==null?$.stale/2:$.update||0,$.update=Math.max(Math.min($.update,$.stale/2),1000),LU(D,$,(Y,J)=>{if(Y)return X(Y);let Q=YQD.operation($.retries);Q.attempt(()=>{NU(J,$,(F,w,Z)=>{if(Q.retry(F))return;if(F)return X(Q.mainError());let G=Q6[J]={lockfilePath:G3(J,$),mtime:w,mtimePrecision:Z,options:$,lastUpdate:Date.now()};KY(J,$),X(null,(O)=>{if(G.released)return O&&O(Object.assign(Error("Lock is already released"),{code:"ERELEASED"}));Mx(J,{...$,realpath:!1},O)})})})})}function Mx(D,$,X){$={fs:MU,realpath:!0,...$},LU(D,$,(Y,J)=>{if(Y)return X(Y);let Q=Q6[J];if(!Q)return X(Object.assign(Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));Q.updateTimeout&&clearTimeout(Q.updateTimeout),Q.released=!0,delete Q6[J],Nx(J,$,X)})}function wQD(D,$,X){$={stale:1e4,realpath:!0,fs:MU,...$},$.stale=Math.max($.stale||0,2000),LU(D,$,(Y,J)=>{if(Y)return X(Y);$.fs.stat(G3(J,$),(Q,F)=>{if(Q)return Q.code==="ENOENT"?X(null,!1):X(Q);return X(null,!Vx(F,$))})})}function ZQD(){return Q6}QQD(()=>{for(let D in Q6){let $=Q6[D].options;try{$.fs.rmdirSync(G3(D,$))}catch(X){}}});GQD.lock=FQD;GQD.unlock=Mx;GQD.check=wQD;GQD.getLocks=ZQD});var Ax=T((jyD,Ix)=>{var BQD=S0();function KQD(D){let $=["mkdir","realpath","stat","rmdir","utimes"],X={...D};return $.forEach((Y)=>{X[Y]=(...J)=>{let Q=J.pop(),F;try{F=D[`${Y}Sync`](...J)}catch(w){return Q(w)}Q(null,F)}}),X}function WQD(D){return(...$)=>new Promise((X,Y)=>{$.push((J,Q)=>{if(J)Y(J);else X(Q)}),D(...$)})}function HQD(D){return(...$)=>{let X,Y;if($.push((J,Q)=>{X=J,Y=Q}),D(...$),X)throw X;return Y}}function VQD(D){if(D={...D},D.fs=KQD(D.fs||BQD),typeof D.retries==="number"&&D.retries>0||D.retries&&typeof D.retries.retries==="number"&&D.retries.retries>0)throw Object.assign(Error("Cannot use retries with the sync api"),{code:"ESYNC"});return D}Ix.exports={toPromise:WQD,toSync:HQD,toSyncOptions:VQD}});var jx=T((EyD,n6)=>{var k9=Lx(),{toPromise:WY,toSync:HY,toSyncOptions:IU}=Ax();async function Rx(D,$){let X=await WY(k9.lock)(D,$);return WY(X)}function NQD(D,$){let X=HY(k9.lock)(D,IU($));return HY(X)}function MQD(D,$){return WY(k9.unlock)(D,$)}function LQD(D,$){return HY(k9.unlock)(D,IU($))}function IQD(D,$){return WY(k9.check)(D,$)}function AQD(D,$){return HY(k9.check)(D,IU($))}n6.exports=Rx;n6.exports.lock=Rx;n6.exports.unlock=MQD;n6.exports.lockSync=NQD;n6.exports.unlockSync=LQD;n6.exports.check=IQD;n6.exports.checkSync=AQD});var ux=T((xx)=>{Object.defineProperty(xx,"__esModule",{value:!0});xx.canStoreURLs=xx.FileUrlStorage=void 0;var Ex=p("fs"),RQD=EQD(Dx()),Tx=jQD(jx());function Px(D){if(typeof WeakMap!="function")return null;var $=new WeakMap,X=new WeakMap;return(Px=function(Y){return Y?X:$})(D)}function jQD(D,$){if(!$&&D&&D.__esModule)return D;if(D===null||typeof D!="object"&&typeof D!="function")return{default:D};var X=Px($);if(X&&X.has(D))return X.get(D);var Y={__proto__:null},J=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var Q in D)if(Q!=="default"&&{}.hasOwnProperty.call(D,Q)){var F=J?Object.getOwnPropertyDescriptor(D,Q):null;F&&(F.get||F.set)?Object.defineProperty(Y,Q,F):Y[Q]=D[Q]}return Y.default=D,X&&X.set(D,Y),Y}function EQD(D){return D&&D.__esModule?D:{default:D}}function U3(D){return U3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},U3(D)}function TQD(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function Cx(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,PQD(Y.key),Y)}}function CQD(D,$,X){if($)Cx(D.prototype,$);if(X)Cx(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function PQD(D){var $=xQD(D,"string");return U3($)=="symbol"?$:$+""}function xQD(D,$){if(U3(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(U3(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var TyD=xx.canStoreURLs=!0,CyD=xx.FileUrlStorage=function(){function D($){TQD(this,D),this.path=$}return CQD(D,[{key:"findAllUploads",value:function(){var X=this;return new Promise(function(Y,J){X._getItems("tus::",function(Q,F){if(Q)J(Q);else Y(F)})})}},{key:"findUploadsByFingerprint",value:function(X){var Y=this;return new Promise(function(J,Q){Y._getItems("tus::".concat(X),function(F,w){if(F)Q(F);else J(w)})})}},{key:"removeUpload",value:function(X){var Y=this;return new Promise(function(J,Q){Y._removeItem(X,function(F){if(F)Q(F);else J()})})}},{key:"addUpload",value:function(X,Y){var J=this,Q=Math.round(Math.random()*1000000000000),F="tus::".concat(X,"::").concat(Q);return new Promise(function(w,Z){J._setItem(F,Y,function(G){if(G)Z(G);else w(F)})})}},{key:"_setItem",value:function(X,Y,J){var Q=this;Tx.lock(this.path,this._lockfileOptions()).then(function(F){J=Q._releaseAndCb(F,J),Q._getData(function(w,Z){if(w){J(w);return}Z[X]=Y,Q._writeData(Z,function(G){return J(G)})})}).catch(J)}},{key:"_getItems",value:function(X,Y){this._getData(function(J,Q){if(J){Y(J);return}var F=Object.keys(Q).filter(function(w){return w.startsWith(X)}).map(function(w){var Z=Q[w];return Z.urlStorageKey=w,Z});Y(null,F)})}},{key:"_removeItem",value:function(X,Y){var J=this;Tx.lock(this.path,this._lockfileOptions()).then(function(Q){Y=J._releaseAndCb(Q,Y),J._getData(function(F,w){if(F){Y(F);return}delete w[X],J._writeData(w,function(Z){return Y(Z)})})}).catch(Y)}},{key:"_lockfileOptions",value:function(){return{realpath:!1,retries:{retries:5,minTimeout:20}}}},{key:"_releaseAndCb",value:function(X,Y){return function(J){if(J){X().then(function(){return Y(J)}).catch(function(Q){return Y((0,RQD.default)([J,Q]))});return}X().then(Y).catch(Y)}}},{key:"_writeData",value:function(X,Y){var J={encoding:"utf8",mode:432,flag:"w"};(0,Ex.writeFile)(this.path,JSON.stringify(X),J,function(Q){return Y(Q)})}},{key:"_getData",value:function(X){(0,Ex.readFile)(this.path,"utf8",function(Y,J){if(Y){if(Y.code==="ENOENT")X(null,{});else X(Y);return}try{J=!J.trim().length?{}:JSON.parse(J)}catch(Q){X(Q);return}X(null,J)})}}])}()});var NY=T((i6)=>{Object.defineProperty(i6,"__esModule",{value:!0});Object.defineProperty(i6,"DefaultHttpStack",{enumerable:!0,get:function(){return fx.default}});Object.defineProperty(i6,"DetailedError",{enumerable:!0,get:function(){return uQD.default}});Object.defineProperty(i6,"FileUrlStorage",{enumerable:!0,get:function(){return yx.FileUrlStorage}});Object.defineProperty(i6,"StreamSource",{enumerable:!0,get:function(){return yQD.default}});i6.Upload=void 0;Object.defineProperty(i6,"canStoreURLs",{enumerable:!0,get:function(){return yx.canStoreURLs}});i6.defaultOptions=void 0;Object.defineProperty(i6,"enableDebugLog",{enumerable:!0,get:function(){return vQD.enableDebugLog}});i6.isSupported=void 0;var uQD=Q8(IO()),vQD=AO(),_QD=Q8(jT()),AU=Q8(YC()),kQD=Q8(RC()),fQD=Q8(PC()),fx=Q8(nC()),yQD=Q8(_O()),yx=ux();function Q8(D){return D&&D.__esModule?D:{default:D}}function y9(D){return y9=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},y9(D)}function bQD(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function vx(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,gx(Y.key),Y)}}function gQD(D,$,X){if($)vx(D.prototype,$);if(X)vx(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function hQD(D,$,X){return $=VY($),mQD(D,bx()?Reflect.construct($,X||[],VY(D).constructor):$.apply(D,X))}function mQD(D,$){if($&&(y9($)==="object"||typeof $==="function"))return $;else if($!==void 0)throw TypeError("Derived constructors may only return object or undefined");return dQD(D)}function dQD(D){if(D===void 0)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return D}function bx(){try{var D=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch($){}return(bx=function(){return!!D})()}function VY(D){return VY=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(X){return X.__proto__||Object.getPrototypeOf(X)},VY(D)}function cQD(D,$){if(typeof $!=="function"&&$!==null)throw TypeError("Super expression must either be null or a function");if(D.prototype=Object.create($&&$.prototype,{constructor:{value:D,writable:!0,configurable:!0}}),Object.defineProperty(D,"prototype",{writable:!1}),$)RU(D,$)}function RU(D,$){return RU=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(Y,J){return Y.__proto__=J,Y},RU(D,$)}function _x(D,$){var X=Object.keys(D);if(Object.getOwnPropertySymbols){var Y=Object.getOwnPropertySymbols(D);$&&(Y=Y.filter(function(J){return Object.getOwnPropertyDescriptor(D,J).enumerable})),X.push.apply(X,Y)}return X}function f9(D){for(var $=1;$<arguments.length;$++){var X=arguments[$]!=null?arguments[$]:{};$%2?_x(Object(X),!0).forEach(function(Y){lQD(D,Y,X[Y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(D,Object.getOwnPropertyDescriptors(X)):_x(Object(X)).forEach(function(Y){Object.defineProperty(D,Y,Object.getOwnPropertyDescriptor(X,Y))})}return D}function lQD(D,$,X){if($=gx($),$ in D)Object.defineProperty(D,$,{value:X,enumerable:!0,configurable:!0,writable:!0});else D[$]=X;return D}function gx(D){var $=nQD(D,"string");return y9($)=="symbol"?$:$+""}function nQD(D,$){if(y9(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(y9(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var kx=i6.defaultOptions=f9(f9({},AU.default.defaultOptions),{},{httpStack:new fx.default,fileReader:new kQD.default,urlStorage:new _QD.default,fingerprint:fQD.default}),xyD=i6.Upload=function(D){function $(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return bQD(this,$),Y=f9(f9({},kx),Y),hQD(this,$,[X,Y])}return cQD($,D),gQD($,null,[{key:"terminate",value:function(Y){var J=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return J=f9(f9({},kx),J),AU.default.terminate(Y,J)}}])}(AU.default),SyD=i6.isSupported=!0});var F6;var MY=o(()=>{F6={name:"@capgo/cli",type:"module",version:"7.82.0",description:"A CLI to upload to capgo servers",author:"Martin martin@capgo.app",license:"Apache 2.0",homepage:"https://github.com/Cap-go/CLI#readme",repository:{type:"git",url:"git+https://github.com/Cap-go/CLI.git"},bugs:{url:"https://github.com/Cap-go/CLI/issues"},keywords:["appflow alternative","ionic","capacitor","auto update","live update","capgo","cli","upload","capgo-cli","sdk"],exports:{".":{import:"./dist/index.js",require:"./dist/index.js"},"./sdk":{types:"./dist/src/sdk.d.ts",import:"./dist/src/sdk.js"}},main:"dist/index.js",types:"dist/src/index.d.ts",bin:{capgo:"dist/index.js"},engines:{npm:">=8.0.0",node:">=20.0.0"},scripts:{build:"tsc && bun build.mjs",dev:"NODE_ENV=development ncc build","no-debug":"node dist/index.js","dev-build":"SUPA_DB=development ncc build",pack:"pkg",types:"npx --yes supabase gen types typescript --project-id=xvwzpoazmxkqosrdewyv > src/types/supabase.types.ts",typecheck:"tsc --noEmit",lint:'eslint "src/**/*.ts" --fix',"check-posix-paths":"node test/check-posix-paths.js","generate-docs":"node dist/index.js generate-docs README.md","test:bundle":"bun test/test-bundle.mjs","test:functional":"bun test/test-functional.mjs","test:semver":"bun test/test-semver-validation.mjs","test:version-edge-cases":"bun test/test-version-validation.mjs","test:regex":"bun test/test-regex-validation.mjs","test:upload":"bun test/test-upload-validation.mjs","test:credentials":"bun test/test-credentials.mjs","test:credentials-validation":"bun test/test-credentials-validation.mjs","test:build-zip-filter":"bun test/test-build-zip-filter.mjs","test:checksum":"bun test/test-checksum-algorithm.mjs","test:esm-sdk":"node test/test-sdk-esm.mjs","test:mcp":"node test/test-mcp.mjs","test:version-detection":"node test/test-get-installed-version.mjs","test:version-detection:setup":"./test/fixtures/setup-test-projects.sh","test:platform-paths":"bun test/test-platform-paths.mjs",test:"bun run test:bundle && bun run test:functional && bun run test:semver && bun run test:version-edge-cases && bun run test:regex && bun run test:upload && bun run test:credentials && bun run test:credentials-validation && bun run test:build-zip-filter && bun run test:checksum && bun run test:esm-sdk && bun run test:mcp && bun run test:version-detection && bun run test:platform-paths"},devDependencies:{"@antfu/eslint-config":"^7.0.0","@bradenmacdonald/s3-lite-client":"npm:@jsr/bradenmacdonald__s3-lite-client@0.9.4","@capacitor/cli":"^8.0.0","@capgo/find-package-manager":"^0.0.18","@clack/prompts":"^1.0.0","@modelcontextprotocol/sdk":"^1.25.3","@sauber/table":"npm:@jsr/sauber__table","@std/semver":"npm:@jsr/std__semver@1.0.6","@supabase/supabase-js":"^2.79.0","@types/adm-zip":"^0.5.7","@types/node":"^25.0.0","@types/prettyjson":"^0.0.33","@types/tmp":"^0.2.6","@vercel/ncc":"^0.38.4","adm-zip":"^0.5.16","ci-info":"^4.3.1",commander:"^14.0.2",eslint:"^9.38.0","git-format-staged":"4.0.1",husky:"^9.1.7","is-wsl":"^3.1.0",micromatch:"^4.0.8",open:"^11.0.0",prettyjson:"^1.2.5",tmp:"^0.2.5","tus-js-client":"^4.3.1",typescript:"^5.9.3",partysocket:"^1.1.11",ws:"^8.18.3",zod:"^4.3.6"}}});async function LY(D){try{let X=`https://registry.npmjs.org/${encodeURIComponent(D.toLowerCase())}`,Y=await fetch(X,{headers:{accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"}});if(!Y.ok)return null;return(await Y.json())["dist-tags"]?.latest||null}catch{return null}}async function F0(){let D=await LY("@capgo/cli")??"",$=D?.split(".")[0];if(D!==F6.version)H.warning(`\uD83D\uDEA8 You are using @capgo/cli@${F6.version} it's not the latest version.
131
+ Please use @capgo/cli@${D}" or @capgo/cli@${$} to keep up to date with the latest features and bug fixes.`)}var q1=o(()=>{vD();MY()});async function cx(D,$,X,Y,J,Q="✅"){await RD(X,{channel:D,event:Y,icon:Q,user_id:$,...J?{tags:{"app-id":J}}:{},notify:!1})}var lx=o(()=>{vD();s$();q1();fD()});import{Buffer as nx}from"node:buffer";import{createHash as pQD}from"node:crypto";function oQD(D){let $=4294967295;for(let X=0;X<D.length;X++){let Y=D[X];$=rQD[($^Y)&255]^$>>>8}return $=$^4294967295,($>>>0).toString(16).padStart(8,"0")}async function p6(D,$="sha256"){let X=nx.isBuffer(D)?D:nx.from(D);if($==="crc32")return oQD(X);let Y=pQD($);return Y.update(X),Y.digest("hex")}var rQD;var q3=o(()=>{rQD=(()=>{let D=[];for(let $=0;$<256;$++){let X=$;for(let Y=0;Y<8;Y++)X=X&1?3988292384^X>>>1:X>>>1;D[$]=X}return D})()});var px=T((pyD,ix)=>{var b9=1000,g9=b9*60,h9=g9*60,F8=h9*24,aQD=F8*7,tQD=F8*365.25;ix.exports=function(D,$){$=$||{};var X=typeof D;if(X==="string"&&D.length>0)return sQD(D);else if(X==="number"&&isFinite(D))return $.long?DFD(D):eQD(D);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(D))};function sQD(D){if(D=String(D),D.length>100)return;var $=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(D);if(!$)return;var X=parseFloat($[1]),Y=($[2]||"ms").toLowerCase();switch(Y){case"years":case"year":case"yrs":case"yr":case"y":return X*tQD;case"weeks":case"week":case"w":return X*aQD;case"days":case"day":case"d":return X*F8;case"hours":case"hour":case"hrs":case"hr":case"h":return X*h9;case"minutes":case"minute":case"mins":case"min":case"m":return X*g9;case"seconds":case"second":case"secs":case"sec":case"s":return X*b9;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return X;default:return}}function eQD(D){var $=Math.abs(D);if($>=F8)return Math.round(D/F8)+"d";if($>=h9)return Math.round(D/h9)+"h";if($>=g9)return Math.round(D/g9)+"m";if($>=b9)return Math.round(D/b9)+"s";return D+"ms"}function DFD(D){var $=Math.abs(D);if($>=F8)return IY(D,$,F8,"day");if($>=h9)return IY(D,$,h9,"hour");if($>=g9)return IY(D,$,g9,"minute");if($>=b9)return IY(D,$,b9,"second");return D+" ms"}function IY(D,$,X,Y){var J=$>=X*1.5;return Math.round(D/X)+" "+Y+(J?"s":"")}});var jU=T((ryD,rx)=>{function $FD(D){X.debug=X,X.default=X,X.coerce=Z,X.disable=F,X.enable=J,X.enabled=w,X.humanize=px(),X.destroy=G,Object.keys(D).forEach((O)=>{X[O]=D[O]}),X.names=[],X.skips=[],X.formatters={};function $(O){let U=0;for(let z=0;z<O.length;z++)U=(U<<5)-U+O.charCodeAt(z),U|=0;return X.colors[Math.abs(U)%X.colors.length]}X.selectColor=$;function X(O){let U,z=null,q,B;function K(...M){if(!K.enabled)return;let L=K,I=Number(new Date),W=I-(U||I);if(L.diff=W,L.prev=U,L.curr=I,U=I,M[0]=X.coerce(M[0]),typeof M[0]!=="string")M.unshift("%O");let N=0;M[0]=M[0].replace(/%([a-zA-Z%])/g,(R,C)=>{if(R==="%%")return"%";N++;let A=X.formatters[C];if(typeof A==="function"){let _=M[N];R=A.call(L,_),M.splice(N,1),N--}return R}),X.formatArgs.call(L,M),(L.log||X.log).apply(L,M)}if(K.namespace=O,K.useColors=X.useColors(),K.color=X.selectColor(O),K.extend=Y,K.destroy=X.destroy,Object.defineProperty(K,"enabled",{enumerable:!0,configurable:!1,get:()=>{if(z!==null)return z;if(q!==X.namespaces)q=X.namespaces,B=X.enabled(O);return B},set:(M)=>{z=M}}),typeof X.init==="function")X.init(K);return K}function Y(O,U){let z=X(this.namespace+(typeof U>"u"?":":U)+O);return z.log=this.log,z}function J(O){X.save(O),X.namespaces=O,X.names=[],X.skips=[];let U=(typeof O==="string"?O:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let z of U)if(z[0]==="-")X.skips.push(z.slice(1));else X.names.push(z)}function Q(O,U){let z=0,q=0,B=-1,K=0;while(z<O.length)if(q<U.length&&(U[q]===O[z]||U[q]==="*"))if(U[q]==="*")B=q,K=z,q++;else z++,q++;else if(B!==-1)q=B+1,K++,z=K;else return!1;while(q<U.length&&U[q]==="*")q++;return q===U.length}function F(){let O=[...X.names,...X.skips.map((U)=>"-"+U)].join(",");return X.enable(""),O}function w(O){for(let U of X.skips)if(Q(O,U))return!1;for(let U of X.names)if(Q(O,U))return!0;return!1}function Z(O){if(O instanceof Error)return O.stack||O.message;return O}function G(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return X.enable(X.load()),X}rx.exports=$FD});var ax=T((ox,AY)=>{ox.formatArgs=JFD;ox.save=YFD;ox.load=QFD;ox.useColors=XFD;ox.storage=FFD();ox.destroy=(()=>{let D=!1;return()=>{if(!D)D=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}})();ox.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function XFD(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let D;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(D=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(D[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function JFD(D){if(D[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+D[0]+(this.useColors?"%c ":" ")+"+"+AY.exports.humanize(this.diff),!this.useColors)return;let $="color: "+this.color;D.splice(1,0,$,"color: inherit");let X=0,Y=0;D[0].replace(/%[a-zA-Z%]/g,(J)=>{if(J==="%%")return;if(X++,J==="%c")Y=X}),D.splice(Y,0,$)}ox.log=console.debug||console.log||(()=>{});function YFD(D){try{if(D)ox.storage.setItem("debug",D);else ox.storage.removeItem("debug")}catch($){}}function QFD(){let D;try{D=ox.storage.getItem("debug")||ox.storage.getItem("DEBUG")}catch($){}if(!D&&typeof process<"u"&&"env"in process)D=process.env.DEBUG;return D}function FFD(){try{return localStorage}catch(D){}}AY.exports=jU()(ox);var{formatters:wFD}=AY.exports;wFD.j=function(D){try{return JSON.stringify(D)}catch($){return"[UnexpectedJSONParseError]: "+$.message}}});var sx=T((ayD,tx)=>{tx.exports=(D,$=process.argv)=>{let X=D.startsWith("-")?"":D.length===1?"-":"--",Y=$.indexOf(X+D),J=$.indexOf("--");return Y!==-1&&(J===-1||Y<J)}});var $S=T((tyD,DS)=>{var KFD=p("os"),ex=p("tty"),D$=sx(),{env:l0}=process,r6;if(D$("no-color")||D$("no-colors")||D$("color=false")||D$("color=never"))r6=0;else if(D$("color")||D$("colors")||D$("color=true")||D$("color=always"))r6=1;if("FORCE_COLOR"in l0)if(l0.FORCE_COLOR==="true")r6=1;else if(l0.FORCE_COLOR==="false")r6=0;else r6=l0.FORCE_COLOR.length===0?1:Math.min(parseInt(l0.FORCE_COLOR,10),3);function EU(D){if(D===0)return!1;return{level:D,hasBasic:!0,has256:D>=2,has16m:D>=3}}function TU(D,$){if(r6===0)return 0;if(D$("color=16m")||D$("color=full")||D$("color=truecolor"))return 3;if(D$("color=256"))return 2;if(D&&!$&&r6===void 0)return 0;let X=r6||0;if(l0.TERM==="dumb")return X;if(process.platform==="win32"){let Y=KFD.release().split(".");if(Number(Y[0])>=10&&Number(Y[2])>=10586)return Number(Y[2])>=14931?3:2;return 1}if("CI"in l0){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((Y)=>(Y in l0))||l0.CI_NAME==="codeship")return 1;return X}if("TEAMCITY_VERSION"in l0)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(l0.TEAMCITY_VERSION)?1:0;if(l0.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in l0){let Y=parseInt((l0.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(l0.TERM_PROGRAM){case"iTerm.app":return Y>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(l0.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(l0.TERM))return 1;if("COLORTERM"in l0)return 1;return X}function WFD(D){let $=TU(D,D&&D.isTTY);return EU($)}DS.exports={supportsColor:WFD,stdout:EU(TU(!0,ex.isatty(1))),stderr:EU(TU(!0,ex.isatty(2)))}});var QS=T((JS,jY)=>{var HFD=p("tty"),RY=p("util");JS.init=RFD;JS.log=LFD;JS.formatArgs=NFD;JS.save=IFD;JS.load=AFD;JS.useColors=VFD;JS.destroy=RY.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");JS.colors=[6,2,3,4,5,1];try{let D=$S();if(D&&(D.stderr||D).level>=2)JS.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221]}catch(D){}JS.inspectOpts=Object.keys(process.env).filter((D)=>{return/^debug_/i.test(D)}).reduce((D,$)=>{let X=$.substring(6).toLowerCase().replace(/_([a-z])/g,(J,Q)=>{return Q.toUpperCase()}),Y=process.env[$];if(/^(yes|on|true|enabled)$/i.test(Y))Y=!0;else if(/^(no|off|false|disabled)$/i.test(Y))Y=!1;else if(Y==="null")Y=null;else Y=Number(Y);return D[X]=Y,D},{});function VFD(){return"colors"in JS.inspectOpts?Boolean(JS.inspectOpts.colors):HFD.isatty(process.stderr.fd)}function NFD(D){let{namespace:$,useColors:X}=this;if(X){let Y=this.color,J="\x1B[3"+(Y<8?Y:"8;5;"+Y),Q=` ${J};1m${$} \x1B[0m`;D[0]=Q+D[0].split(`
132
132
  `).join(`
133
133
  `+Q),D.push(J+"m+"+jY.exports.humanize(this.diff)+"\x1B[0m")}else D[0]=MFD()+$+" "+D[0]}function MFD(){if(JS.inspectOpts.hideDate)return"";return new Date().toISOString()+" "}function LFD(...D){return process.stderr.write(RY.formatWithOptions(JS.inspectOpts,...D)+`
134
134
  `)}function IFD(D){if(D)process.env.DEBUG=D;else delete process.env.DEBUG}function AFD(){return process.env.DEBUG}function RFD(D){D.inspectOpts={};let $=Object.keys(JS.inspectOpts);for(let X=0;X<$.length;X++)D.inspectOpts[$[X]]=JS.inspectOpts[$[X]]}jY.exports=jU()(JS);var{formatters:XS}=jY.exports;XS.o=function(D){return this.inspectOpts.colors=this.useColors,RY.inspect(D,this.inspectOpts).split(`
@@ -255,17 +255,17 @@ Filtered results for: ${this.inputValue?this.inputValue:K6.gray("Enter something
255
255
  `}renderOption(D,$,X){let Y;if($.disabled)Y=D===X?K6.gray().underline($.title):K6.strikethrough().gray($.title);else Y=D===X?K6.cyan().underline($.title):$.title;return($.selected?K6.green($5.radioOn):$5.radioOff)+" "+Y}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let D=[K6.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];if(this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled)D.push(K6.yellow(this.warn));return D.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(OzD.hide);super.render();let D=[Ib.symbol(this.done,this.aborted),K6.bold(this.msg),Ib.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)D+=K6.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1;D+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+D),this.clear=Lb(D,this.out.columns)}}Rb.exports=Ab});var Sb=T((NhD,xb)=>{var Eb=I0(),qzD=z6(),{style:Tb,clear:zzD}=L$(),{erase:BzD,cursor:Cb}=O0();class Pb extends qzD{constructor(D={}){super(D);this.msg=D.message,this.value=D.initial,this.initialValue=!!D.initial,this.yesMsg=D.yes||"yes",this.yesOption=D.yesOption||"(Y/n)",this.noMsg=D.no||"no",this.noOption=D.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
256
256
  `),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
257
257
  `),this.close()}_(D,$){if(D.toLowerCase()==="y")return this.value=!0,this.submit();if(D.toLowerCase()==="n")return this.value=!1,this.submit();return this.bell()}render(){if(this.closed)return;if(this.firstRender)this.out.write(Cb.hide);else this.out.write(zzD(this.outputText,this.out.columns));super.render(),this.outputText=[Tb.symbol(this.done,this.aborted),Eb.bold(this.msg),Tb.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:Eb.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(BzD.line+Cb.to(0)+this.outputText)}}xb.exports=Pb});var vb=T((MhD,ub)=>{ub.exports={TextPrompt:By(),SelectPrompt:Ny(),TogglePrompt:Ry(),DatePrompt:Qb(),NumberPrompt:Ob(),MultiselectPrompt:uq(),AutocompletePrompt:Mb(),AutocompleteMultiselectPrompt:jb(),ConfirmPrompt:Sb()}});var kb=T((_b)=>{var S1=_b,KzD=vb(),ZQ=(D)=>D;function m$(D,$,X={}){return new Promise((Y,J)=>{let Q=new KzD[D]($),F=X.onAbort||ZQ,w=X.onSubmit||ZQ,Z=X.onExit||ZQ;Q.on("state",$.onState||ZQ),Q.on("submit",(G)=>Y(w(G))),Q.on("exit",(G)=>Y(Z(G))),Q.on("abort",(G)=>J(F(G)))})}S1.text=(D)=>m$("TextPrompt",D);S1.password=(D)=>{return D.style="password",S1.text(D)};S1.invisible=(D)=>{return D.style="invisible",S1.text(D)};S1.number=(D)=>m$("NumberPrompt",D);S1.date=(D)=>m$("DatePrompt",D);S1.confirm=(D)=>m$("ConfirmPrompt",D);S1.list=(D)=>{let $=D.separator||",";return m$("TextPrompt",D,{onSubmit:(X)=>X.split($).map((Y)=>Y.trim())})};S1.toggle=(D)=>m$("TogglePrompt",D);S1.select=(D)=>m$("SelectPrompt",D);S1.multiselect=(D)=>{D.choices=[].concat(D.choices||[]);let $=(X)=>X.filter((Y)=>Y.selected).map((Y)=>Y.value);return m$("MultiselectPrompt",D,{onAbort:$,onSubmit:$})};S1.autocompleteMultiselect=(D)=>{D.choices=[].concat(D.choices||[]);let $=(X)=>X.filter((Y)=>Y.selected).map((Y)=>Y.value);return m$("AutocompleteMultiselectPrompt",D,{onAbort:$,onSubmit:$})};var WzD=(D,$)=>Promise.resolve($.filter((X)=>X.title.slice(0,D.length).toLowerCase()===D.toLowerCase()));S1.autocomplete=(D)=>{return D.suggest=D.suggest||WzD,D.choices=[].concat(D.choices||[]),m$("AutocompletePrompt",D)}});var bb=T((IhD,yb)=>{var kq=kb(),HzD=["suggest","format","onState","validate","onRender","type"],fb=()=>{};async function X4(D=[],{onSubmit:$=fb,onCancel:X=fb}={}){let Y={},J=X4._override||{};D=[].concat(D);let Q,F,w,Z,G,O,U=async(z,q,B=!1)=>{if(!B&&z.validate&&z.validate(q)!==!0)return;return z.format?await z.format(q,Y):q};for(F of D){if({name:Z,type:G}=F,typeof G==="function")G=await G(Q,{...Y},F),F.type=G;if(!G)continue;for(let z in F){if(HzD.includes(z))continue;let q=F[z];F[z]=typeof q==="function"?await q(Q,{...Y},O):q}if(O=F,typeof F.message!=="string")throw Error("prompt message is required");if({name:Z,type:G}=F,kq[G]===void 0)throw Error(`prompt type (${G}) is not defined`);if(J[F.name]!==void 0){if(Q=await U(F,J[F.name]),Q!==void 0){Y[Z]=Q;continue}}try{Q=X4._injected?VzD(X4._injected,F.initial):await kq[G](F),Y[Z]=Q=await U(F,Q,!0),w=await $(F,Q,Y)}catch(z){w=!await X(F,Y)}if(w)return Y}return Y}function VzD(D,$){let X=D.shift();if(X instanceof Error)throw X;return X===void 0?$:X}function NzD(D){X4._injected=(X4._injected||[]).concat(D)}function MzD(D){X4._override=Object.assign({},D)}yb.exports=Object.assign(X4,{prompt:X4,prompts:kq,inject:NzD,override:MzD})});var GQ=T((AhD,gb)=>{function LzD(D){D=(Array.isArray(D)?D:D.split(".")).map(Number);let $=0,X=process.versions.node.split(".").map(Number);for(;$<D.length;$++){if(X[$]>D[$])return!1;if(D[$]>X[$])return!0}return!1}gb.exports=LzD("8.6.0")?nf():bb()});var E3=T((mb)=>{Object.defineProperty(mb,"__esModule",{value:!0});mb.logSuccess=mb.logPrompt=mb.logger=mb.output=void 0;var fq=lD(),q8=Gq(),z8=fq.__importDefault(i9()),IzD=C_(),hb={colors:z8.default,stream:process.argv.includes("--json")?process.stderr:process.stdout};mb.output=(0,IzD.isInteractive)()?new q8.TTYOutputStrategy(hb):new q8.StreamOutputStrategy(hb);mb.logger=(0,q8.createDefaultLogger)({output:mb.output,formatterOptions:{titleize:!1,tags:new Map([[q8.LOGGER_LEVELS.DEBUG,z8.default.log.DEBUG("[debug]")],[q8.LOGGER_LEVELS.INFO,z8.default.log.INFO("[info]")],[q8.LOGGER_LEVELS.WARN,z8.default.log.WARN("[warn]")],[q8.LOGGER_LEVELS.ERROR,z8.default.log.ERROR("[error]")]])}});async function AzD(D,$){let{wordWrap:X}=await Promise.resolve().then(()=>fq.__importStar(Gq())),{prompt:Y}=await Promise.resolve().then(()=>fq.__importStar(GQ()));return mb.logger.log({msg:`${z8.default.input("[?]")} ${X(D,{indentation:4})}`,logger:mb.logger,format:!1}),Y($,{onCancel:()=>process.exit(1)})}mb.logPrompt=AzD;function RzD(D){mb.logger.msg(`${z8.default.success("[success]")} ${D}`)}mb.logSuccess=RzD});var UQ=T((lb)=>{Object.defineProperty(lb,"__esModule",{value:!0});lb.resolveNode=lb.requireTS=void 0;var EzD=p("fs"),TzD=n9(),CzD=p("path"),PzD=(D,$)=>{let X=(0,CzD.resolve)($);delete p.cache[X],p.extensions[".ts"]=(J,Q)=>{var F;let w=(0,TzD.readFileSync)(Q,"utf8");if(Q.endsWith(".ts"))w=D.transpileModule(w,{fileName:Q,compilerOptions:{module:D.ModuleKind.CommonJS,moduleResolution:D.ModuleResolutionKind.NodeJs,esModuleInterop:!0,strict:!0,target:D.ScriptTarget.ES2017},reportDiagnostics:!0}).outputText;else w=w.replace(/export\s+\w+\s+(\w+)/gm,"exports.$1");(F=J._compile)===null||F===void 0||F.call(J,w,Q)};let Y=p(X);return delete p.extensions[".ts"],Y};lb.requireTS=PzD;function xzD(D,...$){try{return p.resolve($.join("/"),{paths:[D]})}catch(X){let Y=[D,"node_modules",...$].join("/");if((0,EzD.existsSync)(Y))return Y;return null}}lb.resolveNode=xzD});var qQ=T((ib)=>{(function(){ib.defaults={"0.1":{explicitCharkey:!1,trim:!0,normalize:!0,normalizeTags:!1,attrkey:"@",charkey:"#",explicitArray:!1,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!1,validator:null,xmlns:!1,explicitChildren:!1,childkey:"@@",charsAsChildren:!1,includeWhiteChars:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,emptyTag:""},"0.2":{explicitCharkey:!1,trim:!1,normalize:!1,normalizeTags:!1,attrkey:"$",charkey:"_",explicitArray:!0,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!0,validator:null,xmlns:!1,explicitChildren:!1,preserveChildrenOrder:!1,childkey:"$$",charsAsChildren:!1,includeWhiteChars:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,rootName:"root",xmldec:{version:"1.0",encoding:"UTF-8",standalone:!0},doctype:null,renderOpts:{pretty:!0,indent:" ",newline:`
258
- `},headless:!1,chunkSize:1e4,emptyTag:"",cdata:!1}}}).call(ib)});var d$=T((pb,J4)=>{(function(){var D,$,X,Y,J,Q,F,w=[].slice,Z={}.hasOwnProperty;D=function(){var G,O,U,z,q,B;if(B=arguments[0],q=2<=arguments.length?w.call(arguments,1):[],J(Object.assign))Object.assign.apply(null,arguments);else for(G=0,U=q.length;G<U;G++)if(z=q[G],z!=null)for(O in z){if(!Z.call(z,O))continue;B[O]=z[O]}return B},J=function(G){return!!G&&Object.prototype.toString.call(G)==="[object Function]"},Q=function(G){var O;return!!G&&((O=typeof G)==="function"||O==="object")},X=function(G){if(J(Array.isArray))return Array.isArray(G);else return Object.prototype.toString.call(G)==="[object Array]"},Y=function(G){var O;if(X(G))return!G.length;else{for(O in G){if(!Z.call(G,O))continue;return!1}return!0}},F=function(G){var O,U;return Q(G)&&(U=Object.getPrototypeOf(G))&&(O=U.constructor)&&typeof O==="function"&&O instanceof O&&Function.prototype.toString.call(O)===Function.prototype.toString.call(Object)},$=function(G){if(J(G.valueOf))return G.valueOf();else return G},pb.assign=D,pb.isFunction=J,pb.isObject=Q,pb.isArray=X,pb.isEmpty=Y,pb.isPlainObject=F,pb.getValue=$}).call(pb)});var yq=T((rb,ob)=>{(function(){var D;ob.exports=D=function(){function $(){}return $.prototype.hasFeature=function(X,Y){return!0},$.prototype.createDocumentType=function(X,Y,J){throw Error("This DOM method is not implemented.")},$.prototype.createDocument=function(X,Y,J){throw Error("This DOM method is not implemented.")},$.prototype.createHTMLDocument=function(X){throw Error("This DOM method is not implemented.")},$.prototype.getFeature=function(X,Y){throw Error("This DOM method is not implemented.")},$}()}).call(rb)});var sb=T((ab,tb)=>{(function(){var D;tb.exports=D=function(){function $(){}return $.prototype.handleError=function(X){throw Error(X)},$}()}).call(ab)});var $g=T((eb,Dg)=>{(function(){var D;Dg.exports=D=function(){function $(X){this.arr=X||[]}return Object.defineProperty($.prototype,"length",{get:function(){return this.arr.length}}),$.prototype.item=function(X){return this.arr[X]||null},$.prototype.contains=function(X){return this.arr.indexOf(X)!==-1},$}()}).call(eb)});var Yg=T((Xg,Jg)=>{(function(){var D,$,X;$=sb(),X=$g(),Jg.exports=D=function(){function Y(){var J;this.defaultParams={"canonical-form":!1,"cdata-sections":!1,comments:!1,"datatype-normalization":!1,"element-content-whitespace":!0,entities:!0,"error-handler":new $,infoset:!0,"validate-if-schema":!1,namespaces:!0,"namespace-declarations":!0,"normalize-characters":!1,"schema-location":"","schema-type":"","split-cdata-sections":!0,validate:!1,"well-formed":!0},this.params=J=Object.create(this.defaultParams)}return Object.defineProperty(Y.prototype,"parameterNames",{get:function(){return new X(Object.keys(this.defaultParams))}}),Y.prototype.getParameter=function(J){if(this.params.hasOwnProperty(J))return this.params[J];else return null},Y.prototype.canSetParameter=function(J,Q){return!0},Y.prototype.setParameter=function(J,Q){if(Q!=null)return this.params[J]=Q;else return delete this.params[J]},Y}()}).call(Xg)});var _0=T((Qg,Fg)=>{(function(){Fg.exports={Element:1,Attribute:2,Text:3,CData:4,EntityReference:5,EntityDeclaration:6,ProcessingInstruction:7,Comment:8,Document:9,DocType:10,DocumentFragment:11,NotationDeclaration:12,Declaration:201,Raw:202,AttributeDeclaration:203,ElementDeclaration:204,Dummy:205}}).call(Qg)});var bq=T((wg,Zg)=>{(function(){var D,$,X;D=_0(),X=m1(),Zg.exports=$=function(){function Y(J,Q,F){if(this.parent=J,this.parent)this.options=this.parent.options,this.stringify=this.parent.stringify;if(Q==null)throw Error("Missing attribute name. "+this.debugInfo(Q));this.name=this.stringify.name(Q),this.value=this.stringify.attValue(F),this.type=D.Attribute,this.isId=!1,this.schemaTypeInfo=null}return Object.defineProperty(Y.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(Y.prototype,"ownerElement",{get:function(){return this.parent}}),Object.defineProperty(Y.prototype,"textContent",{get:function(){return this.value},set:function(J){return this.value=J||""}}),Object.defineProperty(Y.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(Y.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(Y.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(Y.prototype,"specified",{get:function(){return!0}}),Y.prototype.clone=function(){return Object.create(this)},Y.prototype.toString=function(J){return this.options.writer.attribute(this,this.options.writer.filterOptions(J))},Y.prototype.debugInfo=function(J){if(J=J||this.name,J==null)return"parent: <"+this.parent.name+">";else return"attribute: {"+J+"}, parent: <"+this.parent.name+">"},Y.prototype.isEqualNode=function(J){if(J.namespaceURI!==this.namespaceURI)return!1;if(J.prefix!==this.prefix)return!1;if(J.localName!==this.localName)return!1;if(J.value!==this.value)return!1;return!0},Y}()}).call(wg)});var zQ=T((Gg,Og)=>{(function(){var D;Og.exports=D=function(){function $(X){this.nodes=X}return Object.defineProperty($.prototype,"length",{get:function(){return Object.keys(this.nodes).length||0}}),$.prototype.clone=function(){return this.nodes=null},$.prototype.getNamedItem=function(X){return this.nodes[X]},$.prototype.setNamedItem=function(X){var Y=this.nodes[X.nodeName];return this.nodes[X.nodeName]=X,Y||null},$.prototype.removeNamedItem=function(X){var Y=this.nodes[X];return delete this.nodes[X],Y||null},$.prototype.item=function(X){return this.nodes[Object.keys(this.nodes)[X]]||null},$.prototype.getNamedItemNS=function(X,Y){throw Error("This DOM method is not implemented.")},$.prototype.setNamedItemNS=function(X){throw Error("This DOM method is not implemented.")},$.prototype.removeNamedItemNS=function(X,Y){throw Error("This DOM method is not implemented.")},$}()}).call(Gg)});var BQ=T((Ug,qg)=>{(function(){var D,$,X,Y,J,Q,F,w,Z,G=function(U,z){for(var q in z)if(O.call(z,q))U[q]=z[q];function B(){this.constructor=U}return B.prototype=z.prototype,U.prototype=new B,U.__super__=z.prototype,U},O={}.hasOwnProperty;Z=d$(),w=Z.isObject,F=Z.isFunction,Q=Z.getValue,J=m1(),D=_0(),$=bq(),Y=zQ(),qg.exports=X=function(U){G(z,U);function z(q,B,K){var M,L,I,W;if(z.__super__.constructor.call(this,q),B==null)throw Error("Missing element name. "+this.debugInfo());if(this.name=this.stringify.name(B),this.type=D.Element,this.attribs={},this.schemaTypeInfo=null,K!=null)this.attribute(K);if(q.type===D.Document){if(this.isRoot=!0,this.documentObject=q,q.rootObject=this,q.children){W=q.children;for(L=0,I=W.length;L<I;L++)if(M=W[L],M.type===D.DocType){M.name=this.name;break}}}}return Object.defineProperty(z.prototype,"tagName",{get:function(){return this.name}}),Object.defineProperty(z.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(z.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(z.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(z.prototype,"id",{get:function(){throw Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(z.prototype,"className",{get:function(){throw Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(z.prototype,"classList",{get:function(){throw Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(z.prototype,"attributes",{get:function(){if(!this.attributeMap||!this.attributeMap.nodes)this.attributeMap=new Y(this.attribs);return this.attributeMap}}),z.prototype.clone=function(){var q,B,K,M;if(K=Object.create(this),K.isRoot)K.documentObject=null;K.attribs={},M=this.attribs;for(B in M){if(!O.call(M,B))continue;q=M[B],K.attribs[B]=q.clone()}return K.children=[],this.children.forEach(function(L){var I=L.clone();return I.parent=K,K.children.push(I)}),K},z.prototype.attribute=function(q,B){var K,M;if(q!=null)q=Q(q);if(w(q))for(K in q){if(!O.call(q,K))continue;M=q[K],this.attribute(K,M)}else{if(F(B))B=B.apply();if(this.options.keepNullAttributes&&B==null)this.attribs[q]=new $(this,q,"");else if(B!=null)this.attribs[q]=new $(this,q,B)}return this},z.prototype.removeAttribute=function(q){var B,K,M;if(q==null)throw Error("Missing attribute name. "+this.debugInfo());if(q=Q(q),Array.isArray(q))for(K=0,M=q.length;K<M;K++)B=q[K],delete this.attribs[B];else delete this.attribs[q];return this},z.prototype.toString=function(q){return this.options.writer.element(this,this.options.writer.filterOptions(q))},z.prototype.att=function(q,B){return this.attribute(q,B)},z.prototype.a=function(q,B){return this.attribute(q,B)},z.prototype.getAttribute=function(q){if(this.attribs.hasOwnProperty(q))return this.attribs[q].value;else return null},z.prototype.setAttribute=function(q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getAttributeNode=function(q){if(this.attribs.hasOwnProperty(q))return this.attribs[q];else return null},z.prototype.setAttributeNode=function(q){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.removeAttributeNode=function(q){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getElementsByTagName=function(q){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getAttributeNS=function(q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.setAttributeNS=function(q,B,K){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.removeAttributeNS=function(q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getAttributeNodeNS=function(q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.setAttributeNodeNS=function(q){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getElementsByTagNameNS=function(q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.hasAttribute=function(q){return this.attribs.hasOwnProperty(q)},z.prototype.hasAttributeNS=function(q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.setIdAttribute=function(q,B){if(this.attribs.hasOwnProperty(q))return this.attribs[q].isId;else return B},z.prototype.setIdAttributeNS=function(q,B,K){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.setIdAttributeNode=function(q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getElementsByTagName=function(q){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getElementsByTagNameNS=function(q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getElementsByClassName=function(q){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.isEqualNode=function(q){var B,K,M;if(!z.__super__.isEqualNode.apply(this,arguments).isEqualNode(q))return!1;if(q.namespaceURI!==this.namespaceURI)return!1;if(q.prefix!==this.prefix)return!1;if(q.localName!==this.localName)return!1;if(q.attribs.length!==this.attribs.length)return!1;for(B=K=0,M=this.attribs.length-1;0<=M?K<=M:K>=M;B=0<=M?++K:--K)if(!this.attribs[B].isEqualNode(q.attribs[B]))return!1;return!0},z}(J)}).call(Ug)});var b3=T((zg,Bg)=>{(function(){var D,$,X=function(J,Q){for(var F in Q)if(Y.call(Q,F))J[F]=Q[F];function w(){this.constructor=J}return w.prototype=Q.prototype,J.prototype=new w,J.__super__=Q.prototype,J},Y={}.hasOwnProperty;$=m1(),Bg.exports=D=function(J){X(Q,J);function Q(F){Q.__super__.constructor.call(this,F),this.value=""}return Object.defineProperty(Q.prototype,"data",{get:function(){return this.value},set:function(F){return this.value=F||""}}),Object.defineProperty(Q.prototype,"length",{get:function(){return this.value.length}}),Object.defineProperty(Q.prototype,"textContent",{get:function(){return this.value},set:function(F){return this.value=F||""}}),Q.prototype.clone=function(){return Object.create(this)},Q.prototype.substringData=function(F,w){throw Error("This DOM method is not implemented."+this.debugInfo())},Q.prototype.appendData=function(F){throw Error("This DOM method is not implemented."+this.debugInfo())},Q.prototype.insertData=function(F,w){throw Error("This DOM method is not implemented."+this.debugInfo())},Q.prototype.deleteData=function(F,w){throw Error("This DOM method is not implemented."+this.debugInfo())},Q.prototype.replaceData=function(F,w,Z){throw Error("This DOM method is not implemented."+this.debugInfo())},Q.prototype.isEqualNode=function(F){if(!Q.__super__.isEqualNode.apply(this,arguments).isEqualNode(F))return!1;if(F.data!==this.data)return!1;return!0},Q}($)}).call(zg)});var KQ=T((Kg,Wg)=>{(function(){var D,$,X,Y=function(Q,F){for(var w in F)if(J.call(F,w))Q[w]=F[w];function Z(){this.constructor=Q}return Z.prototype=F.prototype,Q.prototype=new Z,Q.__super__=F.prototype,Q},J={}.hasOwnProperty;D=_0(),X=b3(),Wg.exports=$=function(Q){Y(F,Q);function F(w,Z){if(F.__super__.constructor.call(this,w),Z==null)throw Error("Missing CDATA text. "+this.debugInfo());this.name="#cdata-section",this.type=D.CData,this.value=this.stringify.cdata(Z)}return F.prototype.clone=function(){return Object.create(this)},F.prototype.toString=function(w){return this.options.writer.cdata(this,this.options.writer.filterOptions(w))},F}(X)}).call(Kg)});var WQ=T((Hg,Vg)=>{(function(){var D,$,X,Y=function(Q,F){for(var w in F)if(J.call(F,w))Q[w]=F[w];function Z(){this.constructor=Q}return Z.prototype=F.prototype,Q.prototype=new Z,Q.__super__=F.prototype,Q},J={}.hasOwnProperty;D=_0(),$=b3(),Vg.exports=X=function(Q){Y(F,Q);function F(w,Z){if(F.__super__.constructor.call(this,w),Z==null)throw Error("Missing comment text. "+this.debugInfo());this.name="#comment",this.type=D.Comment,this.value=this.stringify.comment(Z)}return F.prototype.clone=function(){return Object.create(this)},F.prototype.toString=function(w){return this.options.writer.comment(this,this.options.writer.filterOptions(w))},F}($)}).call(Hg)});var HQ=T((Ng,Mg)=>{(function(){var D,$,X,Y,J=function(F,w){for(var Z in w)if(Q.call(w,Z))F[Z]=w[Z];function G(){this.constructor=F}return G.prototype=w.prototype,F.prototype=new G,F.__super__=w.prototype,F},Q={}.hasOwnProperty;Y=d$().isObject,X=m1(),D=_0(),Mg.exports=$=function(F){J(w,F);function w(Z,G,O,U){var z;if(w.__super__.constructor.call(this,Z),Y(G))z=G,G=z.version,O=z.encoding,U=z.standalone;if(!G)G="1.0";if(this.type=D.Declaration,this.version=this.stringify.xmlVersion(G),O!=null)this.encoding=this.stringify.xmlEncoding(O);if(U!=null)this.standalone=this.stringify.xmlStandalone(U)}return w.prototype.toString=function(Z){return this.options.writer.declaration(this,this.options.writer.filterOptions(Z))},w}(X)}).call(Ng)});var VQ=T((Lg,Ig)=>{(function(){var D,$,X,Y=function(Q,F){for(var w in F)if(J.call(F,w))Q[w]=F[w];function Z(){this.constructor=Q}return Z.prototype=F.prototype,Q.prototype=new Z,Q.__super__=F.prototype,Q},J={}.hasOwnProperty;X=m1(),D=_0(),Ig.exports=$=function(Q){Y(F,Q);function F(w,Z,G,O,U,z){if(F.__super__.constructor.call(this,w),Z==null)throw Error("Missing DTD element name. "+this.debugInfo());if(G==null)throw Error("Missing DTD attribute name. "+this.debugInfo(Z));if(!O)throw Error("Missing DTD attribute type. "+this.debugInfo(Z));if(!U)throw Error("Missing DTD attribute default. "+this.debugInfo(Z));if(U.indexOf("#")!==0)U="#"+U;if(!U.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/))throw Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. "+this.debugInfo(Z));if(z&&!U.match(/^(#FIXED|#DEFAULT)$/))throw Error("Default value only applies to #FIXED or #DEFAULT. "+this.debugInfo(Z));if(this.elementName=this.stringify.name(Z),this.type=D.AttributeDeclaration,this.attributeName=this.stringify.name(G),this.attributeType=this.stringify.dtdAttType(O),z)this.defaultValue=this.stringify.dtdAttDefault(z);this.defaultValueType=U}return F.prototype.toString=function(w){return this.options.writer.dtdAttList(this,this.options.writer.filterOptions(w))},F}(X)}).call(Lg)});var NQ=T((Ag,Rg)=>{(function(){var D,$,X,Y,J=function(F,w){for(var Z in w)if(Q.call(w,Z))F[Z]=w[Z];function G(){this.constructor=F}return G.prototype=w.prototype,F.prototype=new G,F.__super__=w.prototype,F},Q={}.hasOwnProperty;Y=d$().isObject,X=m1(),D=_0(),Rg.exports=$=function(F){J(w,F);function w(Z,G,O,U){if(w.__super__.constructor.call(this,Z),O==null)throw Error("Missing DTD entity name. "+this.debugInfo(O));if(U==null)throw Error("Missing DTD entity value. "+this.debugInfo(O));if(this.pe=!!G,this.name=this.stringify.name(O),this.type=D.EntityDeclaration,!Y(U))this.value=this.stringify.dtdEntityValue(U),this.internal=!0;else{if(!U.pubID&&!U.sysID)throw Error("Public and/or system identifiers are required for an external entity. "+this.debugInfo(O));if(U.pubID&&!U.sysID)throw Error("System identifier is required for a public external entity. "+this.debugInfo(O));if(this.internal=!1,U.pubID!=null)this.pubID=this.stringify.dtdPubID(U.pubID);if(U.sysID!=null)this.sysID=this.stringify.dtdSysID(U.sysID);if(U.nData!=null)this.nData=this.stringify.dtdNData(U.nData);if(this.pe&&this.nData)throw Error("Notation declaration is not allowed in a parameter entity. "+this.debugInfo(O))}}return Object.defineProperty(w.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(w.prototype,"systemId",{get:function(){return this.sysID}}),Object.defineProperty(w.prototype,"notationName",{get:function(){return this.nData||null}}),Object.defineProperty(w.prototype,"inputEncoding",{get:function(){return null}}),Object.defineProperty(w.prototype,"xmlEncoding",{get:function(){return null}}),Object.defineProperty(w.prototype,"xmlVersion",{get:function(){return null}}),w.prototype.toString=function(Z){return this.options.writer.dtdEntity(this,this.options.writer.filterOptions(Z))},w}(X)}).call(Ag)});var MQ=T((jg,Eg)=>{(function(){var D,$,X,Y=function(Q,F){for(var w in F)if(J.call(F,w))Q[w]=F[w];function Z(){this.constructor=Q}return Z.prototype=F.prototype,Q.prototype=new Z,Q.__super__=F.prototype,Q},J={}.hasOwnProperty;X=m1(),D=_0(),Eg.exports=$=function(Q){Y(F,Q);function F(w,Z,G){if(F.__super__.constructor.call(this,w),Z==null)throw Error("Missing DTD element name. "+this.debugInfo());if(!G)G="(#PCDATA)";if(Array.isArray(G))G="("+G.join(",")+")";this.name=this.stringify.name(Z),this.type=D.ElementDeclaration,this.value=this.stringify.dtdElementValue(G)}return F.prototype.toString=function(w){return this.options.writer.dtdElement(this,this.options.writer.filterOptions(w))},F}(X)}).call(jg)});var LQ=T((Tg,Cg)=>{(function(){var D,$,X,Y=function(Q,F){for(var w in F)if(J.call(F,w))Q[w]=F[w];function Z(){this.constructor=Q}return Z.prototype=F.prototype,Q.prototype=new Z,Q.__super__=F.prototype,Q},J={}.hasOwnProperty;X=m1(),D=_0(),Cg.exports=$=function(Q){Y(F,Q);function F(w,Z,G){if(F.__super__.constructor.call(this,w),Z==null)throw Error("Missing DTD notation name. "+this.debugInfo(Z));if(!G.pubID&&!G.sysID)throw Error("Public or system identifiers are required for an external entity. "+this.debugInfo(Z));if(this.name=this.stringify.name(Z),this.type=D.NotationDeclaration,G.pubID!=null)this.pubID=this.stringify.dtdPubID(G.pubID);if(G.sysID!=null)this.sysID=this.stringify.dtdSysID(G.sysID)}return Object.defineProperty(F.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(F.prototype,"systemId",{get:function(){return this.sysID}}),F.prototype.toString=function(w){return this.options.writer.dtdNotation(this,this.options.writer.filterOptions(w))},F}(X)}).call(Tg)});var IQ=T((Pg,xg)=>{(function(){var D,$,X,Y,J,Q,F,w,Z,G=function(U,z){for(var q in z)if(O.call(z,q))U[q]=z[q];function B(){this.constructor=U}return B.prototype=z.prototype,U.prototype=new B,U.__super__=z.prototype,U},O={}.hasOwnProperty;Z=d$().isObject,w=m1(),D=_0(),$=VQ(),Y=NQ(),X=MQ(),J=LQ(),F=zQ(),xg.exports=Q=function(U){G(z,U);function z(q,B,K){var M,L,I,W,N,V;if(z.__super__.constructor.call(this,q),this.type=D.DocType,q.children){W=q.children;for(L=0,I=W.length;L<I;L++)if(M=W[L],M.type===D.Element){this.name=M.name;break}}if(this.documentObject=q,Z(B))N=B,B=N.pubID,K=N.sysID;if(K==null)V=[B,K],K=V[0],B=V[1];if(B!=null)this.pubID=this.stringify.dtdPubID(B);if(K!=null)this.sysID=this.stringify.dtdSysID(K)}return Object.defineProperty(z.prototype,"entities",{get:function(){var q,B,K,M,L;M={},L=this.children;for(B=0,K=L.length;B<K;B++)if(q=L[B],q.type===D.EntityDeclaration&&!q.pe)M[q.name]=q;return new F(M)}}),Object.defineProperty(z.prototype,"notations",{get:function(){var q,B,K,M,L;M={},L=this.children;for(B=0,K=L.length;B<K;B++)if(q=L[B],q.type===D.NotationDeclaration)M[q.name]=q;return new F(M)}}),Object.defineProperty(z.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(z.prototype,"systemId",{get:function(){return this.sysID}}),Object.defineProperty(z.prototype,"internalSubset",{get:function(){throw Error("This DOM method is not implemented."+this.debugInfo())}}),z.prototype.element=function(q,B){var K=new X(this,q,B);return this.children.push(K),this},z.prototype.attList=function(q,B,K,M,L){var I=new $(this,q,B,K,M,L);return this.children.push(I),this},z.prototype.entity=function(q,B){var K=new Y(this,!1,q,B);return this.children.push(K),this},z.prototype.pEntity=function(q,B){var K=new Y(this,!0,q,B);return this.children.push(K),this},z.prototype.notation=function(q,B){var K=new J(this,q,B);return this.children.push(K),this},z.prototype.toString=function(q){return this.options.writer.docType(this,this.options.writer.filterOptions(q))},z.prototype.ele=function(q,B){return this.element(q,B)},z.prototype.att=function(q,B,K,M,L){return this.attList(q,B,K,M,L)},z.prototype.ent=function(q,B){return this.entity(q,B)},z.prototype.pent=function(q,B){return this.pEntity(q,B)},z.prototype.not=function(q,B){return this.notation(q,B)},z.prototype.up=function(){return this.root()||this.documentObject},z.prototype.isEqualNode=function(q){if(!z.__super__.isEqualNode.apply(this,arguments).isEqualNode(q))return!1;if(q.name!==this.name)return!1;if(q.publicId!==this.publicId)return!1;if(q.systemId!==this.systemId)return!1;return!0},z}(w)}).call(Pg)});var AQ=T((Sg,ug)=>{(function(){var D,$,X,Y=function(Q,F){for(var w in F)if(J.call(F,w))Q[w]=F[w];function Z(){this.constructor=Q}return Z.prototype=F.prototype,Q.prototype=new Z,Q.__super__=F.prototype,Q},J={}.hasOwnProperty;D=_0(),$=m1(),ug.exports=X=function(Q){Y(F,Q);function F(w,Z){if(F.__super__.constructor.call(this,w),Z==null)throw Error("Missing raw text. "+this.debugInfo());this.type=D.Raw,this.value=this.stringify.raw(Z)}return F.prototype.clone=function(){return Object.create(this)},F.prototype.toString=function(w){return this.options.writer.raw(this,this.options.writer.filterOptions(w))},F}($)}).call(Sg)});var RQ=T((vg,_g)=>{(function(){var D,$,X,Y=function(Q,F){for(var w in F)if(J.call(F,w))Q[w]=F[w];function Z(){this.constructor=Q}return Z.prototype=F.prototype,Q.prototype=new Z,Q.__super__=F.prototype,Q},J={}.hasOwnProperty;D=_0(),$=b3(),_g.exports=X=function(Q){Y(F,Q);function F(w,Z){if(F.__super__.constructor.call(this,w),Z==null)throw Error("Missing element text. "+this.debugInfo());this.name="#text",this.type=D.Text,this.value=this.stringify.text(Z)}return Object.defineProperty(F.prototype,"isElementContentWhitespace",{get:function(){throw Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(F.prototype,"wholeText",{get:function(){var w,Z,G;G="",Z=this.previousSibling;while(Z)G=Z.data+G,Z=Z.previousSibling;G+=this.data,w=this.nextSibling;while(w)G=G+w.data,w=w.nextSibling;return G}}),F.prototype.clone=function(){return Object.create(this)},F.prototype.toString=function(w){return this.options.writer.text(this,this.options.writer.filterOptions(w))},F.prototype.splitText=function(w){throw Error("This DOM method is not implemented."+this.debugInfo())},F.prototype.replaceWholeText=function(w){throw Error("This DOM method is not implemented."+this.debugInfo())},F}($)}).call(vg)});var jQ=T((kg,fg)=>{(function(){var D,$,X,Y=function(Q,F){for(var w in F)if(J.call(F,w))Q[w]=F[w];function Z(){this.constructor=Q}return Z.prototype=F.prototype,Q.prototype=new Z,Q.__super__=F.prototype,Q},J={}.hasOwnProperty;D=_0(),$=b3(),fg.exports=X=function(Q){Y(F,Q);function F(w,Z,G){if(F.__super__.constructor.call(this,w),Z==null)throw Error("Missing instruction target. "+this.debugInfo());if(this.type=D.ProcessingInstruction,this.target=this.stringify.insTarget(Z),this.name=this.target,G)this.value=this.stringify.insValue(G)}return F.prototype.clone=function(){return Object.create(this)},F.prototype.toString=function(w){return this.options.writer.processingInstruction(this,this.options.writer.filterOptions(w))},F.prototype.isEqualNode=function(w){if(!F.__super__.isEqualNode.apply(this,arguments).isEqualNode(w))return!1;if(w.target!==this.target)return!1;return!0},F}($)}).call(kg)});var gq=T((yg,bg)=>{(function(){var D,$,X,Y=function(Q,F){for(var w in F)if(J.call(F,w))Q[w]=F[w];function Z(){this.constructor=Q}return Z.prototype=F.prototype,Q.prototype=new Z,Q.__super__=F.prototype,Q},J={}.hasOwnProperty;X=m1(),D=_0(),bg.exports=$=function(Q){Y(F,Q);function F(w){F.__super__.constructor.call(this,w),this.type=D.Dummy}return F.prototype.clone=function(){return Object.create(this)},F.prototype.toString=function(w){return""},F}(X)}).call(yg)});var mg=T((gg,hg)=>{(function(){var D;hg.exports=D=function(){function $(X){this.nodes=X}return Object.defineProperty($.prototype,"length",{get:function(){return this.nodes.length||0}}),$.prototype.clone=function(){return this.nodes=null},$.prototype.item=function(X){return this.nodes[X]||null},$}()}).call(gg)});var lg=T((dg,cg)=>{(function(){cg.exports={Disconnected:1,Preceding:2,Following:4,Contains:8,ContainedBy:16,ImplementationSpecific:32}}).call(dg)});var m1=T((ng,ig)=>{(function(){var D,$,X,Y,J,Q,F,w,Z,G,O,U,z,q,B,K,M,L,I,W={}.hasOwnProperty;I=d$(),L=I.isObject,M=I.isFunction,K=I.isEmpty,B=I.getValue,w=null,X=null,Y=null,J=null,Q=null,z=null,q=null,U=null,F=null,$=null,O=null,Z=null,D=null,ig.exports=G=function(){function N(V){if(this.parent=V,this.parent)this.options=this.parent.options,this.stringify=this.parent.stringify;if(this.value=null,this.children=[],this.baseURI=null,!w)w=BQ(),X=KQ(),Y=WQ(),J=HQ(),Q=IQ(),z=AQ(),q=RQ(),U=jQ(),F=gq(),$=_0(),O=mg(),Z=zQ(),D=lg()}return Object.defineProperty(N.prototype,"nodeName",{get:function(){return this.name}}),Object.defineProperty(N.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(N.prototype,"nodeValue",{get:function(){return this.value}}),Object.defineProperty(N.prototype,"parentNode",{get:function(){return this.parent}}),Object.defineProperty(N.prototype,"childNodes",{get:function(){if(!this.childNodeList||!this.childNodeList.nodes)this.childNodeList=new O(this.children);return this.childNodeList}}),Object.defineProperty(N.prototype,"firstChild",{get:function(){return this.children[0]||null}}),Object.defineProperty(N.prototype,"lastChild",{get:function(){return this.children[this.children.length-1]||null}}),Object.defineProperty(N.prototype,"previousSibling",{get:function(){var V=this.parent.children.indexOf(this);return this.parent.children[V-1]||null}}),Object.defineProperty(N.prototype,"nextSibling",{get:function(){var V=this.parent.children.indexOf(this);return this.parent.children[V+1]||null}}),Object.defineProperty(N.prototype,"ownerDocument",{get:function(){return this.document()||null}}),Object.defineProperty(N.prototype,"textContent",{get:function(){var V,R,P,A,_;if(this.nodeType===$.Element||this.nodeType===$.DocumentFragment){_="",A=this.children;for(R=0,P=A.length;R<P;R++)if(V=A[R],V.textContent)_+=V.textContent;return _}else return null},set:function(V){throw Error("This DOM method is not implemented."+this.debugInfo())}}),N.prototype.setParent=function(V){var R,P,A,_,v;if(this.parent=V,V)this.options=V.options,this.stringify=V.stringify;_=this.children,v=[];for(P=0,A=_.length;P<A;P++)R=_[P],v.push(R.setParent(this));return v},N.prototype.element=function(V,R,P){var A,_,v,S,h,g,l,f,j,x,u;if(g=null,R===null&&P==null)j=[{},null],R=j[0],P=j[1];if(R==null)R={};if(R=B(R),!L(R))x=[R,P],P=x[0],R=x[1];if(V!=null)V=B(V);if(Array.isArray(V))for(v=0,l=V.length;v<l;v++)_=V[v],g=this.element(_);else if(M(V))g=this.element(V.apply());else if(L(V))for(h in V){if(!W.call(V,h))continue;if(u=V[h],M(u))u=u.apply();if(!this.options.ignoreDecorators&&this.stringify.convertAttKey&&h.indexOf(this.stringify.convertAttKey)===0)g=this.attribute(h.substr(this.stringify.convertAttKey.length),u);else if(!this.options.separateArrayItems&&Array.isArray(u)&&K(u))g=this.dummy();else if(L(u)&&K(u))g=this.element(h);else if(!this.options.keepNullNodes&&u==null)g=this.dummy();else if(!this.options.separateArrayItems&&Array.isArray(u))for(S=0,f=u.length;S<f;S++)_=u[S],A={},A[h]=_,g=this.element(A);else if(L(u))if(!this.options.ignoreDecorators&&this.stringify.convertTextKey&&h.indexOf(this.stringify.convertTextKey)===0)g=this.element(u);else g=this.element(h),g.element(u);else g=this.element(h,u)}else if(!this.options.keepNullNodes&&P===null)g=this.dummy();else if(!this.options.ignoreDecorators&&this.stringify.convertTextKey&&V.indexOf(this.stringify.convertTextKey)===0)g=this.text(P);else if(!this.options.ignoreDecorators&&this.stringify.convertCDataKey&&V.indexOf(this.stringify.convertCDataKey)===0)g=this.cdata(P);else if(!this.options.ignoreDecorators&&this.stringify.convertCommentKey&&V.indexOf(this.stringify.convertCommentKey)===0)g=this.comment(P);else if(!this.options.ignoreDecorators&&this.stringify.convertRawKey&&V.indexOf(this.stringify.convertRawKey)===0)g=this.raw(P);else if(!this.options.ignoreDecorators&&this.stringify.convertPIKey&&V.indexOf(this.stringify.convertPIKey)===0)g=this.instruction(V.substr(this.stringify.convertPIKey.length),P);else g=this.node(V,R,P);if(g==null)throw Error("Could not create any elements with: "+V+". "+this.debugInfo());return g},N.prototype.insertBefore=function(V,R,P){var A,_,v,S,h;if(V!=null?V.type:void 0){if(v=V,S=R,v.setParent(this),S)_=children.indexOf(S),h=children.splice(_),children.push(v),Array.prototype.push.apply(children,h);else children.push(v);return v}else{if(this.isRoot)throw Error("Cannot insert elements at root level. "+this.debugInfo(V));return _=this.parent.children.indexOf(this),h=this.parent.children.splice(_),A=this.parent.element(V,R,P),Array.prototype.push.apply(this.parent.children,h),A}},N.prototype.insertAfter=function(V,R,P){var A,_,v;if(this.isRoot)throw Error("Cannot insert elements at root level. "+this.debugInfo(V));return _=this.parent.children.indexOf(this),v=this.parent.children.splice(_+1),A=this.parent.element(V,R,P),Array.prototype.push.apply(this.parent.children,v),A},N.prototype.remove=function(){var V,R;if(this.isRoot)throw Error("Cannot remove the root element. "+this.debugInfo());return V=this.parent.children.indexOf(this),[].splice.apply(this.parent.children,[V,V-V+1].concat(R=[])),this.parent},N.prototype.node=function(V,R,P){var A,_;if(V!=null)V=B(V);if(R||(R={}),R=B(R),!L(R))_=[R,P],P=_[0],R=_[1];if(A=new w(this,V,R),P!=null)A.text(P);return this.children.push(A),A},N.prototype.text=function(V){var R;if(L(V))this.element(V);return R=new q(this,V),this.children.push(R),this},N.prototype.cdata=function(V){var R=new X(this,V);return this.children.push(R),this},N.prototype.comment=function(V){var R=new Y(this,V);return this.children.push(R),this},N.prototype.commentBefore=function(V){var R,P,A;return P=this.parent.children.indexOf(this),A=this.parent.children.splice(P),R=this.parent.comment(V),Array.prototype.push.apply(this.parent.children,A),this},N.prototype.commentAfter=function(V){var R,P,A;return P=this.parent.children.indexOf(this),A=this.parent.children.splice(P+1),R=this.parent.comment(V),Array.prototype.push.apply(this.parent.children,A),this},N.prototype.raw=function(V){var R=new z(this,V);return this.children.push(R),this},N.prototype.dummy=function(){var V=new F(this);return V},N.prototype.instruction=function(V,R){var P,A,_,v,S;if(V!=null)V=B(V);if(R!=null)R=B(R);if(Array.isArray(V))for(v=0,S=V.length;v<S;v++)P=V[v],this.instruction(P);else if(L(V))for(P in V){if(!W.call(V,P))continue;A=V[P],this.instruction(P,A)}else{if(M(R))R=R.apply();_=new U(this,V,R),this.children.push(_)}return this},N.prototype.instructionBefore=function(V,R){var P,A,_;return A=this.parent.children.indexOf(this),_=this.parent.children.splice(A),P=this.parent.instruction(V,R),Array.prototype.push.apply(this.parent.children,_),this},N.prototype.instructionAfter=function(V,R){var P,A,_;return A=this.parent.children.indexOf(this),_=this.parent.children.splice(A+1),P=this.parent.instruction(V,R),Array.prototype.push.apply(this.parent.children,_),this},N.prototype.declaration=function(V,R,P){var A,_;if(A=this.document(),_=new J(A,V,R,P),A.children.length===0)A.children.unshift(_);else if(A.children[0].type===$.Declaration)A.children[0]=_;else A.children.unshift(_);return A.root()||A},N.prototype.dtd=function(V,R){var P,A,_,v,S,h,g,l,f,j;A=this.document(),_=new Q(A,V,R),f=A.children;for(v=S=0,g=f.length;S<g;v=++S)if(P=f[v],P.type===$.DocType)return A.children[v]=_,_;j=A.children;for(v=h=0,l=j.length;h<l;v=++h)if(P=j[v],P.isRoot)return A.children.splice(v,0,_),_;return A.children.push(_),_},N.prototype.up=function(){if(this.isRoot)throw Error("The root node has no parent. Use doc() if you need to get the document object.");return this.parent},N.prototype.root=function(){var V=this;while(V)if(V.type===$.Document)return V.rootObject;else if(V.isRoot)return V;else V=V.parent},N.prototype.document=function(){var V=this;while(V)if(V.type===$.Document)return V;else V=V.parent},N.prototype.end=function(V){return this.document().end(V)},N.prototype.prev=function(){var V=this.parent.children.indexOf(this);if(V<1)throw Error("Already at the first node. "+this.debugInfo());return this.parent.children[V-1]},N.prototype.next=function(){var V=this.parent.children.indexOf(this);if(V===-1||V===this.parent.children.length-1)throw Error("Already at the last node. "+this.debugInfo());return this.parent.children[V+1]},N.prototype.importDocument=function(V){var R=V.root().clone();return R.parent=this,R.isRoot=!1,this.children.push(R),this},N.prototype.debugInfo=function(V){var R,P;if(V=V||this.name,V==null&&!((R=this.parent)!=null?R.name:void 0))return"";else if(V==null)return"parent: <"+this.parent.name+">";else if(!((P=this.parent)!=null?P.name:void 0))return"node: <"+V+">";else return"node: <"+V+">, parent: <"+this.parent.name+">"},N.prototype.ele=function(V,R,P){return this.element(V,R,P)},N.prototype.nod=function(V,R,P){return this.node(V,R,P)},N.prototype.txt=function(V){return this.text(V)},N.prototype.dat=function(V){return this.cdata(V)},N.prototype.com=function(V){return this.comment(V)},N.prototype.ins=function(V,R){return this.instruction(V,R)},N.prototype.doc=function(){return this.document()},N.prototype.dec=function(V,R,P){return this.declaration(V,R,P)},N.prototype.e=function(V,R,P){return this.element(V,R,P)},N.prototype.n=function(V,R,P){return this.node(V,R,P)},N.prototype.t=function(V){return this.text(V)},N.prototype.d=function(V){return this.cdata(V)},N.prototype.c=function(V){return this.comment(V)},N.prototype.r=function(V){return this.raw(V)},N.prototype.i=function(V,R){return this.instruction(V,R)},N.prototype.u=function(){return this.up()},N.prototype.importXMLBuilder=function(V){return this.importDocument(V)},N.prototype.replaceChild=function(V,R){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.removeChild=function(V){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.appendChild=function(V){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.hasChildNodes=function(){return this.children.length!==0},N.prototype.cloneNode=function(V){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.normalize=function(){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.isSupported=function(V,R){return!0},N.prototype.hasAttributes=function(){return this.attribs.length!==0},N.prototype.compareDocumentPosition=function(V){var R,P;if(R=this,R===V)return 0;else if(this.document()!==V.document()){if(P=D.Disconnected|D.ImplementationSpecific,Math.random()<0.5)P|=D.Preceding;else P|=D.Following;return P}else if(R.isAncestor(V))return D.Contains|D.Preceding;else if(R.isDescendant(V))return D.Contains|D.Following;else if(R.isPreceding(V))return D.Preceding;else return D.Following},N.prototype.isSameNode=function(V){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.lookupPrefix=function(V){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.isDefaultNamespace=function(V){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.lookupNamespaceURI=function(V){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.isEqualNode=function(V){var R,P,A;if(V.nodeType!==this.nodeType)return!1;if(V.children.length!==this.children.length)return!1;for(R=P=0,A=this.children.length-1;0<=A?P<=A:P>=A;R=0<=A?++P:--P)if(!this.children[R].isEqualNode(V.children[R]))return!1;return!0},N.prototype.getFeature=function(V,R){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.setUserData=function(V,R,P){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.getUserData=function(V){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.contains=function(V){if(!V)return!1;return V===this||this.isDescendant(V)},N.prototype.isDescendant=function(V){var R,P,A,_,v;v=this.children;for(A=0,_=v.length;A<_;A++){if(R=v[A],V===R)return!0;if(P=R.isDescendant(V),P)return!0}return!1},N.prototype.isAncestor=function(V){return V.isDescendant(this)},N.prototype.isPreceding=function(V){var R,P;if(R=this.treePosition(V),P=this.treePosition(this),R===-1||P===-1)return!1;else return R<P},N.prototype.isFollowing=function(V){var R,P;if(R=this.treePosition(V),P=this.treePosition(this),R===-1||P===-1)return!1;else return R>P},N.prototype.treePosition=function(V){var R,P;if(P=0,R=!1,this.foreachTreeNode(this.document(),function(A){if(P++,!R&&A===V)return R=!0}),R)return P;else return-1},N.prototype.foreachTreeNode=function(V,R){var P,A,_,v,S;V||(V=this.document()),v=V.children;for(A=0,_=v.length;A<_;A++)if(P=v[A],S=R(P))return S;else if(S=this.foreachTreeNode(P,R),S)return S},N}()}).call(ng)});var hq=T((pg,rg)=>{(function(){var D,$=function(Y,J){return function(){return Y.apply(J,arguments)}},X={}.hasOwnProperty;rg.exports=D=function(){function Y(J){this.assertLegalName=$(this.assertLegalName,this),this.assertLegalChar=$(this.assertLegalChar,this);var Q,F,w;if(J||(J={}),this.options=J,!this.options.version)this.options.version="1.0";F=J.stringify||{};for(Q in F){if(!X.call(F,Q))continue;w=F[Q],this[Q]=w}}return Y.prototype.name=function(J){if(this.options.noValidation)return J;return this.assertLegalName(""+J||"")},Y.prototype.text=function(J){if(this.options.noValidation)return J;return this.assertLegalChar(this.textEscape(""+J||""))},Y.prototype.cdata=function(J){if(this.options.noValidation)return J;return J=""+J||"",J=J.replace("]]>","]]]]><![CDATA[>"),this.assertLegalChar(J)},Y.prototype.comment=function(J){if(this.options.noValidation)return J;if(J=""+J||"",J.match(/--/))throw Error("Comment text cannot contain double-hypen: "+J);return this.assertLegalChar(J)},Y.prototype.raw=function(J){if(this.options.noValidation)return J;return""+J||""},Y.prototype.attValue=function(J){if(this.options.noValidation)return J;return this.assertLegalChar(this.attEscape(J=""+J||""))},Y.prototype.insTarget=function(J){if(this.options.noValidation)return J;return this.assertLegalChar(""+J||"")},Y.prototype.insValue=function(J){if(this.options.noValidation)return J;if(J=""+J||"",J.match(/\?>/))throw Error("Invalid processing instruction value: "+J);return this.assertLegalChar(J)},Y.prototype.xmlVersion=function(J){if(this.options.noValidation)return J;if(J=""+J||"",!J.match(/1\.[0-9]+/))throw Error("Invalid version number: "+J);return J},Y.prototype.xmlEncoding=function(J){if(this.options.noValidation)return J;if(J=""+J||"",!J.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/))throw Error("Invalid encoding: "+J);return this.assertLegalChar(J)},Y.prototype.xmlStandalone=function(J){if(this.options.noValidation)return J;if(J)return"yes";else return"no"},Y.prototype.dtdPubID=function(J){if(this.options.noValidation)return J;return this.assertLegalChar(""+J||"")},Y.prototype.dtdSysID=function(J){if(this.options.noValidation)return J;return this.assertLegalChar(""+J||"")},Y.prototype.dtdElementValue=function(J){if(this.options.noValidation)return J;return this.assertLegalChar(""+J||"")},Y.prototype.dtdAttType=function(J){if(this.options.noValidation)return J;return this.assertLegalChar(""+J||"")},Y.prototype.dtdAttDefault=function(J){if(this.options.noValidation)return J;return this.assertLegalChar(""+J||"")},Y.prototype.dtdEntityValue=function(J){if(this.options.noValidation)return J;return this.assertLegalChar(""+J||"")},Y.prototype.dtdNData=function(J){if(this.options.noValidation)return J;return this.assertLegalChar(""+J||"")},Y.prototype.convertAttKey="@",Y.prototype.convertPIKey="?",Y.prototype.convertTextKey="#text",Y.prototype.convertCDataKey="#cdata",Y.prototype.convertCommentKey="#comment",Y.prototype.convertRawKey="#raw",Y.prototype.assertLegalChar=function(J){var Q,F;if(this.options.noValidation)return J;if(Q="",this.options.version==="1.0"){if(Q=/[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,F=J.match(Q))throw Error("Invalid character in string: "+J+" at index "+F.index)}else if(this.options.version==="1.1"){if(Q=/[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,F=J.match(Q))throw Error("Invalid character in string: "+J+" at index "+F.index)}return J},Y.prototype.assertLegalName=function(J){var Q;if(this.options.noValidation)return J;if(this.assertLegalChar(J),Q=/^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/,!J.match(Q))throw Error("Invalid character in name");return J},Y.prototype.textEscape=function(J){var Q;if(this.options.noValidation)return J;return Q=this.options.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,J.replace(Q,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r/g,"&#xD;")},Y.prototype.attEscape=function(J){var Q;if(this.options.noValidation)return J;return Q=this.options.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,J.replace(Q,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/\t/g,"&#x9;").replace(/\n/g,"&#xA;").replace(/\r/g,"&#xD;")},Y}()}).call(pg)});var g3=T((og,ag)=>{(function(){ag.exports={None:0,OpenTag:1,InsideTag:2,CloseTag:3}}).call(og)});var mq=T((tg,sg)=>{(function(){var D,$,X,Y,J,Q,F,w,Z,G,O,U,z,q,B,K,M,L={}.hasOwnProperty;M=d$().assign,D=_0(),Z=HQ(),G=IQ(),X=KQ(),Y=WQ(),U=BQ(),q=AQ(),B=RQ(),z=jQ(),O=gq(),J=VQ(),Q=MQ(),F=NQ(),w=LQ(),$=g3(),sg.exports=K=function(){function I(W){var N,V,R;W||(W={}),this.options=W,V=W.writer||{};for(N in V){if(!L.call(V,N))continue;R=V[N],this["_"+N]=this[N],this[N]=R}}return I.prototype.filterOptions=function(W){var N,V,R,P,A,_,v,S;if(W||(W={}),W=M({},this.options,W),N={writer:this},N.pretty=W.pretty||!1,N.allowEmpty=W.allowEmpty||!1,N.indent=(V=W.indent)!=null?V:" ",N.newline=(R=W.newline)!=null?R:`
259
- `,N.offset=(P=W.offset)!=null?P:0,N.dontPrettyTextNodes=(A=(_=W.dontPrettyTextNodes)!=null?_:W.dontprettytextnodes)!=null?A:0,N.spaceBeforeSlash=(v=(S=W.spaceBeforeSlash)!=null?S:W.spacebeforeslash)!=null?v:"",N.spaceBeforeSlash===!0)N.spaceBeforeSlash=" ";return N.suppressPrettyCount=0,N.user={},N.state=$.None,N},I.prototype.indent=function(W,N,V){var R;if(!N.pretty||N.suppressPrettyCount)return"";else if(N.pretty){if(R=(V||0)+N.offset+1,R>0)return Array(R).join(N.indent)}return""},I.prototype.endline=function(W,N,V){if(!N.pretty||N.suppressPrettyCount)return"";else return N.newline},I.prototype.attribute=function(W,N,V){var R;return this.openAttribute(W,N,V),R=" "+W.name+'="'+W.value+'"',this.closeAttribute(W,N,V),R},I.prototype.cdata=function(W,N,V){var R;return this.openNode(W,N,V),N.state=$.OpenTag,R=this.indent(W,N,V)+"<![CDATA[",N.state=$.InsideTag,R+=W.value,N.state=$.CloseTag,R+="]]>"+this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),R},I.prototype.comment=function(W,N,V){var R;return this.openNode(W,N,V),N.state=$.OpenTag,R=this.indent(W,N,V)+"<!-- ",N.state=$.InsideTag,R+=W.value,N.state=$.CloseTag,R+=" -->"+this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),R},I.prototype.declaration=function(W,N,V){var R;if(this.openNode(W,N,V),N.state=$.OpenTag,R=this.indent(W,N,V)+"<?xml",N.state=$.InsideTag,R+=' version="'+W.version+'"',W.encoding!=null)R+=' encoding="'+W.encoding+'"';if(W.standalone!=null)R+=' standalone="'+W.standalone+'"';return N.state=$.CloseTag,R+=N.spaceBeforeSlash+"?>",R+=this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),R},I.prototype.docType=function(W,N,V){var R,P,A,_,v;if(V||(V=0),this.openNode(W,N,V),N.state=$.OpenTag,_=this.indent(W,N,V),_+="<!DOCTYPE "+W.root().name,W.pubID&&W.sysID)_+=' PUBLIC "'+W.pubID+'" "'+W.sysID+'"';else if(W.sysID)_+=' SYSTEM "'+W.sysID+'"';if(W.children.length>0){_+=" [",_+=this.endline(W,N,V),N.state=$.InsideTag,v=W.children;for(P=0,A=v.length;P<A;P++)R=v[P],_+=this.writeChildNode(R,N,V+1);N.state=$.CloseTag,_+="]"}return N.state=$.CloseTag,_+=N.spaceBeforeSlash+">",_+=this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),_},I.prototype.element=function(W,N,V){var R,P,A,_,v,S,h,g,l,f,j,x,u,y;V||(V=0),f=!1,j="",this.openNode(W,N,V),N.state=$.OpenTag,j+=this.indent(W,N,V)+"<"+W.name,x=W.attribs;for(l in x){if(!L.call(x,l))continue;R=x[l],j+=this.attribute(R,N,V)}if(A=W.children.length,_=A===0?null:W.children[0],A===0||W.children.every(function(d){return(d.type===D.Text||d.type===D.Raw)&&d.value===""}))if(N.allowEmpty)j+=">",N.state=$.CloseTag,j+="</"+W.name+">"+this.endline(W,N,V);else N.state=$.CloseTag,j+=N.spaceBeforeSlash+"/>"+this.endline(W,N,V);else if(N.pretty&&A===1&&(_.type===D.Text||_.type===D.Raw)&&_.value!=null)j+=">",N.state=$.InsideTag,N.suppressPrettyCount++,f=!0,j+=this.writeChildNode(_,N,V+1),N.suppressPrettyCount--,f=!1,N.state=$.CloseTag,j+="</"+W.name+">"+this.endline(W,N,V);else{if(N.dontPrettyTextNodes){u=W.children;for(v=0,h=u.length;v<h;v++)if(P=u[v],(P.type===D.Text||P.type===D.Raw)&&P.value!=null){N.suppressPrettyCount++,f=!0;break}}j+=">"+this.endline(W,N,V),N.state=$.InsideTag,y=W.children;for(S=0,g=y.length;S<g;S++)P=y[S],j+=this.writeChildNode(P,N,V+1);if(N.state=$.CloseTag,j+=this.indent(W,N,V)+"</"+W.name+">",f)N.suppressPrettyCount--;j+=this.endline(W,N,V),N.state=$.None}return this.closeNode(W,N,V),j},I.prototype.writeChildNode=function(W,N,V){switch(W.type){case D.CData:return this.cdata(W,N,V);case D.Comment:return this.comment(W,N,V);case D.Element:return this.element(W,N,V);case D.Raw:return this.raw(W,N,V);case D.Text:return this.text(W,N,V);case D.ProcessingInstruction:return this.processingInstruction(W,N,V);case D.Dummy:return"";case D.Declaration:return this.declaration(W,N,V);case D.DocType:return this.docType(W,N,V);case D.AttributeDeclaration:return this.dtdAttList(W,N,V);case D.ElementDeclaration:return this.dtdElement(W,N,V);case D.EntityDeclaration:return this.dtdEntity(W,N,V);case D.NotationDeclaration:return this.dtdNotation(W,N,V);default:throw Error("Unknown XML node type: "+W.constructor.name)}},I.prototype.processingInstruction=function(W,N,V){var R;if(this.openNode(W,N,V),N.state=$.OpenTag,R=this.indent(W,N,V)+"<?",N.state=$.InsideTag,R+=W.target,W.value)R+=" "+W.value;return N.state=$.CloseTag,R+=N.spaceBeforeSlash+"?>",R+=this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),R},I.prototype.raw=function(W,N,V){var R;return this.openNode(W,N,V),N.state=$.OpenTag,R=this.indent(W,N,V),N.state=$.InsideTag,R+=W.value,N.state=$.CloseTag,R+=this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),R},I.prototype.text=function(W,N,V){var R;return this.openNode(W,N,V),N.state=$.OpenTag,R=this.indent(W,N,V),N.state=$.InsideTag,R+=W.value,N.state=$.CloseTag,R+=this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),R},I.prototype.dtdAttList=function(W,N,V){var R;if(this.openNode(W,N,V),N.state=$.OpenTag,R=this.indent(W,N,V)+"<!ATTLIST",N.state=$.InsideTag,R+=" "+W.elementName+" "+W.attributeName+" "+W.attributeType,W.defaultValueType!=="#DEFAULT")R+=" "+W.defaultValueType;if(W.defaultValue)R+=' "'+W.defaultValue+'"';return N.state=$.CloseTag,R+=N.spaceBeforeSlash+">"+this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),R},I.prototype.dtdElement=function(W,N,V){var R;return this.openNode(W,N,V),N.state=$.OpenTag,R=this.indent(W,N,V)+"<!ELEMENT",N.state=$.InsideTag,R+=" "+W.name+" "+W.value,N.state=$.CloseTag,R+=N.spaceBeforeSlash+">"+this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),R},I.prototype.dtdEntity=function(W,N,V){var R;if(this.openNode(W,N,V),N.state=$.OpenTag,R=this.indent(W,N,V)+"<!ENTITY",N.state=$.InsideTag,W.pe)R+=" %";if(R+=" "+W.name,W.value)R+=' "'+W.value+'"';else{if(W.pubID&&W.sysID)R+=' PUBLIC "'+W.pubID+'" "'+W.sysID+'"';else if(W.sysID)R+=' SYSTEM "'+W.sysID+'"';if(W.nData)R+=" NDATA "+W.nData}return N.state=$.CloseTag,R+=N.spaceBeforeSlash+">"+this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),R},I.prototype.dtdNotation=function(W,N,V){var R;if(this.openNode(W,N,V),N.state=$.OpenTag,R=this.indent(W,N,V)+"<!NOTATION",N.state=$.InsideTag,R+=" "+W.name,W.pubID&&W.sysID)R+=' PUBLIC "'+W.pubID+'" "'+W.sysID+'"';else if(W.pubID)R+=' PUBLIC "'+W.pubID+'"';else if(W.sysID)R+=' SYSTEM "'+W.sysID+'"';return N.state=$.CloseTag,R+=N.spaceBeforeSlash+">"+this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),R},I.prototype.openNode=function(W,N,V){},I.prototype.closeNode=function(W,N,V){},I.prototype.openAttribute=function(W,N,V){},I.prototype.closeAttribute=function(W,N,V){},I}()}).call(tg)});var EQ=T((eg,Dh)=>{(function(){var D,$,X=function(J,Q){for(var F in Q)if(Y.call(Q,F))J[F]=Q[F];function w(){this.constructor=J}return w.prototype=Q.prototype,J.prototype=new w,J.__super__=Q.prototype,J},Y={}.hasOwnProperty;$=mq(),Dh.exports=D=function(J){X(Q,J);function Q(F){Q.__super__.constructor.call(this,F)}return Q.prototype.document=function(F,w){var Z,G,O,U,z;w=this.filterOptions(w),U="",z=F.children;for(G=0,O=z.length;G<O;G++)Z=z[G],U+=this.writeChildNode(Z,w,0);if(w.pretty&&U.slice(-w.newline.length)===w.newline)U=U.slice(0,-w.newline.length);return U},Q}($)}).call(eg)});var dq=T(($h,Xh)=>{(function(){var D,$,X,Y,J,Q,F,w,Z=function(O,U){for(var z in U)if(G.call(U,z))O[z]=U[z];function q(){this.constructor=O}return q.prototype=U.prototype,O.prototype=new q,O.__super__=U.prototype,O},G={}.hasOwnProperty;w=d$().isPlainObject,X=yq(),$=Yg(),J=m1(),D=_0(),F=hq(),Q=EQ(),Xh.exports=Y=function(O){Z(U,O);function U(z){if(U.__super__.constructor.call(this,null),this.name="#document",this.type=D.Document,this.documentURI=null,this.domConfig=new $,z||(z={}),!z.writer)z.writer=new Q;this.options=z,this.stringify=new F(z)}return Object.defineProperty(U.prototype,"implementation",{value:new X}),Object.defineProperty(U.prototype,"doctype",{get:function(){var z,q,B,K;K=this.children;for(q=0,B=K.length;q<B;q++)if(z=K[q],z.type===D.DocType)return z;return null}}),Object.defineProperty(U.prototype,"documentElement",{get:function(){return this.rootObject||null}}),Object.defineProperty(U.prototype,"inputEncoding",{get:function(){return null}}),Object.defineProperty(U.prototype,"strictErrorChecking",{get:function(){return!1}}),Object.defineProperty(U.prototype,"xmlEncoding",{get:function(){if(this.children.length!==0&&this.children[0].type===D.Declaration)return this.children[0].encoding;else return null}}),Object.defineProperty(U.prototype,"xmlStandalone",{get:function(){if(this.children.length!==0&&this.children[0].type===D.Declaration)return this.children[0].standalone==="yes";else return!1}}),Object.defineProperty(U.prototype,"xmlVersion",{get:function(){if(this.children.length!==0&&this.children[0].type===D.Declaration)return this.children[0].version;else return"1.0"}}),Object.defineProperty(U.prototype,"URL",{get:function(){return this.documentURI}}),Object.defineProperty(U.prototype,"origin",{get:function(){return null}}),Object.defineProperty(U.prototype,"compatMode",{get:function(){return null}}),Object.defineProperty(U.prototype,"characterSet",{get:function(){return null}}),Object.defineProperty(U.prototype,"contentType",{get:function(){return null}}),U.prototype.end=function(z){var q={};if(!z)z=this.options.writer;else if(w(z))q=z,z=this.options.writer;return z.document(this,z.filterOptions(q))},U.prototype.toString=function(z){return this.options.writer.document(this,this.options.writer.filterOptions(z))},U.prototype.createElement=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createDocumentFragment=function(){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createTextNode=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createComment=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createCDATASection=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createProcessingInstruction=function(z,q){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createAttribute=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createEntityReference=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.getElementsByTagName=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.importNode=function(z,q){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createElementNS=function(z,q){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createAttributeNS=function(z,q){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.getElementsByTagNameNS=function(z,q){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.getElementById=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.adoptNode=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.normalizeDocument=function(){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.renameNode=function(z,q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.getElementsByClassName=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createEvent=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createRange=function(){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createNodeIterator=function(z,q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createTreeWalker=function(z,q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},U}(J)}).call($h)});var Qh=T((Jh,Yh)=>{(function(){var D,$,X,Y,J,Q,F,w,Z,G,O,U,z,q,B,K,M,L,I,W,N,V,R,P,A={}.hasOwnProperty;P=d$(),V=P.isObject,N=P.isFunction,R=P.isPlainObject,W=P.getValue,D=_0(),U=dq(),q=BQ(),Y=KQ(),J=WQ(),K=AQ(),I=RQ(),B=jQ(),G=HQ(),O=IQ(),Q=VQ(),w=NQ(),F=MQ(),Z=LQ(),X=bq(),L=hq(),M=EQ(),$=g3(),Yh.exports=z=function(){function _(v,S,h){var g;if(this.name="?xml",this.type=D.Document,v||(v={}),g={},!v.writer)v.writer=new M;else if(R(v.writer))g=v.writer,v.writer=new M;this.options=v,this.writer=v.writer,this.writerOptions=this.writer.filterOptions(g),this.stringify=new L(v),this.onDataCallback=S||function(){},this.onEndCallback=h||function(){},this.currentNode=null,this.currentLevel=-1,this.openTags={},this.documentStarted=!1,this.documentCompleted=!1,this.root=null}return _.prototype.createChildNode=function(v){var S,h,g,l,f,j,x,u;switch(v.type){case D.CData:this.cdata(v.value);break;case D.Comment:this.comment(v.value);break;case D.Element:g={},x=v.attribs;for(h in x){if(!A.call(x,h))continue;S=x[h],g[h]=S.value}this.node(v.name,g);break;case D.Dummy:this.dummy();break;case D.Raw:this.raw(v.value);break;case D.Text:this.text(v.value);break;case D.ProcessingInstruction:this.instruction(v.target,v.value);break;default:throw Error("This XML node type is not supported in a JS object: "+v.constructor.name)}u=v.children;for(f=0,j=u.length;f<j;f++)if(l=u[f],this.createChildNode(l),l.type===D.Element)this.up();return this},_.prototype.dummy=function(){return this},_.prototype.node=function(v,S,h){var g;if(v==null)throw Error("Missing node name.");if(this.root&&this.currentLevel===-1)throw Error("Document can only have one root node. "+this.debugInfo(v));if(this.openCurrent(),v=W(v),S==null)S={};if(S=W(S),!V(S))g=[S,h],h=g[0],S=g[1];if(this.currentNode=new q(this,v,S),this.currentNode.children=!1,this.currentLevel++,this.openTags[this.currentLevel]=this.currentNode,h!=null)this.text(h);return this},_.prototype.element=function(v,S,h){var g,l,f,j,x,u;if(this.currentNode&&this.currentNode.type===D.DocType)this.dtdElement.apply(this,arguments);else if(Array.isArray(v)||V(v)||N(v)){j=this.options.noValidation,this.options.noValidation=!0,u=new U(this.options).element("TEMP_ROOT"),u.element(v),this.options.noValidation=j,x=u.children;for(l=0,f=x.length;l<f;l++)if(g=x[l],this.createChildNode(g),g.type===D.Element)this.up()}else this.node(v,S,h);return this},_.prototype.attribute=function(v,S){var h,g;if(!this.currentNode||this.currentNode.children)throw Error("att() can only be used immediately after an ele() call in callback mode. "+this.debugInfo(v));if(v!=null)v=W(v);if(V(v))for(h in v){if(!A.call(v,h))continue;g=v[h],this.attribute(h,g)}else{if(N(S))S=S.apply();if(this.options.keepNullAttributes&&S==null)this.currentNode.attribs[v]=new X(this,v,"");else if(S!=null)this.currentNode.attribs[v]=new X(this,v,S)}return this},_.prototype.text=function(v){var S;return this.openCurrent(),S=new I(this,v),this.onData(this.writer.text(S,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},_.prototype.cdata=function(v){var S;return this.openCurrent(),S=new Y(this,v),this.onData(this.writer.cdata(S,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},_.prototype.comment=function(v){var S;return this.openCurrent(),S=new J(this,v),this.onData(this.writer.comment(S,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},_.prototype.raw=function(v){var S;return this.openCurrent(),S=new K(this,v),this.onData(this.writer.raw(S,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},_.prototype.instruction=function(v,S){var h,g,l,f,j;if(this.openCurrent(),v!=null)v=W(v);if(S!=null)S=W(S);if(Array.isArray(v))for(h=0,f=v.length;h<f;h++)g=v[h],this.instruction(g);else if(V(v))for(g in v){if(!A.call(v,g))continue;l=v[g],this.instruction(g,l)}else{if(N(S))S=S.apply();j=new B(this,v,S),this.onData(this.writer.processingInstruction(j,this.writerOptions,this.currentLevel+1),this.currentLevel+1)}return this},_.prototype.declaration=function(v,S,h){var g;if(this.openCurrent(),this.documentStarted)throw Error("declaration() must be the first node.");return g=new G(this,v,S,h),this.onData(this.writer.declaration(g,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},_.prototype.doctype=function(v,S,h){if(this.openCurrent(),v==null)throw Error("Missing root node name.");if(this.root)throw Error("dtd() must come before the root node.");return this.currentNode=new O(this,S,h),this.currentNode.rootNodeName=v,this.currentNode.children=!1,this.currentLevel++,this.openTags[this.currentLevel]=this.currentNode,this},_.prototype.dtdElement=function(v,S){var h;return this.openCurrent(),h=new F(this,v,S),this.onData(this.writer.dtdElement(h,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},_.prototype.attList=function(v,S,h,g,l){var f;return this.openCurrent(),f=new Q(this,v,S,h,g,l),this.onData(this.writer.dtdAttList(f,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},_.prototype.entity=function(v,S){var h;return this.openCurrent(),h=new w(this,!1,v,S),this.onData(this.writer.dtdEntity(h,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},_.prototype.pEntity=function(v,S){var h;return this.openCurrent(),h=new w(this,!0,v,S),this.onData(this.writer.dtdEntity(h,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},_.prototype.notation=function(v,S){var h;return this.openCurrent(),h=new Z(this,v,S),this.onData(this.writer.dtdNotation(h,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},_.prototype.up=function(){if(this.currentLevel<0)throw Error("The document node has no parent.");if(this.currentNode){if(this.currentNode.children)this.closeNode(this.currentNode);else this.openNode(this.currentNode);this.currentNode=null}else this.closeNode(this.openTags[this.currentLevel]);return delete this.openTags[this.currentLevel],this.currentLevel--,this},_.prototype.end=function(){while(this.currentLevel>=0)this.up();return this.onEnd()},_.prototype.openCurrent=function(){if(this.currentNode)return this.currentNode.children=!0,this.openNode(this.currentNode)},_.prototype.openNode=function(v){var S,h,g,l;if(!v.isOpen){if(!this.root&&this.currentLevel===0&&v.type===D.Element)this.root=v;if(h="",v.type===D.Element){this.writerOptions.state=$.OpenTag,h=this.writer.indent(v,this.writerOptions,this.currentLevel)+"<"+v.name,l=v.attribs;for(g in l){if(!A.call(l,g))continue;S=l[g],h+=this.writer.attribute(S,this.writerOptions,this.currentLevel)}h+=(v.children?">":"/>")+this.writer.endline(v,this.writerOptions,this.currentLevel),this.writerOptions.state=$.InsideTag}else{if(this.writerOptions.state=$.OpenTag,h=this.writer.indent(v,this.writerOptions,this.currentLevel)+"<!DOCTYPE "+v.rootNodeName,v.pubID&&v.sysID)h+=' PUBLIC "'+v.pubID+'" "'+v.sysID+'"';else if(v.sysID)h+=' SYSTEM "'+v.sysID+'"';if(v.children)h+=" [",this.writerOptions.state=$.InsideTag;else this.writerOptions.state=$.CloseTag,h+=">";h+=this.writer.endline(v,this.writerOptions,this.currentLevel)}return this.onData(h,this.currentLevel),v.isOpen=!0}},_.prototype.closeNode=function(v){var S;if(!v.isClosed){if(S="",this.writerOptions.state=$.CloseTag,v.type===D.Element)S=this.writer.indent(v,this.writerOptions,this.currentLevel)+"</"+v.name+">"+this.writer.endline(v,this.writerOptions,this.currentLevel);else S=this.writer.indent(v,this.writerOptions,this.currentLevel)+"]>"+this.writer.endline(v,this.writerOptions,this.currentLevel);return this.writerOptions.state=$.None,this.onData(S,this.currentLevel),v.isClosed=!0}},_.prototype.onData=function(v,S){return this.documentStarted=!0,this.onDataCallback(v,S+1)},_.prototype.onEnd=function(){return this.documentCompleted=!0,this.onEndCallback()},_.prototype.debugInfo=function(v){if(v==null)return"";else return"node: <"+v+">"},_.prototype.ele=function(){return this.element.apply(this,arguments)},_.prototype.nod=function(v,S,h){return this.node(v,S,h)},_.prototype.txt=function(v){return this.text(v)},_.prototype.dat=function(v){return this.cdata(v)},_.prototype.com=function(v){return this.comment(v)},_.prototype.ins=function(v,S){return this.instruction(v,S)},_.prototype.dec=function(v,S,h){return this.declaration(v,S,h)},_.prototype.dtd=function(v,S,h){return this.doctype(v,S,h)},_.prototype.e=function(v,S,h){return this.element(v,S,h)},_.prototype.n=function(v,S,h){return this.node(v,S,h)},_.prototype.t=function(v){return this.text(v)},_.prototype.d=function(v){return this.cdata(v)},_.prototype.c=function(v){return this.comment(v)},_.prototype.r=function(v){return this.raw(v)},_.prototype.i=function(v,S){return this.instruction(v,S)},_.prototype.att=function(){if(this.currentNode&&this.currentNode.type===D.DocType)return this.attList.apply(this,arguments);else return this.attribute.apply(this,arguments)},_.prototype.a=function(){if(this.currentNode&&this.currentNode.type===D.DocType)return this.attList.apply(this,arguments);else return this.attribute.apply(this,arguments)},_.prototype.ent=function(v,S){return this.entity(v,S)},_.prototype.pent=function(v,S){return this.pEntity(v,S)},_.prototype.not=function(v,S){return this.notation(v,S)},_}()}).call(Jh)});var Zh=T((Fh,wh)=>{(function(){var D,$,X,Y,J=function(F,w){for(var Z in w)if(Q.call(w,Z))F[Z]=w[Z];function G(){this.constructor=F}return G.prototype=w.prototype,F.prototype=new G,F.__super__=w.prototype,F},Q={}.hasOwnProperty;D=_0(),Y=mq(),$=g3(),wh.exports=X=function(F){J(w,F);function w(Z,G){this.stream=Z,w.__super__.constructor.call(this,G)}return w.prototype.endline=function(Z,G,O){if(Z.isLastRootNode&&G.state===$.CloseTag)return"";else return w.__super__.endline.call(this,Z,G,O)},w.prototype.document=function(Z,G){var O,U,z,q,B,K,M,L,I;M=Z.children;for(U=z=0,B=M.length;z<B;U=++z)O=M[U],O.isLastRootNode=U===Z.children.length-1;G=this.filterOptions(G),L=Z.children,I=[];for(q=0,K=L.length;q<K;q++)O=L[q],I.push(this.writeChildNode(O,G,0));return I},w.prototype.attribute=function(Z,G,O){return this.stream.write(w.__super__.attribute.call(this,Z,G,O))},w.prototype.cdata=function(Z,G,O){return this.stream.write(w.__super__.cdata.call(this,Z,G,O))},w.prototype.comment=function(Z,G,O){return this.stream.write(w.__super__.comment.call(this,Z,G,O))},w.prototype.declaration=function(Z,G,O){return this.stream.write(w.__super__.declaration.call(this,Z,G,O))},w.prototype.docType=function(Z,G,O){var U,z,q,B;if(O||(O=0),this.openNode(Z,G,O),G.state=$.OpenTag,this.stream.write(this.indent(Z,G,O)),this.stream.write("<!DOCTYPE "+Z.root().name),Z.pubID&&Z.sysID)this.stream.write(' PUBLIC "'+Z.pubID+'" "'+Z.sysID+'"');else if(Z.sysID)this.stream.write(' SYSTEM "'+Z.sysID+'"');if(Z.children.length>0){this.stream.write(" ["),this.stream.write(this.endline(Z,G,O)),G.state=$.InsideTag,B=Z.children;for(z=0,q=B.length;z<q;z++)U=B[z],this.writeChildNode(U,G,O+1);G.state=$.CloseTag,this.stream.write("]")}return G.state=$.CloseTag,this.stream.write(G.spaceBeforeSlash+">"),this.stream.write(this.endline(Z,G,O)),G.state=$.None,this.closeNode(Z,G,O)},w.prototype.element=function(Z,G,O){var U,z,q,B,K,M,L,I,W,N;O||(O=0),this.openNode(Z,G,O),G.state=$.OpenTag,this.stream.write(this.indent(Z,G,O)+"<"+Z.name),W=Z.attribs;for(L in W){if(!Q.call(W,L))continue;U=W[L],this.attribute(U,G,O)}if(q=Z.children.length,B=q===0?null:Z.children[0],q===0||Z.children.every(function(V){return(V.type===D.Text||V.type===D.Raw)&&V.value===""}))if(G.allowEmpty)this.stream.write(">"),G.state=$.CloseTag,this.stream.write("</"+Z.name+">");else G.state=$.CloseTag,this.stream.write(G.spaceBeforeSlash+"/>");else if(G.pretty&&q===1&&(B.type===D.Text||B.type===D.Raw)&&B.value!=null)this.stream.write(">"),G.state=$.InsideTag,G.suppressPrettyCount++,I=!0,this.writeChildNode(B,G,O+1),G.suppressPrettyCount--,I=!1,G.state=$.CloseTag,this.stream.write("</"+Z.name+">");else{this.stream.write(">"+this.endline(Z,G,O)),G.state=$.InsideTag,N=Z.children;for(K=0,M=N.length;K<M;K++)z=N[K],this.writeChildNode(z,G,O+1);G.state=$.CloseTag,this.stream.write(this.indent(Z,G,O)+"</"+Z.name+">")}return this.stream.write(this.endline(Z,G,O)),G.state=$.None,this.closeNode(Z,G,O)},w.prototype.processingInstruction=function(Z,G,O){return this.stream.write(w.__super__.processingInstruction.call(this,Z,G,O))},w.prototype.raw=function(Z,G,O){return this.stream.write(w.__super__.raw.call(this,Z,G,O))},w.prototype.text=function(Z,G,O){return this.stream.write(w.__super__.text.call(this,Z,G,O))},w.prototype.dtdAttList=function(Z,G,O){return this.stream.write(w.__super__.dtdAttList.call(this,Z,G,O))},w.prototype.dtdElement=function(Z,G,O){return this.stream.write(w.__super__.dtdElement.call(this,Z,G,O))},w.prototype.dtdEntity=function(Z,G,O){return this.stream.write(w.__super__.dtdEntity.call(this,Z,G,O))},w.prototype.dtdNotation=function(Z,G,O){return this.stream.write(w.__super__.dtdNotation.call(this,Z,G,O))},w}(Y)}).call(Fh)});var Oh=T((Gh,Y4)=>{(function(){var D,$,X,Y,J,Q,F,w,Z,G;G=d$(),w=G.assign,Z=G.isFunction,X=yq(),Y=dq(),J=Qh(),F=EQ(),Q=Zh(),D=_0(),$=g3(),Gh.create=function(O,U,z,q){var B,K;if(O==null)throw Error("Root element needs a name.");if(q=w({},U,z,q),B=new Y(q),K=B.element(O),!q.headless){if(B.declaration(q),q.pubID!=null||q.sysID!=null)B.dtd(q)}return K},Gh.begin=function(O,U,z){var q;if(Z(O))q=[O,U],U=q[0],z=q[1],O={};if(U)return new J(O,U,z);else return new Y(O)},Gh.stringWriter=function(O){return new F(O)},Gh.streamWriter=function(O,U){return new Q(O,U)},Gh.implementation=new X,Gh.nodeType=D,Gh.writerState=$}).call(Gh)});var qh=T((Uh)=>{(function(){var D,$,X,Y,J,Q={}.hasOwnProperty;D=Oh(),$=qQ().defaults,Y=function(F){return typeof F==="string"&&(F.indexOf("&")>=0||F.indexOf(">")>=0||F.indexOf("<")>=0)},J=function(F){return"<![CDATA["+X(F)+"]]>"},X=function(F){return F.replace("]]>","]]]]><![CDATA[>")},Uh.Builder=function(){function F(w){var Z,G,O;this.options={},G=$["0.2"];for(Z in G){if(!Q.call(G,Z))continue;O=G[Z],this.options[Z]=O}for(Z in w){if(!Q.call(w,Z))continue;O=w[Z],this.options[Z]=O}}return F.prototype.buildObject=function(w){var Z,G,O,U,z;if(Z=this.options.attrkey,G=this.options.charkey,Object.keys(w).length===1&&this.options.rootName===$["0.2"].rootName)z=Object.keys(w)[0],w=w[z];else z=this.options.rootName;return O=function(q){return function(B,K){var M,L,I,W,N,V;if(typeof K!=="object")if(q.options.cdata&&Y(K))B.raw(J(K));else B.txt(K);else if(Array.isArray(K))for(W in K){if(!Q.call(K,W))continue;L=K[W];for(N in L)I=L[N],B=O(B.ele(N),I).up()}else for(N in K){if(!Q.call(K,N))continue;if(L=K[N],N===Z){if(typeof L==="object")for(M in L)V=L[M],B=B.att(M,V)}else if(N===G)if(q.options.cdata&&Y(L))B=B.raw(J(L));else B=B.txt(L);else if(Array.isArray(L))for(W in L){if(!Q.call(L,W))continue;if(I=L[W],typeof I==="string")if(q.options.cdata&&Y(I))B=B.ele(N).raw(J(I)).up();else B=B.ele(N,I).up();else B=O(B.ele(N),I).up()}else if(typeof L==="object")B=O(B.ele(N),L).up();else if(typeof L==="string"&&q.options.cdata&&Y(L))B=B.ele(N).raw(J(L)).up();else{if(L==null)L="";B=B.ele(N,L.toString()).up()}}return B}}(this),U=D.create(z,this.options.xmldec,this.options.doctype,{headless:this.options.headless,allowSurrogateChars:this.options.allowSurrogateChars}),O(U,w).end(this.options.renderOpts)},F}()}).call(Uh)});var zh=T((TQ)=>{(function(D){D.parser=function(C,E){return new X(C,E)},D.SAXParser=X,D.SAXStream=G,D.createStream=Z,D.MAX_BUFFER_LENGTH=65536;var $=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];D.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function X(C,E){if(!(this instanceof X))return new X(C,E);var r=this;if(J(r),r.q=r.c="",r.bufferCheckPosition=D.MAX_BUFFER_LENGTH,r.opt=E||{},r.opt.lowercase=r.opt.lowercase||r.opt.lowercasetags,r.looseCase=r.opt.lowercase?"toLowerCase":"toUpperCase",r.tags=[],r.closed=r.closedRoot=r.sawRoot=!1,r.tag=r.error=null,r.strict=!!C,r.noscript=!!(C||r.opt.noscript),r.state=A.BEGIN,r.strictEntities=r.opt.strictEntities,r.ENTITIES=r.strictEntities?Object.create(D.XML_ENTITIES):Object.create(D.ENTITIES),r.attribList=[],r.opt.xmlns)r.ns=Object.create(B);if(r.opt.unquotedAttributeValues===void 0)r.opt.unquotedAttributeValues=!C;if(r.trackPosition=r.opt.position!==!1,r.trackPosition)r.position=r.line=r.column=0;v(r,"onready")}if(!Object.create)Object.create=function(C){function E(){}E.prototype=C;var r=new E;return r};if(!Object.keys)Object.keys=function(C){var E=[];for(var r in C)if(C.hasOwnProperty(r))E.push(r);return E};function Y(C){var E=Math.max(D.MAX_BUFFER_LENGTH,10),r=0;for(var k=0,zD=$.length;k<zD;k++){var t=C[$[k]].length;if(t>E)switch($[k]){case"textNode":h(C);break;case"cdata":S(C,"oncdata",C.cdata),C.cdata="";break;case"script":S(C,"onscript",C.script),C.script="";break;default:l(C,"Max buffer length exceeded: "+$[k])}r=Math.max(r,t)}var KD=D.MAX_BUFFER_LENGTH-r;C.bufferCheckPosition=KD+C.position}function J(C){for(var E=0,r=$.length;E<r;E++)C[$[E]]=""}function Q(C){if(h(C),C.cdata!=="")S(C,"oncdata",C.cdata),C.cdata="";if(C.script!=="")S(C,"onscript",C.script),C.script=""}X.prototype={end:function(){f(this)},write:YD,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){Q(this)}};var F;try{F=p("stream").Stream}catch(C){F=function(){}}if(!F)F=function(){};var w=D.EVENTS.filter(function(C){return C!=="error"&&C!=="end"});function Z(C,E){return new G(C,E)}function G(C,E){if(!(this instanceof G))return new G(C,E);F.apply(this),this._parser=new X(C,E),this.writable=!0,this.readable=!0;var r=this;this._parser.onend=function(){r.emit("end")},this._parser.onerror=function(k){r.emit("error",k),r._parser.error=null},this._decoder=null,w.forEach(function(k){Object.defineProperty(r,"on"+k,{get:function(){return r._parser["on"+k]},set:function(zD){if(!zD)return r.removeAllListeners(k),r._parser["on"+k]=zD,zD;r.on(k,zD)},enumerable:!0,configurable:!1})})}G.prototype=Object.create(F.prototype,{constructor:{value:G}}),G.prototype.write=function(C){if(typeof Buffer==="function"&&typeof Buffer.isBuffer==="function"&&Buffer.isBuffer(C)){if(!this._decoder)this._decoder=new TextDecoder("utf8");C=this._decoder.decode(C,{stream:!0})}return this._parser.write(C.toString()),this.emit("data",C),!0},G.prototype.end=function(C){if(C&&C.length)this.write(C);if(this._decoder){var E=this._decoder.decode();if(E)this._parser.write(E),this.emit("data",E)}return this._parser.end(),!0},G.prototype.on=function(C,E){var r=this;if(!r._parser["on"+C]&&w.indexOf(C)!==-1)r._parser["on"+C]=function(){var k=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);k.splice(0,0,C),r.emit.apply(r,k)};return F.prototype.on.call(r,C,E)};var O="[CDATA[",U="DOCTYPE",z="http://www.w3.org/XML/1998/namespace",q="http://www.w3.org/2000/xmlns/",B={xml:z,xmlns:q},K=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,M=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,L=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,I=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function W(C){return C===" "||C===`
260
- `||C==="\r"||C==="\t"}function N(C){return C==='"'||C==="'"}function V(C){return C===">"||W(C)}function R(C,E){return C.test(E)}function P(C,E){return!R(C,E)}var A=0;D.STATE={BEGIN:A++,BEGIN_WHITESPACE:A++,TEXT:A++,TEXT_ENTITY:A++,OPEN_WAKA:A++,SGML_DECL:A++,SGML_DECL_QUOTED:A++,DOCTYPE:A++,DOCTYPE_QUOTED:A++,DOCTYPE_DTD:A++,DOCTYPE_DTD_QUOTED:A++,COMMENT_STARTING:A++,COMMENT:A++,COMMENT_ENDING:A++,COMMENT_ENDED:A++,CDATA:A++,CDATA_ENDING:A++,CDATA_ENDING_2:A++,PROC_INST:A++,PROC_INST_BODY:A++,PROC_INST_ENDING:A++,OPEN_TAG:A++,OPEN_TAG_SLASH:A++,ATTRIB:A++,ATTRIB_NAME:A++,ATTRIB_NAME_SAW_WHITE:A++,ATTRIB_VALUE:A++,ATTRIB_VALUE_QUOTED:A++,ATTRIB_VALUE_CLOSED:A++,ATTRIB_VALUE_UNQUOTED:A++,ATTRIB_VALUE_ENTITY_Q:A++,ATTRIB_VALUE_ENTITY_U:A++,CLOSE_TAG:A++,CLOSE_TAG_SAW_WHITE:A++,SCRIPT:A++,SCRIPT_ENDING:A++},D.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},D.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(D.ENTITIES).forEach(function(C){var E=D.ENTITIES[C],r=typeof E==="number"?String.fromCharCode(E):E;D.ENTITIES[C]=r});for(var _ in D.STATE)D.STATE[D.STATE[_]]=_;A=D.STATE;function v(C,E,r){C[E]&&C[E](r)}function S(C,E,r){if(C.textNode)h(C);v(C,E,r)}function h(C){if(C.textNode=g(C.opt,C.textNode),C.textNode)v(C,"ontext",C.textNode);C.textNode=""}function g(C,E){if(C.trim)E=E.trim();if(C.normalize)E=E.replace(/\s+/g," ");return E}function l(C,E){if(h(C),C.trackPosition)E+=`
261
- Line: `+C.line+`
262
- Column: `+C.column+`
263
- Char: `+C.c;return E=Error(E),C.error=E,v(C,"onerror",E),C}function f(C){if(C.sawRoot&&!C.closedRoot)j(C,"Unclosed root tag");if(C.state!==A.BEGIN&&C.state!==A.BEGIN_WHITESPACE&&C.state!==A.TEXT)l(C,"Unexpected end");return h(C),C.c="",C.closed=!0,v(C,"onend"),X.call(C,C.strict,C.opt),C}function j(C,E){if(typeof C!=="object"||!(C instanceof X))throw Error("bad call to strictFail");if(C.strict)l(C,E)}function x(C){if(!C.strict)C.tagName=C.tagName[C.looseCase]();var E=C.tags[C.tags.length-1]||C,r=C.tag={name:C.tagName,attributes:{}};if(C.opt.xmlns)r.ns=E.ns;C.attribList.length=0,S(C,"onopentagstart",r)}function u(C,E){var r=C.indexOf(":"),k=r<0?["",C]:C.split(":"),zD=k[0],t=k[1];if(E&&C==="xmlns")zD="xmlns",t="";return{prefix:zD,local:t}}function y(C){if(!C.strict)C.attribName=C.attribName[C.looseCase]();if(C.attribList.indexOf(C.attribName)!==-1||C.tag.attributes.hasOwnProperty(C.attribName)){C.attribName=C.attribValue="";return}if(C.opt.xmlns){var E=u(C.attribName,!0),r=E.prefix,k=E.local;if(r==="xmlns")if(k==="xml"&&C.attribValue!==z)j(C,"xml: prefix must be bound to "+z+`
264
- Actual: `+C.attribValue);else if(k==="xmlns"&&C.attribValue!==q)j(C,"xmlns: prefix must be bound to "+q+`
265
- Actual: `+C.attribValue);else{var zD=C.tag,t=C.tags[C.tags.length-1]||C;if(zD.ns===t.ns)zD.ns=Object.create(t.ns);zD.ns[k]=C.attribValue}C.attribList.push([C.attribName,C.attribValue])}else C.tag.attributes[C.attribName]=C.attribValue,S(C,"onattribute",{name:C.attribName,value:C.attribValue});C.attribName=C.attribValue=""}function d(C,E){if(C.opt.xmlns){var r=C.tag,k=u(C.tagName);if(r.prefix=k.prefix,r.local=k.local,r.uri=r.ns[k.prefix]||"",r.prefix&&!r.uri)j(C,"Unbound namespace prefix: "+JSON.stringify(C.tagName)),r.uri=k.prefix;var zD=C.tags[C.tags.length-1]||C;if(r.ns&&zD.ns!==r.ns)Object.keys(r.ns).forEach(function(gL){S(C,"onopennamespace",{prefix:gL,uri:r.ns[gL]})});for(var t=0,KD=C.attribList.length;t<KD;t++){var uD=C.attribList[t],hD=uD[0],X0=uD[1],v0=u(hD,!0),E1=v0.prefix,bDD=v0.local,bL=E1===""?"":r.ns[E1]||"",nZ={name:hD,value:X0,prefix:E1,local:bDD,uri:bL};if(E1&&E1!=="xmlns"&&!bL)j(C,"Unbound namespace prefix: "+JSON.stringify(E1)),nZ.uri=E1;C.tag.attributes[hD]=nZ,S(C,"onattribute",nZ)}C.attribList.length=0}if(C.tag.isSelfClosing=!!E,C.sawRoot=!0,C.tags.push(C.tag),S(C,"onopentag",C.tag),!E){if(!C.noscript&&C.tagName.toLowerCase()==="script")C.state=A.SCRIPT;else C.state=A.TEXT;C.tag=null,C.tagName=""}C.attribName=C.attribValue="",C.attribList.length=0}function b(C){if(!C.tagName){j(C,"Weird empty close tag."),C.textNode+="</>",C.state=A.TEXT;return}if(C.script){if(C.tagName!=="script"){C.script+="</"+C.tagName+">",C.tagName="",C.state=A.SCRIPT;return}S(C,"onscript",C.script),C.script=""}var E=C.tags.length,r=C.tagName;if(!C.strict)r=r[C.looseCase]();var k=r;while(E--){var zD=C.tags[E];if(zD.name!==k)j(C,"Unexpected close tag");else break}if(E<0){j(C,"Unmatched closing tag: "+C.tagName),C.textNode+="</"+C.tagName+">",C.state=A.TEXT;return}C.tagName=r;var t=C.tags.length;while(t-- >E){var KD=C.tag=C.tags.pop();C.tagName=C.tag.name,S(C,"onclosetag",C.tagName);var uD={};for(var hD in KD.ns)uD[hD]=KD.ns[hD];var X0=C.tags[C.tags.length-1]||C;if(C.opt.xmlns&&KD.ns!==X0.ns)Object.keys(KD.ns).forEach(function(v0){var E1=KD.ns[v0];S(C,"onclosenamespace",{prefix:v0,uri:E1})})}if(E===0)C.closedRoot=!0;C.tagName=C.attribValue=C.attribName="",C.attribList.length=0,C.state=A.TEXT}function a(C){var E=C.entity,r=E.toLowerCase(),k,zD="";if(C.ENTITIES[E])return C.ENTITIES[E];if(C.ENTITIES[r])return C.ENTITIES[r];if(E=r,E.charAt(0)==="#")if(E.charAt(1)==="x")E=E.slice(2),k=parseInt(E,16),zD=k.toString(16);else E=E.slice(1),k=parseInt(E,10),zD=k.toString(10);if(E=E.replace(/^0+/,""),isNaN(k)||zD.toLowerCase()!==E||k<0||k>1114111)return j(C,"Invalid character entity"),"&"+C.entity+";";return String.fromCodePoint(k)}function c(C,E){if(E==="<")C.state=A.OPEN_WAKA,C.startTagPosition=C.position;else if(!W(E))j(C,"Non-whitespace before first tag."),C.textNode=E,C.state=A.TEXT}function n(C,E){var r="";if(E<C.length)r=C.charAt(E);return r}function YD(C){var E=this;if(this.error)throw this.error;if(E.closed)return l(E,"Cannot write after close. Assign an onready handler.");if(C===null)return f(E);if(typeof C==="object")C=C.toString();var r=0,k="";while(!0){if(k=n(C,r++),E.c=k,!k)break;if(E.trackPosition)if(E.position++,k===`
266
- `)E.line++,E.column=0;else E.column++;switch(E.state){case A.BEGIN:if(E.state=A.BEGIN_WHITESPACE,k==="\uFEFF")continue;c(E,k);continue;case A.BEGIN_WHITESPACE:c(E,k);continue;case A.TEXT:if(E.sawRoot&&!E.closedRoot){var t=r-1;while(k&&k!=="<"&&k!=="&")if(k=n(C,r++),k&&E.trackPosition)if(E.position++,k===`
267
- `)E.line++,E.column=0;else E.column++;E.textNode+=C.substring(t,r-1)}if(k==="<"&&!(E.sawRoot&&E.closedRoot&&!E.strict))E.state=A.OPEN_WAKA,E.startTagPosition=E.position;else{if(!W(k)&&(!E.sawRoot||E.closedRoot))j(E,"Text data outside of root node.");if(k==="&")E.state=A.TEXT_ENTITY;else E.textNode+=k}continue;case A.SCRIPT:if(k==="<")E.state=A.SCRIPT_ENDING;else E.script+=k;continue;case A.SCRIPT_ENDING:if(k==="/")E.state=A.CLOSE_TAG;else E.script+="<"+k,E.state=A.SCRIPT;continue;case A.OPEN_WAKA:if(k==="!")E.state=A.SGML_DECL,E.sgmlDecl="";else if(W(k));else if(R(K,k))E.state=A.OPEN_TAG,E.tagName=k;else if(k==="/")E.state=A.CLOSE_TAG,E.tagName="";else if(k==="?")E.state=A.PROC_INST,E.procInstName=E.procInstBody="";else{if(j(E,"Unencoded <"),E.startTagPosition+1<E.position){var zD=E.position-E.startTagPosition;k=Array(zD).join(" ")+k}E.textNode+="<"+k,E.state=A.TEXT}continue;case A.SGML_DECL:if(E.sgmlDecl+k==="--"){E.state=A.COMMENT,E.comment="",E.sgmlDecl="";continue}if(E.doctype&&E.doctype!==!0&&E.sgmlDecl)E.state=A.DOCTYPE_DTD,E.doctype+="<!"+E.sgmlDecl+k,E.sgmlDecl="";else if((E.sgmlDecl+k).toUpperCase()===O)S(E,"onopencdata"),E.state=A.CDATA,E.sgmlDecl="",E.cdata="";else if((E.sgmlDecl+k).toUpperCase()===U){if(E.state=A.DOCTYPE,E.doctype||E.sawRoot)j(E,"Inappropriately located doctype declaration");E.doctype="",E.sgmlDecl=""}else if(k===">")S(E,"onsgmldeclaration",E.sgmlDecl),E.sgmlDecl="",E.state=A.TEXT;else if(N(k))E.state=A.SGML_DECL_QUOTED,E.sgmlDecl+=k;else E.sgmlDecl+=k;continue;case A.SGML_DECL_QUOTED:if(k===E.q)E.state=A.SGML_DECL,E.q="";E.sgmlDecl+=k;continue;case A.DOCTYPE:if(k===">")E.state=A.TEXT,S(E,"ondoctype",E.doctype),E.doctype=!0;else if(E.doctype+=k,k==="[")E.state=A.DOCTYPE_DTD;else if(N(k))E.state=A.DOCTYPE_QUOTED,E.q=k;continue;case A.DOCTYPE_QUOTED:if(E.doctype+=k,k===E.q)E.q="",E.state=A.DOCTYPE;continue;case A.DOCTYPE_DTD:if(k==="]")E.doctype+=k,E.state=A.DOCTYPE;else if(k==="<")E.state=A.OPEN_WAKA,E.startTagPosition=E.position;else if(N(k))E.doctype+=k,E.state=A.DOCTYPE_DTD_QUOTED,E.q=k;else E.doctype+=k;continue;case A.DOCTYPE_DTD_QUOTED:if(E.doctype+=k,k===E.q)E.state=A.DOCTYPE_DTD,E.q="";continue;case A.COMMENT:if(k==="-")E.state=A.COMMENT_ENDING;else E.comment+=k;continue;case A.COMMENT_ENDING:if(k==="-"){if(E.state=A.COMMENT_ENDED,E.comment=g(E.opt,E.comment),E.comment)S(E,"oncomment",E.comment);E.comment=""}else E.comment+="-"+k,E.state=A.COMMENT;continue;case A.COMMENT_ENDED:if(k!==">")j(E,"Malformed comment"),E.comment+="--"+k,E.state=A.COMMENT;else if(E.doctype&&E.doctype!==!0)E.state=A.DOCTYPE_DTD;else E.state=A.TEXT;continue;case A.CDATA:var t=r-1;while(k&&k!=="]")if(k=n(C,r++),k&&E.trackPosition)if(E.position++,k===`
268
- `)E.line++,E.column=0;else E.column++;if(E.cdata+=C.substring(t,r-1),k==="]")E.state=A.CDATA_ENDING;continue;case A.CDATA_ENDING:if(k==="]")E.state=A.CDATA_ENDING_2;else E.cdata+="]"+k,E.state=A.CDATA;continue;case A.CDATA_ENDING_2:if(k===">"){if(E.cdata)S(E,"oncdata",E.cdata);S(E,"onclosecdata"),E.cdata="",E.state=A.TEXT}else if(k==="]")E.cdata+="]";else E.cdata+="]]"+k,E.state=A.CDATA;continue;case A.PROC_INST:if(k==="?")E.state=A.PROC_INST_ENDING;else if(W(k))E.state=A.PROC_INST_BODY;else E.procInstName+=k;continue;case A.PROC_INST_BODY:if(!E.procInstBody&&W(k))continue;else if(k==="?")E.state=A.PROC_INST_ENDING;else E.procInstBody+=k;continue;case A.PROC_INST_ENDING:if(k===">")S(E,"onprocessinginstruction",{name:E.procInstName,body:E.procInstBody}),E.procInstName=E.procInstBody="",E.state=A.TEXT;else E.procInstBody+="?"+k,E.state=A.PROC_INST_BODY;continue;case A.OPEN_TAG:if(R(M,k))E.tagName+=k;else if(x(E),k===">")d(E);else if(k==="/")E.state=A.OPEN_TAG_SLASH;else{if(!W(k))j(E,"Invalid character in tag name");E.state=A.ATTRIB}continue;case A.OPEN_TAG_SLASH:if(k===">")d(E,!0),b(E);else j(E,"Forward-slash in opening tag not followed by >"),E.state=A.ATTRIB;continue;case A.ATTRIB:if(W(k))continue;else if(k===">")d(E);else if(k==="/")E.state=A.OPEN_TAG_SLASH;else if(R(K,k))E.attribName=k,E.attribValue="",E.state=A.ATTRIB_NAME;else j(E,"Invalid attribute name");continue;case A.ATTRIB_NAME:if(k==="=")E.state=A.ATTRIB_VALUE;else if(k===">")j(E,"Attribute without value"),E.attribValue=E.attribName,y(E),d(E);else if(W(k))E.state=A.ATTRIB_NAME_SAW_WHITE;else if(R(M,k))E.attribName+=k;else j(E,"Invalid attribute name");continue;case A.ATTRIB_NAME_SAW_WHITE:if(k==="=")E.state=A.ATTRIB_VALUE;else if(W(k))continue;else if(j(E,"Attribute without value"),E.tag.attributes[E.attribName]="",E.attribValue="",S(E,"onattribute",{name:E.attribName,value:""}),E.attribName="",k===">")d(E);else if(R(K,k))E.attribName=k,E.state=A.ATTRIB_NAME;else j(E,"Invalid attribute name"),E.state=A.ATTRIB;continue;case A.ATTRIB_VALUE:if(W(k))continue;else if(N(k))E.q=k,E.state=A.ATTRIB_VALUE_QUOTED;else{if(!E.opt.unquotedAttributeValues)l(E,"Unquoted attribute value");E.state=A.ATTRIB_VALUE_UNQUOTED,E.attribValue=k}continue;case A.ATTRIB_VALUE_QUOTED:if(k!==E.q){if(k==="&")E.state=A.ATTRIB_VALUE_ENTITY_Q;else E.attribValue+=k;continue}y(E),E.q="",E.state=A.ATTRIB_VALUE_CLOSED;continue;case A.ATTRIB_VALUE_CLOSED:if(W(k))E.state=A.ATTRIB;else if(k===">")d(E);else if(k==="/")E.state=A.OPEN_TAG_SLASH;else if(R(K,k))j(E,"No whitespace between attributes"),E.attribName=k,E.attribValue="",E.state=A.ATTRIB_NAME;else j(E,"Invalid attribute name");continue;case A.ATTRIB_VALUE_UNQUOTED:if(!V(k)){if(k==="&")E.state=A.ATTRIB_VALUE_ENTITY_U;else E.attribValue+=k;continue}if(y(E),k===">")d(E);else E.state=A.ATTRIB;continue;case A.CLOSE_TAG:if(!E.tagName)if(W(k))continue;else if(P(K,k))if(E.script)E.script+="</"+k,E.state=A.SCRIPT;else j(E,"Invalid tagname in closing tag.");else E.tagName=k;else if(k===">")b(E);else if(R(M,k))E.tagName+=k;else if(E.script)E.script+="</"+E.tagName+k,E.tagName="",E.state=A.SCRIPT;else{if(!W(k))j(E,"Invalid tagname in closing tag");E.state=A.CLOSE_TAG_SAW_WHITE}continue;case A.CLOSE_TAG_SAW_WHITE:if(W(k))continue;if(k===">")b(E);else j(E,"Invalid characters in closing tag");continue;case A.TEXT_ENTITY:case A.ATTRIB_VALUE_ENTITY_Q:case A.ATTRIB_VALUE_ENTITY_U:var KD,uD;switch(E.state){case A.TEXT_ENTITY:KD=A.TEXT,uD="textNode";break;case A.ATTRIB_VALUE_ENTITY_Q:KD=A.ATTRIB_VALUE_QUOTED,uD="attribValue";break;case A.ATTRIB_VALUE_ENTITY_U:KD=A.ATTRIB_VALUE_UNQUOTED,uD="attribValue";break}if(k===";"){var hD=a(E);if(E.opt.unparsedEntities&&!Object.values(D.XML_ENTITIES).includes(hD))E.entity="",E.state=KD,E.write(hD);else E[uD]+=hD,E.entity="",E.state=KD}else if(R(E.entity.length?I:L,k))E.entity+=k;else j(E,"Invalid character in entity name"),E[uD]+="&"+E.entity+k,E.entity="",E.state=KD;continue;default:throw Error(E,"Unknown state: "+E.state)}}if(E.position>=E.bufferCheckPosition)Y(E);return E}/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */if(!String.fromCodePoint)(function(){var C=String.fromCharCode,E=Math.floor,r=function(){var k=16384,zD=[],t,KD,uD=-1,hD=arguments.length;if(!hD)return"";var X0="";while(++uD<hD){var v0=Number(arguments[uD]);if(!isFinite(v0)||v0<0||v0>1114111||E(v0)!==v0)throw RangeError("Invalid code point: "+v0);if(v0<=65535)zD.push(v0);else v0-=65536,t=(v0>>10)+55296,KD=v0%1024+56320,zD.push(t,KD);if(uD+1===hD||zD.length>k)X0+=C.apply(null,zD),zD.length=0}return X0};if(Object.defineProperty)Object.defineProperty(String,"fromCodePoint",{value:r,configurable:!0,writable:!0});else String.fromCodePoint=r})()})(typeof TQ>"u"?TQ.sax={}:TQ)});var Kh=T((Bh)=>{(function(){Bh.stripBOM=function(D){if(D[0]==="\uFEFF")return D.substring(1);else return D}}).call(Bh)});var cq=T((Wh)=>{(function(){var D=new RegExp(/(?!xmlns)^.*:/);Wh.normalize=function($){return $.toLowerCase()},Wh.firstCharLowerCase=function($){return $.charAt(0).toLowerCase()+$.slice(1)},Wh.stripPrefix=function($){return $.replace(D,"")},Wh.parseNumbers=function($){if(!isNaN($))$=$%1===0?parseInt($,10):parseFloat($);return $},Wh.parseBooleans=function($){if(/^(?:true|false)$/i.test($))$=$.toLowerCase()==="true";return $}}).call(Wh)});var Vh=T((Hh)=>{(function(){var D,$,X,Y,J,Q,F,w,Z,G=function(z,q){return function(){return z.apply(q,arguments)}},O=function(z,q){for(var B in q)if(U.call(q,B))z[B]=q[B];function K(){this.constructor=z}return K.prototype=q.prototype,z.prototype=new K,z.__super__=q.prototype,z},U={}.hasOwnProperty;w=zh(),Y=p("events"),D=Kh(),F=cq(),Z=p("timers").setImmediate,$=qQ().defaults,J=function(z){return typeof z==="object"&&z!=null&&Object.keys(z).length===0},Q=function(z,q,B){var K,M,L;for(K=0,M=z.length;K<M;K++)L=z[K],q=L(q,B);return q},X=function(z,q,B){var K=Object.create(null);return K.value=B,K.writable=!0,K.enumerable=!0,K.configurable=!0,Object.defineProperty(z,q,K)},Hh.Parser=function(z){O(q,z);function q(B){this.parseStringPromise=G(this.parseStringPromise,this),this.parseString=G(this.parseString,this),this.reset=G(this.reset,this),this.assignOrPush=G(this.assignOrPush,this),this.processAsync=G(this.processAsync,this);var K,M,L;if(!(this instanceof Hh.Parser))return new Hh.Parser(B);this.options={},M=$["0.2"];for(K in M){if(!U.call(M,K))continue;L=M[K],this.options[K]=L}for(K in B){if(!U.call(B,K))continue;L=B[K],this.options[K]=L}if(this.options.xmlns)this.options.xmlnskey=this.options.attrkey+"ns";if(this.options.normalizeTags){if(!this.options.tagNameProcessors)this.options.tagNameProcessors=[];this.options.tagNameProcessors.unshift(F.normalize)}this.reset()}return q.prototype.processAsync=function(){var B,K;try{if(this.remaining.length<=this.options.chunkSize)return B=this.remaining,this.remaining="",this.saxParser=this.saxParser.write(B),this.saxParser.close();else return B=this.remaining.substr(0,this.options.chunkSize),this.remaining=this.remaining.substr(this.options.chunkSize,this.remaining.length),this.saxParser=this.saxParser.write(B),Z(this.processAsync)}catch(M){if(K=M,!this.saxParser.errThrown)return this.saxParser.errThrown=!0,this.emit(K)}},q.prototype.assignOrPush=function(B,K,M){if(!(K in B))if(!this.options.explicitArray)return X(B,K,M);else return X(B,K,[M]);else{if(!(B[K]instanceof Array))X(B,K,[B[K]]);return B[K].push(M)}},q.prototype.reset=function(){var B,K,M,L;return this.removeAllListeners(),this.saxParser=w.parser(this.options.strict,{trim:!1,normalize:!1,xmlns:this.options.xmlns}),this.saxParser.errThrown=!1,this.saxParser.onerror=function(I){return function(W){if(I.saxParser.resume(),!I.saxParser.errThrown)return I.saxParser.errThrown=!0,I.emit("error",W)}}(this),this.saxParser.onend=function(I){return function(){if(!I.saxParser.ended)return I.saxParser.ended=!0,I.emit("end",I.resultObject)}}(this),this.saxParser.ended=!1,this.EXPLICIT_CHARKEY=this.options.explicitCharkey,this.resultObject=null,L=[],B=this.options.attrkey,K=this.options.charkey,this.saxParser.onopentag=function(I){return function(W){var N,V,R,P,A;if(R={},R[K]="",!I.options.ignoreAttrs){A=W.attributes;for(N in A){if(!U.call(A,N))continue;if(!(B in R)&&!I.options.mergeAttrs)R[B]={};if(V=I.options.attrValueProcessors?Q(I.options.attrValueProcessors,W.attributes[N],N):W.attributes[N],P=I.options.attrNameProcessors?Q(I.options.attrNameProcessors,N):N,I.options.mergeAttrs)I.assignOrPush(R,P,V);else X(R[B],P,V)}}if(R["#name"]=I.options.tagNameProcessors?Q(I.options.tagNameProcessors,W.name):W.name,I.options.xmlns)R[I.options.xmlnskey]={uri:W.uri,local:W.local};return L.push(R)}}(this),this.saxParser.onclosetag=function(I){return function(){var W,N,V,R,P,A,_,v,S,h;if(A=L.pop(),P=A["#name"],!I.options.explicitChildren||!I.options.preserveChildrenOrder)delete A["#name"];if(A.cdata===!0)W=A.cdata,delete A.cdata;if(S=L[L.length-1],A[K].match(/^\s*$/)&&!W)N=A[K],delete A[K];else{if(I.options.trim)A[K]=A[K].trim();if(I.options.normalize)A[K]=A[K].replace(/\s{2,}/g," ").trim();if(A[K]=I.options.valueProcessors?Q(I.options.valueProcessors,A[K],P):A[K],Object.keys(A).length===1&&K in A&&!I.EXPLICIT_CHARKEY)A=A[K]}if(J(A))if(typeof I.options.emptyTag==="function")A=I.options.emptyTag();else A=I.options.emptyTag!==""?I.options.emptyTag:N;if(I.options.validator!=null)h="/"+function(){var g,l,f;f=[];for(g=0,l=L.length;g<l;g++)R=L[g],f.push(R["#name"]);return f}().concat(P).join("/"),function(){var g;try{return A=I.options.validator(h,S&&S[P],A)}catch(l){return g=l,I.emit("error",g)}}();if(I.options.explicitChildren&&!I.options.mergeAttrs&&typeof A==="object"){if(!I.options.preserveChildrenOrder){if(R={},I.options.attrkey in A)R[I.options.attrkey]=A[I.options.attrkey],delete A[I.options.attrkey];if(!I.options.charsAsChildren&&I.options.charkey in A)R[I.options.charkey]=A[I.options.charkey],delete A[I.options.charkey];if(Object.getOwnPropertyNames(A).length>0)R[I.options.childkey]=A;A=R}else if(S){S[I.options.childkey]=S[I.options.childkey]||[],_={};for(V in A){if(!U.call(A,V))continue;X(_,V,A[V])}if(S[I.options.childkey].push(_),delete A["#name"],Object.keys(A).length===1&&K in A&&!I.EXPLICIT_CHARKEY)A=A[K]}}if(L.length>0)return I.assignOrPush(S,P,A);else{if(I.options.explicitRoot)v=A,A={},X(A,P,v);return I.resultObject=A,I.saxParser.ended=!0,I.emit("end",I.resultObject)}}}(this),M=function(I){return function(W){var N,V;if(V=L[L.length-1],V){if(V[K]+=W,I.options.explicitChildren&&I.options.preserveChildrenOrder&&I.options.charsAsChildren&&(I.options.includeWhiteChars||W.replace(/\\n/g,"").trim()!=="")){if(V[I.options.childkey]=V[I.options.childkey]||[],N={"#name":"__text__"},N[K]=W,I.options.normalize)N[K]=N[K].replace(/\s{2,}/g," ").trim();V[I.options.childkey].push(N)}return V}}}(this),this.saxParser.ontext=M,this.saxParser.oncdata=function(I){return function(W){var N=M(W);if(N)return N.cdata=!0}}(this)},q.prototype.parseString=function(B,K){var M;if(K!=null&&typeof K==="function")this.on("end",function(L){return this.reset(),K(null,L)}),this.on("error",function(L){return this.reset(),K(L)});try{if(B=B.toString(),B.trim()==="")return this.emit("end",null),!0;if(B=D.stripBOM(B),this.options.async)return this.remaining=B,Z(this.processAsync),this.saxParser;return this.saxParser.write(B).close()}catch(L){if(M=L,!(this.saxParser.errThrown||this.saxParser.ended))return this.emit("error",M),this.saxParser.errThrown=!0;else if(this.saxParser.ended)throw M}},q.prototype.parseStringPromise=function(B){return new Promise(function(K){return function(M,L){return K.parseString(B,function(I,W){if(I)return L(I);else return M(W)})}}(this))},q}(Y),Hh.parseString=function(z,q,B){var K,M,L;if(B!=null){if(typeof B==="function")K=B;if(typeof q==="object")M=q}else{if(typeof q==="function")K=q;M={}}return L=new Hh.Parser(M),L.parseString(z,K)},Hh.parseStringPromise=function(z,q){var B,K;if(typeof q==="object")B=q;return K=new Hh.Parser(B),K.parseStringPromise(z)}}).call(Hh)});var Mh=T((Nh)=>{(function(){var D,$,X,Y,J=function(F,w){for(var Z in w)if(Q.call(w,Z))F[Z]=w[Z];function G(){this.constructor=F}return G.prototype=w.prototype,F.prototype=new G,F.__super__=w.prototype,F},Q={}.hasOwnProperty;$=qQ(),D=qh(),X=Vh(),Y=cq(),Nh.defaults=$.defaults,Nh.processors=Y,Nh.ValidationError=function(F){J(w,F);function w(Z){this.message=Z}return w}(Error),Nh.Builder=D.Builder,Nh.Parser=X.Parser,Nh.parseString=X.parseString,Nh.parseStringPromise=X.parseStringPromise}).call(Nh)});var Ah=T((Lh)=>{Object.defineProperty(Lh,"__esModule",{value:!0});Lh.buildXmlElement=Lh.writeXML=Lh.parseXML=Lh.readXML=void 0;var uzD=lD(),vzD=n9(),h3=uzD.__importDefault(Mh());async function _zD(D){var $;try{let X=await(0,vzD.readFile)(D,{encoding:"utf-8"});try{return await h3.default.parseStringPromise(X)}catch(Y){throw`Error parsing: ${D}, ${($=Y.stack)!==null&&$!==void 0?$:Y}`}}catch(X){throw`Unable to read: ${D}`}}Lh.readXML=_zD;function kzD(D,$){let X=$!==void 0?new h3.default.Parser({...$}):new h3.default.Parser,Y;return X.parseString(D,(J,Q)=>{if(!J)Y=Q}),Y}Lh.parseXML=kzD;async function fzD(D){return new Promise(($)=>{let Y=new h3.default.Builder({headless:!0,explicitRoot:!1,rootName:"deleteme"}).buildObject(D);Y=Y.replace("<deleteme>","").replace("</deleteme>",""),$(Y)})}Lh.writeXML=fzD;function yzD(D,$){return new h3.default.Builder({headless:!0,explicitRoot:!1,rootName:$}).buildObject(D)}Lh.buildXmlElement=yzD});var xh=T((Ch)=>{Object.defineProperty(Ch,"__esModule",{value:!0});Ch.getAllElements=Ch.getFilePath=Ch.getAssets=Ch.getJSModules=Ch.getPluginType=Ch.getPlatformElement=Ch.getPluginPlatform=Ch.printPlugins=Ch.fixName=Ch.getDependencies=Ch.resolvePlugin=Ch.getPlugins=Ch.getIncludedPluginPackages=void 0;var mzD=lD(),dzD=n9(),lq=p("path"),X5=mzD.__importDefault(i9()),czD=mY(),lzD=E3(),Rh=UQ(),nzD=Ah();function jh(D,$){var X,Y,J,Q;let{extConfig:F}=D.app;switch($){case"android":return(Y=(X=F.android)===null||X===void 0?void 0:X.includePlugins)!==null&&Y!==void 0?Y:F.includePlugins;case"ios":return(Q=(J=F.ios)===null||J===void 0?void 0:J.includePlugins)!==null&&Q!==void 0?Q:F.includePlugins}}Ch.getIncludedPluginPackages=jh;async function izD(D,$){var X;let Y=(X=jh(D,$))!==null&&X!==void 0?X:Th(D);return(await Promise.all(Y.map(async(Q)=>Eh(D,Q)))).filter((Q)=>!!Q)}Ch.getPlugins=izD;async function Eh(D,$){try{let X=(0,Rh.resolveNode)(D.app.rootDir,$,"package.json");if(!X)(0,czD.fatal)(`Unable to find ${X5.default.strong(`node_modules/${$}`)}.
258
+ `},headless:!1,chunkSize:1e4,emptyTag:"",cdata:!1}}}).call(ib)});var d$=T((pb,J4)=>{(function(){var D,$,X,Y,J,Q,F,w=[].slice,Z={}.hasOwnProperty;D=function(){var G,O,U,z,q,B;if(B=arguments[0],q=2<=arguments.length?w.call(arguments,1):[],J(Object.assign))Object.assign.apply(null,arguments);else for(G=0,U=q.length;G<U;G++)if(z=q[G],z!=null)for(O in z){if(!Z.call(z,O))continue;B[O]=z[O]}return B},J=function(G){return!!G&&Object.prototype.toString.call(G)==="[object Function]"},Q=function(G){var O;return!!G&&((O=typeof G)==="function"||O==="object")},X=function(G){if(J(Array.isArray))return Array.isArray(G);else return Object.prototype.toString.call(G)==="[object Array]"},Y=function(G){var O;if(X(G))return!G.length;else{for(O in G){if(!Z.call(G,O))continue;return!1}return!0}},F=function(G){var O,U;return Q(G)&&(U=Object.getPrototypeOf(G))&&(O=U.constructor)&&typeof O==="function"&&O instanceof O&&Function.prototype.toString.call(O)===Function.prototype.toString.call(Object)},$=function(G){if(J(G.valueOf))return G.valueOf();else return G},pb.assign=D,pb.isFunction=J,pb.isObject=Q,pb.isArray=X,pb.isEmpty=Y,pb.isPlainObject=F,pb.getValue=$}).call(pb)});var yq=T((rb,ob)=>{(function(){var D;ob.exports=D=function(){function $(){}return $.prototype.hasFeature=function(X,Y){return!0},$.prototype.createDocumentType=function(X,Y,J){throw Error("This DOM method is not implemented.")},$.prototype.createDocument=function(X,Y,J){throw Error("This DOM method is not implemented.")},$.prototype.createHTMLDocument=function(X){throw Error("This DOM method is not implemented.")},$.prototype.getFeature=function(X,Y){throw Error("This DOM method is not implemented.")},$}()}).call(rb)});var sb=T((ab,tb)=>{(function(){var D;tb.exports=D=function(){function $(){}return $.prototype.handleError=function(X){throw Error(X)},$}()}).call(ab)});var $g=T((eb,Dg)=>{(function(){var D;Dg.exports=D=function(){function $(X){this.arr=X||[]}return Object.defineProperty($.prototype,"length",{get:function(){return this.arr.length}}),$.prototype.item=function(X){return this.arr[X]||null},$.prototype.contains=function(X){return this.arr.indexOf(X)!==-1},$}()}).call(eb)});var Yg=T((Xg,Jg)=>{(function(){var D,$,X;$=sb(),X=$g(),Jg.exports=D=function(){function Y(){var J;this.defaultParams={"canonical-form":!1,"cdata-sections":!1,comments:!1,"datatype-normalization":!1,"element-content-whitespace":!0,entities:!0,"error-handler":new $,infoset:!0,"validate-if-schema":!1,namespaces:!0,"namespace-declarations":!0,"normalize-characters":!1,"schema-location":"","schema-type":"","split-cdata-sections":!0,validate:!1,"well-formed":!0},this.params=J=Object.create(this.defaultParams)}return Object.defineProperty(Y.prototype,"parameterNames",{get:function(){return new X(Object.keys(this.defaultParams))}}),Y.prototype.getParameter=function(J){if(this.params.hasOwnProperty(J))return this.params[J];else return null},Y.prototype.canSetParameter=function(J,Q){return!0},Y.prototype.setParameter=function(J,Q){if(Q!=null)return this.params[J]=Q;else return delete this.params[J]},Y}()}).call(Xg)});var _0=T((Qg,Fg)=>{(function(){Fg.exports={Element:1,Attribute:2,Text:3,CData:4,EntityReference:5,EntityDeclaration:6,ProcessingInstruction:7,Comment:8,Document:9,DocType:10,DocumentFragment:11,NotationDeclaration:12,Declaration:201,Raw:202,AttributeDeclaration:203,ElementDeclaration:204,Dummy:205}}).call(Qg)});var bq=T((wg,Zg)=>{(function(){var D,$,X;D=_0(),X=m1(),Zg.exports=$=function(){function Y(J,Q,F){if(this.parent=J,this.parent)this.options=this.parent.options,this.stringify=this.parent.stringify;if(Q==null)throw Error("Missing attribute name. "+this.debugInfo(Q));this.name=this.stringify.name(Q),this.value=this.stringify.attValue(F),this.type=D.Attribute,this.isId=!1,this.schemaTypeInfo=null}return Object.defineProperty(Y.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(Y.prototype,"ownerElement",{get:function(){return this.parent}}),Object.defineProperty(Y.prototype,"textContent",{get:function(){return this.value},set:function(J){return this.value=J||""}}),Object.defineProperty(Y.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(Y.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(Y.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(Y.prototype,"specified",{get:function(){return!0}}),Y.prototype.clone=function(){return Object.create(this)},Y.prototype.toString=function(J){return this.options.writer.attribute(this,this.options.writer.filterOptions(J))},Y.prototype.debugInfo=function(J){if(J=J||this.name,J==null)return"parent: <"+this.parent.name+">";else return"attribute: {"+J+"}, parent: <"+this.parent.name+">"},Y.prototype.isEqualNode=function(J){if(J.namespaceURI!==this.namespaceURI)return!1;if(J.prefix!==this.prefix)return!1;if(J.localName!==this.localName)return!1;if(J.value!==this.value)return!1;return!0},Y}()}).call(wg)});var zQ=T((Gg,Og)=>{(function(){var D;Og.exports=D=function(){function $(X){this.nodes=X}return Object.defineProperty($.prototype,"length",{get:function(){return Object.keys(this.nodes).length||0}}),$.prototype.clone=function(){return this.nodes=null},$.prototype.getNamedItem=function(X){return this.nodes[X]},$.prototype.setNamedItem=function(X){var Y=this.nodes[X.nodeName];return this.nodes[X.nodeName]=X,Y||null},$.prototype.removeNamedItem=function(X){var Y=this.nodes[X];return delete this.nodes[X],Y||null},$.prototype.item=function(X){return this.nodes[Object.keys(this.nodes)[X]]||null},$.prototype.getNamedItemNS=function(X,Y){throw Error("This DOM method is not implemented.")},$.prototype.setNamedItemNS=function(X){throw Error("This DOM method is not implemented.")},$.prototype.removeNamedItemNS=function(X,Y){throw Error("This DOM method is not implemented.")},$}()}).call(Gg)});var BQ=T((Ug,qg)=>{(function(){var D,$,X,Y,J,Q,F,w,Z,G=function(U,z){for(var q in z)if(O.call(z,q))U[q]=z[q];function B(){this.constructor=U}return B.prototype=z.prototype,U.prototype=new B,U.__super__=z.prototype,U},O={}.hasOwnProperty;Z=d$(),w=Z.isObject,F=Z.isFunction,Q=Z.getValue,J=m1(),D=_0(),$=bq(),Y=zQ(),qg.exports=X=function(U){G(z,U);function z(q,B,K){var M,L,I,W;if(z.__super__.constructor.call(this,q),B==null)throw Error("Missing element name. "+this.debugInfo());if(this.name=this.stringify.name(B),this.type=D.Element,this.attribs={},this.schemaTypeInfo=null,K!=null)this.attribute(K);if(q.type===D.Document){if(this.isRoot=!0,this.documentObject=q,q.rootObject=this,q.children){W=q.children;for(L=0,I=W.length;L<I;L++)if(M=W[L],M.type===D.DocType){M.name=this.name;break}}}}return Object.defineProperty(z.prototype,"tagName",{get:function(){return this.name}}),Object.defineProperty(z.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(z.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(z.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(z.prototype,"id",{get:function(){throw Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(z.prototype,"className",{get:function(){throw Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(z.prototype,"classList",{get:function(){throw Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(z.prototype,"attributes",{get:function(){if(!this.attributeMap||!this.attributeMap.nodes)this.attributeMap=new Y(this.attribs);return this.attributeMap}}),z.prototype.clone=function(){var q,B,K,M;if(K=Object.create(this),K.isRoot)K.documentObject=null;K.attribs={},M=this.attribs;for(B in M){if(!O.call(M,B))continue;q=M[B],K.attribs[B]=q.clone()}return K.children=[],this.children.forEach(function(L){var I=L.clone();return I.parent=K,K.children.push(I)}),K},z.prototype.attribute=function(q,B){var K,M;if(q!=null)q=Q(q);if(w(q))for(K in q){if(!O.call(q,K))continue;M=q[K],this.attribute(K,M)}else{if(F(B))B=B.apply();if(this.options.keepNullAttributes&&B==null)this.attribs[q]=new $(this,q,"");else if(B!=null)this.attribs[q]=new $(this,q,B)}return this},z.prototype.removeAttribute=function(q){var B,K,M;if(q==null)throw Error("Missing attribute name. "+this.debugInfo());if(q=Q(q),Array.isArray(q))for(K=0,M=q.length;K<M;K++)B=q[K],delete this.attribs[B];else delete this.attribs[q];return this},z.prototype.toString=function(q){return this.options.writer.element(this,this.options.writer.filterOptions(q))},z.prototype.att=function(q,B){return this.attribute(q,B)},z.prototype.a=function(q,B){return this.attribute(q,B)},z.prototype.getAttribute=function(q){if(this.attribs.hasOwnProperty(q))return this.attribs[q].value;else return null},z.prototype.setAttribute=function(q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getAttributeNode=function(q){if(this.attribs.hasOwnProperty(q))return this.attribs[q];else return null},z.prototype.setAttributeNode=function(q){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.removeAttributeNode=function(q){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getElementsByTagName=function(q){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getAttributeNS=function(q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.setAttributeNS=function(q,B,K){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.removeAttributeNS=function(q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getAttributeNodeNS=function(q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.setAttributeNodeNS=function(q){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getElementsByTagNameNS=function(q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.hasAttribute=function(q){return this.attribs.hasOwnProperty(q)},z.prototype.hasAttributeNS=function(q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.setIdAttribute=function(q,B){if(this.attribs.hasOwnProperty(q))return this.attribs[q].isId;else return B},z.prototype.setIdAttributeNS=function(q,B,K){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.setIdAttributeNode=function(q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getElementsByTagName=function(q){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getElementsByTagNameNS=function(q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getElementsByClassName=function(q){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.isEqualNode=function(q){var B,K,M;if(!z.__super__.isEqualNode.apply(this,arguments).isEqualNode(q))return!1;if(q.namespaceURI!==this.namespaceURI)return!1;if(q.prefix!==this.prefix)return!1;if(q.localName!==this.localName)return!1;if(q.attribs.length!==this.attribs.length)return!1;for(B=K=0,M=this.attribs.length-1;0<=M?K<=M:K>=M;B=0<=M?++K:--K)if(!this.attribs[B].isEqualNode(q.attribs[B]))return!1;return!0},z}(J)}).call(Ug)});var b3=T((zg,Bg)=>{(function(){var D,$,X=function(J,Q){for(var F in Q)if(Y.call(Q,F))J[F]=Q[F];function w(){this.constructor=J}return w.prototype=Q.prototype,J.prototype=new w,J.__super__=Q.prototype,J},Y={}.hasOwnProperty;$=m1(),Bg.exports=D=function(J){X(Q,J);function Q(F){Q.__super__.constructor.call(this,F),this.value=""}return Object.defineProperty(Q.prototype,"data",{get:function(){return this.value},set:function(F){return this.value=F||""}}),Object.defineProperty(Q.prototype,"length",{get:function(){return this.value.length}}),Object.defineProperty(Q.prototype,"textContent",{get:function(){return this.value},set:function(F){return this.value=F||""}}),Q.prototype.clone=function(){return Object.create(this)},Q.prototype.substringData=function(F,w){throw Error("This DOM method is not implemented."+this.debugInfo())},Q.prototype.appendData=function(F){throw Error("This DOM method is not implemented."+this.debugInfo())},Q.prototype.insertData=function(F,w){throw Error("This DOM method is not implemented."+this.debugInfo())},Q.prototype.deleteData=function(F,w){throw Error("This DOM method is not implemented."+this.debugInfo())},Q.prototype.replaceData=function(F,w,Z){throw Error("This DOM method is not implemented."+this.debugInfo())},Q.prototype.isEqualNode=function(F){if(!Q.__super__.isEqualNode.apply(this,arguments).isEqualNode(F))return!1;if(F.data!==this.data)return!1;return!0},Q}($)}).call(zg)});var KQ=T((Kg,Wg)=>{(function(){var D,$,X,Y=function(Q,F){for(var w in F)if(J.call(F,w))Q[w]=F[w];function Z(){this.constructor=Q}return Z.prototype=F.prototype,Q.prototype=new Z,Q.__super__=F.prototype,Q},J={}.hasOwnProperty;D=_0(),X=b3(),Wg.exports=$=function(Q){Y(F,Q);function F(w,Z){if(F.__super__.constructor.call(this,w),Z==null)throw Error("Missing CDATA text. "+this.debugInfo());this.name="#cdata-section",this.type=D.CData,this.value=this.stringify.cdata(Z)}return F.prototype.clone=function(){return Object.create(this)},F.prototype.toString=function(w){return this.options.writer.cdata(this,this.options.writer.filterOptions(w))},F}(X)}).call(Kg)});var WQ=T((Hg,Vg)=>{(function(){var D,$,X,Y=function(Q,F){for(var w in F)if(J.call(F,w))Q[w]=F[w];function Z(){this.constructor=Q}return Z.prototype=F.prototype,Q.prototype=new Z,Q.__super__=F.prototype,Q},J={}.hasOwnProperty;D=_0(),$=b3(),Vg.exports=X=function(Q){Y(F,Q);function F(w,Z){if(F.__super__.constructor.call(this,w),Z==null)throw Error("Missing comment text. "+this.debugInfo());this.name="#comment",this.type=D.Comment,this.value=this.stringify.comment(Z)}return F.prototype.clone=function(){return Object.create(this)},F.prototype.toString=function(w){return this.options.writer.comment(this,this.options.writer.filterOptions(w))},F}($)}).call(Hg)});var HQ=T((Ng,Mg)=>{(function(){var D,$,X,Y,J=function(F,w){for(var Z in w)if(Q.call(w,Z))F[Z]=w[Z];function G(){this.constructor=F}return G.prototype=w.prototype,F.prototype=new G,F.__super__=w.prototype,F},Q={}.hasOwnProperty;Y=d$().isObject,X=m1(),D=_0(),Mg.exports=$=function(F){J(w,F);function w(Z,G,O,U){var z;if(w.__super__.constructor.call(this,Z),Y(G))z=G,G=z.version,O=z.encoding,U=z.standalone;if(!G)G="1.0";if(this.type=D.Declaration,this.version=this.stringify.xmlVersion(G),O!=null)this.encoding=this.stringify.xmlEncoding(O);if(U!=null)this.standalone=this.stringify.xmlStandalone(U)}return w.prototype.toString=function(Z){return this.options.writer.declaration(this,this.options.writer.filterOptions(Z))},w}(X)}).call(Ng)});var VQ=T((Lg,Ig)=>{(function(){var D,$,X,Y=function(Q,F){for(var w in F)if(J.call(F,w))Q[w]=F[w];function Z(){this.constructor=Q}return Z.prototype=F.prototype,Q.prototype=new Z,Q.__super__=F.prototype,Q},J={}.hasOwnProperty;X=m1(),D=_0(),Ig.exports=$=function(Q){Y(F,Q);function F(w,Z,G,O,U,z){if(F.__super__.constructor.call(this,w),Z==null)throw Error("Missing DTD element name. "+this.debugInfo());if(G==null)throw Error("Missing DTD attribute name. "+this.debugInfo(Z));if(!O)throw Error("Missing DTD attribute type. "+this.debugInfo(Z));if(!U)throw Error("Missing DTD attribute default. "+this.debugInfo(Z));if(U.indexOf("#")!==0)U="#"+U;if(!U.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/))throw Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. "+this.debugInfo(Z));if(z&&!U.match(/^(#FIXED|#DEFAULT)$/))throw Error("Default value only applies to #FIXED or #DEFAULT. "+this.debugInfo(Z));if(this.elementName=this.stringify.name(Z),this.type=D.AttributeDeclaration,this.attributeName=this.stringify.name(G),this.attributeType=this.stringify.dtdAttType(O),z)this.defaultValue=this.stringify.dtdAttDefault(z);this.defaultValueType=U}return F.prototype.toString=function(w){return this.options.writer.dtdAttList(this,this.options.writer.filterOptions(w))},F}(X)}).call(Lg)});var NQ=T((Ag,Rg)=>{(function(){var D,$,X,Y,J=function(F,w){for(var Z in w)if(Q.call(w,Z))F[Z]=w[Z];function G(){this.constructor=F}return G.prototype=w.prototype,F.prototype=new G,F.__super__=w.prototype,F},Q={}.hasOwnProperty;Y=d$().isObject,X=m1(),D=_0(),Rg.exports=$=function(F){J(w,F);function w(Z,G,O,U){if(w.__super__.constructor.call(this,Z),O==null)throw Error("Missing DTD entity name. "+this.debugInfo(O));if(U==null)throw Error("Missing DTD entity value. "+this.debugInfo(O));if(this.pe=!!G,this.name=this.stringify.name(O),this.type=D.EntityDeclaration,!Y(U))this.value=this.stringify.dtdEntityValue(U),this.internal=!0;else{if(!U.pubID&&!U.sysID)throw Error("Public and/or system identifiers are required for an external entity. "+this.debugInfo(O));if(U.pubID&&!U.sysID)throw Error("System identifier is required for a public external entity. "+this.debugInfo(O));if(this.internal=!1,U.pubID!=null)this.pubID=this.stringify.dtdPubID(U.pubID);if(U.sysID!=null)this.sysID=this.stringify.dtdSysID(U.sysID);if(U.nData!=null)this.nData=this.stringify.dtdNData(U.nData);if(this.pe&&this.nData)throw Error("Notation declaration is not allowed in a parameter entity. "+this.debugInfo(O))}}return Object.defineProperty(w.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(w.prototype,"systemId",{get:function(){return this.sysID}}),Object.defineProperty(w.prototype,"notationName",{get:function(){return this.nData||null}}),Object.defineProperty(w.prototype,"inputEncoding",{get:function(){return null}}),Object.defineProperty(w.prototype,"xmlEncoding",{get:function(){return null}}),Object.defineProperty(w.prototype,"xmlVersion",{get:function(){return null}}),w.prototype.toString=function(Z){return this.options.writer.dtdEntity(this,this.options.writer.filterOptions(Z))},w}(X)}).call(Ag)});var MQ=T((jg,Eg)=>{(function(){var D,$,X,Y=function(Q,F){for(var w in F)if(J.call(F,w))Q[w]=F[w];function Z(){this.constructor=Q}return Z.prototype=F.prototype,Q.prototype=new Z,Q.__super__=F.prototype,Q},J={}.hasOwnProperty;X=m1(),D=_0(),Eg.exports=$=function(Q){Y(F,Q);function F(w,Z,G){if(F.__super__.constructor.call(this,w),Z==null)throw Error("Missing DTD element name. "+this.debugInfo());if(!G)G="(#PCDATA)";if(Array.isArray(G))G="("+G.join(",")+")";this.name=this.stringify.name(Z),this.type=D.ElementDeclaration,this.value=this.stringify.dtdElementValue(G)}return F.prototype.toString=function(w){return this.options.writer.dtdElement(this,this.options.writer.filterOptions(w))},F}(X)}).call(jg)});var LQ=T((Tg,Cg)=>{(function(){var D,$,X,Y=function(Q,F){for(var w in F)if(J.call(F,w))Q[w]=F[w];function Z(){this.constructor=Q}return Z.prototype=F.prototype,Q.prototype=new Z,Q.__super__=F.prototype,Q},J={}.hasOwnProperty;X=m1(),D=_0(),Cg.exports=$=function(Q){Y(F,Q);function F(w,Z,G){if(F.__super__.constructor.call(this,w),Z==null)throw Error("Missing DTD notation name. "+this.debugInfo(Z));if(!G.pubID&&!G.sysID)throw Error("Public or system identifiers are required for an external entity. "+this.debugInfo(Z));if(this.name=this.stringify.name(Z),this.type=D.NotationDeclaration,G.pubID!=null)this.pubID=this.stringify.dtdPubID(G.pubID);if(G.sysID!=null)this.sysID=this.stringify.dtdSysID(G.sysID)}return Object.defineProperty(F.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(F.prototype,"systemId",{get:function(){return this.sysID}}),F.prototype.toString=function(w){return this.options.writer.dtdNotation(this,this.options.writer.filterOptions(w))},F}(X)}).call(Tg)});var IQ=T((Pg,xg)=>{(function(){var D,$,X,Y,J,Q,F,w,Z,G=function(U,z){for(var q in z)if(O.call(z,q))U[q]=z[q];function B(){this.constructor=U}return B.prototype=z.prototype,U.prototype=new B,U.__super__=z.prototype,U},O={}.hasOwnProperty;Z=d$().isObject,w=m1(),D=_0(),$=VQ(),Y=NQ(),X=MQ(),J=LQ(),F=zQ(),xg.exports=Q=function(U){G(z,U);function z(q,B,K){var M,L,I,W,N,V;if(z.__super__.constructor.call(this,q),this.type=D.DocType,q.children){W=q.children;for(L=0,I=W.length;L<I;L++)if(M=W[L],M.type===D.Element){this.name=M.name;break}}if(this.documentObject=q,Z(B))N=B,B=N.pubID,K=N.sysID;if(K==null)V=[B,K],K=V[0],B=V[1];if(B!=null)this.pubID=this.stringify.dtdPubID(B);if(K!=null)this.sysID=this.stringify.dtdSysID(K)}return Object.defineProperty(z.prototype,"entities",{get:function(){var q,B,K,M,L;M={},L=this.children;for(B=0,K=L.length;B<K;B++)if(q=L[B],q.type===D.EntityDeclaration&&!q.pe)M[q.name]=q;return new F(M)}}),Object.defineProperty(z.prototype,"notations",{get:function(){var q,B,K,M,L;M={},L=this.children;for(B=0,K=L.length;B<K;B++)if(q=L[B],q.type===D.NotationDeclaration)M[q.name]=q;return new F(M)}}),Object.defineProperty(z.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(z.prototype,"systemId",{get:function(){return this.sysID}}),Object.defineProperty(z.prototype,"internalSubset",{get:function(){throw Error("This DOM method is not implemented."+this.debugInfo())}}),z.prototype.element=function(q,B){var K=new X(this,q,B);return this.children.push(K),this},z.prototype.attList=function(q,B,K,M,L){var I=new $(this,q,B,K,M,L);return this.children.push(I),this},z.prototype.entity=function(q,B){var K=new Y(this,!1,q,B);return this.children.push(K),this},z.prototype.pEntity=function(q,B){var K=new Y(this,!0,q,B);return this.children.push(K),this},z.prototype.notation=function(q,B){var K=new J(this,q,B);return this.children.push(K),this},z.prototype.toString=function(q){return this.options.writer.docType(this,this.options.writer.filterOptions(q))},z.prototype.ele=function(q,B){return this.element(q,B)},z.prototype.att=function(q,B,K,M,L){return this.attList(q,B,K,M,L)},z.prototype.ent=function(q,B){return this.entity(q,B)},z.prototype.pent=function(q,B){return this.pEntity(q,B)},z.prototype.not=function(q,B){return this.notation(q,B)},z.prototype.up=function(){return this.root()||this.documentObject},z.prototype.isEqualNode=function(q){if(!z.__super__.isEqualNode.apply(this,arguments).isEqualNode(q))return!1;if(q.name!==this.name)return!1;if(q.publicId!==this.publicId)return!1;if(q.systemId!==this.systemId)return!1;return!0},z}(w)}).call(Pg)});var AQ=T((Sg,ug)=>{(function(){var D,$,X,Y=function(Q,F){for(var w in F)if(J.call(F,w))Q[w]=F[w];function Z(){this.constructor=Q}return Z.prototype=F.prototype,Q.prototype=new Z,Q.__super__=F.prototype,Q},J={}.hasOwnProperty;D=_0(),$=m1(),ug.exports=X=function(Q){Y(F,Q);function F(w,Z){if(F.__super__.constructor.call(this,w),Z==null)throw Error("Missing raw text. "+this.debugInfo());this.type=D.Raw,this.value=this.stringify.raw(Z)}return F.prototype.clone=function(){return Object.create(this)},F.prototype.toString=function(w){return this.options.writer.raw(this,this.options.writer.filterOptions(w))},F}($)}).call(Sg)});var RQ=T((vg,_g)=>{(function(){var D,$,X,Y=function(Q,F){for(var w in F)if(J.call(F,w))Q[w]=F[w];function Z(){this.constructor=Q}return Z.prototype=F.prototype,Q.prototype=new Z,Q.__super__=F.prototype,Q},J={}.hasOwnProperty;D=_0(),$=b3(),_g.exports=X=function(Q){Y(F,Q);function F(w,Z){if(F.__super__.constructor.call(this,w),Z==null)throw Error("Missing element text. "+this.debugInfo());this.name="#text",this.type=D.Text,this.value=this.stringify.text(Z)}return Object.defineProperty(F.prototype,"isElementContentWhitespace",{get:function(){throw Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(F.prototype,"wholeText",{get:function(){var w,Z,G;G="",Z=this.previousSibling;while(Z)G=Z.data+G,Z=Z.previousSibling;G+=this.data,w=this.nextSibling;while(w)G=G+w.data,w=w.nextSibling;return G}}),F.prototype.clone=function(){return Object.create(this)},F.prototype.toString=function(w){return this.options.writer.text(this,this.options.writer.filterOptions(w))},F.prototype.splitText=function(w){throw Error("This DOM method is not implemented."+this.debugInfo())},F.prototype.replaceWholeText=function(w){throw Error("This DOM method is not implemented."+this.debugInfo())},F}($)}).call(vg)});var jQ=T((kg,fg)=>{(function(){var D,$,X,Y=function(Q,F){for(var w in F)if(J.call(F,w))Q[w]=F[w];function Z(){this.constructor=Q}return Z.prototype=F.prototype,Q.prototype=new Z,Q.__super__=F.prototype,Q},J={}.hasOwnProperty;D=_0(),$=b3(),fg.exports=X=function(Q){Y(F,Q);function F(w,Z,G){if(F.__super__.constructor.call(this,w),Z==null)throw Error("Missing instruction target. "+this.debugInfo());if(this.type=D.ProcessingInstruction,this.target=this.stringify.insTarget(Z),this.name=this.target,G)this.value=this.stringify.insValue(G)}return F.prototype.clone=function(){return Object.create(this)},F.prototype.toString=function(w){return this.options.writer.processingInstruction(this,this.options.writer.filterOptions(w))},F.prototype.isEqualNode=function(w){if(!F.__super__.isEqualNode.apply(this,arguments).isEqualNode(w))return!1;if(w.target!==this.target)return!1;return!0},F}($)}).call(kg)});var gq=T((yg,bg)=>{(function(){var D,$,X,Y=function(Q,F){for(var w in F)if(J.call(F,w))Q[w]=F[w];function Z(){this.constructor=Q}return Z.prototype=F.prototype,Q.prototype=new Z,Q.__super__=F.prototype,Q},J={}.hasOwnProperty;X=m1(),D=_0(),bg.exports=$=function(Q){Y(F,Q);function F(w){F.__super__.constructor.call(this,w),this.type=D.Dummy}return F.prototype.clone=function(){return Object.create(this)},F.prototype.toString=function(w){return""},F}(X)}).call(yg)});var mg=T((gg,hg)=>{(function(){var D;hg.exports=D=function(){function $(X){this.nodes=X}return Object.defineProperty($.prototype,"length",{get:function(){return this.nodes.length||0}}),$.prototype.clone=function(){return this.nodes=null},$.prototype.item=function(X){return this.nodes[X]||null},$}()}).call(gg)});var lg=T((dg,cg)=>{(function(){cg.exports={Disconnected:1,Preceding:2,Following:4,Contains:8,ContainedBy:16,ImplementationSpecific:32}}).call(dg)});var m1=T((ng,ig)=>{(function(){var D,$,X,Y,J,Q,F,w,Z,G,O,U,z,q,B,K,M,L,I,W={}.hasOwnProperty;I=d$(),L=I.isObject,M=I.isFunction,K=I.isEmpty,B=I.getValue,w=null,X=null,Y=null,J=null,Q=null,z=null,q=null,U=null,F=null,$=null,O=null,Z=null,D=null,ig.exports=G=function(){function N(V){if(this.parent=V,this.parent)this.options=this.parent.options,this.stringify=this.parent.stringify;if(this.value=null,this.children=[],this.baseURI=null,!w)w=BQ(),X=KQ(),Y=WQ(),J=HQ(),Q=IQ(),z=AQ(),q=RQ(),U=jQ(),F=gq(),$=_0(),O=mg(),Z=zQ(),D=lg()}return Object.defineProperty(N.prototype,"nodeName",{get:function(){return this.name}}),Object.defineProperty(N.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(N.prototype,"nodeValue",{get:function(){return this.value}}),Object.defineProperty(N.prototype,"parentNode",{get:function(){return this.parent}}),Object.defineProperty(N.prototype,"childNodes",{get:function(){if(!this.childNodeList||!this.childNodeList.nodes)this.childNodeList=new O(this.children);return this.childNodeList}}),Object.defineProperty(N.prototype,"firstChild",{get:function(){return this.children[0]||null}}),Object.defineProperty(N.prototype,"lastChild",{get:function(){return this.children[this.children.length-1]||null}}),Object.defineProperty(N.prototype,"previousSibling",{get:function(){var V=this.parent.children.indexOf(this);return this.parent.children[V-1]||null}}),Object.defineProperty(N.prototype,"nextSibling",{get:function(){var V=this.parent.children.indexOf(this);return this.parent.children[V+1]||null}}),Object.defineProperty(N.prototype,"ownerDocument",{get:function(){return this.document()||null}}),Object.defineProperty(N.prototype,"textContent",{get:function(){var V,R,C,A,_;if(this.nodeType===$.Element||this.nodeType===$.DocumentFragment){_="",A=this.children;for(R=0,C=A.length;R<C;R++)if(V=A[R],V.textContent)_+=V.textContent;return _}else return null},set:function(V){throw Error("This DOM method is not implemented."+this.debugInfo())}}),N.prototype.setParent=function(V){var R,C,A,_,v;if(this.parent=V,V)this.options=V.options,this.stringify=V.stringify;_=this.children,v=[];for(C=0,A=_.length;C<A;C++)R=_[C],v.push(R.setParent(this));return v},N.prototype.element=function(V,R,C){var A,_,v,S,h,g,l,f,j,x,u;if(g=null,R===null&&C==null)j=[{},null],R=j[0],C=j[1];if(R==null)R={};if(R=B(R),!L(R))x=[R,C],C=x[0],R=x[1];if(V!=null)V=B(V);if(Array.isArray(V))for(v=0,l=V.length;v<l;v++)_=V[v],g=this.element(_);else if(M(V))g=this.element(V.apply());else if(L(V))for(h in V){if(!W.call(V,h))continue;if(u=V[h],M(u))u=u.apply();if(!this.options.ignoreDecorators&&this.stringify.convertAttKey&&h.indexOf(this.stringify.convertAttKey)===0)g=this.attribute(h.substr(this.stringify.convertAttKey.length),u);else if(!this.options.separateArrayItems&&Array.isArray(u)&&K(u))g=this.dummy();else if(L(u)&&K(u))g=this.element(h);else if(!this.options.keepNullNodes&&u==null)g=this.dummy();else if(!this.options.separateArrayItems&&Array.isArray(u))for(S=0,f=u.length;S<f;S++)_=u[S],A={},A[h]=_,g=this.element(A);else if(L(u))if(!this.options.ignoreDecorators&&this.stringify.convertTextKey&&h.indexOf(this.stringify.convertTextKey)===0)g=this.element(u);else g=this.element(h),g.element(u);else g=this.element(h,u)}else if(!this.options.keepNullNodes&&C===null)g=this.dummy();else if(!this.options.ignoreDecorators&&this.stringify.convertTextKey&&V.indexOf(this.stringify.convertTextKey)===0)g=this.text(C);else if(!this.options.ignoreDecorators&&this.stringify.convertCDataKey&&V.indexOf(this.stringify.convertCDataKey)===0)g=this.cdata(C);else if(!this.options.ignoreDecorators&&this.stringify.convertCommentKey&&V.indexOf(this.stringify.convertCommentKey)===0)g=this.comment(C);else if(!this.options.ignoreDecorators&&this.stringify.convertRawKey&&V.indexOf(this.stringify.convertRawKey)===0)g=this.raw(C);else if(!this.options.ignoreDecorators&&this.stringify.convertPIKey&&V.indexOf(this.stringify.convertPIKey)===0)g=this.instruction(V.substr(this.stringify.convertPIKey.length),C);else g=this.node(V,R,C);if(g==null)throw Error("Could not create any elements with: "+V+". "+this.debugInfo());return g},N.prototype.insertBefore=function(V,R,C){var A,_,v,S,h;if(V!=null?V.type:void 0){if(v=V,S=R,v.setParent(this),S)_=children.indexOf(S),h=children.splice(_),children.push(v),Array.prototype.push.apply(children,h);else children.push(v);return v}else{if(this.isRoot)throw Error("Cannot insert elements at root level. "+this.debugInfo(V));return _=this.parent.children.indexOf(this),h=this.parent.children.splice(_),A=this.parent.element(V,R,C),Array.prototype.push.apply(this.parent.children,h),A}},N.prototype.insertAfter=function(V,R,C){var A,_,v;if(this.isRoot)throw Error("Cannot insert elements at root level. "+this.debugInfo(V));return _=this.parent.children.indexOf(this),v=this.parent.children.splice(_+1),A=this.parent.element(V,R,C),Array.prototype.push.apply(this.parent.children,v),A},N.prototype.remove=function(){var V,R;if(this.isRoot)throw Error("Cannot remove the root element. "+this.debugInfo());return V=this.parent.children.indexOf(this),[].splice.apply(this.parent.children,[V,V-V+1].concat(R=[])),this.parent},N.prototype.node=function(V,R,C){var A,_;if(V!=null)V=B(V);if(R||(R={}),R=B(R),!L(R))_=[R,C],C=_[0],R=_[1];if(A=new w(this,V,R),C!=null)A.text(C);return this.children.push(A),A},N.prototype.text=function(V){var R;if(L(V))this.element(V);return R=new q(this,V),this.children.push(R),this},N.prototype.cdata=function(V){var R=new X(this,V);return this.children.push(R),this},N.prototype.comment=function(V){var R=new Y(this,V);return this.children.push(R),this},N.prototype.commentBefore=function(V){var R,C,A;return C=this.parent.children.indexOf(this),A=this.parent.children.splice(C),R=this.parent.comment(V),Array.prototype.push.apply(this.parent.children,A),this},N.prototype.commentAfter=function(V){var R,C,A;return C=this.parent.children.indexOf(this),A=this.parent.children.splice(C+1),R=this.parent.comment(V),Array.prototype.push.apply(this.parent.children,A),this},N.prototype.raw=function(V){var R=new z(this,V);return this.children.push(R),this},N.prototype.dummy=function(){var V=new F(this);return V},N.prototype.instruction=function(V,R){var C,A,_,v,S;if(V!=null)V=B(V);if(R!=null)R=B(R);if(Array.isArray(V))for(v=0,S=V.length;v<S;v++)C=V[v],this.instruction(C);else if(L(V))for(C in V){if(!W.call(V,C))continue;A=V[C],this.instruction(C,A)}else{if(M(R))R=R.apply();_=new U(this,V,R),this.children.push(_)}return this},N.prototype.instructionBefore=function(V,R){var C,A,_;return A=this.parent.children.indexOf(this),_=this.parent.children.splice(A),C=this.parent.instruction(V,R),Array.prototype.push.apply(this.parent.children,_),this},N.prototype.instructionAfter=function(V,R){var C,A,_;return A=this.parent.children.indexOf(this),_=this.parent.children.splice(A+1),C=this.parent.instruction(V,R),Array.prototype.push.apply(this.parent.children,_),this},N.prototype.declaration=function(V,R,C){var A,_;if(A=this.document(),_=new J(A,V,R,C),A.children.length===0)A.children.unshift(_);else if(A.children[0].type===$.Declaration)A.children[0]=_;else A.children.unshift(_);return A.root()||A},N.prototype.dtd=function(V,R){var C,A,_,v,S,h,g,l,f,j;A=this.document(),_=new Q(A,V,R),f=A.children;for(v=S=0,g=f.length;S<g;v=++S)if(C=f[v],C.type===$.DocType)return A.children[v]=_,_;j=A.children;for(v=h=0,l=j.length;h<l;v=++h)if(C=j[v],C.isRoot)return A.children.splice(v,0,_),_;return A.children.push(_),_},N.prototype.up=function(){if(this.isRoot)throw Error("The root node has no parent. Use doc() if you need to get the document object.");return this.parent},N.prototype.root=function(){var V=this;while(V)if(V.type===$.Document)return V.rootObject;else if(V.isRoot)return V;else V=V.parent},N.prototype.document=function(){var V=this;while(V)if(V.type===$.Document)return V;else V=V.parent},N.prototype.end=function(V){return this.document().end(V)},N.prototype.prev=function(){var V=this.parent.children.indexOf(this);if(V<1)throw Error("Already at the first node. "+this.debugInfo());return this.parent.children[V-1]},N.prototype.next=function(){var V=this.parent.children.indexOf(this);if(V===-1||V===this.parent.children.length-1)throw Error("Already at the last node. "+this.debugInfo());return this.parent.children[V+1]},N.prototype.importDocument=function(V){var R=V.root().clone();return R.parent=this,R.isRoot=!1,this.children.push(R),this},N.prototype.debugInfo=function(V){var R,C;if(V=V||this.name,V==null&&!((R=this.parent)!=null?R.name:void 0))return"";else if(V==null)return"parent: <"+this.parent.name+">";else if(!((C=this.parent)!=null?C.name:void 0))return"node: <"+V+">";else return"node: <"+V+">, parent: <"+this.parent.name+">"},N.prototype.ele=function(V,R,C){return this.element(V,R,C)},N.prototype.nod=function(V,R,C){return this.node(V,R,C)},N.prototype.txt=function(V){return this.text(V)},N.prototype.dat=function(V){return this.cdata(V)},N.prototype.com=function(V){return this.comment(V)},N.prototype.ins=function(V,R){return this.instruction(V,R)},N.prototype.doc=function(){return this.document()},N.prototype.dec=function(V,R,C){return this.declaration(V,R,C)},N.prototype.e=function(V,R,C){return this.element(V,R,C)},N.prototype.n=function(V,R,C){return this.node(V,R,C)},N.prototype.t=function(V){return this.text(V)},N.prototype.d=function(V){return this.cdata(V)},N.prototype.c=function(V){return this.comment(V)},N.prototype.r=function(V){return this.raw(V)},N.prototype.i=function(V,R){return this.instruction(V,R)},N.prototype.u=function(){return this.up()},N.prototype.importXMLBuilder=function(V){return this.importDocument(V)},N.prototype.replaceChild=function(V,R){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.removeChild=function(V){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.appendChild=function(V){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.hasChildNodes=function(){return this.children.length!==0},N.prototype.cloneNode=function(V){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.normalize=function(){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.isSupported=function(V,R){return!0},N.prototype.hasAttributes=function(){return this.attribs.length!==0},N.prototype.compareDocumentPosition=function(V){var R,C;if(R=this,R===V)return 0;else if(this.document()!==V.document()){if(C=D.Disconnected|D.ImplementationSpecific,Math.random()<0.5)C|=D.Preceding;else C|=D.Following;return C}else if(R.isAncestor(V))return D.Contains|D.Preceding;else if(R.isDescendant(V))return D.Contains|D.Following;else if(R.isPreceding(V))return D.Preceding;else return D.Following},N.prototype.isSameNode=function(V){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.lookupPrefix=function(V){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.isDefaultNamespace=function(V){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.lookupNamespaceURI=function(V){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.isEqualNode=function(V){var R,C,A;if(V.nodeType!==this.nodeType)return!1;if(V.children.length!==this.children.length)return!1;for(R=C=0,A=this.children.length-1;0<=A?C<=A:C>=A;R=0<=A?++C:--C)if(!this.children[R].isEqualNode(V.children[R]))return!1;return!0},N.prototype.getFeature=function(V,R){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.setUserData=function(V,R,C){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.getUserData=function(V){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.contains=function(V){if(!V)return!1;return V===this||this.isDescendant(V)},N.prototype.isDescendant=function(V){var R,C,A,_,v;v=this.children;for(A=0,_=v.length;A<_;A++){if(R=v[A],V===R)return!0;if(C=R.isDescendant(V),C)return!0}return!1},N.prototype.isAncestor=function(V){return V.isDescendant(this)},N.prototype.isPreceding=function(V){var R,C;if(R=this.treePosition(V),C=this.treePosition(this),R===-1||C===-1)return!1;else return R<C},N.prototype.isFollowing=function(V){var R,C;if(R=this.treePosition(V),C=this.treePosition(this),R===-1||C===-1)return!1;else return R>C},N.prototype.treePosition=function(V){var R,C;if(C=0,R=!1,this.foreachTreeNode(this.document(),function(A){if(C++,!R&&A===V)return R=!0}),R)return C;else return-1},N.prototype.foreachTreeNode=function(V,R){var C,A,_,v,S;V||(V=this.document()),v=V.children;for(A=0,_=v.length;A<_;A++)if(C=v[A],S=R(C))return S;else if(S=this.foreachTreeNode(C,R),S)return S},N}()}).call(ng)});var hq=T((pg,rg)=>{(function(){var D,$=function(Y,J){return function(){return Y.apply(J,arguments)}},X={}.hasOwnProperty;rg.exports=D=function(){function Y(J){this.assertLegalName=$(this.assertLegalName,this),this.assertLegalChar=$(this.assertLegalChar,this);var Q,F,w;if(J||(J={}),this.options=J,!this.options.version)this.options.version="1.0";F=J.stringify||{};for(Q in F){if(!X.call(F,Q))continue;w=F[Q],this[Q]=w}}return Y.prototype.name=function(J){if(this.options.noValidation)return J;return this.assertLegalName(""+J||"")},Y.prototype.text=function(J){if(this.options.noValidation)return J;return this.assertLegalChar(this.textEscape(""+J||""))},Y.prototype.cdata=function(J){if(this.options.noValidation)return J;return J=""+J||"",J=J.replace("]]>","]]]]><![CDATA[>"),this.assertLegalChar(J)},Y.prototype.comment=function(J){if(this.options.noValidation)return J;if(J=""+J||"",J.match(/--/))throw Error("Comment text cannot contain double-hypen: "+J);return this.assertLegalChar(J)},Y.prototype.raw=function(J){if(this.options.noValidation)return J;return""+J||""},Y.prototype.attValue=function(J){if(this.options.noValidation)return J;return this.assertLegalChar(this.attEscape(J=""+J||""))},Y.prototype.insTarget=function(J){if(this.options.noValidation)return J;return this.assertLegalChar(""+J||"")},Y.prototype.insValue=function(J){if(this.options.noValidation)return J;if(J=""+J||"",J.match(/\?>/))throw Error("Invalid processing instruction value: "+J);return this.assertLegalChar(J)},Y.prototype.xmlVersion=function(J){if(this.options.noValidation)return J;if(J=""+J||"",!J.match(/1\.[0-9]+/))throw Error("Invalid version number: "+J);return J},Y.prototype.xmlEncoding=function(J){if(this.options.noValidation)return J;if(J=""+J||"",!J.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/))throw Error("Invalid encoding: "+J);return this.assertLegalChar(J)},Y.prototype.xmlStandalone=function(J){if(this.options.noValidation)return J;if(J)return"yes";else return"no"},Y.prototype.dtdPubID=function(J){if(this.options.noValidation)return J;return this.assertLegalChar(""+J||"")},Y.prototype.dtdSysID=function(J){if(this.options.noValidation)return J;return this.assertLegalChar(""+J||"")},Y.prototype.dtdElementValue=function(J){if(this.options.noValidation)return J;return this.assertLegalChar(""+J||"")},Y.prototype.dtdAttType=function(J){if(this.options.noValidation)return J;return this.assertLegalChar(""+J||"")},Y.prototype.dtdAttDefault=function(J){if(this.options.noValidation)return J;return this.assertLegalChar(""+J||"")},Y.prototype.dtdEntityValue=function(J){if(this.options.noValidation)return J;return this.assertLegalChar(""+J||"")},Y.prototype.dtdNData=function(J){if(this.options.noValidation)return J;return this.assertLegalChar(""+J||"")},Y.prototype.convertAttKey="@",Y.prototype.convertPIKey="?",Y.prototype.convertTextKey="#text",Y.prototype.convertCDataKey="#cdata",Y.prototype.convertCommentKey="#comment",Y.prototype.convertRawKey="#raw",Y.prototype.assertLegalChar=function(J){var Q,F;if(this.options.noValidation)return J;if(Q="",this.options.version==="1.0"){if(Q=/[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,F=J.match(Q))throw Error("Invalid character in string: "+J+" at index "+F.index)}else if(this.options.version==="1.1"){if(Q=/[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,F=J.match(Q))throw Error("Invalid character in string: "+J+" at index "+F.index)}return J},Y.prototype.assertLegalName=function(J){var Q;if(this.options.noValidation)return J;if(this.assertLegalChar(J),Q=/^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/,!J.match(Q))throw Error("Invalid character in name");return J},Y.prototype.textEscape=function(J){var Q;if(this.options.noValidation)return J;return Q=this.options.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,J.replace(Q,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r/g,"&#xD;")},Y.prototype.attEscape=function(J){var Q;if(this.options.noValidation)return J;return Q=this.options.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,J.replace(Q,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/\t/g,"&#x9;").replace(/\n/g,"&#xA;").replace(/\r/g,"&#xD;")},Y}()}).call(pg)});var g3=T((og,ag)=>{(function(){ag.exports={None:0,OpenTag:1,InsideTag:2,CloseTag:3}}).call(og)});var mq=T((tg,sg)=>{(function(){var D,$,X,Y,J,Q,F,w,Z,G,O,U,z,q,B,K,M,L={}.hasOwnProperty;M=d$().assign,D=_0(),Z=HQ(),G=IQ(),X=KQ(),Y=WQ(),U=BQ(),q=AQ(),B=RQ(),z=jQ(),O=gq(),J=VQ(),Q=MQ(),F=NQ(),w=LQ(),$=g3(),sg.exports=K=function(){function I(W){var N,V,R;W||(W={}),this.options=W,V=W.writer||{};for(N in V){if(!L.call(V,N))continue;R=V[N],this["_"+N]=this[N],this[N]=R}}return I.prototype.filterOptions=function(W){var N,V,R,C,A,_,v,S;if(W||(W={}),W=M({},this.options,W),N={writer:this},N.pretty=W.pretty||!1,N.allowEmpty=W.allowEmpty||!1,N.indent=(V=W.indent)!=null?V:" ",N.newline=(R=W.newline)!=null?R:`
259
+ `,N.offset=(C=W.offset)!=null?C:0,N.dontPrettyTextNodes=(A=(_=W.dontPrettyTextNodes)!=null?_:W.dontprettytextnodes)!=null?A:0,N.spaceBeforeSlash=(v=(S=W.spaceBeforeSlash)!=null?S:W.spacebeforeslash)!=null?v:"",N.spaceBeforeSlash===!0)N.spaceBeforeSlash=" ";return N.suppressPrettyCount=0,N.user={},N.state=$.None,N},I.prototype.indent=function(W,N,V){var R;if(!N.pretty||N.suppressPrettyCount)return"";else if(N.pretty){if(R=(V||0)+N.offset+1,R>0)return Array(R).join(N.indent)}return""},I.prototype.endline=function(W,N,V){if(!N.pretty||N.suppressPrettyCount)return"";else return N.newline},I.prototype.attribute=function(W,N,V){var R;return this.openAttribute(W,N,V),R=" "+W.name+'="'+W.value+'"',this.closeAttribute(W,N,V),R},I.prototype.cdata=function(W,N,V){var R;return this.openNode(W,N,V),N.state=$.OpenTag,R=this.indent(W,N,V)+"<![CDATA[",N.state=$.InsideTag,R+=W.value,N.state=$.CloseTag,R+="]]>"+this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),R},I.prototype.comment=function(W,N,V){var R;return this.openNode(W,N,V),N.state=$.OpenTag,R=this.indent(W,N,V)+"<!-- ",N.state=$.InsideTag,R+=W.value,N.state=$.CloseTag,R+=" -->"+this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),R},I.prototype.declaration=function(W,N,V){var R;if(this.openNode(W,N,V),N.state=$.OpenTag,R=this.indent(W,N,V)+"<?xml",N.state=$.InsideTag,R+=' version="'+W.version+'"',W.encoding!=null)R+=' encoding="'+W.encoding+'"';if(W.standalone!=null)R+=' standalone="'+W.standalone+'"';return N.state=$.CloseTag,R+=N.spaceBeforeSlash+"?>",R+=this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),R},I.prototype.docType=function(W,N,V){var R,C,A,_,v;if(V||(V=0),this.openNode(W,N,V),N.state=$.OpenTag,_=this.indent(W,N,V),_+="<!DOCTYPE "+W.root().name,W.pubID&&W.sysID)_+=' PUBLIC "'+W.pubID+'" "'+W.sysID+'"';else if(W.sysID)_+=' SYSTEM "'+W.sysID+'"';if(W.children.length>0){_+=" [",_+=this.endline(W,N,V),N.state=$.InsideTag,v=W.children;for(C=0,A=v.length;C<A;C++)R=v[C],_+=this.writeChildNode(R,N,V+1);N.state=$.CloseTag,_+="]"}return N.state=$.CloseTag,_+=N.spaceBeforeSlash+">",_+=this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),_},I.prototype.element=function(W,N,V){var R,C,A,_,v,S,h,g,l,f,j,x,u,y;V||(V=0),f=!1,j="",this.openNode(W,N,V),N.state=$.OpenTag,j+=this.indent(W,N,V)+"<"+W.name,x=W.attribs;for(l in x){if(!L.call(x,l))continue;R=x[l],j+=this.attribute(R,N,V)}if(A=W.children.length,_=A===0?null:W.children[0],A===0||W.children.every(function(d){return(d.type===D.Text||d.type===D.Raw)&&d.value===""}))if(N.allowEmpty)j+=">",N.state=$.CloseTag,j+="</"+W.name+">"+this.endline(W,N,V);else N.state=$.CloseTag,j+=N.spaceBeforeSlash+"/>"+this.endline(W,N,V);else if(N.pretty&&A===1&&(_.type===D.Text||_.type===D.Raw)&&_.value!=null)j+=">",N.state=$.InsideTag,N.suppressPrettyCount++,f=!0,j+=this.writeChildNode(_,N,V+1),N.suppressPrettyCount--,f=!1,N.state=$.CloseTag,j+="</"+W.name+">"+this.endline(W,N,V);else{if(N.dontPrettyTextNodes){u=W.children;for(v=0,h=u.length;v<h;v++)if(C=u[v],(C.type===D.Text||C.type===D.Raw)&&C.value!=null){N.suppressPrettyCount++,f=!0;break}}j+=">"+this.endline(W,N,V),N.state=$.InsideTag,y=W.children;for(S=0,g=y.length;S<g;S++)C=y[S],j+=this.writeChildNode(C,N,V+1);if(N.state=$.CloseTag,j+=this.indent(W,N,V)+"</"+W.name+">",f)N.suppressPrettyCount--;j+=this.endline(W,N,V),N.state=$.None}return this.closeNode(W,N,V),j},I.prototype.writeChildNode=function(W,N,V){switch(W.type){case D.CData:return this.cdata(W,N,V);case D.Comment:return this.comment(W,N,V);case D.Element:return this.element(W,N,V);case D.Raw:return this.raw(W,N,V);case D.Text:return this.text(W,N,V);case D.ProcessingInstruction:return this.processingInstruction(W,N,V);case D.Dummy:return"";case D.Declaration:return this.declaration(W,N,V);case D.DocType:return this.docType(W,N,V);case D.AttributeDeclaration:return this.dtdAttList(W,N,V);case D.ElementDeclaration:return this.dtdElement(W,N,V);case D.EntityDeclaration:return this.dtdEntity(W,N,V);case D.NotationDeclaration:return this.dtdNotation(W,N,V);default:throw Error("Unknown XML node type: "+W.constructor.name)}},I.prototype.processingInstruction=function(W,N,V){var R;if(this.openNode(W,N,V),N.state=$.OpenTag,R=this.indent(W,N,V)+"<?",N.state=$.InsideTag,R+=W.target,W.value)R+=" "+W.value;return N.state=$.CloseTag,R+=N.spaceBeforeSlash+"?>",R+=this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),R},I.prototype.raw=function(W,N,V){var R;return this.openNode(W,N,V),N.state=$.OpenTag,R=this.indent(W,N,V),N.state=$.InsideTag,R+=W.value,N.state=$.CloseTag,R+=this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),R},I.prototype.text=function(W,N,V){var R;return this.openNode(W,N,V),N.state=$.OpenTag,R=this.indent(W,N,V),N.state=$.InsideTag,R+=W.value,N.state=$.CloseTag,R+=this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),R},I.prototype.dtdAttList=function(W,N,V){var R;if(this.openNode(W,N,V),N.state=$.OpenTag,R=this.indent(W,N,V)+"<!ATTLIST",N.state=$.InsideTag,R+=" "+W.elementName+" "+W.attributeName+" "+W.attributeType,W.defaultValueType!=="#DEFAULT")R+=" "+W.defaultValueType;if(W.defaultValue)R+=' "'+W.defaultValue+'"';return N.state=$.CloseTag,R+=N.spaceBeforeSlash+">"+this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),R},I.prototype.dtdElement=function(W,N,V){var R;return this.openNode(W,N,V),N.state=$.OpenTag,R=this.indent(W,N,V)+"<!ELEMENT",N.state=$.InsideTag,R+=" "+W.name+" "+W.value,N.state=$.CloseTag,R+=N.spaceBeforeSlash+">"+this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),R},I.prototype.dtdEntity=function(W,N,V){var R;if(this.openNode(W,N,V),N.state=$.OpenTag,R=this.indent(W,N,V)+"<!ENTITY",N.state=$.InsideTag,W.pe)R+=" %";if(R+=" "+W.name,W.value)R+=' "'+W.value+'"';else{if(W.pubID&&W.sysID)R+=' PUBLIC "'+W.pubID+'" "'+W.sysID+'"';else if(W.sysID)R+=' SYSTEM "'+W.sysID+'"';if(W.nData)R+=" NDATA "+W.nData}return N.state=$.CloseTag,R+=N.spaceBeforeSlash+">"+this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),R},I.prototype.dtdNotation=function(W,N,V){var R;if(this.openNode(W,N,V),N.state=$.OpenTag,R=this.indent(W,N,V)+"<!NOTATION",N.state=$.InsideTag,R+=" "+W.name,W.pubID&&W.sysID)R+=' PUBLIC "'+W.pubID+'" "'+W.sysID+'"';else if(W.pubID)R+=' PUBLIC "'+W.pubID+'"';else if(W.sysID)R+=' SYSTEM "'+W.sysID+'"';return N.state=$.CloseTag,R+=N.spaceBeforeSlash+">"+this.endline(W,N,V),N.state=$.None,this.closeNode(W,N,V),R},I.prototype.openNode=function(W,N,V){},I.prototype.closeNode=function(W,N,V){},I.prototype.openAttribute=function(W,N,V){},I.prototype.closeAttribute=function(W,N,V){},I}()}).call(tg)});var EQ=T((eg,Dh)=>{(function(){var D,$,X=function(J,Q){for(var F in Q)if(Y.call(Q,F))J[F]=Q[F];function w(){this.constructor=J}return w.prototype=Q.prototype,J.prototype=new w,J.__super__=Q.prototype,J},Y={}.hasOwnProperty;$=mq(),Dh.exports=D=function(J){X(Q,J);function Q(F){Q.__super__.constructor.call(this,F)}return Q.prototype.document=function(F,w){var Z,G,O,U,z;w=this.filterOptions(w),U="",z=F.children;for(G=0,O=z.length;G<O;G++)Z=z[G],U+=this.writeChildNode(Z,w,0);if(w.pretty&&U.slice(-w.newline.length)===w.newline)U=U.slice(0,-w.newline.length);return U},Q}($)}).call(eg)});var dq=T(($h,Xh)=>{(function(){var D,$,X,Y,J,Q,F,w,Z=function(O,U){for(var z in U)if(G.call(U,z))O[z]=U[z];function q(){this.constructor=O}return q.prototype=U.prototype,O.prototype=new q,O.__super__=U.prototype,O},G={}.hasOwnProperty;w=d$().isPlainObject,X=yq(),$=Yg(),J=m1(),D=_0(),F=hq(),Q=EQ(),Xh.exports=Y=function(O){Z(U,O);function U(z){if(U.__super__.constructor.call(this,null),this.name="#document",this.type=D.Document,this.documentURI=null,this.domConfig=new $,z||(z={}),!z.writer)z.writer=new Q;this.options=z,this.stringify=new F(z)}return Object.defineProperty(U.prototype,"implementation",{value:new X}),Object.defineProperty(U.prototype,"doctype",{get:function(){var z,q,B,K;K=this.children;for(q=0,B=K.length;q<B;q++)if(z=K[q],z.type===D.DocType)return z;return null}}),Object.defineProperty(U.prototype,"documentElement",{get:function(){return this.rootObject||null}}),Object.defineProperty(U.prototype,"inputEncoding",{get:function(){return null}}),Object.defineProperty(U.prototype,"strictErrorChecking",{get:function(){return!1}}),Object.defineProperty(U.prototype,"xmlEncoding",{get:function(){if(this.children.length!==0&&this.children[0].type===D.Declaration)return this.children[0].encoding;else return null}}),Object.defineProperty(U.prototype,"xmlStandalone",{get:function(){if(this.children.length!==0&&this.children[0].type===D.Declaration)return this.children[0].standalone==="yes";else return!1}}),Object.defineProperty(U.prototype,"xmlVersion",{get:function(){if(this.children.length!==0&&this.children[0].type===D.Declaration)return this.children[0].version;else return"1.0"}}),Object.defineProperty(U.prototype,"URL",{get:function(){return this.documentURI}}),Object.defineProperty(U.prototype,"origin",{get:function(){return null}}),Object.defineProperty(U.prototype,"compatMode",{get:function(){return null}}),Object.defineProperty(U.prototype,"characterSet",{get:function(){return null}}),Object.defineProperty(U.prototype,"contentType",{get:function(){return null}}),U.prototype.end=function(z){var q={};if(!z)z=this.options.writer;else if(w(z))q=z,z=this.options.writer;return z.document(this,z.filterOptions(q))},U.prototype.toString=function(z){return this.options.writer.document(this,this.options.writer.filterOptions(z))},U.prototype.createElement=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createDocumentFragment=function(){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createTextNode=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createComment=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createCDATASection=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createProcessingInstruction=function(z,q){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createAttribute=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createEntityReference=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.getElementsByTagName=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.importNode=function(z,q){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createElementNS=function(z,q){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createAttributeNS=function(z,q){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.getElementsByTagNameNS=function(z,q){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.getElementById=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.adoptNode=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.normalizeDocument=function(){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.renameNode=function(z,q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.getElementsByClassName=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createEvent=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createRange=function(){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createNodeIterator=function(z,q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createTreeWalker=function(z,q,B){throw Error("This DOM method is not implemented."+this.debugInfo())},U}(J)}).call($h)});var Qh=T((Jh,Yh)=>{(function(){var D,$,X,Y,J,Q,F,w,Z,G,O,U,z,q,B,K,M,L,I,W,N,V,R,C,A={}.hasOwnProperty;C=d$(),V=C.isObject,N=C.isFunction,R=C.isPlainObject,W=C.getValue,D=_0(),U=dq(),q=BQ(),Y=KQ(),J=WQ(),K=AQ(),I=RQ(),B=jQ(),G=HQ(),O=IQ(),Q=VQ(),w=NQ(),F=MQ(),Z=LQ(),X=bq(),L=hq(),M=EQ(),$=g3(),Yh.exports=z=function(){function _(v,S,h){var g;if(this.name="?xml",this.type=D.Document,v||(v={}),g={},!v.writer)v.writer=new M;else if(R(v.writer))g=v.writer,v.writer=new M;this.options=v,this.writer=v.writer,this.writerOptions=this.writer.filterOptions(g),this.stringify=new L(v),this.onDataCallback=S||function(){},this.onEndCallback=h||function(){},this.currentNode=null,this.currentLevel=-1,this.openTags={},this.documentStarted=!1,this.documentCompleted=!1,this.root=null}return _.prototype.createChildNode=function(v){var S,h,g,l,f,j,x,u;switch(v.type){case D.CData:this.cdata(v.value);break;case D.Comment:this.comment(v.value);break;case D.Element:g={},x=v.attribs;for(h in x){if(!A.call(x,h))continue;S=x[h],g[h]=S.value}this.node(v.name,g);break;case D.Dummy:this.dummy();break;case D.Raw:this.raw(v.value);break;case D.Text:this.text(v.value);break;case D.ProcessingInstruction:this.instruction(v.target,v.value);break;default:throw Error("This XML node type is not supported in a JS object: "+v.constructor.name)}u=v.children;for(f=0,j=u.length;f<j;f++)if(l=u[f],this.createChildNode(l),l.type===D.Element)this.up();return this},_.prototype.dummy=function(){return this},_.prototype.node=function(v,S,h){var g;if(v==null)throw Error("Missing node name.");if(this.root&&this.currentLevel===-1)throw Error("Document can only have one root node. "+this.debugInfo(v));if(this.openCurrent(),v=W(v),S==null)S={};if(S=W(S),!V(S))g=[S,h],h=g[0],S=g[1];if(this.currentNode=new q(this,v,S),this.currentNode.children=!1,this.currentLevel++,this.openTags[this.currentLevel]=this.currentNode,h!=null)this.text(h);return this},_.prototype.element=function(v,S,h){var g,l,f,j,x,u;if(this.currentNode&&this.currentNode.type===D.DocType)this.dtdElement.apply(this,arguments);else if(Array.isArray(v)||V(v)||N(v)){j=this.options.noValidation,this.options.noValidation=!0,u=new U(this.options).element("TEMP_ROOT"),u.element(v),this.options.noValidation=j,x=u.children;for(l=0,f=x.length;l<f;l++)if(g=x[l],this.createChildNode(g),g.type===D.Element)this.up()}else this.node(v,S,h);return this},_.prototype.attribute=function(v,S){var h,g;if(!this.currentNode||this.currentNode.children)throw Error("att() can only be used immediately after an ele() call in callback mode. "+this.debugInfo(v));if(v!=null)v=W(v);if(V(v))for(h in v){if(!A.call(v,h))continue;g=v[h],this.attribute(h,g)}else{if(N(S))S=S.apply();if(this.options.keepNullAttributes&&S==null)this.currentNode.attribs[v]=new X(this,v,"");else if(S!=null)this.currentNode.attribs[v]=new X(this,v,S)}return this},_.prototype.text=function(v){var S;return this.openCurrent(),S=new I(this,v),this.onData(this.writer.text(S,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},_.prototype.cdata=function(v){var S;return this.openCurrent(),S=new Y(this,v),this.onData(this.writer.cdata(S,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},_.prototype.comment=function(v){var S;return this.openCurrent(),S=new J(this,v),this.onData(this.writer.comment(S,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},_.prototype.raw=function(v){var S;return this.openCurrent(),S=new K(this,v),this.onData(this.writer.raw(S,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},_.prototype.instruction=function(v,S){var h,g,l,f,j;if(this.openCurrent(),v!=null)v=W(v);if(S!=null)S=W(S);if(Array.isArray(v))for(h=0,f=v.length;h<f;h++)g=v[h],this.instruction(g);else if(V(v))for(g in v){if(!A.call(v,g))continue;l=v[g],this.instruction(g,l)}else{if(N(S))S=S.apply();j=new B(this,v,S),this.onData(this.writer.processingInstruction(j,this.writerOptions,this.currentLevel+1),this.currentLevel+1)}return this},_.prototype.declaration=function(v,S,h){var g;if(this.openCurrent(),this.documentStarted)throw Error("declaration() must be the first node.");return g=new G(this,v,S,h),this.onData(this.writer.declaration(g,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},_.prototype.doctype=function(v,S,h){if(this.openCurrent(),v==null)throw Error("Missing root node name.");if(this.root)throw Error("dtd() must come before the root node.");return this.currentNode=new O(this,S,h),this.currentNode.rootNodeName=v,this.currentNode.children=!1,this.currentLevel++,this.openTags[this.currentLevel]=this.currentNode,this},_.prototype.dtdElement=function(v,S){var h;return this.openCurrent(),h=new F(this,v,S),this.onData(this.writer.dtdElement(h,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},_.prototype.attList=function(v,S,h,g,l){var f;return this.openCurrent(),f=new Q(this,v,S,h,g,l),this.onData(this.writer.dtdAttList(f,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},_.prototype.entity=function(v,S){var h;return this.openCurrent(),h=new w(this,!1,v,S),this.onData(this.writer.dtdEntity(h,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},_.prototype.pEntity=function(v,S){var h;return this.openCurrent(),h=new w(this,!0,v,S),this.onData(this.writer.dtdEntity(h,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},_.prototype.notation=function(v,S){var h;return this.openCurrent(),h=new Z(this,v,S),this.onData(this.writer.dtdNotation(h,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},_.prototype.up=function(){if(this.currentLevel<0)throw Error("The document node has no parent.");if(this.currentNode){if(this.currentNode.children)this.closeNode(this.currentNode);else this.openNode(this.currentNode);this.currentNode=null}else this.closeNode(this.openTags[this.currentLevel]);return delete this.openTags[this.currentLevel],this.currentLevel--,this},_.prototype.end=function(){while(this.currentLevel>=0)this.up();return this.onEnd()},_.prototype.openCurrent=function(){if(this.currentNode)return this.currentNode.children=!0,this.openNode(this.currentNode)},_.prototype.openNode=function(v){var S,h,g,l;if(!v.isOpen){if(!this.root&&this.currentLevel===0&&v.type===D.Element)this.root=v;if(h="",v.type===D.Element){this.writerOptions.state=$.OpenTag,h=this.writer.indent(v,this.writerOptions,this.currentLevel)+"<"+v.name,l=v.attribs;for(g in l){if(!A.call(l,g))continue;S=l[g],h+=this.writer.attribute(S,this.writerOptions,this.currentLevel)}h+=(v.children?">":"/>")+this.writer.endline(v,this.writerOptions,this.currentLevel),this.writerOptions.state=$.InsideTag}else{if(this.writerOptions.state=$.OpenTag,h=this.writer.indent(v,this.writerOptions,this.currentLevel)+"<!DOCTYPE "+v.rootNodeName,v.pubID&&v.sysID)h+=' PUBLIC "'+v.pubID+'" "'+v.sysID+'"';else if(v.sysID)h+=' SYSTEM "'+v.sysID+'"';if(v.children)h+=" [",this.writerOptions.state=$.InsideTag;else this.writerOptions.state=$.CloseTag,h+=">";h+=this.writer.endline(v,this.writerOptions,this.currentLevel)}return this.onData(h,this.currentLevel),v.isOpen=!0}},_.prototype.closeNode=function(v){var S;if(!v.isClosed){if(S="",this.writerOptions.state=$.CloseTag,v.type===D.Element)S=this.writer.indent(v,this.writerOptions,this.currentLevel)+"</"+v.name+">"+this.writer.endline(v,this.writerOptions,this.currentLevel);else S=this.writer.indent(v,this.writerOptions,this.currentLevel)+"]>"+this.writer.endline(v,this.writerOptions,this.currentLevel);return this.writerOptions.state=$.None,this.onData(S,this.currentLevel),v.isClosed=!0}},_.prototype.onData=function(v,S){return this.documentStarted=!0,this.onDataCallback(v,S+1)},_.prototype.onEnd=function(){return this.documentCompleted=!0,this.onEndCallback()},_.prototype.debugInfo=function(v){if(v==null)return"";else return"node: <"+v+">"},_.prototype.ele=function(){return this.element.apply(this,arguments)},_.prototype.nod=function(v,S,h){return this.node(v,S,h)},_.prototype.txt=function(v){return this.text(v)},_.prototype.dat=function(v){return this.cdata(v)},_.prototype.com=function(v){return this.comment(v)},_.prototype.ins=function(v,S){return this.instruction(v,S)},_.prototype.dec=function(v,S,h){return this.declaration(v,S,h)},_.prototype.dtd=function(v,S,h){return this.doctype(v,S,h)},_.prototype.e=function(v,S,h){return this.element(v,S,h)},_.prototype.n=function(v,S,h){return this.node(v,S,h)},_.prototype.t=function(v){return this.text(v)},_.prototype.d=function(v){return this.cdata(v)},_.prototype.c=function(v){return this.comment(v)},_.prototype.r=function(v){return this.raw(v)},_.prototype.i=function(v,S){return this.instruction(v,S)},_.prototype.att=function(){if(this.currentNode&&this.currentNode.type===D.DocType)return this.attList.apply(this,arguments);else return this.attribute.apply(this,arguments)},_.prototype.a=function(){if(this.currentNode&&this.currentNode.type===D.DocType)return this.attList.apply(this,arguments);else return this.attribute.apply(this,arguments)},_.prototype.ent=function(v,S){return this.entity(v,S)},_.prototype.pent=function(v,S){return this.pEntity(v,S)},_.prototype.not=function(v,S){return this.notation(v,S)},_}()}).call(Jh)});var Zh=T((Fh,wh)=>{(function(){var D,$,X,Y,J=function(F,w){for(var Z in w)if(Q.call(w,Z))F[Z]=w[Z];function G(){this.constructor=F}return G.prototype=w.prototype,F.prototype=new G,F.__super__=w.prototype,F},Q={}.hasOwnProperty;D=_0(),Y=mq(),$=g3(),wh.exports=X=function(F){J(w,F);function w(Z,G){this.stream=Z,w.__super__.constructor.call(this,G)}return w.prototype.endline=function(Z,G,O){if(Z.isLastRootNode&&G.state===$.CloseTag)return"";else return w.__super__.endline.call(this,Z,G,O)},w.prototype.document=function(Z,G){var O,U,z,q,B,K,M,L,I;M=Z.children;for(U=z=0,B=M.length;z<B;U=++z)O=M[U],O.isLastRootNode=U===Z.children.length-1;G=this.filterOptions(G),L=Z.children,I=[];for(q=0,K=L.length;q<K;q++)O=L[q],I.push(this.writeChildNode(O,G,0));return I},w.prototype.attribute=function(Z,G,O){return this.stream.write(w.__super__.attribute.call(this,Z,G,O))},w.prototype.cdata=function(Z,G,O){return this.stream.write(w.__super__.cdata.call(this,Z,G,O))},w.prototype.comment=function(Z,G,O){return this.stream.write(w.__super__.comment.call(this,Z,G,O))},w.prototype.declaration=function(Z,G,O){return this.stream.write(w.__super__.declaration.call(this,Z,G,O))},w.prototype.docType=function(Z,G,O){var U,z,q,B;if(O||(O=0),this.openNode(Z,G,O),G.state=$.OpenTag,this.stream.write(this.indent(Z,G,O)),this.stream.write("<!DOCTYPE "+Z.root().name),Z.pubID&&Z.sysID)this.stream.write(' PUBLIC "'+Z.pubID+'" "'+Z.sysID+'"');else if(Z.sysID)this.stream.write(' SYSTEM "'+Z.sysID+'"');if(Z.children.length>0){this.stream.write(" ["),this.stream.write(this.endline(Z,G,O)),G.state=$.InsideTag,B=Z.children;for(z=0,q=B.length;z<q;z++)U=B[z],this.writeChildNode(U,G,O+1);G.state=$.CloseTag,this.stream.write("]")}return G.state=$.CloseTag,this.stream.write(G.spaceBeforeSlash+">"),this.stream.write(this.endline(Z,G,O)),G.state=$.None,this.closeNode(Z,G,O)},w.prototype.element=function(Z,G,O){var U,z,q,B,K,M,L,I,W,N;O||(O=0),this.openNode(Z,G,O),G.state=$.OpenTag,this.stream.write(this.indent(Z,G,O)+"<"+Z.name),W=Z.attribs;for(L in W){if(!Q.call(W,L))continue;U=W[L],this.attribute(U,G,O)}if(q=Z.children.length,B=q===0?null:Z.children[0],q===0||Z.children.every(function(V){return(V.type===D.Text||V.type===D.Raw)&&V.value===""}))if(G.allowEmpty)this.stream.write(">"),G.state=$.CloseTag,this.stream.write("</"+Z.name+">");else G.state=$.CloseTag,this.stream.write(G.spaceBeforeSlash+"/>");else if(G.pretty&&q===1&&(B.type===D.Text||B.type===D.Raw)&&B.value!=null)this.stream.write(">"),G.state=$.InsideTag,G.suppressPrettyCount++,I=!0,this.writeChildNode(B,G,O+1),G.suppressPrettyCount--,I=!1,G.state=$.CloseTag,this.stream.write("</"+Z.name+">");else{this.stream.write(">"+this.endline(Z,G,O)),G.state=$.InsideTag,N=Z.children;for(K=0,M=N.length;K<M;K++)z=N[K],this.writeChildNode(z,G,O+1);G.state=$.CloseTag,this.stream.write(this.indent(Z,G,O)+"</"+Z.name+">")}return this.stream.write(this.endline(Z,G,O)),G.state=$.None,this.closeNode(Z,G,O)},w.prototype.processingInstruction=function(Z,G,O){return this.stream.write(w.__super__.processingInstruction.call(this,Z,G,O))},w.prototype.raw=function(Z,G,O){return this.stream.write(w.__super__.raw.call(this,Z,G,O))},w.prototype.text=function(Z,G,O){return this.stream.write(w.__super__.text.call(this,Z,G,O))},w.prototype.dtdAttList=function(Z,G,O){return this.stream.write(w.__super__.dtdAttList.call(this,Z,G,O))},w.prototype.dtdElement=function(Z,G,O){return this.stream.write(w.__super__.dtdElement.call(this,Z,G,O))},w.prototype.dtdEntity=function(Z,G,O){return this.stream.write(w.__super__.dtdEntity.call(this,Z,G,O))},w.prototype.dtdNotation=function(Z,G,O){return this.stream.write(w.__super__.dtdNotation.call(this,Z,G,O))},w}(Y)}).call(Fh)});var Oh=T((Gh,Y4)=>{(function(){var D,$,X,Y,J,Q,F,w,Z,G;G=d$(),w=G.assign,Z=G.isFunction,X=yq(),Y=dq(),J=Qh(),F=EQ(),Q=Zh(),D=_0(),$=g3(),Gh.create=function(O,U,z,q){var B,K;if(O==null)throw Error("Root element needs a name.");if(q=w({},U,z,q),B=new Y(q),K=B.element(O),!q.headless){if(B.declaration(q),q.pubID!=null||q.sysID!=null)B.dtd(q)}return K},Gh.begin=function(O,U,z){var q;if(Z(O))q=[O,U],U=q[0],z=q[1],O={};if(U)return new J(O,U,z);else return new Y(O)},Gh.stringWriter=function(O){return new F(O)},Gh.streamWriter=function(O,U){return new Q(O,U)},Gh.implementation=new X,Gh.nodeType=D,Gh.writerState=$}).call(Gh)});var qh=T((Uh)=>{(function(){var D,$,X,Y,J,Q={}.hasOwnProperty;D=Oh(),$=qQ().defaults,Y=function(F){return typeof F==="string"&&(F.indexOf("&")>=0||F.indexOf(">")>=0||F.indexOf("<")>=0)},J=function(F){return"<![CDATA["+X(F)+"]]>"},X=function(F){return F.replace("]]>","]]]]><![CDATA[>")},Uh.Builder=function(){function F(w){var Z,G,O;this.options={},G=$["0.2"];for(Z in G){if(!Q.call(G,Z))continue;O=G[Z],this.options[Z]=O}for(Z in w){if(!Q.call(w,Z))continue;O=w[Z],this.options[Z]=O}}return F.prototype.buildObject=function(w){var Z,G,O,U,z;if(Z=this.options.attrkey,G=this.options.charkey,Object.keys(w).length===1&&this.options.rootName===$["0.2"].rootName)z=Object.keys(w)[0],w=w[z];else z=this.options.rootName;return O=function(q){return function(B,K){var M,L,I,W,N,V;if(typeof K!=="object")if(q.options.cdata&&Y(K))B.raw(J(K));else B.txt(K);else if(Array.isArray(K))for(W in K){if(!Q.call(K,W))continue;L=K[W];for(N in L)I=L[N],B=O(B.ele(N),I).up()}else for(N in K){if(!Q.call(K,N))continue;if(L=K[N],N===Z){if(typeof L==="object")for(M in L)V=L[M],B=B.att(M,V)}else if(N===G)if(q.options.cdata&&Y(L))B=B.raw(J(L));else B=B.txt(L);else if(Array.isArray(L))for(W in L){if(!Q.call(L,W))continue;if(I=L[W],typeof I==="string")if(q.options.cdata&&Y(I))B=B.ele(N).raw(J(I)).up();else B=B.ele(N,I).up();else B=O(B.ele(N),I).up()}else if(typeof L==="object")B=O(B.ele(N),L).up();else if(typeof L==="string"&&q.options.cdata&&Y(L))B=B.ele(N).raw(J(L)).up();else{if(L==null)L="";B=B.ele(N,L.toString()).up()}}return B}}(this),U=D.create(z,this.options.xmldec,this.options.doctype,{headless:this.options.headless,allowSurrogateChars:this.options.allowSurrogateChars}),O(U,w).end(this.options.renderOpts)},F}()}).call(Uh)});var zh=T((TQ)=>{(function(D){D.parser=function(P,E){return new X(P,E)},D.SAXParser=X,D.SAXStream=G,D.createStream=Z,D.MAX_BUFFER_LENGTH=65536;var $=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];D.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function X(P,E){if(!(this instanceof X))return new X(P,E);var r=this;if(J(r),r.q=r.c="",r.bufferCheckPosition=D.MAX_BUFFER_LENGTH,r.opt=E||{},r.opt.lowercase=r.opt.lowercase||r.opt.lowercasetags,r.looseCase=r.opt.lowercase?"toLowerCase":"toUpperCase",r.tags=[],r.closed=r.closedRoot=r.sawRoot=!1,r.tag=r.error=null,r.strict=!!P,r.noscript=!!(P||r.opt.noscript),r.state=A.BEGIN,r.strictEntities=r.opt.strictEntities,r.ENTITIES=r.strictEntities?Object.create(D.XML_ENTITIES):Object.create(D.ENTITIES),r.attribList=[],r.opt.xmlns)r.ns=Object.create(B);if(r.opt.unquotedAttributeValues===void 0)r.opt.unquotedAttributeValues=!P;if(r.trackPosition=r.opt.position!==!1,r.trackPosition)r.position=r.line=r.column=0;v(r,"onready")}if(!Object.create)Object.create=function(P){function E(){}E.prototype=P;var r=new E;return r};if(!Object.keys)Object.keys=function(P){var E=[];for(var r in P)if(P.hasOwnProperty(r))E.push(r);return E};function Y(P){var E=Math.max(D.MAX_BUFFER_LENGTH,10),r=0;for(var k=0,zD=$.length;k<zD;k++){var t=P[$[k]].length;if(t>E)switch($[k]){case"textNode":h(P);break;case"cdata":S(P,"oncdata",P.cdata),P.cdata="";break;case"script":S(P,"onscript",P.script),P.script="";break;default:l(P,"Max buffer length exceeded: "+$[k])}r=Math.max(r,t)}var KD=D.MAX_BUFFER_LENGTH-r;P.bufferCheckPosition=KD+P.position}function J(P){for(var E=0,r=$.length;E<r;E++)P[$[E]]=""}function Q(P){if(h(P),P.cdata!=="")S(P,"oncdata",P.cdata),P.cdata="";if(P.script!=="")S(P,"onscript",P.script),P.script=""}X.prototype={end:function(){f(this)},write:YD,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){Q(this)}};var F;try{F=p("stream").Stream}catch(P){F=function(){}}if(!F)F=function(){};var w=D.EVENTS.filter(function(P){return P!=="error"&&P!=="end"});function Z(P,E){return new G(P,E)}function G(P,E){if(!(this instanceof G))return new G(P,E);F.apply(this),this._parser=new X(P,E),this.writable=!0,this.readable=!0;var r=this;this._parser.onend=function(){r.emit("end")},this._parser.onerror=function(k){r.emit("error",k),r._parser.error=null},this._decoder=null,w.forEach(function(k){Object.defineProperty(r,"on"+k,{get:function(){return r._parser["on"+k]},set:function(zD){if(!zD)return r.removeAllListeners(k),r._parser["on"+k]=zD,zD;r.on(k,zD)},enumerable:!0,configurable:!1})})}G.prototype=Object.create(F.prototype,{constructor:{value:G}}),G.prototype.write=function(P){if(typeof Buffer==="function"&&typeof Buffer.isBuffer==="function"&&Buffer.isBuffer(P)){if(!this._decoder)this._decoder=new TextDecoder("utf8");P=this._decoder.decode(P,{stream:!0})}return this._parser.write(P.toString()),this.emit("data",P),!0},G.prototype.end=function(P){if(P&&P.length)this.write(P);if(this._decoder){var E=this._decoder.decode();if(E)this._parser.write(E),this.emit("data",E)}return this._parser.end(),!0},G.prototype.on=function(P,E){var r=this;if(!r._parser["on"+P]&&w.indexOf(P)!==-1)r._parser["on"+P]=function(){var k=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);k.splice(0,0,P),r.emit.apply(r,k)};return F.prototype.on.call(r,P,E)};var O="[CDATA[",U="DOCTYPE",z="http://www.w3.org/XML/1998/namespace",q="http://www.w3.org/2000/xmlns/",B={xml:z,xmlns:q},K=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,M=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,L=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,I=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function W(P){return P===" "||P===`
260
+ `||P==="\r"||P==="\t"}function N(P){return P==='"'||P==="'"}function V(P){return P===">"||W(P)}function R(P,E){return P.test(E)}function C(P,E){return!R(P,E)}var A=0;D.STATE={BEGIN:A++,BEGIN_WHITESPACE:A++,TEXT:A++,TEXT_ENTITY:A++,OPEN_WAKA:A++,SGML_DECL:A++,SGML_DECL_QUOTED:A++,DOCTYPE:A++,DOCTYPE_QUOTED:A++,DOCTYPE_DTD:A++,DOCTYPE_DTD_QUOTED:A++,COMMENT_STARTING:A++,COMMENT:A++,COMMENT_ENDING:A++,COMMENT_ENDED:A++,CDATA:A++,CDATA_ENDING:A++,CDATA_ENDING_2:A++,PROC_INST:A++,PROC_INST_BODY:A++,PROC_INST_ENDING:A++,OPEN_TAG:A++,OPEN_TAG_SLASH:A++,ATTRIB:A++,ATTRIB_NAME:A++,ATTRIB_NAME_SAW_WHITE:A++,ATTRIB_VALUE:A++,ATTRIB_VALUE_QUOTED:A++,ATTRIB_VALUE_CLOSED:A++,ATTRIB_VALUE_UNQUOTED:A++,ATTRIB_VALUE_ENTITY_Q:A++,ATTRIB_VALUE_ENTITY_U:A++,CLOSE_TAG:A++,CLOSE_TAG_SAW_WHITE:A++,SCRIPT:A++,SCRIPT_ENDING:A++},D.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},D.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(D.ENTITIES).forEach(function(P){var E=D.ENTITIES[P],r=typeof E==="number"?String.fromCharCode(E):E;D.ENTITIES[P]=r});for(var _ in D.STATE)D.STATE[D.STATE[_]]=_;A=D.STATE;function v(P,E,r){P[E]&&P[E](r)}function S(P,E,r){if(P.textNode)h(P);v(P,E,r)}function h(P){if(P.textNode=g(P.opt,P.textNode),P.textNode)v(P,"ontext",P.textNode);P.textNode=""}function g(P,E){if(P.trim)E=E.trim();if(P.normalize)E=E.replace(/\s+/g," ");return E}function l(P,E){if(h(P),P.trackPosition)E+=`
261
+ Line: `+P.line+`
262
+ Column: `+P.column+`
263
+ Char: `+P.c;return E=Error(E),P.error=E,v(P,"onerror",E),P}function f(P){if(P.sawRoot&&!P.closedRoot)j(P,"Unclosed root tag");if(P.state!==A.BEGIN&&P.state!==A.BEGIN_WHITESPACE&&P.state!==A.TEXT)l(P,"Unexpected end");return h(P),P.c="",P.closed=!0,v(P,"onend"),X.call(P,P.strict,P.opt),P}function j(P,E){if(typeof P!=="object"||!(P instanceof X))throw Error("bad call to strictFail");if(P.strict)l(P,E)}function x(P){if(!P.strict)P.tagName=P.tagName[P.looseCase]();var E=P.tags[P.tags.length-1]||P,r=P.tag={name:P.tagName,attributes:{}};if(P.opt.xmlns)r.ns=E.ns;P.attribList.length=0,S(P,"onopentagstart",r)}function u(P,E){var r=P.indexOf(":"),k=r<0?["",P]:P.split(":"),zD=k[0],t=k[1];if(E&&P==="xmlns")zD="xmlns",t="";return{prefix:zD,local:t}}function y(P){if(!P.strict)P.attribName=P.attribName[P.looseCase]();if(P.attribList.indexOf(P.attribName)!==-1||P.tag.attributes.hasOwnProperty(P.attribName)){P.attribName=P.attribValue="";return}if(P.opt.xmlns){var E=u(P.attribName,!0),r=E.prefix,k=E.local;if(r==="xmlns")if(k==="xml"&&P.attribValue!==z)j(P,"xml: prefix must be bound to "+z+`
264
+ Actual: `+P.attribValue);else if(k==="xmlns"&&P.attribValue!==q)j(P,"xmlns: prefix must be bound to "+q+`
265
+ Actual: `+P.attribValue);else{var zD=P.tag,t=P.tags[P.tags.length-1]||P;if(zD.ns===t.ns)zD.ns=Object.create(t.ns);zD.ns[k]=P.attribValue}P.attribList.push([P.attribName,P.attribValue])}else P.tag.attributes[P.attribName]=P.attribValue,S(P,"onattribute",{name:P.attribName,value:P.attribValue});P.attribName=P.attribValue=""}function d(P,E){if(P.opt.xmlns){var r=P.tag,k=u(P.tagName);if(r.prefix=k.prefix,r.local=k.local,r.uri=r.ns[k.prefix]||"",r.prefix&&!r.uri)j(P,"Unbound namespace prefix: "+JSON.stringify(P.tagName)),r.uri=k.prefix;var zD=P.tags[P.tags.length-1]||P;if(r.ns&&zD.ns!==r.ns)Object.keys(r.ns).forEach(function(gL){S(P,"onopennamespace",{prefix:gL,uri:r.ns[gL]})});for(var t=0,KD=P.attribList.length;t<KD;t++){var uD=P.attribList[t],hD=uD[0],X0=uD[1],v0=u(hD,!0),E1=v0.prefix,bDD=v0.local,bL=E1===""?"":r.ns[E1]||"",nZ={name:hD,value:X0,prefix:E1,local:bDD,uri:bL};if(E1&&E1!=="xmlns"&&!bL)j(P,"Unbound namespace prefix: "+JSON.stringify(E1)),nZ.uri=E1;P.tag.attributes[hD]=nZ,S(P,"onattribute",nZ)}P.attribList.length=0}if(P.tag.isSelfClosing=!!E,P.sawRoot=!0,P.tags.push(P.tag),S(P,"onopentag",P.tag),!E){if(!P.noscript&&P.tagName.toLowerCase()==="script")P.state=A.SCRIPT;else P.state=A.TEXT;P.tag=null,P.tagName=""}P.attribName=P.attribValue="",P.attribList.length=0}function b(P){if(!P.tagName){j(P,"Weird empty close tag."),P.textNode+="</>",P.state=A.TEXT;return}if(P.script){if(P.tagName!=="script"){P.script+="</"+P.tagName+">",P.tagName="",P.state=A.SCRIPT;return}S(P,"onscript",P.script),P.script=""}var E=P.tags.length,r=P.tagName;if(!P.strict)r=r[P.looseCase]();var k=r;while(E--){var zD=P.tags[E];if(zD.name!==k)j(P,"Unexpected close tag");else break}if(E<0){j(P,"Unmatched closing tag: "+P.tagName),P.textNode+="</"+P.tagName+">",P.state=A.TEXT;return}P.tagName=r;var t=P.tags.length;while(t-- >E){var KD=P.tag=P.tags.pop();P.tagName=P.tag.name,S(P,"onclosetag",P.tagName);var uD={};for(var hD in KD.ns)uD[hD]=KD.ns[hD];var X0=P.tags[P.tags.length-1]||P;if(P.opt.xmlns&&KD.ns!==X0.ns)Object.keys(KD.ns).forEach(function(v0){var E1=KD.ns[v0];S(P,"onclosenamespace",{prefix:v0,uri:E1})})}if(E===0)P.closedRoot=!0;P.tagName=P.attribValue=P.attribName="",P.attribList.length=0,P.state=A.TEXT}function a(P){var E=P.entity,r=E.toLowerCase(),k,zD="";if(P.ENTITIES[E])return P.ENTITIES[E];if(P.ENTITIES[r])return P.ENTITIES[r];if(E=r,E.charAt(0)==="#")if(E.charAt(1)==="x")E=E.slice(2),k=parseInt(E,16),zD=k.toString(16);else E=E.slice(1),k=parseInt(E,10),zD=k.toString(10);if(E=E.replace(/^0+/,""),isNaN(k)||zD.toLowerCase()!==E||k<0||k>1114111)return j(P,"Invalid character entity"),"&"+P.entity+";";return String.fromCodePoint(k)}function c(P,E){if(E==="<")P.state=A.OPEN_WAKA,P.startTagPosition=P.position;else if(!W(E))j(P,"Non-whitespace before first tag."),P.textNode=E,P.state=A.TEXT}function n(P,E){var r="";if(E<P.length)r=P.charAt(E);return r}function YD(P){var E=this;if(this.error)throw this.error;if(E.closed)return l(E,"Cannot write after close. Assign an onready handler.");if(P===null)return f(E);if(typeof P==="object")P=P.toString();var r=0,k="";while(!0){if(k=n(P,r++),E.c=k,!k)break;if(E.trackPosition)if(E.position++,k===`
266
+ `)E.line++,E.column=0;else E.column++;switch(E.state){case A.BEGIN:if(E.state=A.BEGIN_WHITESPACE,k==="\uFEFF")continue;c(E,k);continue;case A.BEGIN_WHITESPACE:c(E,k);continue;case A.TEXT:if(E.sawRoot&&!E.closedRoot){var t=r-1;while(k&&k!=="<"&&k!=="&")if(k=n(P,r++),k&&E.trackPosition)if(E.position++,k===`
267
+ `)E.line++,E.column=0;else E.column++;E.textNode+=P.substring(t,r-1)}if(k==="<"&&!(E.sawRoot&&E.closedRoot&&!E.strict))E.state=A.OPEN_WAKA,E.startTagPosition=E.position;else{if(!W(k)&&(!E.sawRoot||E.closedRoot))j(E,"Text data outside of root node.");if(k==="&")E.state=A.TEXT_ENTITY;else E.textNode+=k}continue;case A.SCRIPT:if(k==="<")E.state=A.SCRIPT_ENDING;else E.script+=k;continue;case A.SCRIPT_ENDING:if(k==="/")E.state=A.CLOSE_TAG;else E.script+="<"+k,E.state=A.SCRIPT;continue;case A.OPEN_WAKA:if(k==="!")E.state=A.SGML_DECL,E.sgmlDecl="";else if(W(k));else if(R(K,k))E.state=A.OPEN_TAG,E.tagName=k;else if(k==="/")E.state=A.CLOSE_TAG,E.tagName="";else if(k==="?")E.state=A.PROC_INST,E.procInstName=E.procInstBody="";else{if(j(E,"Unencoded <"),E.startTagPosition+1<E.position){var zD=E.position-E.startTagPosition;k=Array(zD).join(" ")+k}E.textNode+="<"+k,E.state=A.TEXT}continue;case A.SGML_DECL:if(E.sgmlDecl+k==="--"){E.state=A.COMMENT,E.comment="",E.sgmlDecl="";continue}if(E.doctype&&E.doctype!==!0&&E.sgmlDecl)E.state=A.DOCTYPE_DTD,E.doctype+="<!"+E.sgmlDecl+k,E.sgmlDecl="";else if((E.sgmlDecl+k).toUpperCase()===O)S(E,"onopencdata"),E.state=A.CDATA,E.sgmlDecl="",E.cdata="";else if((E.sgmlDecl+k).toUpperCase()===U){if(E.state=A.DOCTYPE,E.doctype||E.sawRoot)j(E,"Inappropriately located doctype declaration");E.doctype="",E.sgmlDecl=""}else if(k===">")S(E,"onsgmldeclaration",E.sgmlDecl),E.sgmlDecl="",E.state=A.TEXT;else if(N(k))E.state=A.SGML_DECL_QUOTED,E.sgmlDecl+=k;else E.sgmlDecl+=k;continue;case A.SGML_DECL_QUOTED:if(k===E.q)E.state=A.SGML_DECL,E.q="";E.sgmlDecl+=k;continue;case A.DOCTYPE:if(k===">")E.state=A.TEXT,S(E,"ondoctype",E.doctype),E.doctype=!0;else if(E.doctype+=k,k==="[")E.state=A.DOCTYPE_DTD;else if(N(k))E.state=A.DOCTYPE_QUOTED,E.q=k;continue;case A.DOCTYPE_QUOTED:if(E.doctype+=k,k===E.q)E.q="",E.state=A.DOCTYPE;continue;case A.DOCTYPE_DTD:if(k==="]")E.doctype+=k,E.state=A.DOCTYPE;else if(k==="<")E.state=A.OPEN_WAKA,E.startTagPosition=E.position;else if(N(k))E.doctype+=k,E.state=A.DOCTYPE_DTD_QUOTED,E.q=k;else E.doctype+=k;continue;case A.DOCTYPE_DTD_QUOTED:if(E.doctype+=k,k===E.q)E.state=A.DOCTYPE_DTD,E.q="";continue;case A.COMMENT:if(k==="-")E.state=A.COMMENT_ENDING;else E.comment+=k;continue;case A.COMMENT_ENDING:if(k==="-"){if(E.state=A.COMMENT_ENDED,E.comment=g(E.opt,E.comment),E.comment)S(E,"oncomment",E.comment);E.comment=""}else E.comment+="-"+k,E.state=A.COMMENT;continue;case A.COMMENT_ENDED:if(k!==">")j(E,"Malformed comment"),E.comment+="--"+k,E.state=A.COMMENT;else if(E.doctype&&E.doctype!==!0)E.state=A.DOCTYPE_DTD;else E.state=A.TEXT;continue;case A.CDATA:var t=r-1;while(k&&k!=="]")if(k=n(P,r++),k&&E.trackPosition)if(E.position++,k===`
268
+ `)E.line++,E.column=0;else E.column++;if(E.cdata+=P.substring(t,r-1),k==="]")E.state=A.CDATA_ENDING;continue;case A.CDATA_ENDING:if(k==="]")E.state=A.CDATA_ENDING_2;else E.cdata+="]"+k,E.state=A.CDATA;continue;case A.CDATA_ENDING_2:if(k===">"){if(E.cdata)S(E,"oncdata",E.cdata);S(E,"onclosecdata"),E.cdata="",E.state=A.TEXT}else if(k==="]")E.cdata+="]";else E.cdata+="]]"+k,E.state=A.CDATA;continue;case A.PROC_INST:if(k==="?")E.state=A.PROC_INST_ENDING;else if(W(k))E.state=A.PROC_INST_BODY;else E.procInstName+=k;continue;case A.PROC_INST_BODY:if(!E.procInstBody&&W(k))continue;else if(k==="?")E.state=A.PROC_INST_ENDING;else E.procInstBody+=k;continue;case A.PROC_INST_ENDING:if(k===">")S(E,"onprocessinginstruction",{name:E.procInstName,body:E.procInstBody}),E.procInstName=E.procInstBody="",E.state=A.TEXT;else E.procInstBody+="?"+k,E.state=A.PROC_INST_BODY;continue;case A.OPEN_TAG:if(R(M,k))E.tagName+=k;else if(x(E),k===">")d(E);else if(k==="/")E.state=A.OPEN_TAG_SLASH;else{if(!W(k))j(E,"Invalid character in tag name");E.state=A.ATTRIB}continue;case A.OPEN_TAG_SLASH:if(k===">")d(E,!0),b(E);else j(E,"Forward-slash in opening tag not followed by >"),E.state=A.ATTRIB;continue;case A.ATTRIB:if(W(k))continue;else if(k===">")d(E);else if(k==="/")E.state=A.OPEN_TAG_SLASH;else if(R(K,k))E.attribName=k,E.attribValue="",E.state=A.ATTRIB_NAME;else j(E,"Invalid attribute name");continue;case A.ATTRIB_NAME:if(k==="=")E.state=A.ATTRIB_VALUE;else if(k===">")j(E,"Attribute without value"),E.attribValue=E.attribName,y(E),d(E);else if(W(k))E.state=A.ATTRIB_NAME_SAW_WHITE;else if(R(M,k))E.attribName+=k;else j(E,"Invalid attribute name");continue;case A.ATTRIB_NAME_SAW_WHITE:if(k==="=")E.state=A.ATTRIB_VALUE;else if(W(k))continue;else if(j(E,"Attribute without value"),E.tag.attributes[E.attribName]="",E.attribValue="",S(E,"onattribute",{name:E.attribName,value:""}),E.attribName="",k===">")d(E);else if(R(K,k))E.attribName=k,E.state=A.ATTRIB_NAME;else j(E,"Invalid attribute name"),E.state=A.ATTRIB;continue;case A.ATTRIB_VALUE:if(W(k))continue;else if(N(k))E.q=k,E.state=A.ATTRIB_VALUE_QUOTED;else{if(!E.opt.unquotedAttributeValues)l(E,"Unquoted attribute value");E.state=A.ATTRIB_VALUE_UNQUOTED,E.attribValue=k}continue;case A.ATTRIB_VALUE_QUOTED:if(k!==E.q){if(k==="&")E.state=A.ATTRIB_VALUE_ENTITY_Q;else E.attribValue+=k;continue}y(E),E.q="",E.state=A.ATTRIB_VALUE_CLOSED;continue;case A.ATTRIB_VALUE_CLOSED:if(W(k))E.state=A.ATTRIB;else if(k===">")d(E);else if(k==="/")E.state=A.OPEN_TAG_SLASH;else if(R(K,k))j(E,"No whitespace between attributes"),E.attribName=k,E.attribValue="",E.state=A.ATTRIB_NAME;else j(E,"Invalid attribute name");continue;case A.ATTRIB_VALUE_UNQUOTED:if(!V(k)){if(k==="&")E.state=A.ATTRIB_VALUE_ENTITY_U;else E.attribValue+=k;continue}if(y(E),k===">")d(E);else E.state=A.ATTRIB;continue;case A.CLOSE_TAG:if(!E.tagName)if(W(k))continue;else if(C(K,k))if(E.script)E.script+="</"+k,E.state=A.SCRIPT;else j(E,"Invalid tagname in closing tag.");else E.tagName=k;else if(k===">")b(E);else if(R(M,k))E.tagName+=k;else if(E.script)E.script+="</"+E.tagName+k,E.tagName="",E.state=A.SCRIPT;else{if(!W(k))j(E,"Invalid tagname in closing tag");E.state=A.CLOSE_TAG_SAW_WHITE}continue;case A.CLOSE_TAG_SAW_WHITE:if(W(k))continue;if(k===">")b(E);else j(E,"Invalid characters in closing tag");continue;case A.TEXT_ENTITY:case A.ATTRIB_VALUE_ENTITY_Q:case A.ATTRIB_VALUE_ENTITY_U:var KD,uD;switch(E.state){case A.TEXT_ENTITY:KD=A.TEXT,uD="textNode";break;case A.ATTRIB_VALUE_ENTITY_Q:KD=A.ATTRIB_VALUE_QUOTED,uD="attribValue";break;case A.ATTRIB_VALUE_ENTITY_U:KD=A.ATTRIB_VALUE_UNQUOTED,uD="attribValue";break}if(k===";"){var hD=a(E);if(E.opt.unparsedEntities&&!Object.values(D.XML_ENTITIES).includes(hD))E.entity="",E.state=KD,E.write(hD);else E[uD]+=hD,E.entity="",E.state=KD}else if(R(E.entity.length?I:L,k))E.entity+=k;else j(E,"Invalid character in entity name"),E[uD]+="&"+E.entity+k,E.entity="",E.state=KD;continue;default:throw Error(E,"Unknown state: "+E.state)}}if(E.position>=E.bufferCheckPosition)Y(E);return E}/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */if(!String.fromCodePoint)(function(){var P=String.fromCharCode,E=Math.floor,r=function(){var k=16384,zD=[],t,KD,uD=-1,hD=arguments.length;if(!hD)return"";var X0="";while(++uD<hD){var v0=Number(arguments[uD]);if(!isFinite(v0)||v0<0||v0>1114111||E(v0)!==v0)throw RangeError("Invalid code point: "+v0);if(v0<=65535)zD.push(v0);else v0-=65536,t=(v0>>10)+55296,KD=v0%1024+56320,zD.push(t,KD);if(uD+1===hD||zD.length>k)X0+=P.apply(null,zD),zD.length=0}return X0};if(Object.defineProperty)Object.defineProperty(String,"fromCodePoint",{value:r,configurable:!0,writable:!0});else String.fromCodePoint=r})()})(typeof TQ>"u"?TQ.sax={}:TQ)});var Kh=T((Bh)=>{(function(){Bh.stripBOM=function(D){if(D[0]==="\uFEFF")return D.substring(1);else return D}}).call(Bh)});var cq=T((Wh)=>{(function(){var D=new RegExp(/(?!xmlns)^.*:/);Wh.normalize=function($){return $.toLowerCase()},Wh.firstCharLowerCase=function($){return $.charAt(0).toLowerCase()+$.slice(1)},Wh.stripPrefix=function($){return $.replace(D,"")},Wh.parseNumbers=function($){if(!isNaN($))$=$%1===0?parseInt($,10):parseFloat($);return $},Wh.parseBooleans=function($){if(/^(?:true|false)$/i.test($))$=$.toLowerCase()==="true";return $}}).call(Wh)});var Vh=T((Hh)=>{(function(){var D,$,X,Y,J,Q,F,w,Z,G=function(z,q){return function(){return z.apply(q,arguments)}},O=function(z,q){for(var B in q)if(U.call(q,B))z[B]=q[B];function K(){this.constructor=z}return K.prototype=q.prototype,z.prototype=new K,z.__super__=q.prototype,z},U={}.hasOwnProperty;w=zh(),Y=p("events"),D=Kh(),F=cq(),Z=p("timers").setImmediate,$=qQ().defaults,J=function(z){return typeof z==="object"&&z!=null&&Object.keys(z).length===0},Q=function(z,q,B){var K,M,L;for(K=0,M=z.length;K<M;K++)L=z[K],q=L(q,B);return q},X=function(z,q,B){var K=Object.create(null);return K.value=B,K.writable=!0,K.enumerable=!0,K.configurable=!0,Object.defineProperty(z,q,K)},Hh.Parser=function(z){O(q,z);function q(B){this.parseStringPromise=G(this.parseStringPromise,this),this.parseString=G(this.parseString,this),this.reset=G(this.reset,this),this.assignOrPush=G(this.assignOrPush,this),this.processAsync=G(this.processAsync,this);var K,M,L;if(!(this instanceof Hh.Parser))return new Hh.Parser(B);this.options={},M=$["0.2"];for(K in M){if(!U.call(M,K))continue;L=M[K],this.options[K]=L}for(K in B){if(!U.call(B,K))continue;L=B[K],this.options[K]=L}if(this.options.xmlns)this.options.xmlnskey=this.options.attrkey+"ns";if(this.options.normalizeTags){if(!this.options.tagNameProcessors)this.options.tagNameProcessors=[];this.options.tagNameProcessors.unshift(F.normalize)}this.reset()}return q.prototype.processAsync=function(){var B,K;try{if(this.remaining.length<=this.options.chunkSize)return B=this.remaining,this.remaining="",this.saxParser=this.saxParser.write(B),this.saxParser.close();else return B=this.remaining.substr(0,this.options.chunkSize),this.remaining=this.remaining.substr(this.options.chunkSize,this.remaining.length),this.saxParser=this.saxParser.write(B),Z(this.processAsync)}catch(M){if(K=M,!this.saxParser.errThrown)return this.saxParser.errThrown=!0,this.emit(K)}},q.prototype.assignOrPush=function(B,K,M){if(!(K in B))if(!this.options.explicitArray)return X(B,K,M);else return X(B,K,[M]);else{if(!(B[K]instanceof Array))X(B,K,[B[K]]);return B[K].push(M)}},q.prototype.reset=function(){var B,K,M,L;return this.removeAllListeners(),this.saxParser=w.parser(this.options.strict,{trim:!1,normalize:!1,xmlns:this.options.xmlns}),this.saxParser.errThrown=!1,this.saxParser.onerror=function(I){return function(W){if(I.saxParser.resume(),!I.saxParser.errThrown)return I.saxParser.errThrown=!0,I.emit("error",W)}}(this),this.saxParser.onend=function(I){return function(){if(!I.saxParser.ended)return I.saxParser.ended=!0,I.emit("end",I.resultObject)}}(this),this.saxParser.ended=!1,this.EXPLICIT_CHARKEY=this.options.explicitCharkey,this.resultObject=null,L=[],B=this.options.attrkey,K=this.options.charkey,this.saxParser.onopentag=function(I){return function(W){var N,V,R,C,A;if(R={},R[K]="",!I.options.ignoreAttrs){A=W.attributes;for(N in A){if(!U.call(A,N))continue;if(!(B in R)&&!I.options.mergeAttrs)R[B]={};if(V=I.options.attrValueProcessors?Q(I.options.attrValueProcessors,W.attributes[N],N):W.attributes[N],C=I.options.attrNameProcessors?Q(I.options.attrNameProcessors,N):N,I.options.mergeAttrs)I.assignOrPush(R,C,V);else X(R[B],C,V)}}if(R["#name"]=I.options.tagNameProcessors?Q(I.options.tagNameProcessors,W.name):W.name,I.options.xmlns)R[I.options.xmlnskey]={uri:W.uri,local:W.local};return L.push(R)}}(this),this.saxParser.onclosetag=function(I){return function(){var W,N,V,R,C,A,_,v,S,h;if(A=L.pop(),C=A["#name"],!I.options.explicitChildren||!I.options.preserveChildrenOrder)delete A["#name"];if(A.cdata===!0)W=A.cdata,delete A.cdata;if(S=L[L.length-1],A[K].match(/^\s*$/)&&!W)N=A[K],delete A[K];else{if(I.options.trim)A[K]=A[K].trim();if(I.options.normalize)A[K]=A[K].replace(/\s{2,}/g," ").trim();if(A[K]=I.options.valueProcessors?Q(I.options.valueProcessors,A[K],C):A[K],Object.keys(A).length===1&&K in A&&!I.EXPLICIT_CHARKEY)A=A[K]}if(J(A))if(typeof I.options.emptyTag==="function")A=I.options.emptyTag();else A=I.options.emptyTag!==""?I.options.emptyTag:N;if(I.options.validator!=null)h="/"+function(){var g,l,f;f=[];for(g=0,l=L.length;g<l;g++)R=L[g],f.push(R["#name"]);return f}().concat(C).join("/"),function(){var g;try{return A=I.options.validator(h,S&&S[C],A)}catch(l){return g=l,I.emit("error",g)}}();if(I.options.explicitChildren&&!I.options.mergeAttrs&&typeof A==="object"){if(!I.options.preserveChildrenOrder){if(R={},I.options.attrkey in A)R[I.options.attrkey]=A[I.options.attrkey],delete A[I.options.attrkey];if(!I.options.charsAsChildren&&I.options.charkey in A)R[I.options.charkey]=A[I.options.charkey],delete A[I.options.charkey];if(Object.getOwnPropertyNames(A).length>0)R[I.options.childkey]=A;A=R}else if(S){S[I.options.childkey]=S[I.options.childkey]||[],_={};for(V in A){if(!U.call(A,V))continue;X(_,V,A[V])}if(S[I.options.childkey].push(_),delete A["#name"],Object.keys(A).length===1&&K in A&&!I.EXPLICIT_CHARKEY)A=A[K]}}if(L.length>0)return I.assignOrPush(S,C,A);else{if(I.options.explicitRoot)v=A,A={},X(A,C,v);return I.resultObject=A,I.saxParser.ended=!0,I.emit("end",I.resultObject)}}}(this),M=function(I){return function(W){var N,V;if(V=L[L.length-1],V){if(V[K]+=W,I.options.explicitChildren&&I.options.preserveChildrenOrder&&I.options.charsAsChildren&&(I.options.includeWhiteChars||W.replace(/\\n/g,"").trim()!=="")){if(V[I.options.childkey]=V[I.options.childkey]||[],N={"#name":"__text__"},N[K]=W,I.options.normalize)N[K]=N[K].replace(/\s{2,}/g," ").trim();V[I.options.childkey].push(N)}return V}}}(this),this.saxParser.ontext=M,this.saxParser.oncdata=function(I){return function(W){var N=M(W);if(N)return N.cdata=!0}}(this)},q.prototype.parseString=function(B,K){var M;if(K!=null&&typeof K==="function")this.on("end",function(L){return this.reset(),K(null,L)}),this.on("error",function(L){return this.reset(),K(L)});try{if(B=B.toString(),B.trim()==="")return this.emit("end",null),!0;if(B=D.stripBOM(B),this.options.async)return this.remaining=B,Z(this.processAsync),this.saxParser;return this.saxParser.write(B).close()}catch(L){if(M=L,!(this.saxParser.errThrown||this.saxParser.ended))return this.emit("error",M),this.saxParser.errThrown=!0;else if(this.saxParser.ended)throw M}},q.prototype.parseStringPromise=function(B){return new Promise(function(K){return function(M,L){return K.parseString(B,function(I,W){if(I)return L(I);else return M(W)})}}(this))},q}(Y),Hh.parseString=function(z,q,B){var K,M,L;if(B!=null){if(typeof B==="function")K=B;if(typeof q==="object")M=q}else{if(typeof q==="function")K=q;M={}}return L=new Hh.Parser(M),L.parseString(z,K)},Hh.parseStringPromise=function(z,q){var B,K;if(typeof q==="object")B=q;return K=new Hh.Parser(B),K.parseStringPromise(z)}}).call(Hh)});var Mh=T((Nh)=>{(function(){var D,$,X,Y,J=function(F,w){for(var Z in w)if(Q.call(w,Z))F[Z]=w[Z];function G(){this.constructor=F}return G.prototype=w.prototype,F.prototype=new G,F.__super__=w.prototype,F},Q={}.hasOwnProperty;$=qQ(),D=qh(),X=Vh(),Y=cq(),Nh.defaults=$.defaults,Nh.processors=Y,Nh.ValidationError=function(F){J(w,F);function w(Z){this.message=Z}return w}(Error),Nh.Builder=D.Builder,Nh.Parser=X.Parser,Nh.parseString=X.parseString,Nh.parseStringPromise=X.parseStringPromise}).call(Nh)});var Ah=T((Lh)=>{Object.defineProperty(Lh,"__esModule",{value:!0});Lh.buildXmlElement=Lh.writeXML=Lh.parseXML=Lh.readXML=void 0;var uzD=lD(),vzD=n9(),h3=uzD.__importDefault(Mh());async function _zD(D){var $;try{let X=await(0,vzD.readFile)(D,{encoding:"utf-8"});try{return await h3.default.parseStringPromise(X)}catch(Y){throw`Error parsing: ${D}, ${($=Y.stack)!==null&&$!==void 0?$:Y}`}}catch(X){throw`Unable to read: ${D}`}}Lh.readXML=_zD;function kzD(D,$){let X=$!==void 0?new h3.default.Parser({...$}):new h3.default.Parser,Y;return X.parseString(D,(J,Q)=>{if(!J)Y=Q}),Y}Lh.parseXML=kzD;async function fzD(D){return new Promise(($)=>{let Y=new h3.default.Builder({headless:!0,explicitRoot:!1,rootName:"deleteme"}).buildObject(D);Y=Y.replace("<deleteme>","").replace("</deleteme>",""),$(Y)})}Lh.writeXML=fzD;function yzD(D,$){return new h3.default.Builder({headless:!0,explicitRoot:!1,rootName:$}).buildObject(D)}Lh.buildXmlElement=yzD});var xh=T((Ch)=>{Object.defineProperty(Ch,"__esModule",{value:!0});Ch.getAllElements=Ch.getFilePath=Ch.getAssets=Ch.getJSModules=Ch.getPluginType=Ch.getPlatformElement=Ch.getPluginPlatform=Ch.printPlugins=Ch.fixName=Ch.getDependencies=Ch.resolvePlugin=Ch.getPlugins=Ch.getIncludedPluginPackages=void 0;var mzD=lD(),dzD=n9(),lq=p("path"),X5=mzD.__importDefault(i9()),czD=mY(),lzD=E3(),Rh=UQ(),nzD=Ah();function jh(D,$){var X,Y,J,Q;let{extConfig:F}=D.app;switch($){case"android":return(Y=(X=F.android)===null||X===void 0?void 0:X.includePlugins)!==null&&Y!==void 0?Y:F.includePlugins;case"ios":return(Q=(J=F.ios)===null||J===void 0?void 0:J.includePlugins)!==null&&Q!==void 0?Q:F.includePlugins}}Ch.getIncludedPluginPackages=jh;async function izD(D,$){var X;let Y=(X=jh(D,$))!==null&&X!==void 0?X:Th(D);return(await Promise.all(Y.map(async(Q)=>Eh(D,Q)))).filter((Q)=>!!Q)}Ch.getPlugins=izD;async function Eh(D,$){try{let X=(0,Rh.resolveNode)(D.app.rootDir,$,"package.json");if(!X)(0,czD.fatal)(`Unable to find ${X5.default.strong(`node_modules/${$}`)}.
269
269
  Are you sure ${X5.default.strong($)} is installed?`);let Y=(0,lq.dirname)(X),J=await(0,dzD.readJSON)(X);if(!J)return null;if(J.capacitor)return{id:$,name:nq($),version:J.version,rootPath:Y,repository:J.repository,manifest:J.capacitor};let Q=(0,lq.join)(Y,"plugin.xml"),F=await(0,nzD.readXML)(Q);return{id:$,name:nq($),version:J.version,rootPath:Y,repository:J.repository,xml:F.plugin}}catch(X){}return null}Ch.resolvePlugin=Eh;function Th(D){var $,X;return[...Object.keys(($=D.app.package.dependencies)!==null&&$!==void 0?$:{}),...Object.keys((X=D.app.package.devDependencies)!==null&&X!==void 0?X:{})]}Ch.getDependencies=Th;function nq(D){return D=D.replace(/\//g,"_").replace(/-/g,"_").replace(/@/g,"").replace(/_\w/g,($)=>$[1].toUpperCase()),D.charAt(0).toUpperCase()+D.slice(1)}Ch.fixName=nq;function pzD(D,$,X="capacitor"){if(D.length===0)return;let Y,J=D.length===1?"":"s";switch(X){case"cordova":Y=`Found ${D.length} Cordova plugin${J} for ${X5.default.strong($)}:
270
270
  `;break;case"incompatible":Y=`Found ${D.length} incompatible Cordova plugin${J} for ${X5.default.strong($)}, skipped install:
271
271
  `;break;case"capacitor":Y=`Found ${D.length} Capacitor plugin${J} for ${X5.default.strong($)}:
@@ -306,7 +306,7 @@ To use ${L8.default.strong($)} files, you must install TypeScript in your projec
306
306
 
307
307
  ${(Y=J.stack)!==null&&Y!==void 0?Y:J}`);throw J}}async function SID(D,$,X){var Y;try{return{extConfigType:"js",extConfigName:$,extConfigFilePath:X,extConfig:await p(X)}}catch(J){(0,ZF.fatal)(`Parsing ${L8.default.strong($)} failed.
308
308
 
309
- ${(Y=J.stack)!==null&&Y!==void 0?Y:J}`)}}async function uID(D){var $;let X=(0,CD.resolve)(D,Pi.CONFIG_FILE_NAME_TS);if(await(0,w1.pathExists)(X))return xID(D,Pi.CONFIG_FILE_NAME_TS,X);let Y=(0,CD.resolve)(D,Pi.CONFIG_FILE_NAME_JS);if(await(0,w1.pathExists)(Y))return SID(D,Pi.CONFIG_FILE_NAME_JS,Y);let J=(0,CD.resolve)(D,Pi.CONFIG_FILE_NAME_JSON);return{extConfigType:"json",extConfigName:Pi.CONFIG_FILE_NAME_JSON,extConfigFilePath:J,extConfig:($=await(0,az.tryFn)(w1.readJSON,J))!==null&&$!==void 0?$:{}}}async function vID(D){let X=(0,CD.join)(D,"assets"),Y="ios-spm-template.tar.gz",J="capacitor-cordova-ios-plugins.tar.gz",Q="android-template.tar.gz",F="capacitor-cordova-android-plugins.tar.gz";return{rootDir:D,assetsDir:"assets",assetsDirAbs:X,assets:{ios:{platformTemplateArchive:"ios-spm-template.tar.gz",platformTemplateArchiveAbs:(0,CD.resolve)(X,"ios-spm-template.tar.gz"),cordovaPluginsTemplateArchive:"capacitor-cordova-ios-plugins.tar.gz",cordovaPluginsTemplateArchiveAbs:(0,CD.resolve)(X,"capacitor-cordova-ios-plugins.tar.gz")},android:{platformTemplateArchive:"android-template.tar.gz",platformTemplateArchiveAbs:(0,CD.resolve)(X,"android-template.tar.gz"),cordovaPluginsTemplateArchive:"capacitor-cordova-android-plugins.tar.gz",cordovaPluginsTemplateArchiveAbs:(0,CD.resolve)(X,"capacitor-cordova-android-plugins.tar.gz")}},package:await(0,w1.readJSON)((0,CD.resolve)(D,"package.json")).catch(()=>({name:"@capacitor/cli",version:"0.0.0"})),os:yID(process.platform)}}async function _ID(D,$,X){var Y,J,Q,F,w,Z,G,O,U,z,q,B,K,M,L,I,W;let N="android",V=(J=(Y=$.android)===null||Y===void 0?void 0:Y.path)!==null&&J!==void 0?J:"android",R=(0,CD.resolve)(D,V),P="app",A="app/src",_="app/src/main",v="app/src/main/assets",S="app/src/main/assets/public",h="app/src/main/res",g="app/build/outputs/apk/",l=((Q=$.android)===null||Q===void 0?void 0:Q.flavor)||"";if((F=$.android)===null||F===void 0?void 0:F.flavor)g=`${g}/${(w=$.android)===null||w===void 0?void 0:w.flavor}`;let f=(0,jID.parseApkNameFromFlavor)(l),j=`${g}/debug`,x="capacitor-cordova-android-plugins",u=(0,M8.lazy)(()=>hID(X.os)),y={keystorePath:(G=(Z=$.android)===null||Z===void 0?void 0:Z.buildOptions)===null||G===void 0?void 0:G.keystorePath,keystorePassword:(U=(O=$.android)===null||O===void 0?void 0:O.buildOptions)===null||U===void 0?void 0:U.keystorePassword,keystoreAlias:(q=(z=$.android)===null||z===void 0?void 0:z.buildOptions)===null||q===void 0?void 0:q.keystoreAlias,keystoreAliasPassword:(K=(B=$.android)===null||B===void 0?void 0:B.buildOptions)===null||K===void 0?void 0:K.keystoreAliasPassword,signingType:(L=(M=$.android)===null||M===void 0?void 0:M.buildOptions)===null||L===void 0?void 0:L.signingType,releaseType:(W=(I=$.android)===null||I===void 0?void 0:I.buildOptions)===null||W===void 0?void 0:W.releaseType};return{name:"android",minVersion:"24",studioPath:u,platformDir:V,platformDirAbs:R,cordovaPluginsDir:x,cordovaPluginsDirAbs:(0,CD.resolve)(R,x),appDir:"app",appDirAbs:(0,CD.resolve)(R,"app"),srcDir:"app/src",srcDirAbs:(0,CD.resolve)(R,"app/src"),srcMainDir:"app/src/main",srcMainDirAbs:(0,CD.resolve)(R,"app/src/main"),assetsDir:"app/src/main/assets",assetsDirAbs:(0,CD.resolve)(R,"app/src/main/assets"),webDir:"app/src/main/assets/public",webDirAbs:(0,CD.resolve)(R,"app/src/main/assets/public"),resDir:"app/src/main/res",resDirAbs:(0,CD.resolve)(R,"app/src/main/res"),apkName:f,buildOutputDir:j,buildOutputDirAbs:(0,CD.resolve)(R,j),flavor:l,buildOptions:y}}async function kID(D,$){var X,Y,J,Q,F,w,Z,G,O,U,z,q;let B="ios",K=(Y=(X=$.ios)===null||X===void 0?void 0:X.path)!==null&&Y!==void 0?Y:"ios",M=(0,CD.resolve)(D,K),L=(Q=(J=$.ios)===null||J===void 0?void 0:J.scheme)!==null&&Q!==void 0?Q:"App",I="App",W=(0,CD.resolve)(M,"App"),N="App/App",V=(0,CD.resolve)(M,"App/App"),R="App/App.xcodeproj",P=(0,CD.resolve)(M,"App/App.xcodeproj"),A=(0,M8.lazy)(()=>bID(W)),_=(0,M8.lazy)(()=>mID()),v=(0,M8.lazy)(()=>dID(D,M,W)),S=(0,M8.lazy)(()=>gID(W,V,P)),h="capacitor-cordova-ios-plugins",g={exportMethod:(w=(F=$.ios)===null||F===void 0?void 0:F.buildOptions)===null||w===void 0?void 0:w.exportMethod,xcodeSigningStyle:(G=(Z=$.ios)===null||Z===void 0?void 0:Z.buildOptions)===null||G===void 0?void 0:G.signingStyle,signingCertificate:(U=(O=$.ios)===null||O===void 0?void 0:O.buildOptions)===null||U===void 0?void 0:U.signingCertificate,provisioningProfile:(q=(z=$.ios)===null||z===void 0?void 0:z.buildOptions)===null||q===void 0?void 0:q.provisioningProfile};return{name:"ios",minVersion:"15.0",platformDir:K,platformDirAbs:M,scheme:L,cordovaPluginsDir:"capacitor-cordova-ios-plugins",cordovaPluginsDirAbs:(0,CD.resolve)(M,"capacitor-cordova-ios-plugins"),nativeProjectDir:"App",nativeProjectDirAbs:W,nativeTargetDir:"App/App",nativeTargetDirAbs:V,nativeXcodeProjDir:"App/App.xcodeproj",nativeXcodeProjDirAbs:P,nativeXcodeWorkspaceDir:(0,M8.lazy)(async()=>(0,CD.relative)(M,await A)),nativeXcodeWorkspaceDirAbs:A,webDir:(0,M8.lazy)(async()=>(0,CD.relative)(M,await S)),webDirAbs:S,podPath:_,packageManager:v,buildOptions:g}}async function fID(D,$){let X=$,Y=(0,CD.resolve)(D,X);return{name:"web",platformDir:X,platformDirAbs:Y}}function yID(D){switch(D){case"darwin":return"mac";case"win32":return"windows";case"linux":return"linux"}return"unknown"}async function bID(D){return(0,CD.resolve)(D,"App.xcworkspace")}async function gID(D,$,X){let Y=/path\s=\spublic[\s\S]+?sourceTree\s=\s([^;]+)/,J=(0,CD.resolve)(X,"project.pbxproj");try{let F=(await(0,w1.readFile)(J,{encoding:"utf8"})).match(Y);if(F&&F[1]==="SOURCE_ROOT")return EID.logger.warn(`Using the iOS project root for the ${L8.default.strong("public")} directory is deprecated.
309
+ ${(Y=J.stack)!==null&&Y!==void 0?Y:J}`)}}async function uID(D){var $;let X=(0,CD.resolve)(D,Pi.CONFIG_FILE_NAME_TS);if(await(0,w1.pathExists)(X))return xID(D,Pi.CONFIG_FILE_NAME_TS,X);let Y=(0,CD.resolve)(D,Pi.CONFIG_FILE_NAME_JS);if(await(0,w1.pathExists)(Y))return SID(D,Pi.CONFIG_FILE_NAME_JS,Y);let J=(0,CD.resolve)(D,Pi.CONFIG_FILE_NAME_JSON);return{extConfigType:"json",extConfigName:Pi.CONFIG_FILE_NAME_JSON,extConfigFilePath:J,extConfig:($=await(0,az.tryFn)(w1.readJSON,J))!==null&&$!==void 0?$:{}}}async function vID(D){let X=(0,CD.join)(D,"assets"),Y="ios-spm-template.tar.gz",J="capacitor-cordova-ios-plugins.tar.gz",Q="android-template.tar.gz",F="capacitor-cordova-android-plugins.tar.gz";return{rootDir:D,assetsDir:"assets",assetsDirAbs:X,assets:{ios:{platformTemplateArchive:"ios-spm-template.tar.gz",platformTemplateArchiveAbs:(0,CD.resolve)(X,"ios-spm-template.tar.gz"),cordovaPluginsTemplateArchive:"capacitor-cordova-ios-plugins.tar.gz",cordovaPluginsTemplateArchiveAbs:(0,CD.resolve)(X,"capacitor-cordova-ios-plugins.tar.gz")},android:{platformTemplateArchive:"android-template.tar.gz",platformTemplateArchiveAbs:(0,CD.resolve)(X,"android-template.tar.gz"),cordovaPluginsTemplateArchive:"capacitor-cordova-android-plugins.tar.gz",cordovaPluginsTemplateArchiveAbs:(0,CD.resolve)(X,"capacitor-cordova-android-plugins.tar.gz")}},package:await(0,w1.readJSON)((0,CD.resolve)(D,"package.json")).catch(()=>({name:"@capacitor/cli",version:"0.0.0"})),os:yID(process.platform)}}async function _ID(D,$,X){var Y,J,Q,F,w,Z,G,O,U,z,q,B,K,M,L,I,W;let N="android",V=(J=(Y=$.android)===null||Y===void 0?void 0:Y.path)!==null&&J!==void 0?J:"android",R=(0,CD.resolve)(D,V),C="app",A="app/src",_="app/src/main",v="app/src/main/assets",S="app/src/main/assets/public",h="app/src/main/res",g="app/build/outputs/apk/",l=((Q=$.android)===null||Q===void 0?void 0:Q.flavor)||"";if((F=$.android)===null||F===void 0?void 0:F.flavor)g=`${g}/${(w=$.android)===null||w===void 0?void 0:w.flavor}`;let f=(0,jID.parseApkNameFromFlavor)(l),j=`${g}/debug`,x="capacitor-cordova-android-plugins",u=(0,M8.lazy)(()=>hID(X.os)),y={keystorePath:(G=(Z=$.android)===null||Z===void 0?void 0:Z.buildOptions)===null||G===void 0?void 0:G.keystorePath,keystorePassword:(U=(O=$.android)===null||O===void 0?void 0:O.buildOptions)===null||U===void 0?void 0:U.keystorePassword,keystoreAlias:(q=(z=$.android)===null||z===void 0?void 0:z.buildOptions)===null||q===void 0?void 0:q.keystoreAlias,keystoreAliasPassword:(K=(B=$.android)===null||B===void 0?void 0:B.buildOptions)===null||K===void 0?void 0:K.keystoreAliasPassword,signingType:(L=(M=$.android)===null||M===void 0?void 0:M.buildOptions)===null||L===void 0?void 0:L.signingType,releaseType:(W=(I=$.android)===null||I===void 0?void 0:I.buildOptions)===null||W===void 0?void 0:W.releaseType};return{name:"android",minVersion:"24",studioPath:u,platformDir:V,platformDirAbs:R,cordovaPluginsDir:x,cordovaPluginsDirAbs:(0,CD.resolve)(R,x),appDir:"app",appDirAbs:(0,CD.resolve)(R,"app"),srcDir:"app/src",srcDirAbs:(0,CD.resolve)(R,"app/src"),srcMainDir:"app/src/main",srcMainDirAbs:(0,CD.resolve)(R,"app/src/main"),assetsDir:"app/src/main/assets",assetsDirAbs:(0,CD.resolve)(R,"app/src/main/assets"),webDir:"app/src/main/assets/public",webDirAbs:(0,CD.resolve)(R,"app/src/main/assets/public"),resDir:"app/src/main/res",resDirAbs:(0,CD.resolve)(R,"app/src/main/res"),apkName:f,buildOutputDir:j,buildOutputDirAbs:(0,CD.resolve)(R,j),flavor:l,buildOptions:y}}async function kID(D,$){var X,Y,J,Q,F,w,Z,G,O,U,z,q;let B="ios",K=(Y=(X=$.ios)===null||X===void 0?void 0:X.path)!==null&&Y!==void 0?Y:"ios",M=(0,CD.resolve)(D,K),L=(Q=(J=$.ios)===null||J===void 0?void 0:J.scheme)!==null&&Q!==void 0?Q:"App",I="App",W=(0,CD.resolve)(M,"App"),N="App/App",V=(0,CD.resolve)(M,"App/App"),R="App/App.xcodeproj",C=(0,CD.resolve)(M,"App/App.xcodeproj"),A=(0,M8.lazy)(()=>bID(W)),_=(0,M8.lazy)(()=>mID()),v=(0,M8.lazy)(()=>dID(D,M,W)),S=(0,M8.lazy)(()=>gID(W,V,C)),h="capacitor-cordova-ios-plugins",g={exportMethod:(w=(F=$.ios)===null||F===void 0?void 0:F.buildOptions)===null||w===void 0?void 0:w.exportMethod,xcodeSigningStyle:(G=(Z=$.ios)===null||Z===void 0?void 0:Z.buildOptions)===null||G===void 0?void 0:G.signingStyle,signingCertificate:(U=(O=$.ios)===null||O===void 0?void 0:O.buildOptions)===null||U===void 0?void 0:U.signingCertificate,provisioningProfile:(q=(z=$.ios)===null||z===void 0?void 0:z.buildOptions)===null||q===void 0?void 0:q.provisioningProfile};return{name:"ios",minVersion:"15.0",platformDir:K,platformDirAbs:M,scheme:L,cordovaPluginsDir:"capacitor-cordova-ios-plugins",cordovaPluginsDirAbs:(0,CD.resolve)(M,"capacitor-cordova-ios-plugins"),nativeProjectDir:"App",nativeProjectDirAbs:W,nativeTargetDir:"App/App",nativeTargetDirAbs:V,nativeXcodeProjDir:"App/App.xcodeproj",nativeXcodeProjDirAbs:C,nativeXcodeWorkspaceDir:(0,M8.lazy)(async()=>(0,CD.relative)(M,await A)),nativeXcodeWorkspaceDirAbs:A,webDir:(0,M8.lazy)(async()=>(0,CD.relative)(M,await S)),webDirAbs:S,podPath:_,packageManager:v,buildOptions:g}}async function fID(D,$){let X=$,Y=(0,CD.resolve)(D,X);return{name:"web",platformDir:X,platformDirAbs:Y}}function yID(D){switch(D){case"darwin":return"mac";case"win32":return"windows";case"linux":return"linux"}return"unknown"}async function bID(D){return(0,CD.resolve)(D,"App.xcworkspace")}async function gID(D,$,X){let Y=/path\s=\spublic[\s\S]+?sourceTree\s=\s([^;]+)/,J=(0,CD.resolve)(X,"project.pbxproj");try{let F=(await(0,w1.readFile)(J,{encoding:"utf8"})).match(Y);if(F&&F[1]==="SOURCE_ROOT")return EID.logger.warn(`Using the iOS project root for the ${L8.default.strong("public")} directory is deprecated.
310
310
  Please follow the Upgrade Guide to move ${L8.default.strong("public")} inside the iOS target directory: ${L8.default.strong("https://capacitorjs.com/docs/updating/3-0#move-public-into-the-ios-target-directory")}`),(0,CD.resolve)(D,"public")}catch(Q){}return(0,CD.resolve)($,"public")}async function hID(D){if(process.env.CAPACITOR_ANDROID_STUDIO_PATH)return process.env.CAPACITOR_ANDROID_STUDIO_PATH;switch(D){case"mac":return"/Applications/Android Studio.app";case"windows":{let{runCommand:$}=await Promise.resolve().then(()=>$B.__importStar(iQ())),X="C:\\Program Files\\Android\\Android Studio\\bin\\studio64.exe";try{if(!await(0,w1.pathExists)(X)){let Y=await $("REG",["QUERY","HKEY_LOCAL_MACHINE\\SOFTWARE\\Android Studio","/v","Path"]);Y=Y.replace(/(\r\n|\n|\r)/gm,"");let J=Y.indexOf("REG_SZ");if(J>0)X=Y.substring(J+6).trim()+"\\bin\\studio64.exe"}}catch(Y){tz("Error checking registry for Android Studio path: %O",Y);break}return X}case"linux":{try{if(await(0,w1.pathExists)("/usr/local/android-studio/bin/studio"))return"/usr/local/android-studio/bin/studio"}catch(Y){tz("Error checking for studio executable: %O",Y)}return"/usr/local/android-studio/bin/studio.sh"}}return""}async function mID(){if(process.env.CAPACITOR_COCOAPODS_PATH)return process.env.CAPACITOR_COCOAPODS_PATH;return"pod"}async function dID(D,$,X){if((0,w1.existsSync)((0,CD.resolve)(X,"CapApp-SPM")))return"SPM";let Y="";if(await(0,w1.pathExists)((0,CD.resolve)(D,"Gemfile")))Y=(0,CD.resolve)(D,"Gemfile");else if(await(0,w1.pathExists)((0,CD.resolve)($,"Gemfile")))Y=(0,CD.resolve)($,"Gemfile");else if(await(0,w1.pathExists)((0,CD.resolve)(X,"Gemfile")))Y=(0,CD.resolve)(X,"Gemfile");if(Y=="")try{let Q=await(0,Ci.getCommandOutput)("git",["rev-parse","--show-toplevel"],{cwd:D});if(Q!=null)Y=(0,CD.resolve)(Q,"Gemfile")}catch(Q){}try{let Q=(await(0,w1.readFile)(Y)).toString();if(!Q)return"Cocoapods";if(new RegExp(/gem\s+['"]cocoapods/).test(Q)&&await(0,Ci.isInstalled)("bundle"))return"bundler";else return"Cocoapods"}catch{return"Cocoapods"}}function cID(D){return`import type { CapacitorConfig } from '@capacitor/cli';
311
311
 
312
312
  const config: CapacitorConfig = ${(0,TID.formatJSObject)(D)};
@@ -315,7 +315,7 @@ export default config;
315
315
  `}});async function ui(){let D=await OX.loadConfig();return{config:D.app.extConfig,path:D.app.extConfigFilePath}}async function XB(D,$,X=!1){let Y=await OX.loadConfig(),{extConfig:J}=Y.app;if(J){if(!J.plugins)J.plugins={extConfig:{},[D]:{}};if(!J.plugins[D])J.plugins[D]={};if(!X)J.plugins[D]=$.config.plugins?.[D];else J=$.config;OX.writeConfig(J,Y.app.extConfigFilePath)}}async function U5(D,$=!1){await XB("CapacitorUpdater",D,$)}var OX;var GF=o(()=>{OX=V0(Si(),1)});function m(D,$,X){function Y(w,Z){if(!w._zod)Object.defineProperty(w,"_zod",{value:{def:Z,constr:F,traits:new Set},enumerable:!1});if(w._zod.traits.has(D))return;w._zod.traits.add(D),$(w,Z);let G=F.prototype,O=Object.keys(G);for(let U=0;U<O.length;U++){let z=O[U];if(!(z in w))w[z]=G[z].bind(w)}}let J=X?.Parent??Object;class Q extends J{}Object.defineProperty(Q,"name",{value:D});function F(w){var Z;let G=X?.Parent?new Q:this;Y(G,w),(Z=G._zod).deferred??(Z.deferred=[]);for(let O of G._zod.deferred)O();return G}return Object.defineProperty(F,"init",{value:Y}),Object.defineProperty(F,Symbol.hasInstance,{value:(w)=>{if(X?.Parent&&w instanceof X.Parent)return!0;return w?._zod?.traits?.has(D)}}),Object.defineProperty(F,"name",{value:D}),F}function k0(D){if(D)Object.assign(UX,D);return UX}var JB,YB,l$,I8,UX;var q5=o(()=>{JB=Object.freeze({status:"aborted"});YB=Symbol("zod_brand");l$=class l$ extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};I8=class I8 extends Error{constructor(D){super(`Encountered unidirectional transform during encode: ${D}`);this.name="ZodEncodeError"}};UX={}});var $D={};a1($D,{unwrapMessage:()=>qX,uint8ArrayToHex:()=>KAD,uint8ArrayToBase64url:()=>zAD,uint8ArrayToBase64:()=>ki,stringifyPrimitive:()=>e,slugify:()=>wB,shallowClone:()=>GB,safeExtend:()=>wAD,required:()=>OAD,randomString:()=>DAD,propertyKeyTypes:()=>KX,promiseAllObject:()=>eID,primitiveTypes:()=>OB,prefixIssues:()=>d1,pick:()=>YAD,partial:()=>GAD,parsedType:()=>DD,optionalKeys:()=>UB,omit:()=>QAD,objectClone:()=>aID,numKeys:()=>$AD,nullish:()=>G4,normalizeParams:()=>XD,mergeDefs:()=>V6,merge:()=>ZAD,jsonStringifyReplacer:()=>z5,joinValues:()=>i,issue:()=>K5,isPlainObject:()=>U4,isObject:()=>A8,hexToUint8Array:()=>BAD,getSizableOrigin:()=>WX,getParsedType:()=>XAD,getLengthableOrigin:()=>HX,getEnumValues:()=>zX,getElementAtPath:()=>sID,floatSafeRemainder:()=>FB,finalizeIssue:()=>_1,extend:()=>FAD,escapeRegex:()=>F$,esc:()=>OF,defineLazy:()=>SD,createTransparentProxy:()=>JAD,cloneDef:()=>tID,clone:()=>L1,cleanRegex:()=>BX,cleanEnum:()=>UAD,captureStackTrace:()=>UF,cached:()=>B5,base64urlToUint8Array:()=>qAD,base64ToUint8Array:()=>_i,assignProp:()=>O4,assertNotEqual:()=>iID,assertNever:()=>rID,assertIs:()=>pID,assertEqual:()=>nID,assert:()=>oID,allowsEval:()=>ZB,aborted:()=>q4,NUMBER_FORMAT_RANGES:()=>qB,Class:()=>fi,BIGINT_FORMAT_RANGES:()=>zB});function nID(D){return D}function iID(D){return D}function pID(D){}function rID(D){throw Error("Unexpected value in exhaustive check")}function oID(D){}function zX(D){let $=Object.values(D).filter((Y)=>typeof Y==="number");return Object.entries(D).filter(([Y,J])=>$.indexOf(+Y)===-1).map(([Y,J])=>J)}function i(D,$="|"){return D.map((X)=>e(X)).join($)}function z5(D,$){if(typeof $==="bigint")return $.toString();return $}function B5(D){return{get value(){{let X=D();return Object.defineProperty(this,"value",{value:X}),X}throw Error("cached value already set")}}}function G4(D){return D===null||D===void 0}function BX(D){let $=D.startsWith("^")?1:0,X=D.endsWith("$")?D.length-1:D.length;return D.slice($,X)}function FB(D,$){let X=(D.toString().split(".")[1]||"").length,Y=$.toString(),J=(Y.split(".")[1]||"").length;if(J===0&&/\d?e-\d?/.test(Y)){let Z=Y.match(/\d?e-(\d?)/);if(Z?.[1])J=Number.parseInt(Z[1])}let Q=X>J?X:J,F=Number.parseInt(D.toFixed(Q).replace(".","")),w=Number.parseInt($.toFixed(Q).replace(".",""));return F%w/10**Q}function SD(D,$,X){let Y=void 0;Object.defineProperty(D,$,{get(){if(Y===vi)return;if(Y===void 0)Y=vi,Y=X();return Y},set(J){Object.defineProperty(D,$,{value:J})},configurable:!0})}function aID(D){return Object.create(Object.getPrototypeOf(D),Object.getOwnPropertyDescriptors(D))}function O4(D,$,X){Object.defineProperty(D,$,{value:X,writable:!0,enumerable:!0,configurable:!0})}function V6(...D){let $={};for(let X of D){let Y=Object.getOwnPropertyDescriptors(X);Object.assign($,Y)}return Object.defineProperties({},$)}function tID(D){return V6(D._zod.def)}function sID(D,$){if(!$)return D;return $.reduce((X,Y)=>X?.[Y],D)}function eID(D){let $=Object.keys(D),X=$.map((Y)=>D[Y]);return Promise.all(X).then((Y)=>{let J={};for(let Q=0;Q<$.length;Q++)J[$[Q]]=Y[Q];return J})}function DAD(D=10){let X="";for(let Y=0;Y<D;Y++)X+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return X}function OF(D){return JSON.stringify(D)}function wB(D){return D.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function A8(D){return typeof D==="object"&&D!==null&&!Array.isArray(D)}function U4(D){if(A8(D)===!1)return!1;let $=D.constructor;if($===void 0)return!0;if(typeof $!=="function")return!0;let X=$.prototype;if(A8(X)===!1)return!1;if(Object.prototype.hasOwnProperty.call(X,"isPrototypeOf")===!1)return!1;return!0}function GB(D){if(U4(D))return{...D};if(Array.isArray(D))return[...D];return D}function $AD(D){let $=0;for(let X in D)if(Object.prototype.hasOwnProperty.call(D,X))$++;return $}function F$(D){return D.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function L1(D,$,X){let Y=new D._zod.constr($??D._zod.def);if(!$||X?.parent)Y._zod.parent=D;return Y}function XD(D){let $=D;if(!$)return{};if(typeof $==="string")return{error:()=>$};if($?.message!==void 0){if($?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");$.error=$.message}if(delete $.message,typeof $.error==="string")return{...$,error:()=>$.error};return $}function JAD(D){let $;return new Proxy({},{get(X,Y,J){return $??($=D()),Reflect.get($,Y,J)},set(X,Y,J,Q){return $??($=D()),Reflect.set($,Y,J,Q)},has(X,Y){return $??($=D()),Reflect.has($,Y)},deleteProperty(X,Y){return $??($=D()),Reflect.deleteProperty($,Y)},ownKeys(X){return $??($=D()),Reflect.ownKeys($)},getOwnPropertyDescriptor(X,Y){return $??($=D()),Reflect.getOwnPropertyDescriptor($,Y)},defineProperty(X,Y,J){return $??($=D()),Reflect.defineProperty($,Y,J)}})}function e(D){if(typeof D==="bigint")return D.toString()+"n";if(typeof D==="string")return`"${D}"`;return`${D}`}function UB(D){return Object.keys(D).filter(($)=>{return D[$]._zod.optin==="optional"&&D[$]._zod.optout==="optional"})}function YAD(D,$){let X=D._zod.def,Y=X.checks;if(Y&&Y.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let Q=V6(D._zod.def,{get shape(){let F={};for(let w in $){if(!(w in X.shape))throw Error(`Unrecognized key: "${w}"`);if(!$[w])continue;F[w]=X.shape[w]}return O4(this,"shape",F),F},checks:[]});return L1(D,Q)}function QAD(D,$){let X=D._zod.def,Y=X.checks;if(Y&&Y.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let Q=V6(D._zod.def,{get shape(){let F={...D._zod.def.shape};for(let w in $){if(!(w in X.shape))throw Error(`Unrecognized key: "${w}"`);if(!$[w])continue;delete F[w]}return O4(this,"shape",F),F},checks:[]});return L1(D,Q)}function FAD(D,$){if(!U4($))throw Error("Invalid input to extend: expected a plain object");let X=D._zod.def.checks;if(X&&X.length>0){let Q=D._zod.def.shape;for(let F in $)if(Object.getOwnPropertyDescriptor(Q,F)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let J=V6(D._zod.def,{get shape(){let Q={...D._zod.def.shape,...$};return O4(this,"shape",Q),Q}});return L1(D,J)}function wAD(D,$){if(!U4($))throw Error("Invalid input to safeExtend: expected a plain object");let X=V6(D._zod.def,{get shape(){let Y={...D._zod.def.shape,...$};return O4(this,"shape",Y),Y}});return L1(D,X)}function ZAD(D,$){let X=V6(D._zod.def,{get shape(){let Y={...D._zod.def.shape,...$._zod.def.shape};return O4(this,"shape",Y),Y},get catchall(){return $._zod.def.catchall},checks:[]});return L1(D,X)}function GAD(D,$,X){let J=$._zod.def.checks;if(J&&J.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let F=V6($._zod.def,{get shape(){let w=$._zod.def.shape,Z={...w};if(X)for(let G in X){if(!(G in w))throw Error(`Unrecognized key: "${G}"`);if(!X[G])continue;Z[G]=D?new D({type:"optional",innerType:w[G]}):w[G]}else for(let G in w)Z[G]=D?new D({type:"optional",innerType:w[G]}):w[G];return O4(this,"shape",Z),Z},checks:[]});return L1($,F)}function OAD(D,$,X){let Y=V6($._zod.def,{get shape(){let J=$._zod.def.shape,Q={...J};if(X)for(let F in X){if(!(F in Q))throw Error(`Unrecognized key: "${F}"`);if(!X[F])continue;Q[F]=new D({type:"nonoptional",innerType:J[F]})}else for(let F in J)Q[F]=new D({type:"nonoptional",innerType:J[F]});return O4(this,"shape",Q),Q}});return L1($,Y)}function q4(D,$=0){if(D.aborted===!0)return!0;for(let X=$;X<D.issues.length;X++)if(D.issues[X]?.continue!==!0)return!0;return!1}function d1(D,$){return $.map((X)=>{var Y;return(Y=X).path??(Y.path=[]),X.path.unshift(D),X})}function qX(D){return typeof D==="string"?D:D?.message}function _1(D,$,X){let Y={...D,path:D.path??[]};if(!D.message){let J=qX(D.inst?._zod.def?.error?.(D))??qX($?.error?.(D))??qX(X.customError?.(D))??qX(X.localeError?.(D))??"Invalid input";Y.message=J}if(delete Y.inst,delete Y.continue,!$?.reportInput)delete Y.input;return Y}function WX(D){if(D instanceof Set)return"set";if(D instanceof Map)return"map";if(D instanceof File)return"file";return"unknown"}function HX(D){if(Array.isArray(D))return"array";if(typeof D==="string")return"string";return"unknown"}function DD(D){let $=typeof D;switch($){case"number":return Number.isNaN(D)?"nan":"number";case"object":{if(D===null)return"null";if(Array.isArray(D))return"array";let X=D;if(X&&Object.getPrototypeOf(X)!==Object.prototype&&"constructor"in X&&X.constructor)return X.constructor.name}}return $}function K5(...D){let[$,X,Y]=D;if(typeof $==="string")return{message:$,code:"custom",input:X,inst:Y};return{...$}}function UAD(D){return Object.entries(D).filter(([$,X])=>{return Number.isNaN(Number.parseInt($,10))}).map(($)=>$[1])}function _i(D){let $=atob(D),X=new Uint8Array($.length);for(let Y=0;Y<$.length;Y++)X[Y]=$.charCodeAt(Y);return X}function ki(D){let $="";for(let X=0;X<D.length;X++)$+=String.fromCharCode(D[X]);return btoa($)}function qAD(D){let $=D.replace(/-/g,"+").replace(/_/g,"/"),X="=".repeat((4-$.length%4)%4);return _i($+X)}function zAD(D){return ki(D).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function BAD(D){let $=D.replace(/^0x/,"");if($.length%2!==0)throw Error("Invalid hex string length");let X=new Uint8Array($.length/2);for(let Y=0;Y<$.length;Y+=2)X[Y/2]=Number.parseInt($.slice(Y,Y+2),16);return X}function KAD(D){return Array.from(D).map(($)=>$.toString(16).padStart(2,"0")).join("")}class fi{constructor(...D){}}var vi,UF,ZB,XAD=(D)=>{let $=typeof D;switch($){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(D)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(D))return"array";if(D===null)return"null";if(D.then&&typeof D.then==="function"&&D.catch&&typeof D.catch==="function")return"promise";if(typeof Map<"u"&&D instanceof Map)return"map";if(typeof Set<"u"&&D instanceof Set)return"set";if(typeof Date<"u"&&D instanceof Date)return"date";if(typeof File<"u"&&D instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${$}`)}},KX,OB,qB,zB;var HD=o(()=>{vi=Symbol("evaluating");UF="captureStackTrace"in Error?Error.captureStackTrace:(...D)=>{};ZB=B5(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(D){return!1}});KX=new Set(["string","number","symbol"]),OB=new Set(["string","number","bigint","boolean","symbol","undefined"]);qB={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},zB={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]}});function NX(D,$=(X)=>X.message){let X={},Y=[];for(let J of D.issues)if(J.path.length>0)X[J.path[0]]=X[J.path[0]]||[],X[J.path[0]].push($(J));else Y.push($(J));return{formErrors:Y,fieldErrors:X}}function MX(D,$=(X)=>X.message){let X={_errors:[]},Y=(J)=>{for(let Q of J.issues)if(Q.code==="invalid_union"&&Q.errors.length)Q.errors.map((F)=>Y({issues:F}));else if(Q.code==="invalid_key")Y({issues:Q.issues});else if(Q.code==="invalid_element")Y({issues:Q.issues});else if(Q.path.length===0)X._errors.push($(Q));else{let F=X,w=0;while(w<Q.path.length){let Z=Q.path[w];if(w!==Q.path.length-1)F[Z]=F[Z]||{_errors:[]};else F[Z]=F[Z]||{_errors:[]},F[Z]._errors.push($(Q));F=F[Z],w++}}};return Y(D),X}function BB(D,$=(X)=>X.message){let X={errors:[]},Y=(J,Q=[])=>{var F,w;for(let Z of J.issues)if(Z.code==="invalid_union"&&Z.errors.length)Z.errors.map((G)=>Y({issues:G},Z.path));else if(Z.code==="invalid_key")Y({issues:Z.issues},Z.path);else if(Z.code==="invalid_element")Y({issues:Z.issues},Z.path);else{let G=[...Q,...Z.path];if(G.length===0){X.errors.push($(Z));continue}let O=X,U=0;while(U<G.length){let z=G[U],q=U===G.length-1;if(typeof z==="string")O.properties??(O.properties={}),(F=O.properties)[z]??(F[z]={errors:[]}),O=O.properties[z];else O.items??(O.items=[]),(w=O.items)[z]??(w[z]={errors:[]}),O=O.items[z];if(q)O.errors.push($(Z));U++}}};return Y(D),X}function bi(D){let $=[],X=D.map((Y)=>typeof Y==="object"?Y.key:Y);for(let Y of X)if(typeof Y==="number")$.push(`[${Y}]`);else if(typeof Y==="symbol")$.push(`[${JSON.stringify(String(Y))}]`);else if(/[^\w$]/.test(Y))$.push(`[${JSON.stringify(Y)}]`);else{if($.length)$.push(".");$.push(Y)}return $.join("")}function KB(D){let $=[],X=[...D.issues].sort((Y,J)=>(Y.path??[]).length-(J.path??[]).length);for(let Y of X)if($.push(`✖ ${Y.message}`),Y.path?.length)$.push(` → at ${bi(Y.path)}`);return $.join(`
316
316
  `)}var yi=(D,$)=>{D.name="$ZodError",Object.defineProperty(D,"_zod",{value:D._zod,enumerable:!1}),Object.defineProperty(D,"issues",{value:$,enumerable:!1}),D.message=JSON.stringify($,z5,2),Object.defineProperty(D,"toString",{value:()=>D.message,enumerable:!1})},VX,k1;var WB=o(()=>{q5();HD();VX=m("$ZodError",yi),k1=m("$ZodError",yi,{Parent:Error})});var W5=(D)=>($,X,Y,J)=>{let Q=Y?Object.assign(Y,{async:!1}):{async:!1},F=$._zod.run({value:X,issues:[]},Q);if(F instanceof Promise)throw new l$;if(F.issues.length){let w=new(J?.Err??D)(F.issues.map((Z)=>_1(Z,Q,k0())));throw UF(w,J?.callee),w}return F.value},qF,H5=(D)=>async($,X,Y,J)=>{let Q=Y?Object.assign(Y,{async:!0}):{async:!0},F=$._zod.run({value:X,issues:[]},Q);if(F instanceof Promise)F=await F;if(F.issues.length){let w=new(J?.Err??D)(F.issues.map((Z)=>_1(Z,Q,k0())));throw UF(w,J?.callee),w}return F.value},zF,V5=(D)=>($,X,Y)=>{let J=Y?{...Y,async:!1}:{async:!1},Q=$._zod.run({value:X,issues:[]},J);if(Q instanceof Promise)throw new l$;return Q.issues.length?{success:!1,error:new(D??VX)(Q.issues.map((F)=>_1(F,J,k0())))}:{success:!0,data:Q.value}},HB,N5=(D)=>async($,X,Y)=>{let J=Y?Object.assign(Y,{async:!0}):{async:!0},Q=$._zod.run({value:X,issues:[]},J);if(Q instanceof Promise)Q=await Q;return Q.issues.length?{success:!1,error:new D(Q.issues.map((F)=>_1(F,J,k0())))}:{success:!0,data:Q.value}},VB,BF=(D)=>($,X,Y)=>{let J=Y?Object.assign(Y,{direction:"backward"}):{direction:"backward"};return W5(D)($,X,J)},HAD,KF=(D)=>($,X,Y)=>{return W5(D)($,X,Y)},VAD,WF=(D)=>async($,X,Y)=>{let J=Y?Object.assign(Y,{direction:"backward"}):{direction:"backward"};return H5(D)($,X,J)},NAD,HF=(D)=>async($,X,Y)=>{return H5(D)($,X,Y)},MAD,VF=(D)=>($,X,Y)=>{let J=Y?Object.assign(Y,{direction:"backward"}):{direction:"backward"};return V5(D)($,X,J)},LAD,NF=(D)=>($,X,Y)=>{return V5(D)($,X,Y)},IAD,MF=(D)=>async($,X,Y)=>{let J=Y?Object.assign(Y,{direction:"backward"}):{direction:"backward"};return N5(D)($,X,J)},AAD,LF=(D)=>async($,X,Y)=>{return N5(D)($,X,Y)},RAD;var NB=o(()=>{q5();WB();HD();qF=W5(k1),zF=H5(k1),HB=V5(k1),VB=N5(k1),HAD=BF(k1),VAD=KF(k1),NAD=WF(k1),MAD=HF(k1),LAD=VF(k1),IAD=NF(k1),AAD=MF(k1),RAD=LF(k1)});var w$={};a1(w$,{xid:()=>AB,uuid7:()=>CAD,uuid6:()=>TAD,uuid4:()=>EAD,uuid:()=>R8,uppercase:()=>pB,unicodeEmail:()=>gi,undefined:()=>nB,ulid:()=>IB,time:()=>bB,string:()=>hB,sha512_hex:()=>oAD,sha512_base64url:()=>tAD,sha512_base64:()=>aAD,sha384_hex:()=>iAD,sha384_base64url:()=>rAD,sha384_base64:()=>pAD,sha256_hex:()=>cAD,sha256_base64url:()=>nAD,sha256_base64:()=>lAD,sha1_hex:()=>hAD,sha1_base64url:()=>dAD,sha1_base64:()=>mAD,rfc5322Email:()=>xAD,number:()=>LX,null:()=>lB,nanoid:()=>jB,md5_hex:()=>yAD,md5_base64url:()=>gAD,md5_base64:()=>bAD,mac:()=>uB,lowercase:()=>iB,ksuid:()=>RB,ipv6:()=>SB,ipv4:()=>xB,integer:()=>dB,idnEmail:()=>SAD,html5Email:()=>PAD,hostname:()=>_AD,hex:()=>fAD,guid:()=>TB,extendedDuration:()=>jAD,emoji:()=>PB,email:()=>CB,e164:()=>fB,duration:()=>EB,domain:()=>kAD,datetime:()=>gB,date:()=>yB,cuid2:()=>LB,cuid:()=>MB,cidrv6:()=>_B,cidrv4:()=>vB,browserEmail:()=>uAD,boolean:()=>cB,bigint:()=>mB,base64url:()=>IF,base64:()=>kB});function PB(){return new RegExp(vAD,"u")}function mi(D){return typeof D.precision==="number"?D.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":D.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${D.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function bB(D){return new RegExp(`^${mi(D)}$`)}function gB(D){let $=mi({precision:D.precision}),X=["Z"];if(D.local)X.push("");if(D.offset)X.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let Y=`${$}(?:${X.join("|")})`;return new RegExp(`^${hi}T(?:${Y})$`)}function IX(D,$){return new RegExp(`^[A-Za-z0-9+/]{${D}}${$}$`)}function AX(D){return new RegExp(`^[A-Za-z0-9_-]{${D}}$`)}var MB,LB,IB,AB,RB,jB,EB,jAD,TB,R8=(D)=>{if(!D)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${D}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)},EAD,TAD,CAD,CB,PAD,xAD,gi,SAD,uAD,vAD="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",xB,SB,uB=(D)=>{let $=F$(D??":");return new RegExp(`^(?:[0-9A-F]{2}${$}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${$}){5}[0-9a-f]{2}$`)},vB,_B,kB,IF,_AD,kAD,fB,hi="(?:(?:\\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])))",yB,hB=(D)=>{let $=D?`[\\s\\S]{${D?.minimum??0},${D?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${$}$`)},mB,dB,LX,cB,lB,nB,iB,pB,fAD,yAD,bAD,gAD,hAD,mAD,dAD,cAD,lAD,nAD,iAD,pAD,rAD,oAD,aAD,tAD;var AF=o(()=>{HD();MB=/^[cC][^\s-]{8,}$/,LB=/^[0-9a-z]+$/,IB=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,AB=/^[0-9a-vA-V]{20}$/,RB=/^[A-Za-z0-9]{27}$/,jB=/^[a-zA-Z0-9_-]{21}$/,EB=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,jAD=/^[-+]?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)?)??$/,TB=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,EAD=R8(4),TAD=R8(6),CAD=R8(7),CB=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,PAD=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,xAD=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,gi=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,SAD=gi,uAD=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;xB=/^(?:(?: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])$/,SB=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,vB=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,_B=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,kB=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,IF=/^[A-Za-z0-9_-]*$/,_AD=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,kAD=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,fB=/^\+[1-9]\d{6,14}$/,yB=new RegExp(`^${hi}$`);mB=/^-?\d+n?$/,dB=/^-?\d+$/,LX=/^-?\d+(?:\.\d+)?$/,cB=/^(?:true|false)$/i,lB=/^null$/i,nB=/^undefined$/i,iB=/^[^A-Z]*$/,pB=/^[^a-z]*$/,fAD=/^[0-9a-fA-F]*$/;yAD=/^[0-9a-fA-F]{32}$/,bAD=IX(22,"=="),gAD=AX(22),hAD=/^[0-9a-fA-F]{40}$/,mAD=IX(27,"="),dAD=AX(27),cAD=/^[0-9a-fA-F]{64}$/,lAD=IX(43,"="),nAD=AX(43),iAD=/^[0-9a-fA-F]{96}$/,pAD=IX(64,""),rAD=AX(64),oAD=/^[0-9a-fA-F]{128}$/,aAD=IX(86,"=="),tAD=AX(86)});function di(D,$,X){if(D.issues.length)$.issues.push(...d1(X,D.issues))}var $0,ci,RF,jF,rB,oB,aB,tB,sB,eB,DK,$K,XK,M5,JK,YK,QK,FK,wK,ZK,GK,OK,UK;var EF=o(()=>{q5();AF();HD();$0=m("$ZodCheck",(D,$)=>{var X;D._zod??(D._zod={}),D._zod.def=$,(X=D._zod).onattach??(X.onattach=[])}),ci={number:"number",bigint:"bigint",object:"date"},RF=m("$ZodCheckLessThan",(D,$)=>{$0.init(D,$);let X=ci[typeof $.value];D._zod.onattach.push((Y)=>{let J=Y._zod.bag,Q=($.inclusive?J.maximum:J.exclusiveMaximum)??Number.POSITIVE_INFINITY;if($.value<Q)if($.inclusive)J.maximum=$.value;else J.exclusiveMaximum=$.value}),D._zod.check=(Y)=>{if($.inclusive?Y.value<=$.value:Y.value<$.value)return;Y.issues.push({origin:X,code:"too_big",maximum:typeof $.value==="object"?$.value.getTime():$.value,input:Y.value,inclusive:$.inclusive,inst:D,continue:!$.abort})}}),jF=m("$ZodCheckGreaterThan",(D,$)=>{$0.init(D,$);let X=ci[typeof $.value];D._zod.onattach.push((Y)=>{let J=Y._zod.bag,Q=($.inclusive?J.minimum:J.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if($.value>Q)if($.inclusive)J.minimum=$.value;else J.exclusiveMinimum=$.value}),D._zod.check=(Y)=>{if($.inclusive?Y.value>=$.value:Y.value>$.value)return;Y.issues.push({origin:X,code:"too_small",minimum:typeof $.value==="object"?$.value.getTime():$.value,input:Y.value,inclusive:$.inclusive,inst:D,continue:!$.abort})}}),rB=m("$ZodCheckMultipleOf",(D,$)=>{$0.init(D,$),D._zod.onattach.push((X)=>{var Y;(Y=X._zod.bag).multipleOf??(Y.multipleOf=$.value)}),D._zod.check=(X)=>{if(typeof X.value!==typeof $.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof X.value==="bigint"?X.value%$.value===BigInt(0):FB(X.value,$.value)===0)return;X.issues.push({origin:typeof X.value,code:"not_multiple_of",divisor:$.value,input:X.value,inst:D,continue:!$.abort})}}),oB=m("$ZodCheckNumberFormat",(D,$)=>{$0.init(D,$),$.format=$.format||"float64";let X=$.format?.includes("int"),Y=X?"int":"number",[J,Q]=qB[$.format];D._zod.onattach.push((F)=>{let w=F._zod.bag;if(w.format=$.format,w.minimum=J,w.maximum=Q,X)w.pattern=dB}),D._zod.check=(F)=>{let w=F.value;if(X){if(!Number.isInteger(w)){F.issues.push({expected:Y,format:$.format,code:"invalid_type",continue:!1,input:w,inst:D});return}if(!Number.isSafeInteger(w)){if(w>0)F.issues.push({input:w,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:D,origin:Y,inclusive:!0,continue:!$.abort});else F.issues.push({input:w,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:D,origin:Y,inclusive:!0,continue:!$.abort});return}}if(w<J)F.issues.push({origin:"number",input:w,code:"too_small",minimum:J,inclusive:!0,inst:D,continue:!$.abort});if(w>Q)F.issues.push({origin:"number",input:w,code:"too_big",maximum:Q,inclusive:!0,inst:D,continue:!$.abort})}}),aB=m("$ZodCheckBigIntFormat",(D,$)=>{$0.init(D,$);let[X,Y]=zB[$.format];D._zod.onattach.push((J)=>{let Q=J._zod.bag;Q.format=$.format,Q.minimum=X,Q.maximum=Y}),D._zod.check=(J)=>{let Q=J.value;if(Q<X)J.issues.push({origin:"bigint",input:Q,code:"too_small",minimum:X,inclusive:!0,inst:D,continue:!$.abort});if(Q>Y)J.issues.push({origin:"bigint",input:Q,code:"too_big",maximum:Y,inclusive:!0,inst:D,continue:!$.abort})}}),tB=m("$ZodCheckMaxSize",(D,$)=>{var X;$0.init(D,$),(X=D._zod.def).when??(X.when=(Y)=>{let J=Y.value;return!G4(J)&&J.size!==void 0}),D._zod.onattach.push((Y)=>{let J=Y._zod.bag.maximum??Number.POSITIVE_INFINITY;if($.maximum<J)Y._zod.bag.maximum=$.maximum}),D._zod.check=(Y)=>{let J=Y.value;if(J.size<=$.maximum)return;Y.issues.push({origin:WX(J),code:"too_big",maximum:$.maximum,inclusive:!0,input:J,inst:D,continue:!$.abort})}}),sB=m("$ZodCheckMinSize",(D,$)=>{var X;$0.init(D,$),(X=D._zod.def).when??(X.when=(Y)=>{let J=Y.value;return!G4(J)&&J.size!==void 0}),D._zod.onattach.push((Y)=>{let J=Y._zod.bag.minimum??Number.NEGATIVE_INFINITY;if($.minimum>J)Y._zod.bag.minimum=$.minimum}),D._zod.check=(Y)=>{let J=Y.value;if(J.size>=$.minimum)return;Y.issues.push({origin:WX(J),code:"too_small",minimum:$.minimum,inclusive:!0,input:J,inst:D,continue:!$.abort})}}),eB=m("$ZodCheckSizeEquals",(D,$)=>{var X;$0.init(D,$),(X=D._zod.def).when??(X.when=(Y)=>{let J=Y.value;return!G4(J)&&J.size!==void 0}),D._zod.onattach.push((Y)=>{let J=Y._zod.bag;J.minimum=$.size,J.maximum=$.size,J.size=$.size}),D._zod.check=(Y)=>{let J=Y.value,Q=J.size;if(Q===$.size)return;let F=Q>$.size;Y.issues.push({origin:WX(J),...F?{code:"too_big",maximum:$.size}:{code:"too_small",minimum:$.size},inclusive:!0,exact:!0,input:Y.value,inst:D,continue:!$.abort})}}),DK=m("$ZodCheckMaxLength",(D,$)=>{var X;$0.init(D,$),(X=D._zod.def).when??(X.when=(Y)=>{let J=Y.value;return!G4(J)&&J.length!==void 0}),D._zod.onattach.push((Y)=>{let J=Y._zod.bag.maximum??Number.POSITIVE_INFINITY;if($.maximum<J)Y._zod.bag.maximum=$.maximum}),D._zod.check=(Y)=>{let J=Y.value;if(J.length<=$.maximum)return;let F=HX(J);Y.issues.push({origin:F,code:"too_big",maximum:$.maximum,inclusive:!0,input:J,inst:D,continue:!$.abort})}}),$K=m("$ZodCheckMinLength",(D,$)=>{var X;$0.init(D,$),(X=D._zod.def).when??(X.when=(Y)=>{let J=Y.value;return!G4(J)&&J.length!==void 0}),D._zod.onattach.push((Y)=>{let J=Y._zod.bag.minimum??Number.NEGATIVE_INFINITY;if($.minimum>J)Y._zod.bag.minimum=$.minimum}),D._zod.check=(Y)=>{let J=Y.value;if(J.length>=$.minimum)return;let F=HX(J);Y.issues.push({origin:F,code:"too_small",minimum:$.minimum,inclusive:!0,input:J,inst:D,continue:!$.abort})}}),XK=m("$ZodCheckLengthEquals",(D,$)=>{var X;$0.init(D,$),(X=D._zod.def).when??(X.when=(Y)=>{let J=Y.value;return!G4(J)&&J.length!==void 0}),D._zod.onattach.push((Y)=>{let J=Y._zod.bag;J.minimum=$.length,J.maximum=$.length,J.length=$.length}),D._zod.check=(Y)=>{let J=Y.value,Q=J.length;if(Q===$.length)return;let F=HX(J),w=Q>$.length;Y.issues.push({origin:F,...w?{code:"too_big",maximum:$.length}:{code:"too_small",minimum:$.length},inclusive:!0,exact:!0,input:Y.value,inst:D,continue:!$.abort})}}),M5=m("$ZodCheckStringFormat",(D,$)=>{var X,Y;if($0.init(D,$),D._zod.onattach.push((J)=>{let Q=J._zod.bag;if(Q.format=$.format,$.pattern)Q.patterns??(Q.patterns=new Set),Q.patterns.add($.pattern)}),$.pattern)(X=D._zod).check??(X.check=(J)=>{if($.pattern.lastIndex=0,$.pattern.test(J.value))return;J.issues.push({origin:"string",code:"invalid_format",format:$.format,input:J.value,...$.pattern?{pattern:$.pattern.toString()}:{},inst:D,continue:!$.abort})});else(Y=D._zod).check??(Y.check=()=>{})}),JK=m("$ZodCheckRegex",(D,$)=>{M5.init(D,$),D._zod.check=(X)=>{if($.pattern.lastIndex=0,$.pattern.test(X.value))return;X.issues.push({origin:"string",code:"invalid_format",format:"regex",input:X.value,pattern:$.pattern.toString(),inst:D,continue:!$.abort})}}),YK=m("$ZodCheckLowerCase",(D,$)=>{$.pattern??($.pattern=iB),M5.init(D,$)}),QK=m("$ZodCheckUpperCase",(D,$)=>{$.pattern??($.pattern=pB),M5.init(D,$)}),FK=m("$ZodCheckIncludes",(D,$)=>{$0.init(D,$);let X=F$($.includes),Y=new RegExp(typeof $.position==="number"?`^.{${$.position}}${X}`:X);$.pattern=Y,D._zod.onattach.push((J)=>{let Q=J._zod.bag;Q.patterns??(Q.patterns=new Set),Q.patterns.add(Y)}),D._zod.check=(J)=>{if(J.value.includes($.includes,$.position))return;J.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:$.includes,input:J.value,inst:D,continue:!$.abort})}}),wK=m("$ZodCheckStartsWith",(D,$)=>{$0.init(D,$);let X=new RegExp(`^${F$($.prefix)}.*`);$.pattern??($.pattern=X),D._zod.onattach.push((Y)=>{let J=Y._zod.bag;J.patterns??(J.patterns=new Set),J.patterns.add(X)}),D._zod.check=(Y)=>{if(Y.value.startsWith($.prefix))return;Y.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:$.prefix,input:Y.value,inst:D,continue:!$.abort})}}),ZK=m("$ZodCheckEndsWith",(D,$)=>{$0.init(D,$);let X=new RegExp(`.*${F$($.suffix)}$`);$.pattern??($.pattern=X),D._zod.onattach.push((Y)=>{let J=Y._zod.bag;J.patterns??(J.patterns=new Set),J.patterns.add(X)}),D._zod.check=(Y)=>{if(Y.value.endsWith($.suffix))return;Y.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:$.suffix,input:Y.value,inst:D,continue:!$.abort})}});GK=m("$ZodCheckProperty",(D,$)=>{$0.init(D,$),D._zod.check=(X)=>{let Y=$.schema._zod.run({value:X.value[$.property],issues:[]},{});if(Y instanceof Promise)return Y.then((J)=>di(J,X,$.property));di(Y,X,$.property);return}}),OK=m("$ZodCheckMimeType",(D,$)=>{$0.init(D,$);let X=new Set($.mime);D._zod.onattach.push((Y)=>{Y._zod.bag.mime=$.mime}),D._zod.check=(Y)=>{if(X.has(Y.value.type))return;Y.issues.push({code:"invalid_value",values:$.mime,input:Y.value.type,inst:D,continue:!$.abort})}}),UK=m("$ZodCheckOverwrite",(D,$)=>{$0.init(D,$),D._zod.check=(X)=>{X.value=$.tx(X.value)}})});class TF{constructor(D=[]){if(this.content=[],this.indent=0,this)this.args=D}indented(D){this.indent+=1,D(this),this.indent-=1}write(D){if(typeof D==="function"){D(this,{execution:"sync"}),D(this,{execution:"async"});return}let X=D.split(`
317
317
  `).filter((Q)=>Q),Y=Math.min(...X.map((Q)=>Q.length-Q.trimStart().length)),J=X.map((Q)=>Q.slice(Y)).map((Q)=>" ".repeat(this.indent*2)+Q);for(let Q of J)this.content.push(Q)}compile(){let D=Function,$=this?.args,Y=[...(this?.content??[""]).map((J)=>` ${J}`)];return new D(...$,Y.join(`
318
- `))}}var qK;var zK=o(()=>{qK={major:4,minor:3,patch:6}});function kK(D){if(D==="")return!0;if(D.length%4!==0)return!1;try{return atob(D),!0}catch{return!1}}function Xp(D){if(!IF.test(D))return!1;let $=D.replace(/[-_]/g,(Y)=>Y==="-"?"+":"/"),X=$.padEnd(Math.ceil($.length/4)*4,"=");return kK(X)}function Jp(D,$=null){try{let X=D.split(".");if(X.length!==3)return!1;let[Y]=X;if(!Y)return!1;let J=JSON.parse(atob(Y));if("typ"in J&&J?.typ!=="JWT")return!1;if(!J.alg)return!1;if($&&(!("alg"in J)||J.alg!==$))return!1;return!0}catch{return!1}}function ni(D,$,X){if(D.issues.length)$.issues.push(...d1(X,D.issues));$.value[X]=D.value}function uF(D,$,X,Y,J){if(D.issues.length){if(J&&!(X in Y))return;$.issues.push(...d1(X,D.issues))}if(D.value===void 0){if(X in Y)$.value[X]=void 0}else $.value[X]=D.value}function Yp(D){let $=Object.keys(D.shape);for(let Y of $)if(!D.shape?.[Y]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${Y}": expected a Zod schema`);let X=UB(D.shape);return{...D,keys:$,keySet:new Set($),numKeys:$.length,optionalKeys:new Set(X)}}function Qp(D,$,X,Y,J,Q){let F=[],w=J.keySet,Z=J.catchall._zod,G=Z.def.type,O=Z.optout==="optional";for(let U in $){if(w.has(U))continue;if(G==="never"){F.push(U);continue}let z=Z.run({value:$[U],issues:[]},Y);if(z instanceof Promise)D.push(z.then((q)=>uF(q,X,U,$,O)));else uF(z,X,U,$,O)}if(F.length)X.issues.push({code:"unrecognized_keys",keys:F,input:$,inst:Q});if(!D.length)return X;return Promise.all(D).then(()=>{return X})}function ii(D,$,X,Y){for(let Q of D)if(Q.issues.length===0)return $.value=Q.value,$;let J=D.filter((Q)=>!q4(Q));if(J.length===1)return $.value=J[0].value,J[0];return $.issues.push({code:"invalid_union",input:$.value,inst:X,errors:D.map((Q)=>Q.issues.map((F)=>_1(F,Y,k0())))}),$}function pi(D,$,X,Y){let J=D.filter((Q)=>Q.issues.length===0);if(J.length===1)return $.value=J[0].value,$;if(J.length===0)$.issues.push({code:"invalid_union",input:$.value,inst:X,errors:D.map((Q)=>Q.issues.map((F)=>_1(F,Y,k0())))});else $.issues.push({code:"invalid_union",input:$.value,inst:X,errors:[],inclusive:!1});return $}function BK(D,$){if(D===$)return{valid:!0,data:D};if(D instanceof Date&&$ instanceof Date&&+D===+$)return{valid:!0,data:D};if(U4(D)&&U4($)){let X=Object.keys($),Y=Object.keys(D).filter((Q)=>X.indexOf(Q)!==-1),J={...D,...$};for(let Q of Y){let F=BK(D[Q],$[Q]);if(!F.valid)return{valid:!1,mergeErrorPath:[Q,...F.mergeErrorPath]};J[Q]=F.data}return{valid:!0,data:J}}if(Array.isArray(D)&&Array.isArray($)){if(D.length!==$.length)return{valid:!1,mergeErrorPath:[]};let X=[];for(let Y=0;Y<D.length;Y++){let J=D[Y],Q=$[Y],F=BK(J,Q);if(!F.valid)return{valid:!1,mergeErrorPath:[Y,...F.mergeErrorPath]};X.push(F.data)}return{valid:!0,data:X}}return{valid:!1,mergeErrorPath:[]}}function ri(D,$,X){let Y=new Map,J;for(let w of $.issues)if(w.code==="unrecognized_keys"){J??(J=w);for(let Z of w.keys){if(!Y.has(Z))Y.set(Z,{});Y.get(Z).l=!0}}else D.issues.push(w);for(let w of X.issues)if(w.code==="unrecognized_keys")for(let Z of w.keys){if(!Y.has(Z))Y.set(Z,{});Y.get(Z).r=!0}else D.issues.push(w);let Q=[...Y].filter(([,w])=>w.l&&w.r).map(([w])=>w);if(Q.length&&J)D.issues.push({...J,keys:Q});if(q4(D))return D;let F=BK($.value,X.value);if(!F.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(F.mergeErrorPath)}`);return D.value=F.data,D}function CF(D,$,X){if(D.issues.length)$.issues.push(...d1(X,D.issues));$.value[X]=D.value}function oi(D,$,X,Y,J,Q,F){if(D.issues.length)if(KX.has(typeof Y))X.issues.push(...d1(Y,D.issues));else X.issues.push({code:"invalid_key",origin:"map",input:J,inst:Q,issues:D.issues.map((w)=>_1(w,F,k0()))});if($.issues.length)if(KX.has(typeof Y))X.issues.push(...d1(Y,$.issues));else X.issues.push({origin:"map",code:"invalid_element",input:J,inst:Q,key:Y,issues:$.issues.map((w)=>_1(w,F,k0()))});X.value.set(D.value,$.value)}function ai(D,$){if(D.issues.length)$.issues.push(...D.issues);$.value.add(D.value)}function ti(D,$){if(D.issues.length&&$===void 0)return{issues:[],value:void 0};return D}function si(D,$){if(D.value===void 0)D.value=$.defaultValue;return D}function ei(D,$){if(!D.issues.length&&D.value===void 0)D.issues.push({code:"invalid_type",expected:"nonoptional",input:D.value,inst:$});return D}function PF(D,$,X){if(D.issues.length)return D.aborted=!0,D;return $._zod.run({value:D.value,issues:D.issues},X)}function xF(D,$,X){if(D.issues.length)return D.aborted=!0,D;if((X.direction||"forward")==="forward"){let J=$.transform(D.value,D);if(J instanceof Promise)return J.then((Q)=>SF(D,Q,$.out,X));return SF(D,J,$.out,X)}else{let J=$.reverseTransform(D.value,D);if(J instanceof Promise)return J.then((Q)=>SF(D,Q,$.in,X));return SF(D,J,$.in,X)}}function SF(D,$,X,Y){if(D.issues.length)return D.aborted=!0,D;return X._zod.run({value:$,issues:D.issues},Y)}function Dp(D){return D.value=Object.freeze(D.value),D}function $p(D,$,X,Y){if(!D){let J={code:"custom",input:X,inst:Y,path:[...Y._zod.def.path??[]],continue:!Y._zod.def.abort};if(Y._zod.def.params)J.params=Y._zod.def.params;$.issues.push(K5(J))}}var AD,j8,tD,KK,WK,HK,VK,NK,MK,LK,IK,AK,RK,jK,EK,TK,CK,PK,xK,SK,uK,vK,_K,fK,yK,bK,gK,hK,vF,mK,RX,_F,dK,cK,lK,nK,iK,pK,rK,oK,aK,tK,Fp,sK,jX,eK,DW,$W,kF,XW,JW,YW,QW,FW,wW,ZW,fF,GW,OW,UW,qW,zW,BW,KW,WW,HW,EX,VW,NW,MW,LW,IW,AW;var RW=o(()=>{EF();q5();NB();AF();HD();zK();HD();AD=m("$ZodType",(D,$)=>{var X;D??(D={}),D._zod.def=$,D._zod.bag=D._zod.bag||{},D._zod.version=qK;let Y=[...D._zod.def.checks??[]];if(D._zod.traits.has("$ZodCheck"))Y.unshift(D);for(let J of Y)for(let Q of J._zod.onattach)Q(D);if(Y.length===0)(X=D._zod).deferred??(X.deferred=[]),D._zod.deferred?.push(()=>{D._zod.run=D._zod.parse});else{let J=(F,w,Z)=>{let G=q4(F),O;for(let U of w){if(U._zod.def.when){if(!U._zod.def.when(F))continue}else if(G)continue;let z=F.issues.length,q=U._zod.check(F);if(q instanceof Promise&&Z?.async===!1)throw new l$;if(O||q instanceof Promise)O=(O??Promise.resolve()).then(async()=>{if(await q,F.issues.length===z)return;if(!G)G=q4(F,z)});else{if(F.issues.length===z)continue;if(!G)G=q4(F,z)}}if(O)return O.then(()=>{return F});return F},Q=(F,w,Z)=>{if(q4(F))return F.aborted=!0,F;let G=J(w,Y,Z);if(G instanceof Promise){if(Z.async===!1)throw new l$;return G.then((O)=>D._zod.parse(O,Z))}return D._zod.parse(G,Z)};D._zod.run=(F,w)=>{if(w.skipChecks)return D._zod.parse(F,w);if(w.direction==="backward"){let G=D._zod.parse({value:F.value,issues:[]},{...w,skipChecks:!0});if(G instanceof Promise)return G.then((O)=>{return Q(O,F,w)});return Q(G,F,w)}let Z=D._zod.parse(F,w);if(Z instanceof Promise){if(w.async===!1)throw new l$;return Z.then((G)=>J(G,Y,w))}return J(Z,Y,w)}}SD(D,"~standard",()=>({validate:(J)=>{try{let Q=HB(D,J);return Q.success?{value:Q.data}:{issues:Q.error?.issues}}catch(Q){return VB(D,J).then((F)=>F.success?{value:F.data}:{issues:F.error?.issues})}},vendor:"zod",version:1}))}),j8=m("$ZodString",(D,$)=>{AD.init(D,$),D._zod.pattern=[...D?._zod.bag?.patterns??[]].pop()??hB(D._zod.bag),D._zod.parse=(X,Y)=>{if($.coerce)try{X.value=String(X.value)}catch(J){}if(typeof X.value==="string")return X;return X.issues.push({expected:"string",code:"invalid_type",input:X.value,inst:D}),X}}),tD=m("$ZodStringFormat",(D,$)=>{M5.init(D,$),j8.init(D,$)}),KK=m("$ZodGUID",(D,$)=>{$.pattern??($.pattern=TB),tD.init(D,$)}),WK=m("$ZodUUID",(D,$)=>{if($.version){let Y={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[$.version];if(Y===void 0)throw Error(`Invalid UUID version: "${$.version}"`);$.pattern??($.pattern=R8(Y))}else $.pattern??($.pattern=R8());tD.init(D,$)}),HK=m("$ZodEmail",(D,$)=>{$.pattern??($.pattern=CB),tD.init(D,$)}),VK=m("$ZodURL",(D,$)=>{tD.init(D,$),D._zod.check=(X)=>{try{let Y=X.value.trim(),J=new URL(Y);if($.hostname){if($.hostname.lastIndex=0,!$.hostname.test(J.hostname))X.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:$.hostname.source,input:X.value,inst:D,continue:!$.abort})}if($.protocol){if($.protocol.lastIndex=0,!$.protocol.test(J.protocol.endsWith(":")?J.protocol.slice(0,-1):J.protocol))X.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:$.protocol.source,input:X.value,inst:D,continue:!$.abort})}if($.normalize)X.value=J.href;else X.value=Y;return}catch(Y){X.issues.push({code:"invalid_format",format:"url",input:X.value,inst:D,continue:!$.abort})}}}),NK=m("$ZodEmoji",(D,$)=>{$.pattern??($.pattern=PB()),tD.init(D,$)}),MK=m("$ZodNanoID",(D,$)=>{$.pattern??($.pattern=jB),tD.init(D,$)}),LK=m("$ZodCUID",(D,$)=>{$.pattern??($.pattern=MB),tD.init(D,$)}),IK=m("$ZodCUID2",(D,$)=>{$.pattern??($.pattern=LB),tD.init(D,$)}),AK=m("$ZodULID",(D,$)=>{$.pattern??($.pattern=IB),tD.init(D,$)}),RK=m("$ZodXID",(D,$)=>{$.pattern??($.pattern=AB),tD.init(D,$)}),jK=m("$ZodKSUID",(D,$)=>{$.pattern??($.pattern=RB),tD.init(D,$)}),EK=m("$ZodISODateTime",(D,$)=>{$.pattern??($.pattern=gB($)),tD.init(D,$)}),TK=m("$ZodISODate",(D,$)=>{$.pattern??($.pattern=yB),tD.init(D,$)}),CK=m("$ZodISOTime",(D,$)=>{$.pattern??($.pattern=bB($)),tD.init(D,$)}),PK=m("$ZodISODuration",(D,$)=>{$.pattern??($.pattern=EB),tD.init(D,$)}),xK=m("$ZodIPv4",(D,$)=>{$.pattern??($.pattern=xB),tD.init(D,$),D._zod.bag.format="ipv4"}),SK=m("$ZodIPv6",(D,$)=>{$.pattern??($.pattern=SB),tD.init(D,$),D._zod.bag.format="ipv6",D._zod.check=(X)=>{try{new URL(`http://[${X.value}]`)}catch{X.issues.push({code:"invalid_format",format:"ipv6",input:X.value,inst:D,continue:!$.abort})}}}),uK=m("$ZodMAC",(D,$)=>{$.pattern??($.pattern=uB($.delimiter)),tD.init(D,$),D._zod.bag.format="mac"}),vK=m("$ZodCIDRv4",(D,$)=>{$.pattern??($.pattern=vB),tD.init(D,$)}),_K=m("$ZodCIDRv6",(D,$)=>{$.pattern??($.pattern=_B),tD.init(D,$),D._zod.check=(X)=>{let Y=X.value.split("/");try{if(Y.length!==2)throw Error();let[J,Q]=Y;if(!Q)throw Error();let F=Number(Q);if(`${F}`!==Q)throw Error();if(F<0||F>128)throw Error();new URL(`http://[${J}]`)}catch{X.issues.push({code:"invalid_format",format:"cidrv6",input:X.value,inst:D,continue:!$.abort})}}});fK=m("$ZodBase64",(D,$)=>{$.pattern??($.pattern=kB),tD.init(D,$),D._zod.bag.contentEncoding="base64",D._zod.check=(X)=>{if(kK(X.value))return;X.issues.push({code:"invalid_format",format:"base64",input:X.value,inst:D,continue:!$.abort})}});yK=m("$ZodBase64URL",(D,$)=>{$.pattern??($.pattern=IF),tD.init(D,$),D._zod.bag.contentEncoding="base64url",D._zod.check=(X)=>{if(Xp(X.value))return;X.issues.push({code:"invalid_format",format:"base64url",input:X.value,inst:D,continue:!$.abort})}}),bK=m("$ZodE164",(D,$)=>{$.pattern??($.pattern=fB),tD.init(D,$)});gK=m("$ZodJWT",(D,$)=>{tD.init(D,$),D._zod.check=(X)=>{if(Jp(X.value,$.alg))return;X.issues.push({code:"invalid_format",format:"jwt",input:X.value,inst:D,continue:!$.abort})}}),hK=m("$ZodCustomStringFormat",(D,$)=>{tD.init(D,$),D._zod.check=(X)=>{if($.fn(X.value))return;X.issues.push({code:"invalid_format",format:$.format,input:X.value,inst:D,continue:!$.abort})}}),vF=m("$ZodNumber",(D,$)=>{AD.init(D,$),D._zod.pattern=D._zod.bag.pattern??LX,D._zod.parse=(X,Y)=>{if($.coerce)try{X.value=Number(X.value)}catch(F){}let J=X.value;if(typeof J==="number"&&!Number.isNaN(J)&&Number.isFinite(J))return X;let Q=typeof J==="number"?Number.isNaN(J)?"NaN":!Number.isFinite(J)?"Infinity":void 0:void 0;return X.issues.push({expected:"number",code:"invalid_type",input:J,inst:D,...Q?{received:Q}:{}}),X}}),mK=m("$ZodNumberFormat",(D,$)=>{oB.init(D,$),vF.init(D,$)}),RX=m("$ZodBoolean",(D,$)=>{AD.init(D,$),D._zod.pattern=cB,D._zod.parse=(X,Y)=>{if($.coerce)try{X.value=Boolean(X.value)}catch(Q){}let J=X.value;if(typeof J==="boolean")return X;return X.issues.push({expected:"boolean",code:"invalid_type",input:J,inst:D}),X}}),_F=m("$ZodBigInt",(D,$)=>{AD.init(D,$),D._zod.pattern=mB,D._zod.parse=(X,Y)=>{if($.coerce)try{X.value=BigInt(X.value)}catch(J){}if(typeof X.value==="bigint")return X;return X.issues.push({expected:"bigint",code:"invalid_type",input:X.value,inst:D}),X}}),dK=m("$ZodBigIntFormat",(D,$)=>{aB.init(D,$),_F.init(D,$)}),cK=m("$ZodSymbol",(D,$)=>{AD.init(D,$),D._zod.parse=(X,Y)=>{let J=X.value;if(typeof J==="symbol")return X;return X.issues.push({expected:"symbol",code:"invalid_type",input:J,inst:D}),X}}),lK=m("$ZodUndefined",(D,$)=>{AD.init(D,$),D._zod.pattern=nB,D._zod.values=new Set([void 0]),D._zod.optin="optional",D._zod.optout="optional",D._zod.parse=(X,Y)=>{let J=X.value;if(typeof J>"u")return X;return X.issues.push({expected:"undefined",code:"invalid_type",input:J,inst:D}),X}}),nK=m("$ZodNull",(D,$)=>{AD.init(D,$),D._zod.pattern=lB,D._zod.values=new Set([null]),D._zod.parse=(X,Y)=>{let J=X.value;if(J===null)return X;return X.issues.push({expected:"null",code:"invalid_type",input:J,inst:D}),X}}),iK=m("$ZodAny",(D,$)=>{AD.init(D,$),D._zod.parse=(X)=>X}),pK=m("$ZodUnknown",(D,$)=>{AD.init(D,$),D._zod.parse=(X)=>X}),rK=m("$ZodNever",(D,$)=>{AD.init(D,$),D._zod.parse=(X,Y)=>{return X.issues.push({expected:"never",code:"invalid_type",input:X.value,inst:D}),X}}),oK=m("$ZodVoid",(D,$)=>{AD.init(D,$),D._zod.parse=(X,Y)=>{let J=X.value;if(typeof J>"u")return X;return X.issues.push({expected:"void",code:"invalid_type",input:J,inst:D}),X}}),aK=m("$ZodDate",(D,$)=>{AD.init(D,$),D._zod.parse=(X,Y)=>{if($.coerce)try{X.value=new Date(X.value)}catch(w){}let J=X.value,Q=J instanceof Date;if(Q&&!Number.isNaN(J.getTime()))return X;return X.issues.push({expected:"date",code:"invalid_type",input:J,...Q?{received:"Invalid Date"}:{},inst:D}),X}});tK=m("$ZodArray",(D,$)=>{AD.init(D,$),D._zod.parse=(X,Y)=>{let J=X.value;if(!Array.isArray(J))return X.issues.push({expected:"array",code:"invalid_type",input:J,inst:D}),X;X.value=Array(J.length);let Q=[];for(let F=0;F<J.length;F++){let w=J[F],Z=$.element._zod.run({value:w,issues:[]},Y);if(Z instanceof Promise)Q.push(Z.then((G)=>ni(G,X,F)));else ni(Z,X,F)}if(Q.length)return Promise.all(Q).then(()=>X);return X}});Fp=m("$ZodObject",(D,$)=>{if(AD.init(D,$),!Object.getOwnPropertyDescriptor($,"shape")?.get){let w=$.shape;Object.defineProperty($,"shape",{get:()=>{let Z={...w};return Object.defineProperty($,"shape",{value:Z}),Z}})}let Y=B5(()=>Yp($));SD(D._zod,"propValues",()=>{let w=$.shape,Z={};for(let G in w){let O=w[G]._zod;if(O.values){Z[G]??(Z[G]=new Set);for(let U of O.values)Z[G].add(U)}}return Z});let J=A8,Q=$.catchall,F;D._zod.parse=(w,Z)=>{F??(F=Y.value);let G=w.value;if(!J(G))return w.issues.push({expected:"object",code:"invalid_type",input:G,inst:D}),w;w.value={};let O=[],U=F.shape;for(let z of F.keys){let q=U[z],B=q._zod.optout==="optional",K=q._zod.run({value:G[z],issues:[]},Z);if(K instanceof Promise)O.push(K.then((M)=>uF(M,w,z,G,B)));else uF(K,w,z,G,B)}if(!Q)return O.length?Promise.all(O).then(()=>w):w;return Qp(O,G,w,Z,Y.value,D)}}),sK=m("$ZodObjectJIT",(D,$)=>{Fp.init(D,$);let X=D._zod.parse,Y=B5(()=>Yp($)),J=(z)=>{let q=new TF(["shape","payload","ctx"]),B=Y.value,K=(W)=>{let N=OF(W);return`shape[${N}]._zod.run({ value: input[${N}], issues: [] }, ctx)`};q.write("const input = payload.value;");let M=Object.create(null),L=0;for(let W of B.keys)M[W]=`key_${L++}`;q.write("const newResult = {};");for(let W of B.keys){let N=M[W],V=OF(W),P=z[W]?._zod?.optout==="optional";if(q.write(`const ${N} = ${K(W)};`),P)q.write(`
318
+ `))}}var qK;var zK=o(()=>{qK={major:4,minor:3,patch:6}});function kK(D){if(D==="")return!0;if(D.length%4!==0)return!1;try{return atob(D),!0}catch{return!1}}function Xp(D){if(!IF.test(D))return!1;let $=D.replace(/[-_]/g,(Y)=>Y==="-"?"+":"/"),X=$.padEnd(Math.ceil($.length/4)*4,"=");return kK(X)}function Jp(D,$=null){try{let X=D.split(".");if(X.length!==3)return!1;let[Y]=X;if(!Y)return!1;let J=JSON.parse(atob(Y));if("typ"in J&&J?.typ!=="JWT")return!1;if(!J.alg)return!1;if($&&(!("alg"in J)||J.alg!==$))return!1;return!0}catch{return!1}}function ni(D,$,X){if(D.issues.length)$.issues.push(...d1(X,D.issues));$.value[X]=D.value}function uF(D,$,X,Y,J){if(D.issues.length){if(J&&!(X in Y))return;$.issues.push(...d1(X,D.issues))}if(D.value===void 0){if(X in Y)$.value[X]=void 0}else $.value[X]=D.value}function Yp(D){let $=Object.keys(D.shape);for(let Y of $)if(!D.shape?.[Y]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${Y}": expected a Zod schema`);let X=UB(D.shape);return{...D,keys:$,keySet:new Set($),numKeys:$.length,optionalKeys:new Set(X)}}function Qp(D,$,X,Y,J,Q){let F=[],w=J.keySet,Z=J.catchall._zod,G=Z.def.type,O=Z.optout==="optional";for(let U in $){if(w.has(U))continue;if(G==="never"){F.push(U);continue}let z=Z.run({value:$[U],issues:[]},Y);if(z instanceof Promise)D.push(z.then((q)=>uF(q,X,U,$,O)));else uF(z,X,U,$,O)}if(F.length)X.issues.push({code:"unrecognized_keys",keys:F,input:$,inst:Q});if(!D.length)return X;return Promise.all(D).then(()=>{return X})}function ii(D,$,X,Y){for(let Q of D)if(Q.issues.length===0)return $.value=Q.value,$;let J=D.filter((Q)=>!q4(Q));if(J.length===1)return $.value=J[0].value,J[0];return $.issues.push({code:"invalid_union",input:$.value,inst:X,errors:D.map((Q)=>Q.issues.map((F)=>_1(F,Y,k0())))}),$}function pi(D,$,X,Y){let J=D.filter((Q)=>Q.issues.length===0);if(J.length===1)return $.value=J[0].value,$;if(J.length===0)$.issues.push({code:"invalid_union",input:$.value,inst:X,errors:D.map((Q)=>Q.issues.map((F)=>_1(F,Y,k0())))});else $.issues.push({code:"invalid_union",input:$.value,inst:X,errors:[],inclusive:!1});return $}function BK(D,$){if(D===$)return{valid:!0,data:D};if(D instanceof Date&&$ instanceof Date&&+D===+$)return{valid:!0,data:D};if(U4(D)&&U4($)){let X=Object.keys($),Y=Object.keys(D).filter((Q)=>X.indexOf(Q)!==-1),J={...D,...$};for(let Q of Y){let F=BK(D[Q],$[Q]);if(!F.valid)return{valid:!1,mergeErrorPath:[Q,...F.mergeErrorPath]};J[Q]=F.data}return{valid:!0,data:J}}if(Array.isArray(D)&&Array.isArray($)){if(D.length!==$.length)return{valid:!1,mergeErrorPath:[]};let X=[];for(let Y=0;Y<D.length;Y++){let J=D[Y],Q=$[Y],F=BK(J,Q);if(!F.valid)return{valid:!1,mergeErrorPath:[Y,...F.mergeErrorPath]};X.push(F.data)}return{valid:!0,data:X}}return{valid:!1,mergeErrorPath:[]}}function ri(D,$,X){let Y=new Map,J;for(let w of $.issues)if(w.code==="unrecognized_keys"){J??(J=w);for(let Z of w.keys){if(!Y.has(Z))Y.set(Z,{});Y.get(Z).l=!0}}else D.issues.push(w);for(let w of X.issues)if(w.code==="unrecognized_keys")for(let Z of w.keys){if(!Y.has(Z))Y.set(Z,{});Y.get(Z).r=!0}else D.issues.push(w);let Q=[...Y].filter(([,w])=>w.l&&w.r).map(([w])=>w);if(Q.length&&J)D.issues.push({...J,keys:Q});if(q4(D))return D;let F=BK($.value,X.value);if(!F.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(F.mergeErrorPath)}`);return D.value=F.data,D}function CF(D,$,X){if(D.issues.length)$.issues.push(...d1(X,D.issues));$.value[X]=D.value}function oi(D,$,X,Y,J,Q,F){if(D.issues.length)if(KX.has(typeof Y))X.issues.push(...d1(Y,D.issues));else X.issues.push({code:"invalid_key",origin:"map",input:J,inst:Q,issues:D.issues.map((w)=>_1(w,F,k0()))});if($.issues.length)if(KX.has(typeof Y))X.issues.push(...d1(Y,$.issues));else X.issues.push({origin:"map",code:"invalid_element",input:J,inst:Q,key:Y,issues:$.issues.map((w)=>_1(w,F,k0()))});X.value.set(D.value,$.value)}function ai(D,$){if(D.issues.length)$.issues.push(...D.issues);$.value.add(D.value)}function ti(D,$){if(D.issues.length&&$===void 0)return{issues:[],value:void 0};return D}function si(D,$){if(D.value===void 0)D.value=$.defaultValue;return D}function ei(D,$){if(!D.issues.length&&D.value===void 0)D.issues.push({code:"invalid_type",expected:"nonoptional",input:D.value,inst:$});return D}function PF(D,$,X){if(D.issues.length)return D.aborted=!0,D;return $._zod.run({value:D.value,issues:D.issues},X)}function xF(D,$,X){if(D.issues.length)return D.aborted=!0,D;if((X.direction||"forward")==="forward"){let J=$.transform(D.value,D);if(J instanceof Promise)return J.then((Q)=>SF(D,Q,$.out,X));return SF(D,J,$.out,X)}else{let J=$.reverseTransform(D.value,D);if(J instanceof Promise)return J.then((Q)=>SF(D,Q,$.in,X));return SF(D,J,$.in,X)}}function SF(D,$,X,Y){if(D.issues.length)return D.aborted=!0,D;return X._zod.run({value:$,issues:D.issues},Y)}function Dp(D){return D.value=Object.freeze(D.value),D}function $p(D,$,X,Y){if(!D){let J={code:"custom",input:X,inst:Y,path:[...Y._zod.def.path??[]],continue:!Y._zod.def.abort};if(Y._zod.def.params)J.params=Y._zod.def.params;$.issues.push(K5(J))}}var AD,j8,tD,KK,WK,HK,VK,NK,MK,LK,IK,AK,RK,jK,EK,TK,CK,PK,xK,SK,uK,vK,_K,fK,yK,bK,gK,hK,vF,mK,RX,_F,dK,cK,lK,nK,iK,pK,rK,oK,aK,tK,Fp,sK,jX,eK,DW,$W,kF,XW,JW,YW,QW,FW,wW,ZW,fF,GW,OW,UW,qW,zW,BW,KW,WW,HW,EX,VW,NW,MW,LW,IW,AW;var RW=o(()=>{EF();q5();NB();AF();HD();zK();HD();AD=m("$ZodType",(D,$)=>{var X;D??(D={}),D._zod.def=$,D._zod.bag=D._zod.bag||{},D._zod.version=qK;let Y=[...D._zod.def.checks??[]];if(D._zod.traits.has("$ZodCheck"))Y.unshift(D);for(let J of Y)for(let Q of J._zod.onattach)Q(D);if(Y.length===0)(X=D._zod).deferred??(X.deferred=[]),D._zod.deferred?.push(()=>{D._zod.run=D._zod.parse});else{let J=(F,w,Z)=>{let G=q4(F),O;for(let U of w){if(U._zod.def.when){if(!U._zod.def.when(F))continue}else if(G)continue;let z=F.issues.length,q=U._zod.check(F);if(q instanceof Promise&&Z?.async===!1)throw new l$;if(O||q instanceof Promise)O=(O??Promise.resolve()).then(async()=>{if(await q,F.issues.length===z)return;if(!G)G=q4(F,z)});else{if(F.issues.length===z)continue;if(!G)G=q4(F,z)}}if(O)return O.then(()=>{return F});return F},Q=(F,w,Z)=>{if(q4(F))return F.aborted=!0,F;let G=J(w,Y,Z);if(G instanceof Promise){if(Z.async===!1)throw new l$;return G.then((O)=>D._zod.parse(O,Z))}return D._zod.parse(G,Z)};D._zod.run=(F,w)=>{if(w.skipChecks)return D._zod.parse(F,w);if(w.direction==="backward"){let G=D._zod.parse({value:F.value,issues:[]},{...w,skipChecks:!0});if(G instanceof Promise)return G.then((O)=>{return Q(O,F,w)});return Q(G,F,w)}let Z=D._zod.parse(F,w);if(Z instanceof Promise){if(w.async===!1)throw new l$;return Z.then((G)=>J(G,Y,w))}return J(Z,Y,w)}}SD(D,"~standard",()=>({validate:(J)=>{try{let Q=HB(D,J);return Q.success?{value:Q.data}:{issues:Q.error?.issues}}catch(Q){return VB(D,J).then((F)=>F.success?{value:F.data}:{issues:F.error?.issues})}},vendor:"zod",version:1}))}),j8=m("$ZodString",(D,$)=>{AD.init(D,$),D._zod.pattern=[...D?._zod.bag?.patterns??[]].pop()??hB(D._zod.bag),D._zod.parse=(X,Y)=>{if($.coerce)try{X.value=String(X.value)}catch(J){}if(typeof X.value==="string")return X;return X.issues.push({expected:"string",code:"invalid_type",input:X.value,inst:D}),X}}),tD=m("$ZodStringFormat",(D,$)=>{M5.init(D,$),j8.init(D,$)}),KK=m("$ZodGUID",(D,$)=>{$.pattern??($.pattern=TB),tD.init(D,$)}),WK=m("$ZodUUID",(D,$)=>{if($.version){let Y={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[$.version];if(Y===void 0)throw Error(`Invalid UUID version: "${$.version}"`);$.pattern??($.pattern=R8(Y))}else $.pattern??($.pattern=R8());tD.init(D,$)}),HK=m("$ZodEmail",(D,$)=>{$.pattern??($.pattern=CB),tD.init(D,$)}),VK=m("$ZodURL",(D,$)=>{tD.init(D,$),D._zod.check=(X)=>{try{let Y=X.value.trim(),J=new URL(Y);if($.hostname){if($.hostname.lastIndex=0,!$.hostname.test(J.hostname))X.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:$.hostname.source,input:X.value,inst:D,continue:!$.abort})}if($.protocol){if($.protocol.lastIndex=0,!$.protocol.test(J.protocol.endsWith(":")?J.protocol.slice(0,-1):J.protocol))X.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:$.protocol.source,input:X.value,inst:D,continue:!$.abort})}if($.normalize)X.value=J.href;else X.value=Y;return}catch(Y){X.issues.push({code:"invalid_format",format:"url",input:X.value,inst:D,continue:!$.abort})}}}),NK=m("$ZodEmoji",(D,$)=>{$.pattern??($.pattern=PB()),tD.init(D,$)}),MK=m("$ZodNanoID",(D,$)=>{$.pattern??($.pattern=jB),tD.init(D,$)}),LK=m("$ZodCUID",(D,$)=>{$.pattern??($.pattern=MB),tD.init(D,$)}),IK=m("$ZodCUID2",(D,$)=>{$.pattern??($.pattern=LB),tD.init(D,$)}),AK=m("$ZodULID",(D,$)=>{$.pattern??($.pattern=IB),tD.init(D,$)}),RK=m("$ZodXID",(D,$)=>{$.pattern??($.pattern=AB),tD.init(D,$)}),jK=m("$ZodKSUID",(D,$)=>{$.pattern??($.pattern=RB),tD.init(D,$)}),EK=m("$ZodISODateTime",(D,$)=>{$.pattern??($.pattern=gB($)),tD.init(D,$)}),TK=m("$ZodISODate",(D,$)=>{$.pattern??($.pattern=yB),tD.init(D,$)}),CK=m("$ZodISOTime",(D,$)=>{$.pattern??($.pattern=bB($)),tD.init(D,$)}),PK=m("$ZodISODuration",(D,$)=>{$.pattern??($.pattern=EB),tD.init(D,$)}),xK=m("$ZodIPv4",(D,$)=>{$.pattern??($.pattern=xB),tD.init(D,$),D._zod.bag.format="ipv4"}),SK=m("$ZodIPv6",(D,$)=>{$.pattern??($.pattern=SB),tD.init(D,$),D._zod.bag.format="ipv6",D._zod.check=(X)=>{try{new URL(`http://[${X.value}]`)}catch{X.issues.push({code:"invalid_format",format:"ipv6",input:X.value,inst:D,continue:!$.abort})}}}),uK=m("$ZodMAC",(D,$)=>{$.pattern??($.pattern=uB($.delimiter)),tD.init(D,$),D._zod.bag.format="mac"}),vK=m("$ZodCIDRv4",(D,$)=>{$.pattern??($.pattern=vB),tD.init(D,$)}),_K=m("$ZodCIDRv6",(D,$)=>{$.pattern??($.pattern=_B),tD.init(D,$),D._zod.check=(X)=>{let Y=X.value.split("/");try{if(Y.length!==2)throw Error();let[J,Q]=Y;if(!Q)throw Error();let F=Number(Q);if(`${F}`!==Q)throw Error();if(F<0||F>128)throw Error();new URL(`http://[${J}]`)}catch{X.issues.push({code:"invalid_format",format:"cidrv6",input:X.value,inst:D,continue:!$.abort})}}});fK=m("$ZodBase64",(D,$)=>{$.pattern??($.pattern=kB),tD.init(D,$),D._zod.bag.contentEncoding="base64",D._zod.check=(X)=>{if(kK(X.value))return;X.issues.push({code:"invalid_format",format:"base64",input:X.value,inst:D,continue:!$.abort})}});yK=m("$ZodBase64URL",(D,$)=>{$.pattern??($.pattern=IF),tD.init(D,$),D._zod.bag.contentEncoding="base64url",D._zod.check=(X)=>{if(Xp(X.value))return;X.issues.push({code:"invalid_format",format:"base64url",input:X.value,inst:D,continue:!$.abort})}}),bK=m("$ZodE164",(D,$)=>{$.pattern??($.pattern=fB),tD.init(D,$)});gK=m("$ZodJWT",(D,$)=>{tD.init(D,$),D._zod.check=(X)=>{if(Jp(X.value,$.alg))return;X.issues.push({code:"invalid_format",format:"jwt",input:X.value,inst:D,continue:!$.abort})}}),hK=m("$ZodCustomStringFormat",(D,$)=>{tD.init(D,$),D._zod.check=(X)=>{if($.fn(X.value))return;X.issues.push({code:"invalid_format",format:$.format,input:X.value,inst:D,continue:!$.abort})}}),vF=m("$ZodNumber",(D,$)=>{AD.init(D,$),D._zod.pattern=D._zod.bag.pattern??LX,D._zod.parse=(X,Y)=>{if($.coerce)try{X.value=Number(X.value)}catch(F){}let J=X.value;if(typeof J==="number"&&!Number.isNaN(J)&&Number.isFinite(J))return X;let Q=typeof J==="number"?Number.isNaN(J)?"NaN":!Number.isFinite(J)?"Infinity":void 0:void 0;return X.issues.push({expected:"number",code:"invalid_type",input:J,inst:D,...Q?{received:Q}:{}}),X}}),mK=m("$ZodNumberFormat",(D,$)=>{oB.init(D,$),vF.init(D,$)}),RX=m("$ZodBoolean",(D,$)=>{AD.init(D,$),D._zod.pattern=cB,D._zod.parse=(X,Y)=>{if($.coerce)try{X.value=Boolean(X.value)}catch(Q){}let J=X.value;if(typeof J==="boolean")return X;return X.issues.push({expected:"boolean",code:"invalid_type",input:J,inst:D}),X}}),_F=m("$ZodBigInt",(D,$)=>{AD.init(D,$),D._zod.pattern=mB,D._zod.parse=(X,Y)=>{if($.coerce)try{X.value=BigInt(X.value)}catch(J){}if(typeof X.value==="bigint")return X;return X.issues.push({expected:"bigint",code:"invalid_type",input:X.value,inst:D}),X}}),dK=m("$ZodBigIntFormat",(D,$)=>{aB.init(D,$),_F.init(D,$)}),cK=m("$ZodSymbol",(D,$)=>{AD.init(D,$),D._zod.parse=(X,Y)=>{let J=X.value;if(typeof J==="symbol")return X;return X.issues.push({expected:"symbol",code:"invalid_type",input:J,inst:D}),X}}),lK=m("$ZodUndefined",(D,$)=>{AD.init(D,$),D._zod.pattern=nB,D._zod.values=new Set([void 0]),D._zod.optin="optional",D._zod.optout="optional",D._zod.parse=(X,Y)=>{let J=X.value;if(typeof J>"u")return X;return X.issues.push({expected:"undefined",code:"invalid_type",input:J,inst:D}),X}}),nK=m("$ZodNull",(D,$)=>{AD.init(D,$),D._zod.pattern=lB,D._zod.values=new Set([null]),D._zod.parse=(X,Y)=>{let J=X.value;if(J===null)return X;return X.issues.push({expected:"null",code:"invalid_type",input:J,inst:D}),X}}),iK=m("$ZodAny",(D,$)=>{AD.init(D,$),D._zod.parse=(X)=>X}),pK=m("$ZodUnknown",(D,$)=>{AD.init(D,$),D._zod.parse=(X)=>X}),rK=m("$ZodNever",(D,$)=>{AD.init(D,$),D._zod.parse=(X,Y)=>{return X.issues.push({expected:"never",code:"invalid_type",input:X.value,inst:D}),X}}),oK=m("$ZodVoid",(D,$)=>{AD.init(D,$),D._zod.parse=(X,Y)=>{let J=X.value;if(typeof J>"u")return X;return X.issues.push({expected:"void",code:"invalid_type",input:J,inst:D}),X}}),aK=m("$ZodDate",(D,$)=>{AD.init(D,$),D._zod.parse=(X,Y)=>{if($.coerce)try{X.value=new Date(X.value)}catch(w){}let J=X.value,Q=J instanceof Date;if(Q&&!Number.isNaN(J.getTime()))return X;return X.issues.push({expected:"date",code:"invalid_type",input:J,...Q?{received:"Invalid Date"}:{},inst:D}),X}});tK=m("$ZodArray",(D,$)=>{AD.init(D,$),D._zod.parse=(X,Y)=>{let J=X.value;if(!Array.isArray(J))return X.issues.push({expected:"array",code:"invalid_type",input:J,inst:D}),X;X.value=Array(J.length);let Q=[];for(let F=0;F<J.length;F++){let w=J[F],Z=$.element._zod.run({value:w,issues:[]},Y);if(Z instanceof Promise)Q.push(Z.then((G)=>ni(G,X,F)));else ni(Z,X,F)}if(Q.length)return Promise.all(Q).then(()=>X);return X}});Fp=m("$ZodObject",(D,$)=>{if(AD.init(D,$),!Object.getOwnPropertyDescriptor($,"shape")?.get){let w=$.shape;Object.defineProperty($,"shape",{get:()=>{let Z={...w};return Object.defineProperty($,"shape",{value:Z}),Z}})}let Y=B5(()=>Yp($));SD(D._zod,"propValues",()=>{let w=$.shape,Z={};for(let G in w){let O=w[G]._zod;if(O.values){Z[G]??(Z[G]=new Set);for(let U of O.values)Z[G].add(U)}}return Z});let J=A8,Q=$.catchall,F;D._zod.parse=(w,Z)=>{F??(F=Y.value);let G=w.value;if(!J(G))return w.issues.push({expected:"object",code:"invalid_type",input:G,inst:D}),w;w.value={};let O=[],U=F.shape;for(let z of F.keys){let q=U[z],B=q._zod.optout==="optional",K=q._zod.run({value:G[z],issues:[]},Z);if(K instanceof Promise)O.push(K.then((M)=>uF(M,w,z,G,B)));else uF(K,w,z,G,B)}if(!Q)return O.length?Promise.all(O).then(()=>w):w;return Qp(O,G,w,Z,Y.value,D)}}),sK=m("$ZodObjectJIT",(D,$)=>{Fp.init(D,$);let X=D._zod.parse,Y=B5(()=>Yp($)),J=(z)=>{let q=new TF(["shape","payload","ctx"]),B=Y.value,K=(W)=>{let N=OF(W);return`shape[${N}]._zod.run({ value: input[${N}], issues: [] }, ctx)`};q.write("const input = payload.value;");let M=Object.create(null),L=0;for(let W of B.keys)M[W]=`key_${L++}`;q.write("const newResult = {};");for(let W of B.keys){let N=M[W],V=OF(W),C=z[W]?._zod?.optout==="optional";if(q.write(`const ${N} = ${K(W)};`),C)q.write(`
319
319
  if (${N}.issues.length) {
320
320
  if (${V} in input) {
321
321
  payload.issues = payload.issues.concat(${N}.issues.map(iss => ({
@@ -397,7 +397,7 @@ For more information, visit: https://capgo.app/docs/webapp/2fa-enforcement/
397
397
  )`).eq("name",X).eq("app_id",$).single();if(J)throw H.error(`Error fetching native packages: ${J.message}`),Error(`Error fetching native packages: ${J.message}`);return kED(Y.version.native_packages??[])}async function xa(D,$,X,Y){let J=A0();J.start(`Checking bundle checksum compatibility with channel ${X}`);let Q=await _ED(D,$,X);if(!Q){J.stop(`No checksum found for channel ${X}, the bundle will be uploaded`);return}if(Q&&Q===Y)throw J.stop("Checksum check failed"),H.error(`Cannot upload the same bundle content.
398
398
  Current bundle checksum matches remote bundle for channel ${X}
399
399
  Did you build your app before uploading?
400
- PS: You can ignore this check with "--ignore-checksum-check"`),Error("Cannot upload the same bundle content");J.stop(`Checksum compatible with ${X} channel`)}function iD(D,$){return D||$?.plugins?.CapacitorUpdater?.appId||$?.appId}function k8(D){let $=[];if(!D.localVersion)return{compatible:!0,reasons:[],message:"Package only exists on remote (will be removed)"};if(!D.remoteVersion)return $.push("new_plugin"),{compatible:!1,reasons:$,message:"New native plugin added (requires app store update)"};let X=!1;try{let F=t2(D.localVersion),w=t2(D.remoteVersion);X=_I(F,w)}catch{X=!1}if(!X)$.push("version_mismatch");let Y=D.localIosChecksum&&D.remoteIosChecksum&&D.localIosChecksum!==D.remoteIosChecksum,J=D.localAndroidChecksum&&D.remoteAndroidChecksum&&D.localAndroidChecksum!==D.remoteAndroidChecksum;if(Y&&J)$.push("both_platforms_changed");else if(Y)$.push("ios_code_changed");else if(J)$.push("android_code_changed");if($.length===0)return{compatible:!0,reasons:[],message:"Compatible"};let Q=[];for(let F of $)switch(F){case"version_mismatch":Q.push(`version changed: ${D.remoteVersion} → ${D.localVersion}`);break;case"ios_code_changed":Q.push("iOS native code changed");break;case"android_code_changed":Q.push("Android native code changed");break;case"both_platforms_changed":Q.push("iOS and Android native code changed");break;case"new_plugin":Q.push("new plugin (requires app store update)");break;case"removed_plugin":Q.push("plugin removed");break}return{compatible:!1,reasons:$,message:Q.join(", ")}}function L4(D){return k8(D).compatible}async function OZ(D,$,X,Y,J){let Q=await vM(Y,J),F=await Pa(D,$,X),w=Q.filter((G)=>!!G.native).map((G)=>{let O=F.get(G.name);if(O)return{name:G.name,localVersion:G.version,remoteVersion:O.version,localIosChecksum:G.ios_checksum,remoteIosChecksum:O.ios_checksum,localAndroidChecksum:G.android_checksum,remoteAndroidChecksum:O.android_checksum};return{name:G.name,localVersion:G.version,remoteVersion:void 0,localIosChecksum:G.ios_checksum,localAndroidChecksum:G.android_checksum}}),Z=[...F].filter(([G])=>Q.find((O)=>O.name===G)===void 0).map(([G,O])=>({name:G,localVersion:void 0,remoteVersion:O.version,remoteIosChecksum:O.ios_checksum,remoteAndroidChecksum:O.android_checksum}));return w.push(...Z),{finalCompatibility:w,localDependencies:Q}}async function _M(D,$,X,Y){let J=await Pa(D,$,X),Q=Y.map((w)=>{let Z=J.get(w.name);if(Z)return{name:w.name,localVersion:w.version,remoteVersion:Z.version,localIosChecksum:w.ios_checksum,remoteIosChecksum:Z.ios_checksum,localAndroidChecksum:w.android_checksum,remoteAndroidChecksum:Z.android_checksum};return{name:w.name,localVersion:w.version,remoteVersion:void 0,localIosChecksum:w.ios_checksum,localAndroidChecksum:w.android_checksum}}),F=[...J].filter(([w])=>Y.find((Z)=>Z.name===w)===void 0).map(([w,Z])=>({name:w,localVersion:void 0,remoteVersion:Z.version,remoteIosChecksum:Z.ios_checksum,remoteAndroidChecksum:Z.android_checksum}));return Q.push(...F),{finalCompatibility:Q,localDependencies:Y}}function fED(D){if(!G0(D))return null;try{return JSON.parse(f0(D,"utf-8"))}catch{return null}}function $2(D){if(!D)return!1;return/@capgo\/capacitor-updater|CapgoCapacitorUpdater|CapacitorUpdaterPlugin/.test(D)}function yED(D,$){if(!$)return kD(D,A6);return Y2.isAbsolute($)?$:CM(D,$)}function bED(D=I6(),$){let X=yED(D,$),Y=Y2.basename(X)===A6?X2(X):X,J=[kD(Y,"ios","App"),kD(D,"ios","App")].find((P)=>G0(P));if(!J)return{shouldCheck:!1,valid:!0,details:[]};let Q=fED(X),F={...Q?.dependencies,...Q?.devDependencies,...Q?.optionalDependencies},w=Object.prototype.hasOwnProperty.call(F,"@capgo/capacitor-updater"),Z=[Y,D].some((P)=>G0(kD(P,"node_modules","@capgo","capacitor-updater"))),G=kD(J,"Podfile"),O=kD(J,"CapApp-SPM","Package.swift"),U=G0(G)?f0(G,"utf-8"):void 0,z=G0(O)?f0(O,"utf-8"):void 0,q=$2(U)||$2(z),B=kD(J,"Podfile.lock"),K=kD(J,"App.xcworkspace","xcshareddata","swiftpm","Package.resolved"),M=kD(J,"App","capacitor.plugins.json"),L=G0(B)?f0(B,"utf-8"):void 0,I=G0(K)?f0(K,"utf-8"):void 0,W=G0(M)?f0(M,"utf-8"):void 0,N=$2(L)||$2(I)||$2(W);if(!(w||Z||q||N))return{shouldCheck:!1,valid:!0,details:[]};let R=[];if(!q)R.push(`Missing @capgo/capacitor-updater in iOS dependency files (${G} or ${O})`);if(!N)R.push(`Missing @capgo/capacitor-updater in iOS native project outputs (${B}, ${K}, or ${M})`);return{shouldCheck:!0,valid:q&&N,details:R}}async function Sa(D,$,X,Y){let J=await c0({message:"Would you like to sync your project with Capacitor now? This is recommended to ensure encrypted updates work properly."});if(yD(J)){if(D&&$&&X)await cx("onboarding-v2",$,X,"canceled","\uD83E\uDD37");throw H.error("Canceled Capacitor sync"),Error("Capacitor sync cancelled")}if(J){let Q=_8(),F=A0();F.start("Running the command...");let w;try{await new Promise((Z,G)=>{let O=WED(Q.runner,["cap","sync"],{stdio:"pipe"});O.on("close",(U)=>{if(U===0)Z();else G(Error(`Command failed with exit code ${U}`))}),O.on("error",(U)=>{G(U)})})}catch(Z){w=Z,H.error(`Failed to run Capacitor sync: ${Z}`),H.warn(`Please run "${Q.runner} cap sync" manually to ensure encrypted updates work properly`)}if(Y?.validateIosUpdater){let Z=bED(I6(),Y.packageJsonPath);if(Z.shouldCheck&&!Z.valid){F.stop("iOS sync check failed ❌"),H.error("Capgo iOS dependency sync verification failed.");for(let G of Z.details)H.error(G);throw H.error("Stop here to avoid testing on a broken native iOS project."),H.warn("Best fix: reset the iOS folder, then run sync again."),H.info(`1. ${Q.runner} cap rm ios`),H.info(`2. ${Q.runner} cap add ios`),H.info(`3. ${Q.runner} cap sync ios`),Error("iOS sync validation failed. Reset your iOS folder and retry.")}}if(w){F.stop("Error");return}F.stop("Capacitor sync completed ✅")}else{let Q=_8();H.warn("⚠️ Important: If you upload encrypted bundles without syncing, updates will fail!"),H.info(`Remember to run "${Q.runner} cap sync" before uploading encrypted bundles`)}}var V4,PM,qa,DZ,i5=".capgo_key",i1=".capgo_key_v2",$Z,R6,Qa="https://capgo.app",Fa="https://files.capgo.app",wa="https://api.capgo.app",Za="https://console.capgo.app",xM=120000,LED=20971520,IED=1073741824,AED=103809024,A6="package.json",p5,Ba,R1,r5=(D,$)=>D>=$,QZ="5.10.0",FZ="6.25.0",Q2="7.0.30",Ga=!1,n5="npm",D2="install",TM="npx";var fD=o(()=>{VI();vD();D6();wE();lx();q3();GF();So();rw();V4=V0(l2(),1),PM=V0(KO(),1),qa=V0(WT(),1),DZ=V0(NY(),1),$Z=`${i5}.pub`,R6=`${i1}.pub`,p5=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-z-][0-9a-z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-z-][0-9a-z-]*))*))?(?:\+([0-9a-z-]+(?:\.[0-9a-z-]+)*))?$/i;Ba=/([A-Za-z0-9]+)\.(java|swift|kt|scala)$/;((F)=>{F[F.none=0]="none";F[F.read=1]="read";F[F.upload=2]="upload";F[F.write=3]="write";F[F.admin=4]="admin";F[F.super_admin=5]="super_admin"})(R1||={})});var j6=T((IrD,Qt)=>{var Jt=["nodebuffer","arraybuffer","fragments"],Yt=typeof Blob<"u";if(Yt)Jt.push("blob");Qt.exports={BINARY_TYPES:Jt,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:Yt,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var F2=T((ArD,BZ)=>{var{EMPTY_BUFFER:$TD}=j6(),bM=Buffer[Symbol.species];function XTD(D,$){if(D.length===0)return $TD;if(D.length===1)return D[0];let X=Buffer.allocUnsafe($),Y=0;for(let J=0;J<D.length;J++){let Q=D[J];X.set(Q,Y),Y+=Q.length}if(Y<$)return new bM(X.buffer,X.byteOffset,Y);return X}function Ft(D,$,X,Y,J){for(let Q=0;Q<J;Q++)X[Y+Q]=D[Q]^$[Q&3]}function wt(D,$){for(let X=0;X<D.length;X++)D[X]^=$[X&3]}function JTD(D){if(D.length===D.buffer.byteLength)return D.buffer;return D.buffer.slice(D.byteOffset,D.byteOffset+D.length)}function gM(D){if(gM.readOnly=!0,Buffer.isBuffer(D))return D;let $;if(D instanceof ArrayBuffer)$=new bM(D);else if(ArrayBuffer.isView(D))$=new bM(D.buffer,D.byteOffset,D.byteLength);else $=Buffer.from(D),gM.readOnly=!1;return $}BZ.exports={concat:XTD,mask:Ft,toArrayBuffer:JTD,toBuffer:gM,unmask:wt};if(!process.env.WS_NO_BUFFER_UTIL)try{let D=(()=>{throw new Error("Cannot require module "+"bufferutil");})();BZ.exports.mask=function($,X,Y,J,Q){if(Q<48)Ft($,X,Y,J,Q);else D.mask($,X,Y,J,Q)},BZ.exports.unmask=function($,X){if($.length<32)wt($,X);else D.unmask($,X)}}catch(D){}});var Ut=T((RrD,Ot)=>{var Zt=Symbol("kDone"),hM=Symbol("kRun");class Gt{constructor(D){this[Zt]=()=>{this.pending--,this[hM]()},this.concurrency=D||1/0,this.jobs=[],this.pending=0}add(D){this.jobs.push(D),this[hM]()}[hM](){if(this.pending===this.concurrency)return;if(this.jobs.length){let D=this.jobs.shift();this.pending++,D(this[Zt])}}}Ot.exports=Gt});var Z2=T((jrD,Wt)=>{var w2=p("zlib"),qt=F2(),YTD=Ut(),{kStatusCode:zt}=j6(),QTD=Buffer[Symbol.species],FTD=Buffer.from([0,0,255,255]),WZ=Symbol("permessage-deflate"),E6=Symbol("total-length"),t5=Symbol("callback"),I4=Symbol("buffers"),s5=Symbol("error"),KZ;class Bt{constructor(D,$,X){if(this._maxPayload=X|0,this._options=D||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!$,this._deflate=null,this._inflate=null,this.params=null,!KZ){let Y=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;KZ=new YTD(Y)}}static get extensionName(){return"permessage-deflate"}offer(){let D={};if(this._options.serverNoContextTakeover)D.server_no_context_takeover=!0;if(this._options.clientNoContextTakeover)D.client_no_context_takeover=!0;if(this._options.serverMaxWindowBits)D.server_max_window_bits=this._options.serverMaxWindowBits;if(this._options.clientMaxWindowBits)D.client_max_window_bits=this._options.clientMaxWindowBits;else if(this._options.clientMaxWindowBits==null)D.client_max_window_bits=!0;return D}accept(D){return D=this.normalizeParams(D),this.params=this._isServer?this.acceptAsServer(D):this.acceptAsClient(D),this.params}cleanup(){if(this._inflate)this._inflate.close(),this._inflate=null;if(this._deflate){let D=this._deflate[t5];if(this._deflate.close(),this._deflate=null,D)D(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(D){let $=this._options,X=D.find((Y)=>{if($.serverNoContextTakeover===!1&&Y.server_no_context_takeover||Y.server_max_window_bits&&($.serverMaxWindowBits===!1||typeof $.serverMaxWindowBits==="number"&&$.serverMaxWindowBits>Y.server_max_window_bits)||typeof $.clientMaxWindowBits==="number"&&!Y.client_max_window_bits)return!1;return!0});if(!X)throw Error("None of the extension offers can be accepted");if($.serverNoContextTakeover)X.server_no_context_takeover=!0;if($.clientNoContextTakeover)X.client_no_context_takeover=!0;if(typeof $.serverMaxWindowBits==="number")X.server_max_window_bits=$.serverMaxWindowBits;if(typeof $.clientMaxWindowBits==="number")X.client_max_window_bits=$.clientMaxWindowBits;else if(X.client_max_window_bits===!0||$.clientMaxWindowBits===!1)delete X.client_max_window_bits;return X}acceptAsClient(D){let $=D[0];if(this._options.clientNoContextTakeover===!1&&$.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!$.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")$.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&$.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return $}normalizeParams(D){return D.forEach(($)=>{Object.keys($).forEach((X)=>{let Y=$[X];if(Y.length>1)throw Error(`Parameter "${X}" must have only a single value`);if(Y=Y[0],X==="client_max_window_bits"){if(Y!==!0){let J=+Y;if(!Number.isInteger(J)||J<8||J>15)throw TypeError(`Invalid value for parameter "${X}": ${Y}`);Y=J}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${X}": ${Y}`)}else if(X==="server_max_window_bits"){let J=+Y;if(!Number.isInteger(J)||J<8||J>15)throw TypeError(`Invalid value for parameter "${X}": ${Y}`);Y=J}else if(X==="client_no_context_takeover"||X==="server_no_context_takeover"){if(Y!==!0)throw TypeError(`Invalid value for parameter "${X}": ${Y}`)}else throw Error(`Unknown parameter "${X}"`);$[X]=Y})}),D}decompress(D,$,X){KZ.add((Y)=>{this._decompress(D,$,(J,Q)=>{Y(),X(J,Q)})})}compress(D,$,X){KZ.add((Y)=>{this._compress(D,$,(J,Q)=>{Y(),X(J,Q)})})}_decompress(D,$,X){let Y=this._isServer?"client":"server";if(!this._inflate){let J=`${Y}_max_window_bits`,Q=typeof this.params[J]!=="number"?w2.Z_DEFAULT_WINDOWBITS:this.params[J];this._inflate=w2.createInflateRaw({...this._options.zlibInflateOptions,windowBits:Q}),this._inflate[WZ]=this,this._inflate[E6]=0,this._inflate[I4]=[],this._inflate.on("error",ZTD),this._inflate.on("data",Kt)}if(this._inflate[t5]=X,this._inflate.write(D),$)this._inflate.write(FTD);this._inflate.flush(()=>{let J=this._inflate[s5];if(J){this._inflate.close(),this._inflate=null,X(J);return}let Q=qt.concat(this._inflate[I4],this._inflate[E6]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[E6]=0,this._inflate[I4]=[],$&&this.params[`${Y}_no_context_takeover`])this._inflate.reset();X(null,Q)})}_compress(D,$,X){let Y=this._isServer?"server":"client";if(!this._deflate){let J=`${Y}_max_window_bits`,Q=typeof this.params[J]!=="number"?w2.Z_DEFAULT_WINDOWBITS:this.params[J];this._deflate=w2.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:Q}),this._deflate[E6]=0,this._deflate[I4]=[],this._deflate.on("data",wTD)}this._deflate[t5]=X,this._deflate.write(D),this._deflate.flush(w2.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let J=qt.concat(this._deflate[I4],this._deflate[E6]);if($)J=new QTD(J.buffer,J.byteOffset,J.length-4);if(this._deflate[t5]=null,this._deflate[E6]=0,this._deflate[I4]=[],$&&this.params[`${Y}_no_context_takeover`])this._deflate.reset();X(null,J)})}}Wt.exports=Bt;function wTD(D){this[I4].push(D),this[E6]+=D.length}function Kt(D){if(this[E6]+=D.length,this[WZ]._maxPayload<1||this[E6]<=this[WZ]._maxPayload){this[I4].push(D);return}this[s5]=RangeError("Max payload size exceeded"),this[s5].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[s5][zt]=1009,this.removeListener("data",Kt),this.reset()}function ZTD(D){if(this[WZ]._inflate=null,this[s5]){this[t5](this[s5]);return}D[zt]=1007,this[t5](D)}});var e5=T((ErD,HZ)=>{var{isUtf8:Ht}=p("buffer"),{hasBlob:GTD}=j6(),OTD=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function UTD(D){return D>=1000&&D<=1014&&D!==1004&&D!==1005&&D!==1006||D>=3000&&D<=4999}function mM(D){let $=D.length,X=0;while(X<$)if((D[X]&128)===0)X++;else if((D[X]&224)===192){if(X+1===$||(D[X+1]&192)!==128||(D[X]&254)===192)return!1;X+=2}else if((D[X]&240)===224){if(X+2>=$||(D[X+1]&192)!==128||(D[X+2]&192)!==128||D[X]===224&&(D[X+1]&224)===128||D[X]===237&&(D[X+1]&224)===160)return!1;X+=3}else if((D[X]&248)===240){if(X+3>=$||(D[X+1]&192)!==128||(D[X+2]&192)!==128||(D[X+3]&192)!==128||D[X]===240&&(D[X+1]&240)===128||D[X]===244&&D[X+1]>143||D[X]>244)return!1;X+=4}else return!1;return!0}function qTD(D){return GTD&&typeof D==="object"&&typeof D.arrayBuffer==="function"&&typeof D.type==="string"&&typeof D.stream==="function"&&(D[Symbol.toStringTag]==="Blob"||D[Symbol.toStringTag]==="File")}HZ.exports={isBlob:qTD,isValidStatusCode:UTD,isValidUTF8:mM,tokenChars:OTD};if(Ht)HZ.exports.isValidUTF8=function(D){return D.length<24?mM(D):Ht(D)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let D=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();HZ.exports.isValidUTF8=function($){return $.length<32?mM($):D($)}}catch(D){}});var cM=T((TrD,It)=>{var{Writable:zTD}=p("stream"),Vt=Z2(),{BINARY_TYPES:BTD,EMPTY_BUFFER:Nt,kStatusCode:KTD,kWebSocket:WTD}=j6(),{concat:dM,toArrayBuffer:HTD,unmask:VTD}=F2(),{isValidStatusCode:NTD,isValidUTF8:Mt}=e5(),VZ=Buffer[Symbol.species];class Lt extends zTD{constructor(D={}){super();this._allowSynchronousEvents=D.allowSynchronousEvents!==void 0?D.allowSynchronousEvents:!0,this._binaryType=D.binaryType||BTD[0],this._extensions=D.extensions||{},this._isServer=!!D.isServer,this._maxPayload=D.maxPayload|0,this._skipUTF8Validation=!!D.skipUTF8Validation,this[WTD]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(D,$,X){if(this._opcode===8&&this._state==0)return X();this._bufferedBytes+=D.length,this._buffers.push(D),this.startLoop(X)}consume(D){if(this._bufferedBytes-=D,D===this._buffers[0].length)return this._buffers.shift();if(D<this._buffers[0].length){let X=this._buffers[0];return this._buffers[0]=new VZ(X.buffer,X.byteOffset+D,X.length-D),new VZ(X.buffer,X.byteOffset,D)}let $=Buffer.allocUnsafe(D);do{let X=this._buffers[0],Y=$.length-D;if(D>=X.length)$.set(this._buffers.shift(),Y);else $.set(new Uint8Array(X.buffer,X.byteOffset,D),Y),this._buffers[0]=new VZ(X.buffer,X.byteOffset+D,X.length-D);D-=X.length}while(D>0);return $}startLoop(D){this._loop=!0;do switch(this._state){case 0:this.getInfo(D);break;case 1:this.getPayloadLength16(D);break;case 2:this.getPayloadLength64(D);break;case 3:this.getMask();break;case 4:this.getData(D);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)D()}getInfo(D){if(this._bufferedBytes<2){this._loop=!1;return}let $=this.consume(2);if(($[0]&48)!==0){let Y=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");D(Y);return}let X=($[0]&64)===64;if(X&&!this._extensions[Vt.extensionName]){let Y=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");D(Y);return}if(this._fin=($[0]&128)===128,this._opcode=$[0]&15,this._payloadLength=$[1]&127,this._opcode===0){if(X){let Y=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");D(Y);return}if(!this._fragmented){let Y=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");D(Y);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let Y=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");D(Y);return}this._compressed=X}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let Y=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");D(Y);return}if(X){let Y=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");D(Y);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let Y=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");D(Y);return}}else{let Y=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");D(Y);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=($[1]&128)===128,this._isServer){if(!this._masked){let Y=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");D(Y);return}}else if(this._masked){let Y=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");D(Y);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength(D)}getPayloadLength16(D){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(D)}getPayloadLength64(D){if(this._bufferedBytes<8){this._loop=!1;return}let $=this.consume(8),X=$.readUInt32BE(0);if(X>Math.pow(2,21)-1){let Y=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");D(Y);return}this._payloadLength=X*Math.pow(2,32)+$.readUInt32BE(4),this.haveLength(D)}haveLength(D){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let $=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");D($);return}}if(this._masked)this._state=3;else this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(D){let $=Nt;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if($=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)VTD($,this._mask)}if(this._opcode>7){this.controlMessage($,D);return}if(this._compressed){this._state=5,this.decompress($,D);return}if($.length)this._messageLength=this._totalPayloadLength,this._fragments.push($);this.dataMessage(D)}decompress(D,$){this._extensions[Vt.extensionName].decompress(D,this._fin,(Y,J)=>{if(Y)return $(Y);if(J.length){if(this._messageLength+=J.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let Q=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");$(Q);return}this._fragments.push(J)}if(this.dataMessage($),this._state===0)this.startLoop($)})}dataMessage(D){if(!this._fin){this._state=0;return}let $=this._messageLength,X=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let Y;if(this._binaryType==="nodebuffer")Y=dM(X,$);else if(this._binaryType==="arraybuffer")Y=HTD(dM(X,$));else if(this._binaryType==="blob")Y=new Blob(X);else Y=X;if(this._allowSynchronousEvents)this.emit("message",Y,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",Y,!0),this._state=0,this.startLoop(D)})}else{let Y=dM(X,$);if(!this._skipUTF8Validation&&!Mt(Y)){let J=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");D(J);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",Y,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",Y,!1),this._state=0,this.startLoop(D)})}}controlMessage(D,$){if(this._opcode===8){if(D.length===0)this._loop=!1,this.emit("conclude",1005,Nt),this.end();else{let X=D.readUInt16BE(0);if(!NTD(X)){let J=this.createError(RangeError,`invalid status code ${X}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");$(J);return}let Y=new VZ(D.buffer,D.byteOffset+2,D.length-2);if(!this._skipUTF8Validation&&!Mt(Y)){let J=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");$(J);return}this._loop=!1,this.emit("conclude",X,Y),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",D),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",D),this._state=0,this.startLoop($)})}createError(D,$,X,Y,J){this._loop=!1,this._errored=!0;let Q=new D(X?`Invalid WebSocket frame: ${$}`:$);return Error.captureStackTrace(Q,this.createError),Q.code=J,Q[KTD]=Y,Q}}It.exports=Lt});var nM=T((PrD,jt)=>{var{Duplex:CrD}=p("stream"),{randomFillSync:MTD}=p("crypto"),At=Z2(),{EMPTY_BUFFER:LTD,kWebSocket:ITD,NOOP:ATD}=j6(),{isBlob:D7,isValidStatusCode:RTD}=e5(),{mask:Rt,toBuffer:y8}=F2(),O$=Symbol("kByteLength"),jTD=Buffer.alloc(4),b8,$7=8192,j$=0,ETD=1,TTD=2;class A4{constructor(D,$,X){if(this._extensions=$||{},X)this._generateMask=X,this._maskBuffer=Buffer.alloc(4);this._socket=D,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=j$,this.onerror=ATD,this[ITD]=void 0}static frame(D,$){let X,Y=!1,J=2,Q=!1;if($.mask){if(X=$.maskBuffer||jTD,$.generateMask)$.generateMask(X);else{if($7===8192){if(b8===void 0)b8=Buffer.alloc(8192);MTD(b8,0,8192),$7=0}X[0]=b8[$7++],X[1]=b8[$7++],X[2]=b8[$7++],X[3]=b8[$7++]}Q=(X[0]|X[1]|X[2]|X[3])===0,J=6}let F;if(typeof D==="string")if((!$.mask||Q)&&$[O$]!==void 0)F=$[O$];else D=Buffer.from(D),F=D.length;else F=D.length,Y=$.mask&&$.readOnly&&!Q;let w=F;if(F>=65536)J+=8,w=127;else if(F>125)J+=2,w=126;let Z=Buffer.allocUnsafe(Y?F+J:J);if(Z[0]=$.fin?$.opcode|128:$.opcode,$.rsv1)Z[0]|=64;if(Z[1]=w,w===126)Z.writeUInt16BE(F,2);else if(w===127)Z[2]=Z[3]=0,Z.writeUIntBE(F,4,6);if(!$.mask)return[Z,D];if(Z[1]|=128,Z[J-4]=X[0],Z[J-3]=X[1],Z[J-2]=X[2],Z[J-1]=X[3],Q)return[Z,D];if(Y)return Rt(D,X,Z,J,F),[Z];return Rt(D,X,D,0,F),[Z,D]}close(D,$,X,Y){let J;if(D===void 0)J=LTD;else if(typeof D!=="number"||!RTD(D))throw TypeError("First argument must be a valid error code number");else if($===void 0||!$.length)J=Buffer.allocUnsafe(2),J.writeUInt16BE(D,0);else{let F=Buffer.byteLength($);if(F>123)throw RangeError("The message must not be greater than 123 bytes");if(J=Buffer.allocUnsafe(2+F),J.writeUInt16BE(D,0),typeof $==="string")J.write($,2);else J.set($,2)}let Q={[O$]:J.length,fin:!0,generateMask:this._generateMask,mask:X,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==j$)this.enqueue([this.dispatch,J,!1,Q,Y]);else this.sendFrame(A4.frame(J,Q),Y)}ping(D,$,X){let Y,J;if(typeof D==="string")Y=Buffer.byteLength(D),J=!1;else if(D7(D))Y=D.size,J=!1;else D=y8(D),Y=D.length,J=y8.readOnly;if(Y>125)throw RangeError("The data size must not be greater than 125 bytes");let Q={[O$]:Y,fin:!0,generateMask:this._generateMask,mask:$,maskBuffer:this._maskBuffer,opcode:9,readOnly:J,rsv1:!1};if(D7(D))if(this._state!==j$)this.enqueue([this.getBlobData,D,!1,Q,X]);else this.getBlobData(D,!1,Q,X);else if(this._state!==j$)this.enqueue([this.dispatch,D,!1,Q,X]);else this.sendFrame(A4.frame(D,Q),X)}pong(D,$,X){let Y,J;if(typeof D==="string")Y=Buffer.byteLength(D),J=!1;else if(D7(D))Y=D.size,J=!1;else D=y8(D),Y=D.length,J=y8.readOnly;if(Y>125)throw RangeError("The data size must not be greater than 125 bytes");let Q={[O$]:Y,fin:!0,generateMask:this._generateMask,mask:$,maskBuffer:this._maskBuffer,opcode:10,readOnly:J,rsv1:!1};if(D7(D))if(this._state!==j$)this.enqueue([this.getBlobData,D,!1,Q,X]);else this.getBlobData(D,!1,Q,X);else if(this._state!==j$)this.enqueue([this.dispatch,D,!1,Q,X]);else this.sendFrame(A4.frame(D,Q),X)}send(D,$,X){let Y=this._extensions[At.extensionName],J=$.binary?2:1,Q=$.compress,F,w;if(typeof D==="string")F=Buffer.byteLength(D),w=!1;else if(D7(D))F=D.size,w=!1;else D=y8(D),F=D.length,w=y8.readOnly;if(this._firstFragment){if(this._firstFragment=!1,Q&&Y&&Y.params[Y._isServer?"server_no_context_takeover":"client_no_context_takeover"])Q=F>=Y._threshold;this._compress=Q}else Q=!1,J=0;if($.fin)this._firstFragment=!0;let Z={[O$]:F,fin:$.fin,generateMask:this._generateMask,mask:$.mask,maskBuffer:this._maskBuffer,opcode:J,readOnly:w,rsv1:Q};if(D7(D))if(this._state!==j$)this.enqueue([this.getBlobData,D,this._compress,Z,X]);else this.getBlobData(D,this._compress,Z,X);else if(this._state!==j$)this.enqueue([this.dispatch,D,this._compress,Z,X]);else this.dispatch(D,this._compress,Z,X)}getBlobData(D,$,X,Y){this._bufferedBytes+=X[O$],this._state=TTD,D.arrayBuffer().then((J)=>{if(this._socket.destroyed){let F=Error("The socket was closed while the blob was being read");process.nextTick(lM,this,F,Y);return}this._bufferedBytes-=X[O$];let Q=y8(J);if(!$)this._state=j$,this.sendFrame(A4.frame(Q,X),Y),this.dequeue();else this.dispatch(Q,$,X,Y)}).catch((J)=>{process.nextTick(CTD,this,J,Y)})}dispatch(D,$,X,Y){if(!$){this.sendFrame(A4.frame(D,X),Y);return}let J=this._extensions[At.extensionName];this._bufferedBytes+=X[O$],this._state=ETD,J.compress(D,X.fin,(Q,F)=>{if(this._socket.destroyed){let w=Error("The socket was closed while data was being compressed");lM(this,w,Y);return}this._bufferedBytes-=X[O$],this._state=j$,X.readOnly=!1,this.sendFrame(A4.frame(F,X),Y),this.dequeue()})}dequeue(){while(this._state===j$&&this._queue.length){let D=this._queue.shift();this._bufferedBytes-=D[3][O$],Reflect.apply(D[0],this,D.slice(1))}}enqueue(D){this._bufferedBytes+=D[3][O$],this._queue.push(D)}sendFrame(D,$){if(D.length===2)this._socket.cork(),this._socket.write(D[0]),this._socket.write(D[1],$),this._socket.uncork();else this._socket.write(D[0],$)}}jt.exports=A4;function lM(D,$,X){if(typeof X==="function")X($);for(let Y=0;Y<D._queue.length;Y++){let J=D._queue[Y],Q=J[J.length-1];if(typeof Q==="function")Q($)}}function CTD(D,$,X){lM(D,$,X),D.onerror($)}});var _t=T((xrD,vt)=>{var{kForOnEventAttribute:G2,kListener:iM}=j6(),Et=Symbol("kCode"),Tt=Symbol("kData"),Ct=Symbol("kError"),Pt=Symbol("kMessage"),xt=Symbol("kReason"),X7=Symbol("kTarget"),St=Symbol("kType"),ut=Symbol("kWasClean");class R4{constructor(D){this[X7]=null,this[St]=D}get target(){return this[X7]}get type(){return this[St]}}Object.defineProperty(R4.prototype,"target",{enumerable:!0});Object.defineProperty(R4.prototype,"type",{enumerable:!0});class J7 extends R4{constructor(D,$={}){super(D);this[Et]=$.code===void 0?0:$.code,this[xt]=$.reason===void 0?"":$.reason,this[ut]=$.wasClean===void 0?!1:$.wasClean}get code(){return this[Et]}get reason(){return this[xt]}get wasClean(){return this[ut]}}Object.defineProperty(J7.prototype,"code",{enumerable:!0});Object.defineProperty(J7.prototype,"reason",{enumerable:!0});Object.defineProperty(J7.prototype,"wasClean",{enumerable:!0});class O2 extends R4{constructor(D,$={}){super(D);this[Ct]=$.error===void 0?null:$.error,this[Pt]=$.message===void 0?"":$.message}get error(){return this[Ct]}get message(){return this[Pt]}}Object.defineProperty(O2.prototype,"error",{enumerable:!0});Object.defineProperty(O2.prototype,"message",{enumerable:!0});class MZ extends R4{constructor(D,$={}){super(D);this[Tt]=$.data===void 0?null:$.data}get data(){return this[Tt]}}Object.defineProperty(MZ.prototype,"data",{enumerable:!0});var PTD={addEventListener(D,$,X={}){for(let J of this.listeners(D))if(!X[G2]&&J[iM]===$&&!J[G2])return;let Y;if(D==="message")Y=function(Q,F){let w=new MZ("message",{data:F?Q:Q.toString()});w[X7]=this,NZ($,this,w)};else if(D==="close")Y=function(Q,F){let w=new J7("close",{code:Q,reason:F.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});w[X7]=this,NZ($,this,w)};else if(D==="error")Y=function(Q){let F=new O2("error",{error:Q,message:Q.message});F[X7]=this,NZ($,this,F)};else if(D==="open")Y=function(){let Q=new R4("open");Q[X7]=this,NZ($,this,Q)};else return;if(Y[G2]=!!X[G2],Y[iM]=$,X.once)this.once(D,Y);else this.on(D,Y)},removeEventListener(D,$){for(let X of this.listeners(D))if(X[iM]===$&&!X[G2]){this.removeListener(D,X);break}}};vt.exports={CloseEvent:J7,ErrorEvent:O2,Event:R4,EventTarget:PTD,MessageEvent:MZ};function NZ(D,$,X){if(typeof D==="object"&&D.handleEvent)D.handleEvent.call(D,X);else D.call($,X)}});var pM=T((SrD,kt)=>{var{tokenChars:U2}=e5();function o$(D,$,X){if(D[$]===void 0)D[$]=[X];else D[$].push(X)}function xTD(D){let $=Object.create(null),X=Object.create(null),Y=!1,J=!1,Q=!1,F,w,Z=-1,G=-1,O=-1,U=0;for(;U<D.length;U++)if(G=D.charCodeAt(U),F===void 0)if(O===-1&&U2[G]===1){if(Z===-1)Z=U}else if(U!==0&&(G===32||G===9)){if(O===-1&&Z!==-1)O=U}else if(G===59||G===44){if(Z===-1)throw SyntaxError(`Unexpected character at index ${U}`);if(O===-1)O=U;let q=D.slice(Z,O);if(G===44)o$($,q,X),X=Object.create(null);else F=q;Z=O=-1}else throw SyntaxError(`Unexpected character at index ${U}`);else if(w===void 0)if(O===-1&&U2[G]===1){if(Z===-1)Z=U}else if(G===32||G===9){if(O===-1&&Z!==-1)O=U}else if(G===59||G===44){if(Z===-1)throw SyntaxError(`Unexpected character at index ${U}`);if(O===-1)O=U;if(o$(X,D.slice(Z,O),!0),G===44)o$($,F,X),X=Object.create(null),F=void 0;Z=O=-1}else if(G===61&&Z!==-1&&O===-1)w=D.slice(Z,U),Z=O=-1;else throw SyntaxError(`Unexpected character at index ${U}`);else if(J){if(U2[G]!==1)throw SyntaxError(`Unexpected character at index ${U}`);if(Z===-1)Z=U;else if(!Y)Y=!0;J=!1}else if(Q)if(U2[G]===1){if(Z===-1)Z=U}else if(G===34&&Z!==-1)Q=!1,O=U;else if(G===92)J=!0;else throw SyntaxError(`Unexpected character at index ${U}`);else if(G===34&&D.charCodeAt(U-1)===61)Q=!0;else if(O===-1&&U2[G]===1){if(Z===-1)Z=U}else if(Z!==-1&&(G===32||G===9)){if(O===-1)O=U}else if(G===59||G===44){if(Z===-1)throw SyntaxError(`Unexpected character at index ${U}`);if(O===-1)O=U;let q=D.slice(Z,O);if(Y)q=q.replace(/\\/g,""),Y=!1;if(o$(X,w,q),G===44)o$($,F,X),X=Object.create(null),F=void 0;w=void 0,Z=O=-1}else throw SyntaxError(`Unexpected character at index ${U}`);if(Z===-1||Q||G===32||G===9)throw SyntaxError("Unexpected end of input");if(O===-1)O=U;let z=D.slice(Z,O);if(F===void 0)o$($,z,X);else{if(w===void 0)o$(X,z,!0);else if(Y)o$(X,w,z.replace(/\\/g,""));else o$(X,w,z);o$($,F,X)}return $}function STD(D){return Object.keys(D).map(($)=>{let X=D[$];if(!Array.isArray(X))X=[X];return X.map((Y)=>{return[$].concat(Object.keys(Y).map((J)=>{let Q=Y[J];if(!Array.isArray(Q))Q=[Q];return Q.map((F)=>F===!0?J:`${J}=${F}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}kt.exports={format:STD,parse:xTD}});var RZ=T((_rD,pt)=>{var uTD=p("events"),vTD=p("https"),_TD=p("http"),bt=p("net"),kTD=p("tls"),{randomBytes:fTD,createHash:yTD}=p("crypto"),{Duplex:urD,Readable:vrD}=p("stream"),{URL:rM}=p("url"),j4=Z2(),bTD=cM(),gTD=nM(),{isBlob:hTD}=e5(),{BINARY_TYPES:ft,CLOSE_TIMEOUT:mTD,EMPTY_BUFFER:LZ,GUID:dTD,kForOnEventAttribute:oM,kListener:cTD,kStatusCode:lTD,kWebSocket:i0,NOOP:gt}=j6(),{EventTarget:{addEventListener:nTD,removeEventListener:iTD}}=_t(),{format:pTD,parse:rTD}=pM(),{toBuffer:oTD}=F2(),ht=Symbol("kAborted"),aM=[8,13],T6=["CONNECTING","OPEN","CLOSING","CLOSED"],aTD=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class ED extends uTD{constructor(D,$,X){super();if(this._binaryType=ft[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=LZ,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=ED.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,D!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,$===void 0)$=[];else if(!Array.isArray($))if(typeof $==="object"&&$!==null)X=$,$=[];else $=[$];mt(this,D,$,X)}else this._autoPong=X.autoPong,this._closeTimeout=X.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(D){if(!ft.includes(D))return;if(this._binaryType=D,this._receiver)this._receiver._binaryType=D}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(D,$,X){let Y=new bTD({allowSynchronousEvents:X.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:X.maxPayload,skipUTF8Validation:X.skipUTF8Validation}),J=new gTD(D,this._extensions,X.generateMask);if(this._receiver=Y,this._sender=J,this._socket=D,Y[i0]=this,J[i0]=this,D[i0]=this,Y.on("conclude",eTD),Y.on("drain",DCD),Y.on("error",$CD),Y.on("message",XCD),Y.on("ping",JCD),Y.on("pong",YCD),J.onerror=QCD,D.setTimeout)D.setTimeout(0);if(D.setNoDelay)D.setNoDelay();if($.length>0)D.unshift($);D.on("close",lt),D.on("data",AZ),D.on("end",nt),D.on("error",it),this._readyState=ED.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=ED.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[j4.extensionName])this._extensions[j4.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=ED.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(D,$){if(this.readyState===ED.CLOSED)return;if(this.readyState===ED.CONNECTING){p1(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===ED.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=ED.CLOSING,this._sender.close(D,$,!this._isServer,(X)=>{if(X)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),ct(this)}pause(){if(this.readyState===ED.CONNECTING||this.readyState===ED.CLOSED)return;this._paused=!0,this._socket.pause()}ping(D,$,X){if(this.readyState===ED.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof D==="function")X=D,D=$=void 0;else if(typeof $==="function")X=$,$=void 0;if(typeof D==="number")D=D.toString();if(this.readyState!==ED.OPEN){tM(this,D,X);return}if($===void 0)$=!this._isServer;this._sender.ping(D||LZ,$,X)}pong(D,$,X){if(this.readyState===ED.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof D==="function")X=D,D=$=void 0;else if(typeof $==="function")X=$,$=void 0;if(typeof D==="number")D=D.toString();if(this.readyState!==ED.OPEN){tM(this,D,X);return}if($===void 0)$=!this._isServer;this._sender.pong(D||LZ,$,X)}resume(){if(this.readyState===ED.CONNECTING||this.readyState===ED.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send(D,$,X){if(this.readyState===ED.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")X=$,$={};if(typeof D==="number")D=D.toString();if(this.readyState!==ED.OPEN){tM(this,D,X);return}let Y={binary:typeof D!=="string",mask:!this._isServer,compress:!0,fin:!0,...$};if(!this._extensions[j4.extensionName])Y.compress=!1;this._sender.send(D||LZ,Y,X)}terminate(){if(this.readyState===ED.CLOSED)return;if(this.readyState===ED.CONNECTING){p1(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=ED.CLOSING,this._socket.destroy()}}Object.defineProperty(ED,"CONNECTING",{enumerable:!0,value:T6.indexOf("CONNECTING")});Object.defineProperty(ED.prototype,"CONNECTING",{enumerable:!0,value:T6.indexOf("CONNECTING")});Object.defineProperty(ED,"OPEN",{enumerable:!0,value:T6.indexOf("OPEN")});Object.defineProperty(ED.prototype,"OPEN",{enumerable:!0,value:T6.indexOf("OPEN")});Object.defineProperty(ED,"CLOSING",{enumerable:!0,value:T6.indexOf("CLOSING")});Object.defineProperty(ED.prototype,"CLOSING",{enumerable:!0,value:T6.indexOf("CLOSING")});Object.defineProperty(ED,"CLOSED",{enumerable:!0,value:T6.indexOf("CLOSED")});Object.defineProperty(ED.prototype,"CLOSED",{enumerable:!0,value:T6.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((D)=>{Object.defineProperty(ED.prototype,D,{enumerable:!0})});["open","error","close","message"].forEach((D)=>{Object.defineProperty(ED.prototype,`on${D}`,{enumerable:!0,get(){for(let $ of this.listeners(D))if($[oM])return $[cTD];return null},set($){for(let X of this.listeners(D))if(X[oM]){this.removeListener(D,X);break}if(typeof $!=="function")return;this.addEventListener(D,$,{[oM]:!0})}})});ED.prototype.addEventListener=nTD;ED.prototype.removeEventListener=iTD;pt.exports=ED;function mt(D,$,X,Y){let J={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:mTD,protocolVersion:aM[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...Y,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(D._autoPong=J.autoPong,D._closeTimeout=J.closeTimeout,!aM.includes(J.protocolVersion))throw RangeError(`Unsupported protocol version: ${J.protocolVersion} (supported versions: ${aM.join(", ")})`);let Q;if($ instanceof rM)Q=$;else try{Q=new rM($)}catch(K){throw SyntaxError(`Invalid URL: ${$}`)}if(Q.protocol==="http:")Q.protocol="ws:";else if(Q.protocol==="https:")Q.protocol="wss:";D._url=Q.href;let F=Q.protocol==="wss:",w=Q.protocol==="ws+unix:",Z;if(Q.protocol!=="ws:"&&!F&&!w)Z=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(w&&!Q.pathname)Z="The URL's pathname is empty";else if(Q.hash)Z="The URL contains a fragment identifier";if(Z){let K=SyntaxError(Z);if(D._redirects===0)throw K;else{IZ(D,K);return}}let G=F?443:80,O=fTD(16).toString("base64"),U=F?vTD.request:_TD.request,z=new Set,q;if(J.createConnection=J.createConnection||(F?sTD:tTD),J.defaultPort=J.defaultPort||G,J.port=Q.port||G,J.host=Q.hostname.startsWith("[")?Q.hostname.slice(1,-1):Q.hostname,J.headers={...J.headers,"Sec-WebSocket-Version":J.protocolVersion,"Sec-WebSocket-Key":O,Connection:"Upgrade",Upgrade:"websocket"},J.path=Q.pathname+Q.search,J.timeout=J.handshakeTimeout,J.perMessageDeflate)q=new j4(J.perMessageDeflate!==!0?J.perMessageDeflate:{},!1,J.maxPayload),J.headers["Sec-WebSocket-Extensions"]=pTD({[j4.extensionName]:q.offer()});if(X.length){for(let K of X){if(typeof K!=="string"||!aTD.test(K)||z.has(K))throw SyntaxError("An invalid or duplicated subprotocol was specified");z.add(K)}J.headers["Sec-WebSocket-Protocol"]=X.join(",")}if(J.origin)if(J.protocolVersion<13)J.headers["Sec-WebSocket-Origin"]=J.origin;else J.headers.Origin=J.origin;if(Q.username||Q.password)J.auth=`${Q.username}:${Q.password}`;if(w){let K=J.path.split(":");J.socketPath=K[0],J.path=K[1]}let B;if(J.followRedirects){if(D._redirects===0){D._originalIpc=w,D._originalSecure=F,D._originalHostOrSocketPath=w?J.socketPath:Q.host;let K=Y&&Y.headers;if(Y={...Y,headers:{}},K)for(let[M,L]of Object.entries(K))Y.headers[M.toLowerCase()]=L}else if(D.listenerCount("redirect")===0){let K=w?D._originalIpc?J.socketPath===D._originalHostOrSocketPath:!1:D._originalIpc?!1:Q.host===D._originalHostOrSocketPath;if(!K||D._originalSecure&&!F){if(delete J.headers.authorization,delete J.headers.cookie,!K)delete J.headers.host;J.auth=void 0}}if(J.auth&&!Y.headers.authorization)Y.headers.authorization="Basic "+Buffer.from(J.auth).toString("base64");if(B=D._req=U(J),D._redirects)D.emit("redirect",D.url,B)}else B=D._req=U(J);if(J.timeout)B.on("timeout",()=>{p1(D,B,"Opening handshake has timed out")});if(B.on("error",(K)=>{if(B===null||B[ht])return;B=D._req=null,IZ(D,K)}),B.on("response",(K)=>{let M=K.headers.location,L=K.statusCode;if(M&&J.followRedirects&&L>=300&&L<400){if(++D._redirects>J.maxRedirects){p1(D,B,"Maximum redirects exceeded");return}B.abort();let I;try{I=new rM(M,$)}catch(W){let N=SyntaxError(`Invalid URL: ${M}`);IZ(D,N);return}mt(D,I,X,Y)}else if(!D.emit("unexpected-response",B,K))p1(D,B,`Unexpected server response: ${K.statusCode}`)}),B.on("upgrade",(K,M,L)=>{if(D.emit("upgrade",K),D.readyState!==ED.CONNECTING)return;B=D._req=null;let I=K.headers.upgrade;if(I===void 0||I.toLowerCase()!=="websocket"){p1(D,M,"Invalid Upgrade header");return}let W=yTD("sha1").update(O+dTD).digest("base64");if(K.headers["sec-websocket-accept"]!==W){p1(D,M,"Invalid Sec-WebSocket-Accept header");return}let N=K.headers["sec-websocket-protocol"],V;if(N!==void 0){if(!z.size)V="Server sent a subprotocol but none was requested";else if(!z.has(N))V="Server sent an invalid subprotocol"}else if(z.size)V="Server sent no subprotocol";if(V){p1(D,M,V);return}if(N)D._protocol=N;let R=K.headers["sec-websocket-extensions"];if(R!==void 0){if(!q){p1(D,M,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let P;try{P=rTD(R)}catch(_){p1(D,M,"Invalid Sec-WebSocket-Extensions header");return}let A=Object.keys(P);if(A.length!==1||A[0]!==j4.extensionName){p1(D,M,"Server indicated an extension that was not requested");return}try{q.accept(P[j4.extensionName])}catch(_){p1(D,M,"Invalid Sec-WebSocket-Extensions header");return}D._extensions[j4.extensionName]=q}D.setSocket(M,L,{allowSynchronousEvents:J.allowSynchronousEvents,generateMask:J.generateMask,maxPayload:J.maxPayload,skipUTF8Validation:J.skipUTF8Validation})}),J.finishRequest)J.finishRequest(B,D);else B.end()}function IZ(D,$){D._readyState=ED.CLOSING,D._errorEmitted=!0,D.emit("error",$),D.emitClose()}function tTD(D){return D.path=D.socketPath,bt.connect(D)}function sTD(D){if(D.path=void 0,!D.servername&&D.servername!=="")D.servername=bt.isIP(D.host)?"":D.host;return kTD.connect(D)}function p1(D,$,X){D._readyState=ED.CLOSING;let Y=Error(X);if(Error.captureStackTrace(Y,p1),$.setHeader){if($[ht]=!0,$.abort(),$.socket&&!$.socket.destroyed)$.socket.destroy();process.nextTick(IZ,D,Y)}else $.destroy(Y),$.once("error",D.emit.bind(D,"error")),$.once("close",D.emitClose.bind(D))}function tM(D,$,X){if($){let Y=hTD($)?$.size:oTD($).length;if(D._socket)D._sender._bufferedBytes+=Y;else D._bufferedAmount+=Y}if(X){let Y=Error(`WebSocket is not open: readyState ${D.readyState} (${T6[D.readyState]})`);process.nextTick(X,Y)}}function eTD(D,$){let X=this[i0];if(X._closeFrameReceived=!0,X._closeMessage=$,X._closeCode=D,X._socket[i0]===void 0)return;if(X._socket.removeListener("data",AZ),process.nextTick(dt,X._socket),D===1005)X.close();else X.close(D,$)}function DCD(){let D=this[i0];if(!D.isPaused)D._socket.resume()}function $CD(D){let $=this[i0];if($._socket[i0]!==void 0)$._socket.removeListener("data",AZ),process.nextTick(dt,$._socket),$.close(D[lTD]);if(!$._errorEmitted)$._errorEmitted=!0,$.emit("error",D)}function yt(){this[i0].emitClose()}function XCD(D,$){this[i0].emit("message",D,$)}function JCD(D){let $=this[i0];if($._autoPong)$.pong(D,!this._isServer,gt);$.emit("ping",D)}function YCD(D){this[i0].emit("pong",D)}function dt(D){D.resume()}function QCD(D){let $=this[i0];if($.readyState===ED.CLOSED)return;if($.readyState===ED.OPEN)$._readyState=ED.CLOSING,ct($);if(this._socket.end(),!$._errorEmitted)$._errorEmitted=!0,$.emit("error",D)}function ct(D){D._closeTimer=setTimeout(D._socket.destroy.bind(D._socket),D._closeTimeout)}function lt(){let D=this[i0];if(this.removeListener("close",lt),this.removeListener("data",AZ),this.removeListener("end",nt),D._readyState=ED.CLOSING,!this._readableState.endEmitted&&!D._closeFrameReceived&&!D._receiver._writableState.errorEmitted&&this._readableState.length!==0){let $=this.read(this._readableState.length);D._receiver.write($)}if(D._receiver.end(),this[i0]=void 0,clearTimeout(D._closeTimer),D._receiver._writableState.finished||D._receiver._writableState.errorEmitted)D.emitClose();else D._receiver.on("error",yt),D._receiver.on("finish",yt)}function AZ(D){if(!this[i0]._receiver.write(D))this.pause()}function nt(){let D=this[i0];D._readyState=ED.CLOSING,D._receiver.end(),this.end()}function it(){let D=this[i0];if(this.removeListener("error",it),this.on("error",gt),D)D._readyState=ED.CLOSING,this.destroy()}});var tt=T((frD,at)=>{var krD=RZ(),{Duplex:FCD}=p("stream");function rt(D){D.emit("close")}function wCD(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function ot(D){if(this.removeListener("error",ot),this.destroy(),this.listenerCount("error")===0)this.emit("error",D)}function ZCD(D,$){let X=!0,Y=new FCD({...$,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return D.on("message",function(Q,F){let w=!F&&Y._readableState.objectMode?Q.toString():Q;if(!Y.push(w))D.pause()}),D.once("error",function(Q){if(Y.destroyed)return;X=!1,Y.destroy(Q)}),D.once("close",function(){if(Y.destroyed)return;Y.push(null)}),Y._destroy=function(J,Q){if(D.readyState===D.CLOSED){Q(J),process.nextTick(rt,Y);return}let F=!1;if(D.once("error",function(Z){F=!0,Q(Z)}),D.once("close",function(){if(!F)Q(J);process.nextTick(rt,Y)}),X)D.terminate()},Y._final=function(J){if(D.readyState===D.CONNECTING){D.once("open",function(){Y._final(J)});return}if(D._socket===null)return;if(D._socket._writableState.finished){if(J(),Y._readableState.endEmitted)Y.destroy()}else D._socket.once("finish",function(){J()}),D.close()},Y._read=function(){if(D.isPaused)D.resume()},Y._write=function(J,Q,F){if(D.readyState===D.CONNECTING){D.once("open",function(){Y._write(J,Q,F)});return}D.send(J,F)},Y.on("end",wCD),Y.on("error",ot),Y}at.exports=ZCD});var et=T((yrD,st)=>{var{tokenChars:GCD}=e5();function OCD(D){let $=new Set,X=-1,Y=-1,J=0;for(J;J<D.length;J++){let F=D.charCodeAt(J);if(Y===-1&&GCD[F]===1){if(X===-1)X=J}else if(J!==0&&(F===32||F===9)){if(Y===-1&&X!==-1)Y=J}else if(F===44){if(X===-1)throw SyntaxError(`Unexpected character at index ${J}`);if(Y===-1)Y=J;let w=D.slice(X,Y);if($.has(w))throw SyntaxError(`The "${w}" subprotocol is duplicated`);$.add(w),X=Y=-1}else throw SyntaxError(`Unexpected character at index ${J}`)}if(X===-1||Y!==-1)throw SyntaxError("Unexpected end of input");let Q=D.slice(X,J);if($.has(Q))throw SyntaxError(`The "${Q}" subprotocol is duplicated`);return $.add(Q),$}st.exports={parse:OCD}});var Ys=T((grD,Js)=>{var UCD=p("events"),jZ=p("http"),{Duplex:brD}=p("stream"),{createHash:qCD}=p("crypto"),Ds=pM(),g8=Z2(),zCD=et(),BCD=RZ(),{CLOSE_TIMEOUT:KCD,GUID:WCD,kWebSocket:HCD}=j6(),VCD=/^[+/0-9A-Za-z]{22}==$/;class Xs extends UCD{constructor(D,$){super();if(D={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:KCD,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:BCD,...D},D.port==null&&!D.server&&!D.noServer||D.port!=null&&(D.server||D.noServer)||D.server&&D.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(D.port!=null)this._server=jZ.createServer((X,Y)=>{let J=jZ.STATUS_CODES[426];Y.writeHead(426,{"Content-Length":J.length,"Content-Type":"text/plain"}),Y.end(J)}),this._server.listen(D.port,D.host,D.backlog,$);else if(D.server)this._server=D.server;if(this._server){let X=this.emit.bind(this,"connection");this._removeListeners=NCD(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(Y,J,Q)=>{this.handleUpgrade(Y,J,Q,X)}})}if(D.perMessageDeflate===!0)D.perMessageDeflate={};if(D.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=D,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');if(!this._server)return null;return this._server.address()}close(D){if(this._state===2){if(D)this.once("close",()=>{D(Error("The server is not running"))});process.nextTick(q2,this);return}if(D)this.once("close",D);if(this._state===1)return;if(this._state=1,this.options.noServer||this.options.server){if(this._server)this._removeListeners(),this._removeListeners=this._server=null;if(this.clients)if(!this.clients.size)process.nextTick(q2,this);else this._shouldEmitClose=!0;else process.nextTick(q2,this)}else{let $=this._server;this._removeListeners(),this._removeListeners=this._server=null,$.close(()=>{q2(this)})}}shouldHandle(D){if(this.options.path){let $=D.url.indexOf("?");if(($!==-1?D.url.slice(0,$):D.url)!==this.options.path)return!1}return!0}handleUpgrade(D,$,X,Y){$.on("error",$s);let J=D.headers["sec-websocket-key"],Q=D.headers.upgrade,F=+D.headers["sec-websocket-version"];if(D.method!=="GET"){h8(this,D,$,405,"Invalid HTTP method");return}if(Q===void 0||Q.toLowerCase()!=="websocket"){h8(this,D,$,400,"Invalid Upgrade header");return}if(J===void 0||!VCD.test(J)){h8(this,D,$,400,"Missing or invalid Sec-WebSocket-Key header");return}if(F!==13&&F!==8){h8(this,D,$,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(D)){z2($,400);return}let w=D.headers["sec-websocket-protocol"],Z=new Set;if(w!==void 0)try{Z=zCD.parse(w)}catch(U){h8(this,D,$,400,"Invalid Sec-WebSocket-Protocol header");return}let G=D.headers["sec-websocket-extensions"],O={};if(this.options.perMessageDeflate&&G!==void 0){let U=new g8(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let z=Ds.parse(G);if(z[g8.extensionName])U.accept(z[g8.extensionName]),O[g8.extensionName]=U}catch(z){h8(this,D,$,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let U={origin:D.headers[`${F===8?"sec-websocket-origin":"origin"}`],secure:!!(D.socket.authorized||D.socket.encrypted),req:D};if(this.options.verifyClient.length===2){this.options.verifyClient(U,(z,q,B,K)=>{if(!z)return z2($,q||401,B,K);this.completeUpgrade(O,J,Z,D,$,X,Y)});return}if(!this.options.verifyClient(U))return z2($,401)}this.completeUpgrade(O,J,Z,D,$,X,Y)}completeUpgrade(D,$,X,Y,J,Q,F){if(!J.readable||!J.writable)return J.destroy();if(J[HCD])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return z2(J,503);let Z=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${qCD("sha1").update($+WCD).digest("base64")}`],G=new this.options.WebSocket(null,void 0,this.options);if(X.size){let O=this.options.handleProtocols?this.options.handleProtocols(X,Y):X.values().next().value;if(O)Z.push(`Sec-WebSocket-Protocol: ${O}`),G._protocol=O}if(D[g8.extensionName]){let O=D[g8.extensionName].params,U=Ds.format({[g8.extensionName]:[O]});Z.push(`Sec-WebSocket-Extensions: ${U}`),G._extensions=D}if(this.emit("headers",Z,Y),J.write(Z.concat(`\r
400
+ PS: You can ignore this check with "--ignore-checksum-check"`),Error("Cannot upload the same bundle content");J.stop(`Checksum compatible with ${X} channel`)}function iD(D,$){return D||$?.plugins?.CapacitorUpdater?.appId||$?.appId}function k8(D){let $=[];if(!D.localVersion)return{compatible:!0,reasons:[],message:"Package only exists on remote (will be removed)"};if(!D.remoteVersion)return $.push("new_plugin"),{compatible:!1,reasons:$,message:"New native plugin added (requires app store update)"};let X=!1;try{let F=t2(D.localVersion),w=t2(D.remoteVersion);X=_I(F,w)}catch{X=!1}if(!X)$.push("version_mismatch");let Y=D.localIosChecksum&&D.remoteIosChecksum&&D.localIosChecksum!==D.remoteIosChecksum,J=D.localAndroidChecksum&&D.remoteAndroidChecksum&&D.localAndroidChecksum!==D.remoteAndroidChecksum;if(Y&&J)$.push("both_platforms_changed");else if(Y)$.push("ios_code_changed");else if(J)$.push("android_code_changed");if($.length===0)return{compatible:!0,reasons:[],message:"Compatible"};let Q=[];for(let F of $)switch(F){case"version_mismatch":Q.push(`version changed: ${D.remoteVersion} → ${D.localVersion}`);break;case"ios_code_changed":Q.push("iOS native code changed");break;case"android_code_changed":Q.push("Android native code changed");break;case"both_platforms_changed":Q.push("iOS and Android native code changed");break;case"new_plugin":Q.push("new plugin (requires app store update)");break;case"removed_plugin":Q.push("plugin removed");break}return{compatible:!1,reasons:$,message:Q.join(", ")}}function L4(D){return k8(D).compatible}async function OZ(D,$,X,Y,J){let Q=await vM(Y,J),F=await Pa(D,$,X),w=Q.filter((G)=>!!G.native).map((G)=>{let O=F.get(G.name);if(O)return{name:G.name,localVersion:G.version,remoteVersion:O.version,localIosChecksum:G.ios_checksum,remoteIosChecksum:O.ios_checksum,localAndroidChecksum:G.android_checksum,remoteAndroidChecksum:O.android_checksum};return{name:G.name,localVersion:G.version,remoteVersion:void 0,localIosChecksum:G.ios_checksum,localAndroidChecksum:G.android_checksum}}),Z=[...F].filter(([G])=>Q.find((O)=>O.name===G)===void 0).map(([G,O])=>({name:G,localVersion:void 0,remoteVersion:O.version,remoteIosChecksum:O.ios_checksum,remoteAndroidChecksum:O.android_checksum}));return w.push(...Z),{finalCompatibility:w,localDependencies:Q}}async function _M(D,$,X,Y){let J=await Pa(D,$,X),Q=Y.map((w)=>{let Z=J.get(w.name);if(Z)return{name:w.name,localVersion:w.version,remoteVersion:Z.version,localIosChecksum:w.ios_checksum,remoteIosChecksum:Z.ios_checksum,localAndroidChecksum:w.android_checksum,remoteAndroidChecksum:Z.android_checksum};return{name:w.name,localVersion:w.version,remoteVersion:void 0,localIosChecksum:w.ios_checksum,localAndroidChecksum:w.android_checksum}}),F=[...J].filter(([w])=>Y.find((Z)=>Z.name===w)===void 0).map(([w,Z])=>({name:w,localVersion:void 0,remoteVersion:Z.version,remoteIosChecksum:Z.ios_checksum,remoteAndroidChecksum:Z.android_checksum}));return Q.push(...F),{finalCompatibility:Q,localDependencies:Y}}function fED(D){if(!G0(D))return null;try{return JSON.parse(f0(D,"utf-8"))}catch{return null}}function $2(D){if(!D)return!1;return/@capgo\/capacitor-updater|CapgoCapacitorUpdater|CapacitorUpdaterPlugin/.test(D)}function yED(D,$){if(!$)return kD(D,A6);return Y2.isAbsolute($)?$:CM(D,$)}function bED(D=I6(),$){let X=yED(D,$),Y=Y2.basename(X)===A6?X2(X):X,J=[kD(Y,"ios","App"),kD(D,"ios","App")].find((C)=>G0(C));if(!J)return{shouldCheck:!1,valid:!0,details:[]};let Q=fED(X),F={...Q?.dependencies,...Q?.devDependencies,...Q?.optionalDependencies},w=Object.prototype.hasOwnProperty.call(F,"@capgo/capacitor-updater"),Z=[Y,D].some((C)=>G0(kD(C,"node_modules","@capgo","capacitor-updater"))),G=kD(J,"Podfile"),O=kD(J,"CapApp-SPM","Package.swift"),U=G0(G)?f0(G,"utf-8"):void 0,z=G0(O)?f0(O,"utf-8"):void 0,q=$2(U)||$2(z),B=kD(J,"Podfile.lock"),K=kD(J,"App.xcworkspace","xcshareddata","swiftpm","Package.resolved"),M=kD(J,"App","capacitor.plugins.json"),L=G0(B)?f0(B,"utf-8"):void 0,I=G0(K)?f0(K,"utf-8"):void 0,W=G0(M)?f0(M,"utf-8"):void 0,N=$2(L)||$2(I)||$2(W);if(!(w||Z||q||N))return{shouldCheck:!1,valid:!0,details:[]};let R=[];if(!q)R.push(`Missing @capgo/capacitor-updater in iOS dependency files (${G} or ${O})`);if(!N)R.push(`Missing @capgo/capacitor-updater in iOS native project outputs (${B}, ${K}, or ${M})`);return{shouldCheck:!0,valid:q&&N,details:R}}async function Sa(D,$,X,Y){let J=await c0({message:"Would you like to sync your project with Capacitor now? This is recommended to ensure encrypted updates work properly."});if(yD(J)){if(D&&$&&X)await cx("onboarding-v2",$,X,"canceled","\uD83E\uDD37");throw H.error("Canceled Capacitor sync"),Error("Capacitor sync cancelled")}if(J){let Q=_8(),F=A0();F.start("Running the command...");let w;try{await new Promise((Z,G)=>{let O=WED(Q.runner,["cap","sync"],{stdio:"pipe"});O.on("close",(U)=>{if(U===0)Z();else G(Error(`Command failed with exit code ${U}`))}),O.on("error",(U)=>{G(U)})})}catch(Z){w=Z,H.error(`Failed to run Capacitor sync: ${Z}`),H.warn(`Please run "${Q.runner} cap sync" manually to ensure encrypted updates work properly`)}if(Y?.validateIosUpdater){let Z=bED(I6(),Y.packageJsonPath);if(Z.shouldCheck&&!Z.valid){F.stop("iOS sync check failed ❌"),H.error("Capgo iOS dependency sync verification failed.");for(let G of Z.details)H.error(G);throw H.error("Stop here to avoid testing on a broken native iOS project."),H.warn("Best fix: reset the iOS folder, then run sync again."),H.info(`1. ${Q.runner} cap rm ios`),H.info(`2. ${Q.runner} cap add ios`),H.info(`3. ${Q.runner} cap sync ios`),Error("iOS sync validation failed. Reset your iOS folder and retry.")}}if(w){F.stop("Error");return}F.stop("Capacitor sync completed ✅")}else{let Q=_8();H.warn("⚠️ Important: If you upload encrypted bundles without syncing, updates will fail!"),H.info(`Remember to run "${Q.runner} cap sync" before uploading encrypted bundles`)}}var V4,PM,qa,DZ,i5=".capgo_key",i1=".capgo_key_v2",$Z,R6,Qa="https://capgo.app",Fa="https://files.capgo.app",wa="https://api.capgo.app",Za="https://console.capgo.app",xM=120000,LED=20971520,IED=1073741824,AED=103809024,A6="package.json",p5,Ba,R1,r5=(D,$)=>D>=$,QZ="5.10.0",FZ="6.25.0",Q2="7.0.30",Ga=!1,n5="npm",D2="install",TM="npx";var fD=o(()=>{VI();vD();D6();wE();lx();q3();GF();So();rw();V4=V0(l2(),1),PM=V0(KO(),1),qa=V0(WT(),1),DZ=V0(NY(),1),$Z=`${i5}.pub`,R6=`${i1}.pub`,p5=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-z-][0-9a-z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-z-][0-9a-z-]*))*))?(?:\+([0-9a-z-]+(?:\.[0-9a-z-]+)*))?$/i;Ba=/([A-Za-z0-9]+)\.(java|swift|kt|scala)$/;((F)=>{F[F.none=0]="none";F[F.read=1]="read";F[F.upload=2]="upload";F[F.write=3]="write";F[F.admin=4]="admin";F[F.super_admin=5]="super_admin"})(R1||={})});var j6=T((IrD,Qt)=>{var Jt=["nodebuffer","arraybuffer","fragments"],Yt=typeof Blob<"u";if(Yt)Jt.push("blob");Qt.exports={BINARY_TYPES:Jt,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:Yt,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var F2=T((ArD,BZ)=>{var{EMPTY_BUFFER:$TD}=j6(),bM=Buffer[Symbol.species];function XTD(D,$){if(D.length===0)return $TD;if(D.length===1)return D[0];let X=Buffer.allocUnsafe($),Y=0;for(let J=0;J<D.length;J++){let Q=D[J];X.set(Q,Y),Y+=Q.length}if(Y<$)return new bM(X.buffer,X.byteOffset,Y);return X}function Ft(D,$,X,Y,J){for(let Q=0;Q<J;Q++)X[Y+Q]=D[Q]^$[Q&3]}function wt(D,$){for(let X=0;X<D.length;X++)D[X]^=$[X&3]}function JTD(D){if(D.length===D.buffer.byteLength)return D.buffer;return D.buffer.slice(D.byteOffset,D.byteOffset+D.length)}function gM(D){if(gM.readOnly=!0,Buffer.isBuffer(D))return D;let $;if(D instanceof ArrayBuffer)$=new bM(D);else if(ArrayBuffer.isView(D))$=new bM(D.buffer,D.byteOffset,D.byteLength);else $=Buffer.from(D),gM.readOnly=!1;return $}BZ.exports={concat:XTD,mask:Ft,toArrayBuffer:JTD,toBuffer:gM,unmask:wt};if(!process.env.WS_NO_BUFFER_UTIL)try{let D=(()=>{throw new Error("Cannot require module "+"bufferutil");})();BZ.exports.mask=function($,X,Y,J,Q){if(Q<48)Ft($,X,Y,J,Q);else D.mask($,X,Y,J,Q)},BZ.exports.unmask=function($,X){if($.length<32)wt($,X);else D.unmask($,X)}}catch(D){}});var Ut=T((RrD,Ot)=>{var Zt=Symbol("kDone"),hM=Symbol("kRun");class Gt{constructor(D){this[Zt]=()=>{this.pending--,this[hM]()},this.concurrency=D||1/0,this.jobs=[],this.pending=0}add(D){this.jobs.push(D),this[hM]()}[hM](){if(this.pending===this.concurrency)return;if(this.jobs.length){let D=this.jobs.shift();this.pending++,D(this[Zt])}}}Ot.exports=Gt});var Z2=T((jrD,Wt)=>{var w2=p("zlib"),qt=F2(),YTD=Ut(),{kStatusCode:zt}=j6(),QTD=Buffer[Symbol.species],FTD=Buffer.from([0,0,255,255]),WZ=Symbol("permessage-deflate"),E6=Symbol("total-length"),t5=Symbol("callback"),I4=Symbol("buffers"),s5=Symbol("error"),KZ;class Bt{constructor(D,$,X){if(this._maxPayload=X|0,this._options=D||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!$,this._deflate=null,this._inflate=null,this.params=null,!KZ){let Y=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;KZ=new YTD(Y)}}static get extensionName(){return"permessage-deflate"}offer(){let D={};if(this._options.serverNoContextTakeover)D.server_no_context_takeover=!0;if(this._options.clientNoContextTakeover)D.client_no_context_takeover=!0;if(this._options.serverMaxWindowBits)D.server_max_window_bits=this._options.serverMaxWindowBits;if(this._options.clientMaxWindowBits)D.client_max_window_bits=this._options.clientMaxWindowBits;else if(this._options.clientMaxWindowBits==null)D.client_max_window_bits=!0;return D}accept(D){return D=this.normalizeParams(D),this.params=this._isServer?this.acceptAsServer(D):this.acceptAsClient(D),this.params}cleanup(){if(this._inflate)this._inflate.close(),this._inflate=null;if(this._deflate){let D=this._deflate[t5];if(this._deflate.close(),this._deflate=null,D)D(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(D){let $=this._options,X=D.find((Y)=>{if($.serverNoContextTakeover===!1&&Y.server_no_context_takeover||Y.server_max_window_bits&&($.serverMaxWindowBits===!1||typeof $.serverMaxWindowBits==="number"&&$.serverMaxWindowBits>Y.server_max_window_bits)||typeof $.clientMaxWindowBits==="number"&&!Y.client_max_window_bits)return!1;return!0});if(!X)throw Error("None of the extension offers can be accepted");if($.serverNoContextTakeover)X.server_no_context_takeover=!0;if($.clientNoContextTakeover)X.client_no_context_takeover=!0;if(typeof $.serverMaxWindowBits==="number")X.server_max_window_bits=$.serverMaxWindowBits;if(typeof $.clientMaxWindowBits==="number")X.client_max_window_bits=$.clientMaxWindowBits;else if(X.client_max_window_bits===!0||$.clientMaxWindowBits===!1)delete X.client_max_window_bits;return X}acceptAsClient(D){let $=D[0];if(this._options.clientNoContextTakeover===!1&&$.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!$.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")$.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&$.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return $}normalizeParams(D){return D.forEach(($)=>{Object.keys($).forEach((X)=>{let Y=$[X];if(Y.length>1)throw Error(`Parameter "${X}" must have only a single value`);if(Y=Y[0],X==="client_max_window_bits"){if(Y!==!0){let J=+Y;if(!Number.isInteger(J)||J<8||J>15)throw TypeError(`Invalid value for parameter "${X}": ${Y}`);Y=J}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${X}": ${Y}`)}else if(X==="server_max_window_bits"){let J=+Y;if(!Number.isInteger(J)||J<8||J>15)throw TypeError(`Invalid value for parameter "${X}": ${Y}`);Y=J}else if(X==="client_no_context_takeover"||X==="server_no_context_takeover"){if(Y!==!0)throw TypeError(`Invalid value for parameter "${X}": ${Y}`)}else throw Error(`Unknown parameter "${X}"`);$[X]=Y})}),D}decompress(D,$,X){KZ.add((Y)=>{this._decompress(D,$,(J,Q)=>{Y(),X(J,Q)})})}compress(D,$,X){KZ.add((Y)=>{this._compress(D,$,(J,Q)=>{Y(),X(J,Q)})})}_decompress(D,$,X){let Y=this._isServer?"client":"server";if(!this._inflate){let J=`${Y}_max_window_bits`,Q=typeof this.params[J]!=="number"?w2.Z_DEFAULT_WINDOWBITS:this.params[J];this._inflate=w2.createInflateRaw({...this._options.zlibInflateOptions,windowBits:Q}),this._inflate[WZ]=this,this._inflate[E6]=0,this._inflate[I4]=[],this._inflate.on("error",ZTD),this._inflate.on("data",Kt)}if(this._inflate[t5]=X,this._inflate.write(D),$)this._inflate.write(FTD);this._inflate.flush(()=>{let J=this._inflate[s5];if(J){this._inflate.close(),this._inflate=null,X(J);return}let Q=qt.concat(this._inflate[I4],this._inflate[E6]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[E6]=0,this._inflate[I4]=[],$&&this.params[`${Y}_no_context_takeover`])this._inflate.reset();X(null,Q)})}_compress(D,$,X){let Y=this._isServer?"server":"client";if(!this._deflate){let J=`${Y}_max_window_bits`,Q=typeof this.params[J]!=="number"?w2.Z_DEFAULT_WINDOWBITS:this.params[J];this._deflate=w2.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:Q}),this._deflate[E6]=0,this._deflate[I4]=[],this._deflate.on("data",wTD)}this._deflate[t5]=X,this._deflate.write(D),this._deflate.flush(w2.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let J=qt.concat(this._deflate[I4],this._deflate[E6]);if($)J=new QTD(J.buffer,J.byteOffset,J.length-4);if(this._deflate[t5]=null,this._deflate[E6]=0,this._deflate[I4]=[],$&&this.params[`${Y}_no_context_takeover`])this._deflate.reset();X(null,J)})}}Wt.exports=Bt;function wTD(D){this[I4].push(D),this[E6]+=D.length}function Kt(D){if(this[E6]+=D.length,this[WZ]._maxPayload<1||this[E6]<=this[WZ]._maxPayload){this[I4].push(D);return}this[s5]=RangeError("Max payload size exceeded"),this[s5].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[s5][zt]=1009,this.removeListener("data",Kt),this.reset()}function ZTD(D){if(this[WZ]._inflate=null,this[s5]){this[t5](this[s5]);return}D[zt]=1007,this[t5](D)}});var e5=T((ErD,HZ)=>{var{isUtf8:Ht}=p("buffer"),{hasBlob:GTD}=j6(),OTD=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function UTD(D){return D>=1000&&D<=1014&&D!==1004&&D!==1005&&D!==1006||D>=3000&&D<=4999}function mM(D){let $=D.length,X=0;while(X<$)if((D[X]&128)===0)X++;else if((D[X]&224)===192){if(X+1===$||(D[X+1]&192)!==128||(D[X]&254)===192)return!1;X+=2}else if((D[X]&240)===224){if(X+2>=$||(D[X+1]&192)!==128||(D[X+2]&192)!==128||D[X]===224&&(D[X+1]&224)===128||D[X]===237&&(D[X+1]&224)===160)return!1;X+=3}else if((D[X]&248)===240){if(X+3>=$||(D[X+1]&192)!==128||(D[X+2]&192)!==128||(D[X+3]&192)!==128||D[X]===240&&(D[X+1]&240)===128||D[X]===244&&D[X+1]>143||D[X]>244)return!1;X+=4}else return!1;return!0}function qTD(D){return GTD&&typeof D==="object"&&typeof D.arrayBuffer==="function"&&typeof D.type==="string"&&typeof D.stream==="function"&&(D[Symbol.toStringTag]==="Blob"||D[Symbol.toStringTag]==="File")}HZ.exports={isBlob:qTD,isValidStatusCode:UTD,isValidUTF8:mM,tokenChars:OTD};if(Ht)HZ.exports.isValidUTF8=function(D){return D.length<24?mM(D):Ht(D)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let D=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();HZ.exports.isValidUTF8=function($){return $.length<32?mM($):D($)}}catch(D){}});var cM=T((TrD,It)=>{var{Writable:zTD}=p("stream"),Vt=Z2(),{BINARY_TYPES:BTD,EMPTY_BUFFER:Nt,kStatusCode:KTD,kWebSocket:WTD}=j6(),{concat:dM,toArrayBuffer:HTD,unmask:VTD}=F2(),{isValidStatusCode:NTD,isValidUTF8:Mt}=e5(),VZ=Buffer[Symbol.species];class Lt extends zTD{constructor(D={}){super();this._allowSynchronousEvents=D.allowSynchronousEvents!==void 0?D.allowSynchronousEvents:!0,this._binaryType=D.binaryType||BTD[0],this._extensions=D.extensions||{},this._isServer=!!D.isServer,this._maxPayload=D.maxPayload|0,this._skipUTF8Validation=!!D.skipUTF8Validation,this[WTD]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(D,$,X){if(this._opcode===8&&this._state==0)return X();this._bufferedBytes+=D.length,this._buffers.push(D),this.startLoop(X)}consume(D){if(this._bufferedBytes-=D,D===this._buffers[0].length)return this._buffers.shift();if(D<this._buffers[0].length){let X=this._buffers[0];return this._buffers[0]=new VZ(X.buffer,X.byteOffset+D,X.length-D),new VZ(X.buffer,X.byteOffset,D)}let $=Buffer.allocUnsafe(D);do{let X=this._buffers[0],Y=$.length-D;if(D>=X.length)$.set(this._buffers.shift(),Y);else $.set(new Uint8Array(X.buffer,X.byteOffset,D),Y),this._buffers[0]=new VZ(X.buffer,X.byteOffset+D,X.length-D);D-=X.length}while(D>0);return $}startLoop(D){this._loop=!0;do switch(this._state){case 0:this.getInfo(D);break;case 1:this.getPayloadLength16(D);break;case 2:this.getPayloadLength64(D);break;case 3:this.getMask();break;case 4:this.getData(D);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)D()}getInfo(D){if(this._bufferedBytes<2){this._loop=!1;return}let $=this.consume(2);if(($[0]&48)!==0){let Y=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");D(Y);return}let X=($[0]&64)===64;if(X&&!this._extensions[Vt.extensionName]){let Y=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");D(Y);return}if(this._fin=($[0]&128)===128,this._opcode=$[0]&15,this._payloadLength=$[1]&127,this._opcode===0){if(X){let Y=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");D(Y);return}if(!this._fragmented){let Y=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");D(Y);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let Y=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");D(Y);return}this._compressed=X}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let Y=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");D(Y);return}if(X){let Y=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");D(Y);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let Y=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");D(Y);return}}else{let Y=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");D(Y);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=($[1]&128)===128,this._isServer){if(!this._masked){let Y=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");D(Y);return}}else if(this._masked){let Y=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");D(Y);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength(D)}getPayloadLength16(D){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(D)}getPayloadLength64(D){if(this._bufferedBytes<8){this._loop=!1;return}let $=this.consume(8),X=$.readUInt32BE(0);if(X>Math.pow(2,21)-1){let Y=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");D(Y);return}this._payloadLength=X*Math.pow(2,32)+$.readUInt32BE(4),this.haveLength(D)}haveLength(D){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let $=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");D($);return}}if(this._masked)this._state=3;else this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(D){let $=Nt;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if($=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)VTD($,this._mask)}if(this._opcode>7){this.controlMessage($,D);return}if(this._compressed){this._state=5,this.decompress($,D);return}if($.length)this._messageLength=this._totalPayloadLength,this._fragments.push($);this.dataMessage(D)}decompress(D,$){this._extensions[Vt.extensionName].decompress(D,this._fin,(Y,J)=>{if(Y)return $(Y);if(J.length){if(this._messageLength+=J.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let Q=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");$(Q);return}this._fragments.push(J)}if(this.dataMessage($),this._state===0)this.startLoop($)})}dataMessage(D){if(!this._fin){this._state=0;return}let $=this._messageLength,X=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let Y;if(this._binaryType==="nodebuffer")Y=dM(X,$);else if(this._binaryType==="arraybuffer")Y=HTD(dM(X,$));else if(this._binaryType==="blob")Y=new Blob(X);else Y=X;if(this._allowSynchronousEvents)this.emit("message",Y,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",Y,!0),this._state=0,this.startLoop(D)})}else{let Y=dM(X,$);if(!this._skipUTF8Validation&&!Mt(Y)){let J=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");D(J);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",Y,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",Y,!1),this._state=0,this.startLoop(D)})}}controlMessage(D,$){if(this._opcode===8){if(D.length===0)this._loop=!1,this.emit("conclude",1005,Nt),this.end();else{let X=D.readUInt16BE(0);if(!NTD(X)){let J=this.createError(RangeError,`invalid status code ${X}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");$(J);return}let Y=new VZ(D.buffer,D.byteOffset+2,D.length-2);if(!this._skipUTF8Validation&&!Mt(Y)){let J=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");$(J);return}this._loop=!1,this.emit("conclude",X,Y),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",D),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",D),this._state=0,this.startLoop($)})}createError(D,$,X,Y,J){this._loop=!1,this._errored=!0;let Q=new D(X?`Invalid WebSocket frame: ${$}`:$);return Error.captureStackTrace(Q,this.createError),Q.code=J,Q[KTD]=Y,Q}}It.exports=Lt});var nM=T((PrD,jt)=>{var{Duplex:CrD}=p("stream"),{randomFillSync:MTD}=p("crypto"),At=Z2(),{EMPTY_BUFFER:LTD,kWebSocket:ITD,NOOP:ATD}=j6(),{isBlob:D7,isValidStatusCode:RTD}=e5(),{mask:Rt,toBuffer:y8}=F2(),O$=Symbol("kByteLength"),jTD=Buffer.alloc(4),b8,$7=8192,j$=0,ETD=1,TTD=2;class A4{constructor(D,$,X){if(this._extensions=$||{},X)this._generateMask=X,this._maskBuffer=Buffer.alloc(4);this._socket=D,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=j$,this.onerror=ATD,this[ITD]=void 0}static frame(D,$){let X,Y=!1,J=2,Q=!1;if($.mask){if(X=$.maskBuffer||jTD,$.generateMask)$.generateMask(X);else{if($7===8192){if(b8===void 0)b8=Buffer.alloc(8192);MTD(b8,0,8192),$7=0}X[0]=b8[$7++],X[1]=b8[$7++],X[2]=b8[$7++],X[3]=b8[$7++]}Q=(X[0]|X[1]|X[2]|X[3])===0,J=6}let F;if(typeof D==="string")if((!$.mask||Q)&&$[O$]!==void 0)F=$[O$];else D=Buffer.from(D),F=D.length;else F=D.length,Y=$.mask&&$.readOnly&&!Q;let w=F;if(F>=65536)J+=8,w=127;else if(F>125)J+=2,w=126;let Z=Buffer.allocUnsafe(Y?F+J:J);if(Z[0]=$.fin?$.opcode|128:$.opcode,$.rsv1)Z[0]|=64;if(Z[1]=w,w===126)Z.writeUInt16BE(F,2);else if(w===127)Z[2]=Z[3]=0,Z.writeUIntBE(F,4,6);if(!$.mask)return[Z,D];if(Z[1]|=128,Z[J-4]=X[0],Z[J-3]=X[1],Z[J-2]=X[2],Z[J-1]=X[3],Q)return[Z,D];if(Y)return Rt(D,X,Z,J,F),[Z];return Rt(D,X,D,0,F),[Z,D]}close(D,$,X,Y){let J;if(D===void 0)J=LTD;else if(typeof D!=="number"||!RTD(D))throw TypeError("First argument must be a valid error code number");else if($===void 0||!$.length)J=Buffer.allocUnsafe(2),J.writeUInt16BE(D,0);else{let F=Buffer.byteLength($);if(F>123)throw RangeError("The message must not be greater than 123 bytes");if(J=Buffer.allocUnsafe(2+F),J.writeUInt16BE(D,0),typeof $==="string")J.write($,2);else J.set($,2)}let Q={[O$]:J.length,fin:!0,generateMask:this._generateMask,mask:X,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==j$)this.enqueue([this.dispatch,J,!1,Q,Y]);else this.sendFrame(A4.frame(J,Q),Y)}ping(D,$,X){let Y,J;if(typeof D==="string")Y=Buffer.byteLength(D),J=!1;else if(D7(D))Y=D.size,J=!1;else D=y8(D),Y=D.length,J=y8.readOnly;if(Y>125)throw RangeError("The data size must not be greater than 125 bytes");let Q={[O$]:Y,fin:!0,generateMask:this._generateMask,mask:$,maskBuffer:this._maskBuffer,opcode:9,readOnly:J,rsv1:!1};if(D7(D))if(this._state!==j$)this.enqueue([this.getBlobData,D,!1,Q,X]);else this.getBlobData(D,!1,Q,X);else if(this._state!==j$)this.enqueue([this.dispatch,D,!1,Q,X]);else this.sendFrame(A4.frame(D,Q),X)}pong(D,$,X){let Y,J;if(typeof D==="string")Y=Buffer.byteLength(D),J=!1;else if(D7(D))Y=D.size,J=!1;else D=y8(D),Y=D.length,J=y8.readOnly;if(Y>125)throw RangeError("The data size must not be greater than 125 bytes");let Q={[O$]:Y,fin:!0,generateMask:this._generateMask,mask:$,maskBuffer:this._maskBuffer,opcode:10,readOnly:J,rsv1:!1};if(D7(D))if(this._state!==j$)this.enqueue([this.getBlobData,D,!1,Q,X]);else this.getBlobData(D,!1,Q,X);else if(this._state!==j$)this.enqueue([this.dispatch,D,!1,Q,X]);else this.sendFrame(A4.frame(D,Q),X)}send(D,$,X){let Y=this._extensions[At.extensionName],J=$.binary?2:1,Q=$.compress,F,w;if(typeof D==="string")F=Buffer.byteLength(D),w=!1;else if(D7(D))F=D.size,w=!1;else D=y8(D),F=D.length,w=y8.readOnly;if(this._firstFragment){if(this._firstFragment=!1,Q&&Y&&Y.params[Y._isServer?"server_no_context_takeover":"client_no_context_takeover"])Q=F>=Y._threshold;this._compress=Q}else Q=!1,J=0;if($.fin)this._firstFragment=!0;let Z={[O$]:F,fin:$.fin,generateMask:this._generateMask,mask:$.mask,maskBuffer:this._maskBuffer,opcode:J,readOnly:w,rsv1:Q};if(D7(D))if(this._state!==j$)this.enqueue([this.getBlobData,D,this._compress,Z,X]);else this.getBlobData(D,this._compress,Z,X);else if(this._state!==j$)this.enqueue([this.dispatch,D,this._compress,Z,X]);else this.dispatch(D,this._compress,Z,X)}getBlobData(D,$,X,Y){this._bufferedBytes+=X[O$],this._state=TTD,D.arrayBuffer().then((J)=>{if(this._socket.destroyed){let F=Error("The socket was closed while the blob was being read");process.nextTick(lM,this,F,Y);return}this._bufferedBytes-=X[O$];let Q=y8(J);if(!$)this._state=j$,this.sendFrame(A4.frame(Q,X),Y),this.dequeue();else this.dispatch(Q,$,X,Y)}).catch((J)=>{process.nextTick(CTD,this,J,Y)})}dispatch(D,$,X,Y){if(!$){this.sendFrame(A4.frame(D,X),Y);return}let J=this._extensions[At.extensionName];this._bufferedBytes+=X[O$],this._state=ETD,J.compress(D,X.fin,(Q,F)=>{if(this._socket.destroyed){let w=Error("The socket was closed while data was being compressed");lM(this,w,Y);return}this._bufferedBytes-=X[O$],this._state=j$,X.readOnly=!1,this.sendFrame(A4.frame(F,X),Y),this.dequeue()})}dequeue(){while(this._state===j$&&this._queue.length){let D=this._queue.shift();this._bufferedBytes-=D[3][O$],Reflect.apply(D[0],this,D.slice(1))}}enqueue(D){this._bufferedBytes+=D[3][O$],this._queue.push(D)}sendFrame(D,$){if(D.length===2)this._socket.cork(),this._socket.write(D[0]),this._socket.write(D[1],$),this._socket.uncork();else this._socket.write(D[0],$)}}jt.exports=A4;function lM(D,$,X){if(typeof X==="function")X($);for(let Y=0;Y<D._queue.length;Y++){let J=D._queue[Y],Q=J[J.length-1];if(typeof Q==="function")Q($)}}function CTD(D,$,X){lM(D,$,X),D.onerror($)}});var _t=T((xrD,vt)=>{var{kForOnEventAttribute:G2,kListener:iM}=j6(),Et=Symbol("kCode"),Tt=Symbol("kData"),Ct=Symbol("kError"),Pt=Symbol("kMessage"),xt=Symbol("kReason"),X7=Symbol("kTarget"),St=Symbol("kType"),ut=Symbol("kWasClean");class R4{constructor(D){this[X7]=null,this[St]=D}get target(){return this[X7]}get type(){return this[St]}}Object.defineProperty(R4.prototype,"target",{enumerable:!0});Object.defineProperty(R4.prototype,"type",{enumerable:!0});class J7 extends R4{constructor(D,$={}){super(D);this[Et]=$.code===void 0?0:$.code,this[xt]=$.reason===void 0?"":$.reason,this[ut]=$.wasClean===void 0?!1:$.wasClean}get code(){return this[Et]}get reason(){return this[xt]}get wasClean(){return this[ut]}}Object.defineProperty(J7.prototype,"code",{enumerable:!0});Object.defineProperty(J7.prototype,"reason",{enumerable:!0});Object.defineProperty(J7.prototype,"wasClean",{enumerable:!0});class O2 extends R4{constructor(D,$={}){super(D);this[Ct]=$.error===void 0?null:$.error,this[Pt]=$.message===void 0?"":$.message}get error(){return this[Ct]}get message(){return this[Pt]}}Object.defineProperty(O2.prototype,"error",{enumerable:!0});Object.defineProperty(O2.prototype,"message",{enumerable:!0});class MZ extends R4{constructor(D,$={}){super(D);this[Tt]=$.data===void 0?null:$.data}get data(){return this[Tt]}}Object.defineProperty(MZ.prototype,"data",{enumerable:!0});var PTD={addEventListener(D,$,X={}){for(let J of this.listeners(D))if(!X[G2]&&J[iM]===$&&!J[G2])return;let Y;if(D==="message")Y=function(Q,F){let w=new MZ("message",{data:F?Q:Q.toString()});w[X7]=this,NZ($,this,w)};else if(D==="close")Y=function(Q,F){let w=new J7("close",{code:Q,reason:F.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});w[X7]=this,NZ($,this,w)};else if(D==="error")Y=function(Q){let F=new O2("error",{error:Q,message:Q.message});F[X7]=this,NZ($,this,F)};else if(D==="open")Y=function(){let Q=new R4("open");Q[X7]=this,NZ($,this,Q)};else return;if(Y[G2]=!!X[G2],Y[iM]=$,X.once)this.once(D,Y);else this.on(D,Y)},removeEventListener(D,$){for(let X of this.listeners(D))if(X[iM]===$&&!X[G2]){this.removeListener(D,X);break}}};vt.exports={CloseEvent:J7,ErrorEvent:O2,Event:R4,EventTarget:PTD,MessageEvent:MZ};function NZ(D,$,X){if(typeof D==="object"&&D.handleEvent)D.handleEvent.call(D,X);else D.call($,X)}});var pM=T((SrD,kt)=>{var{tokenChars:U2}=e5();function o$(D,$,X){if(D[$]===void 0)D[$]=[X];else D[$].push(X)}function xTD(D){let $=Object.create(null),X=Object.create(null),Y=!1,J=!1,Q=!1,F,w,Z=-1,G=-1,O=-1,U=0;for(;U<D.length;U++)if(G=D.charCodeAt(U),F===void 0)if(O===-1&&U2[G]===1){if(Z===-1)Z=U}else if(U!==0&&(G===32||G===9)){if(O===-1&&Z!==-1)O=U}else if(G===59||G===44){if(Z===-1)throw SyntaxError(`Unexpected character at index ${U}`);if(O===-1)O=U;let q=D.slice(Z,O);if(G===44)o$($,q,X),X=Object.create(null);else F=q;Z=O=-1}else throw SyntaxError(`Unexpected character at index ${U}`);else if(w===void 0)if(O===-1&&U2[G]===1){if(Z===-1)Z=U}else if(G===32||G===9){if(O===-1&&Z!==-1)O=U}else if(G===59||G===44){if(Z===-1)throw SyntaxError(`Unexpected character at index ${U}`);if(O===-1)O=U;if(o$(X,D.slice(Z,O),!0),G===44)o$($,F,X),X=Object.create(null),F=void 0;Z=O=-1}else if(G===61&&Z!==-1&&O===-1)w=D.slice(Z,U),Z=O=-1;else throw SyntaxError(`Unexpected character at index ${U}`);else if(J){if(U2[G]!==1)throw SyntaxError(`Unexpected character at index ${U}`);if(Z===-1)Z=U;else if(!Y)Y=!0;J=!1}else if(Q)if(U2[G]===1){if(Z===-1)Z=U}else if(G===34&&Z!==-1)Q=!1,O=U;else if(G===92)J=!0;else throw SyntaxError(`Unexpected character at index ${U}`);else if(G===34&&D.charCodeAt(U-1)===61)Q=!0;else if(O===-1&&U2[G]===1){if(Z===-1)Z=U}else if(Z!==-1&&(G===32||G===9)){if(O===-1)O=U}else if(G===59||G===44){if(Z===-1)throw SyntaxError(`Unexpected character at index ${U}`);if(O===-1)O=U;let q=D.slice(Z,O);if(Y)q=q.replace(/\\/g,""),Y=!1;if(o$(X,w,q),G===44)o$($,F,X),X=Object.create(null),F=void 0;w=void 0,Z=O=-1}else throw SyntaxError(`Unexpected character at index ${U}`);if(Z===-1||Q||G===32||G===9)throw SyntaxError("Unexpected end of input");if(O===-1)O=U;let z=D.slice(Z,O);if(F===void 0)o$($,z,X);else{if(w===void 0)o$(X,z,!0);else if(Y)o$(X,w,z.replace(/\\/g,""));else o$(X,w,z);o$($,F,X)}return $}function STD(D){return Object.keys(D).map(($)=>{let X=D[$];if(!Array.isArray(X))X=[X];return X.map((Y)=>{return[$].concat(Object.keys(Y).map((J)=>{let Q=Y[J];if(!Array.isArray(Q))Q=[Q];return Q.map((F)=>F===!0?J:`${J}=${F}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}kt.exports={format:STD,parse:xTD}});var RZ=T((_rD,pt)=>{var uTD=p("events"),vTD=p("https"),_TD=p("http"),bt=p("net"),kTD=p("tls"),{randomBytes:fTD,createHash:yTD}=p("crypto"),{Duplex:urD,Readable:vrD}=p("stream"),{URL:rM}=p("url"),j4=Z2(),bTD=cM(),gTD=nM(),{isBlob:hTD}=e5(),{BINARY_TYPES:ft,CLOSE_TIMEOUT:mTD,EMPTY_BUFFER:LZ,GUID:dTD,kForOnEventAttribute:oM,kListener:cTD,kStatusCode:lTD,kWebSocket:i0,NOOP:gt}=j6(),{EventTarget:{addEventListener:nTD,removeEventListener:iTD}}=_t(),{format:pTD,parse:rTD}=pM(),{toBuffer:oTD}=F2(),ht=Symbol("kAborted"),aM=[8,13],T6=["CONNECTING","OPEN","CLOSING","CLOSED"],aTD=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class ED extends uTD{constructor(D,$,X){super();if(this._binaryType=ft[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=LZ,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=ED.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,D!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,$===void 0)$=[];else if(!Array.isArray($))if(typeof $==="object"&&$!==null)X=$,$=[];else $=[$];mt(this,D,$,X)}else this._autoPong=X.autoPong,this._closeTimeout=X.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(D){if(!ft.includes(D))return;if(this._binaryType=D,this._receiver)this._receiver._binaryType=D}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(D,$,X){let Y=new bTD({allowSynchronousEvents:X.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:X.maxPayload,skipUTF8Validation:X.skipUTF8Validation}),J=new gTD(D,this._extensions,X.generateMask);if(this._receiver=Y,this._sender=J,this._socket=D,Y[i0]=this,J[i0]=this,D[i0]=this,Y.on("conclude",eTD),Y.on("drain",DCD),Y.on("error",$CD),Y.on("message",XCD),Y.on("ping",JCD),Y.on("pong",YCD),J.onerror=QCD,D.setTimeout)D.setTimeout(0);if(D.setNoDelay)D.setNoDelay();if($.length>0)D.unshift($);D.on("close",lt),D.on("data",AZ),D.on("end",nt),D.on("error",it),this._readyState=ED.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=ED.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[j4.extensionName])this._extensions[j4.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=ED.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(D,$){if(this.readyState===ED.CLOSED)return;if(this.readyState===ED.CONNECTING){p1(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===ED.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=ED.CLOSING,this._sender.close(D,$,!this._isServer,(X)=>{if(X)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),ct(this)}pause(){if(this.readyState===ED.CONNECTING||this.readyState===ED.CLOSED)return;this._paused=!0,this._socket.pause()}ping(D,$,X){if(this.readyState===ED.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof D==="function")X=D,D=$=void 0;else if(typeof $==="function")X=$,$=void 0;if(typeof D==="number")D=D.toString();if(this.readyState!==ED.OPEN){tM(this,D,X);return}if($===void 0)$=!this._isServer;this._sender.ping(D||LZ,$,X)}pong(D,$,X){if(this.readyState===ED.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof D==="function")X=D,D=$=void 0;else if(typeof $==="function")X=$,$=void 0;if(typeof D==="number")D=D.toString();if(this.readyState!==ED.OPEN){tM(this,D,X);return}if($===void 0)$=!this._isServer;this._sender.pong(D||LZ,$,X)}resume(){if(this.readyState===ED.CONNECTING||this.readyState===ED.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send(D,$,X){if(this.readyState===ED.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")X=$,$={};if(typeof D==="number")D=D.toString();if(this.readyState!==ED.OPEN){tM(this,D,X);return}let Y={binary:typeof D!=="string",mask:!this._isServer,compress:!0,fin:!0,...$};if(!this._extensions[j4.extensionName])Y.compress=!1;this._sender.send(D||LZ,Y,X)}terminate(){if(this.readyState===ED.CLOSED)return;if(this.readyState===ED.CONNECTING){p1(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=ED.CLOSING,this._socket.destroy()}}Object.defineProperty(ED,"CONNECTING",{enumerable:!0,value:T6.indexOf("CONNECTING")});Object.defineProperty(ED.prototype,"CONNECTING",{enumerable:!0,value:T6.indexOf("CONNECTING")});Object.defineProperty(ED,"OPEN",{enumerable:!0,value:T6.indexOf("OPEN")});Object.defineProperty(ED.prototype,"OPEN",{enumerable:!0,value:T6.indexOf("OPEN")});Object.defineProperty(ED,"CLOSING",{enumerable:!0,value:T6.indexOf("CLOSING")});Object.defineProperty(ED.prototype,"CLOSING",{enumerable:!0,value:T6.indexOf("CLOSING")});Object.defineProperty(ED,"CLOSED",{enumerable:!0,value:T6.indexOf("CLOSED")});Object.defineProperty(ED.prototype,"CLOSED",{enumerable:!0,value:T6.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((D)=>{Object.defineProperty(ED.prototype,D,{enumerable:!0})});["open","error","close","message"].forEach((D)=>{Object.defineProperty(ED.prototype,`on${D}`,{enumerable:!0,get(){for(let $ of this.listeners(D))if($[oM])return $[cTD];return null},set($){for(let X of this.listeners(D))if(X[oM]){this.removeListener(D,X);break}if(typeof $!=="function")return;this.addEventListener(D,$,{[oM]:!0})}})});ED.prototype.addEventListener=nTD;ED.prototype.removeEventListener=iTD;pt.exports=ED;function mt(D,$,X,Y){let J={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:mTD,protocolVersion:aM[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...Y,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(D._autoPong=J.autoPong,D._closeTimeout=J.closeTimeout,!aM.includes(J.protocolVersion))throw RangeError(`Unsupported protocol version: ${J.protocolVersion} (supported versions: ${aM.join(", ")})`);let Q;if($ instanceof rM)Q=$;else try{Q=new rM($)}catch(K){throw SyntaxError(`Invalid URL: ${$}`)}if(Q.protocol==="http:")Q.protocol="ws:";else if(Q.protocol==="https:")Q.protocol="wss:";D._url=Q.href;let F=Q.protocol==="wss:",w=Q.protocol==="ws+unix:",Z;if(Q.protocol!=="ws:"&&!F&&!w)Z=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(w&&!Q.pathname)Z="The URL's pathname is empty";else if(Q.hash)Z="The URL contains a fragment identifier";if(Z){let K=SyntaxError(Z);if(D._redirects===0)throw K;else{IZ(D,K);return}}let G=F?443:80,O=fTD(16).toString("base64"),U=F?vTD.request:_TD.request,z=new Set,q;if(J.createConnection=J.createConnection||(F?sTD:tTD),J.defaultPort=J.defaultPort||G,J.port=Q.port||G,J.host=Q.hostname.startsWith("[")?Q.hostname.slice(1,-1):Q.hostname,J.headers={...J.headers,"Sec-WebSocket-Version":J.protocolVersion,"Sec-WebSocket-Key":O,Connection:"Upgrade",Upgrade:"websocket"},J.path=Q.pathname+Q.search,J.timeout=J.handshakeTimeout,J.perMessageDeflate)q=new j4(J.perMessageDeflate!==!0?J.perMessageDeflate:{},!1,J.maxPayload),J.headers["Sec-WebSocket-Extensions"]=pTD({[j4.extensionName]:q.offer()});if(X.length){for(let K of X){if(typeof K!=="string"||!aTD.test(K)||z.has(K))throw SyntaxError("An invalid or duplicated subprotocol was specified");z.add(K)}J.headers["Sec-WebSocket-Protocol"]=X.join(",")}if(J.origin)if(J.protocolVersion<13)J.headers["Sec-WebSocket-Origin"]=J.origin;else J.headers.Origin=J.origin;if(Q.username||Q.password)J.auth=`${Q.username}:${Q.password}`;if(w){let K=J.path.split(":");J.socketPath=K[0],J.path=K[1]}let B;if(J.followRedirects){if(D._redirects===0){D._originalIpc=w,D._originalSecure=F,D._originalHostOrSocketPath=w?J.socketPath:Q.host;let K=Y&&Y.headers;if(Y={...Y,headers:{}},K)for(let[M,L]of Object.entries(K))Y.headers[M.toLowerCase()]=L}else if(D.listenerCount("redirect")===0){let K=w?D._originalIpc?J.socketPath===D._originalHostOrSocketPath:!1:D._originalIpc?!1:Q.host===D._originalHostOrSocketPath;if(!K||D._originalSecure&&!F){if(delete J.headers.authorization,delete J.headers.cookie,!K)delete J.headers.host;J.auth=void 0}}if(J.auth&&!Y.headers.authorization)Y.headers.authorization="Basic "+Buffer.from(J.auth).toString("base64");if(B=D._req=U(J),D._redirects)D.emit("redirect",D.url,B)}else B=D._req=U(J);if(J.timeout)B.on("timeout",()=>{p1(D,B,"Opening handshake has timed out")});if(B.on("error",(K)=>{if(B===null||B[ht])return;B=D._req=null,IZ(D,K)}),B.on("response",(K)=>{let M=K.headers.location,L=K.statusCode;if(M&&J.followRedirects&&L>=300&&L<400){if(++D._redirects>J.maxRedirects){p1(D,B,"Maximum redirects exceeded");return}B.abort();let I;try{I=new rM(M,$)}catch(W){let N=SyntaxError(`Invalid URL: ${M}`);IZ(D,N);return}mt(D,I,X,Y)}else if(!D.emit("unexpected-response",B,K))p1(D,B,`Unexpected server response: ${K.statusCode}`)}),B.on("upgrade",(K,M,L)=>{if(D.emit("upgrade",K),D.readyState!==ED.CONNECTING)return;B=D._req=null;let I=K.headers.upgrade;if(I===void 0||I.toLowerCase()!=="websocket"){p1(D,M,"Invalid Upgrade header");return}let W=yTD("sha1").update(O+dTD).digest("base64");if(K.headers["sec-websocket-accept"]!==W){p1(D,M,"Invalid Sec-WebSocket-Accept header");return}let N=K.headers["sec-websocket-protocol"],V;if(N!==void 0){if(!z.size)V="Server sent a subprotocol but none was requested";else if(!z.has(N))V="Server sent an invalid subprotocol"}else if(z.size)V="Server sent no subprotocol";if(V){p1(D,M,V);return}if(N)D._protocol=N;let R=K.headers["sec-websocket-extensions"];if(R!==void 0){if(!q){p1(D,M,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let C;try{C=rTD(R)}catch(_){p1(D,M,"Invalid Sec-WebSocket-Extensions header");return}let A=Object.keys(C);if(A.length!==1||A[0]!==j4.extensionName){p1(D,M,"Server indicated an extension that was not requested");return}try{q.accept(C[j4.extensionName])}catch(_){p1(D,M,"Invalid Sec-WebSocket-Extensions header");return}D._extensions[j4.extensionName]=q}D.setSocket(M,L,{allowSynchronousEvents:J.allowSynchronousEvents,generateMask:J.generateMask,maxPayload:J.maxPayload,skipUTF8Validation:J.skipUTF8Validation})}),J.finishRequest)J.finishRequest(B,D);else B.end()}function IZ(D,$){D._readyState=ED.CLOSING,D._errorEmitted=!0,D.emit("error",$),D.emitClose()}function tTD(D){return D.path=D.socketPath,bt.connect(D)}function sTD(D){if(D.path=void 0,!D.servername&&D.servername!=="")D.servername=bt.isIP(D.host)?"":D.host;return kTD.connect(D)}function p1(D,$,X){D._readyState=ED.CLOSING;let Y=Error(X);if(Error.captureStackTrace(Y,p1),$.setHeader){if($[ht]=!0,$.abort(),$.socket&&!$.socket.destroyed)$.socket.destroy();process.nextTick(IZ,D,Y)}else $.destroy(Y),$.once("error",D.emit.bind(D,"error")),$.once("close",D.emitClose.bind(D))}function tM(D,$,X){if($){let Y=hTD($)?$.size:oTD($).length;if(D._socket)D._sender._bufferedBytes+=Y;else D._bufferedAmount+=Y}if(X){let Y=Error(`WebSocket is not open: readyState ${D.readyState} (${T6[D.readyState]})`);process.nextTick(X,Y)}}function eTD(D,$){let X=this[i0];if(X._closeFrameReceived=!0,X._closeMessage=$,X._closeCode=D,X._socket[i0]===void 0)return;if(X._socket.removeListener("data",AZ),process.nextTick(dt,X._socket),D===1005)X.close();else X.close(D,$)}function DCD(){let D=this[i0];if(!D.isPaused)D._socket.resume()}function $CD(D){let $=this[i0];if($._socket[i0]!==void 0)$._socket.removeListener("data",AZ),process.nextTick(dt,$._socket),$.close(D[lTD]);if(!$._errorEmitted)$._errorEmitted=!0,$.emit("error",D)}function yt(){this[i0].emitClose()}function XCD(D,$){this[i0].emit("message",D,$)}function JCD(D){let $=this[i0];if($._autoPong)$.pong(D,!this._isServer,gt);$.emit("ping",D)}function YCD(D){this[i0].emit("pong",D)}function dt(D){D.resume()}function QCD(D){let $=this[i0];if($.readyState===ED.CLOSED)return;if($.readyState===ED.OPEN)$._readyState=ED.CLOSING,ct($);if(this._socket.end(),!$._errorEmitted)$._errorEmitted=!0,$.emit("error",D)}function ct(D){D._closeTimer=setTimeout(D._socket.destroy.bind(D._socket),D._closeTimeout)}function lt(){let D=this[i0];if(this.removeListener("close",lt),this.removeListener("data",AZ),this.removeListener("end",nt),D._readyState=ED.CLOSING,!this._readableState.endEmitted&&!D._closeFrameReceived&&!D._receiver._writableState.errorEmitted&&this._readableState.length!==0){let $=this.read(this._readableState.length);D._receiver.write($)}if(D._receiver.end(),this[i0]=void 0,clearTimeout(D._closeTimer),D._receiver._writableState.finished||D._receiver._writableState.errorEmitted)D.emitClose();else D._receiver.on("error",yt),D._receiver.on("finish",yt)}function AZ(D){if(!this[i0]._receiver.write(D))this.pause()}function nt(){let D=this[i0];D._readyState=ED.CLOSING,D._receiver.end(),this.end()}function it(){let D=this[i0];if(this.removeListener("error",it),this.on("error",gt),D)D._readyState=ED.CLOSING,this.destroy()}});var tt=T((frD,at)=>{var krD=RZ(),{Duplex:FCD}=p("stream");function rt(D){D.emit("close")}function wCD(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function ot(D){if(this.removeListener("error",ot),this.destroy(),this.listenerCount("error")===0)this.emit("error",D)}function ZCD(D,$){let X=!0,Y=new FCD({...$,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return D.on("message",function(Q,F){let w=!F&&Y._readableState.objectMode?Q.toString():Q;if(!Y.push(w))D.pause()}),D.once("error",function(Q){if(Y.destroyed)return;X=!1,Y.destroy(Q)}),D.once("close",function(){if(Y.destroyed)return;Y.push(null)}),Y._destroy=function(J,Q){if(D.readyState===D.CLOSED){Q(J),process.nextTick(rt,Y);return}let F=!1;if(D.once("error",function(Z){F=!0,Q(Z)}),D.once("close",function(){if(!F)Q(J);process.nextTick(rt,Y)}),X)D.terminate()},Y._final=function(J){if(D.readyState===D.CONNECTING){D.once("open",function(){Y._final(J)});return}if(D._socket===null)return;if(D._socket._writableState.finished){if(J(),Y._readableState.endEmitted)Y.destroy()}else D._socket.once("finish",function(){J()}),D.close()},Y._read=function(){if(D.isPaused)D.resume()},Y._write=function(J,Q,F){if(D.readyState===D.CONNECTING){D.once("open",function(){Y._write(J,Q,F)});return}D.send(J,F)},Y.on("end",wCD),Y.on("error",ot),Y}at.exports=ZCD});var et=T((yrD,st)=>{var{tokenChars:GCD}=e5();function OCD(D){let $=new Set,X=-1,Y=-1,J=0;for(J;J<D.length;J++){let F=D.charCodeAt(J);if(Y===-1&&GCD[F]===1){if(X===-1)X=J}else if(J!==0&&(F===32||F===9)){if(Y===-1&&X!==-1)Y=J}else if(F===44){if(X===-1)throw SyntaxError(`Unexpected character at index ${J}`);if(Y===-1)Y=J;let w=D.slice(X,Y);if($.has(w))throw SyntaxError(`The "${w}" subprotocol is duplicated`);$.add(w),X=Y=-1}else throw SyntaxError(`Unexpected character at index ${J}`)}if(X===-1||Y!==-1)throw SyntaxError("Unexpected end of input");let Q=D.slice(X,J);if($.has(Q))throw SyntaxError(`The "${Q}" subprotocol is duplicated`);return $.add(Q),$}st.exports={parse:OCD}});var Ys=T((grD,Js)=>{var UCD=p("events"),jZ=p("http"),{Duplex:brD}=p("stream"),{createHash:qCD}=p("crypto"),Ds=pM(),g8=Z2(),zCD=et(),BCD=RZ(),{CLOSE_TIMEOUT:KCD,GUID:WCD,kWebSocket:HCD}=j6(),VCD=/^[+/0-9A-Za-z]{22}==$/;class Xs extends UCD{constructor(D,$){super();if(D={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:KCD,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:BCD,...D},D.port==null&&!D.server&&!D.noServer||D.port!=null&&(D.server||D.noServer)||D.server&&D.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(D.port!=null)this._server=jZ.createServer((X,Y)=>{let J=jZ.STATUS_CODES[426];Y.writeHead(426,{"Content-Length":J.length,"Content-Type":"text/plain"}),Y.end(J)}),this._server.listen(D.port,D.host,D.backlog,$);else if(D.server)this._server=D.server;if(this._server){let X=this.emit.bind(this,"connection");this._removeListeners=NCD(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(Y,J,Q)=>{this.handleUpgrade(Y,J,Q,X)}})}if(D.perMessageDeflate===!0)D.perMessageDeflate={};if(D.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=D,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');if(!this._server)return null;return this._server.address()}close(D){if(this._state===2){if(D)this.once("close",()=>{D(Error("The server is not running"))});process.nextTick(q2,this);return}if(D)this.once("close",D);if(this._state===1)return;if(this._state=1,this.options.noServer||this.options.server){if(this._server)this._removeListeners(),this._removeListeners=this._server=null;if(this.clients)if(!this.clients.size)process.nextTick(q2,this);else this._shouldEmitClose=!0;else process.nextTick(q2,this)}else{let $=this._server;this._removeListeners(),this._removeListeners=this._server=null,$.close(()=>{q2(this)})}}shouldHandle(D){if(this.options.path){let $=D.url.indexOf("?");if(($!==-1?D.url.slice(0,$):D.url)!==this.options.path)return!1}return!0}handleUpgrade(D,$,X,Y){$.on("error",$s);let J=D.headers["sec-websocket-key"],Q=D.headers.upgrade,F=+D.headers["sec-websocket-version"];if(D.method!=="GET"){h8(this,D,$,405,"Invalid HTTP method");return}if(Q===void 0||Q.toLowerCase()!=="websocket"){h8(this,D,$,400,"Invalid Upgrade header");return}if(J===void 0||!VCD.test(J)){h8(this,D,$,400,"Missing or invalid Sec-WebSocket-Key header");return}if(F!==13&&F!==8){h8(this,D,$,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(D)){z2($,400);return}let w=D.headers["sec-websocket-protocol"],Z=new Set;if(w!==void 0)try{Z=zCD.parse(w)}catch(U){h8(this,D,$,400,"Invalid Sec-WebSocket-Protocol header");return}let G=D.headers["sec-websocket-extensions"],O={};if(this.options.perMessageDeflate&&G!==void 0){let U=new g8(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let z=Ds.parse(G);if(z[g8.extensionName])U.accept(z[g8.extensionName]),O[g8.extensionName]=U}catch(z){h8(this,D,$,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let U={origin:D.headers[`${F===8?"sec-websocket-origin":"origin"}`],secure:!!(D.socket.authorized||D.socket.encrypted),req:D};if(this.options.verifyClient.length===2){this.options.verifyClient(U,(z,q,B,K)=>{if(!z)return z2($,q||401,B,K);this.completeUpgrade(O,J,Z,D,$,X,Y)});return}if(!this.options.verifyClient(U))return z2($,401)}this.completeUpgrade(O,J,Z,D,$,X,Y)}completeUpgrade(D,$,X,Y,J,Q,F){if(!J.readable||!J.writable)return J.destroy();if(J[HCD])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return z2(J,503);let Z=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${qCD("sha1").update($+WCD).digest("base64")}`],G=new this.options.WebSocket(null,void 0,this.options);if(X.size){let O=this.options.handleProtocols?this.options.handleProtocols(X,Y):X.values().next().value;if(O)Z.push(`Sec-WebSocket-Protocol: ${O}`),G._protocol=O}if(D[g8.extensionName]){let O=D[g8.extensionName].params,U=Ds.format({[g8.extensionName]:[O]});Z.push(`Sec-WebSocket-Extensions: ${U}`),G._extensions=D}if(this.emit("headers",Z,Y),J.write(Z.concat(`\r
401
401
  `).join(`\r
402
402
  `)),J.removeListener("error",$s),G.setSocket(J,Q,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients)this.clients.add(G),G.on("close",()=>{if(this.clients.delete(G),this._shouldEmitClose&&!this.clients.size)process.nextTick(q2,this)});F(G,Y)}}Js.exports=Xs;function NCD(D,$){for(let X of Object.keys($))D.on(X,$[X]);return function(){for(let Y of Object.keys($))D.removeListener(Y,$[Y])}}function q2(D){D._state=2,D.emit("close")}function $s(){this.destroy()}function z2(D,$,X,Y){X=X||jZ.STATUS_CODES[$],Y={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(X),...Y},D.once("finish",D.destroy),D.end(`HTTP/1.1 ${$} ${jZ.STATUS_CODES[$]}\r
403
403
  `+Object.keys(Y).map((J)=>`${J}: ${Y[J]}`).join(`\r
@@ -419,7 +419,7 @@ PS: You can ignore this check with "--ignore-checksum-check"`),Error("Cannot upl
419
419
  * Copyright (c) 2014-present, Jon Schlinkert.
420
420
  * Licensed under the MIT License.
421
421
  */var tPD=p("util"),Ge=we(),Ze=(D)=>D!==null&&typeof D==="object"&&!Array.isArray(D),sPD=(D)=>{return($)=>D===!0?Number($):String($)},ML=(D)=>{return typeof D==="number"||typeof D==="string"&&D!==""},I2=(D)=>Number.isInteger(+D),LL=(D)=>{let $=`${D}`,X=-1;if($[0]==="-")$=$.slice(1);if($==="0")return!1;while($[++X]==="0");return X>0},ePD=(D,$,X)=>{if(typeof D==="string"||typeof $==="string")return!0;return X.stringify===!0},DxD=(D,$,X)=>{if($>0){let Y=D[0]==="-"?"-":"";if(Y)D=D.slice(1);D=Y+D.padStart(Y?$-1:$,"0")}if(X===!1)return String(D);return D},gZ=(D,$)=>{let X=D[0]==="-"?"-":"";if(X)D=D.slice(1),$--;while(D.length<$)D="0"+D;return X?"-"+D:D},$xD=(D,$,X)=>{D.negatives.sort((w,Z)=>w<Z?-1:w>Z?1:0),D.positives.sort((w,Z)=>w<Z?-1:w>Z?1:0);let Y=$.capture?"":"?:",J="",Q="",F;if(D.positives.length)J=D.positives.map((w)=>gZ(String(w),X)).join("|");if(D.negatives.length)Q=`-(${Y}${D.negatives.map((w)=>gZ(String(w),X)).join("|")})`;if(J&&Q)F=`${J}|${Q}`;else F=J||Q;if($.wrap)return`(${Y}${F})`;return F},Oe=(D,$,X,Y)=>{if(X)return Ge(D,$,{wrap:!1,...Y});let J=String.fromCharCode(D);if(D===$)return J;let Q=String.fromCharCode($);return`[${J}-${Q}]`},Ue=(D,$,X)=>{if(Array.isArray(D)){let Y=X.wrap===!0,J=X.capture?"":"?:";return Y?`(${J}${D.join("|")})`:D.join("|")}return Ge(D,$,X)},qe=(...D)=>{return RangeError("Invalid range arguments: "+tPD.inspect(...D))},ze=(D,$,X)=>{if(X.strictRanges===!0)throw qe([D,$]);return[]},XxD=(D,$)=>{if($.strictRanges===!0)throw TypeError(`Expected step "${D}" to be a number`);return[]},JxD=(D,$,X=1,Y={})=>{let J=Number(D),Q=Number($);if(!Number.isInteger(J)||!Number.isInteger(Q)){if(Y.strictRanges===!0)throw qe([D,$]);return[]}if(J===0)J=0;if(Q===0)Q=0;let F=J>Q,w=String(D),Z=String($),G=String(X);X=Math.max(Math.abs(X),1);let O=LL(w)||LL(Z)||LL(G),U=O?Math.max(w.length,Z.length,G.length):0,z=O===!1&&ePD(D,$,Y)===!1,q=Y.transform||sPD(z);if(Y.toRegex&&X===1)return Oe(gZ(D,U),gZ($,U),!0,Y);let B={negatives:[],positives:[]},K=(I)=>B[I<0?"negatives":"positives"].push(Math.abs(I)),M=[],L=0;while(F?J>=Q:J<=Q){if(Y.toRegex===!0&&X>1)K(J);else M.push(DxD(q(J,L),U,z));J=F?J-X:J+X,L++}if(Y.toRegex===!0)return X>1?$xD(B,Y,U):Ue(M,null,{wrap:!1,...Y});return M},YxD=(D,$,X=1,Y={})=>{if(!I2(D)&&D.length>1||!I2($)&&$.length>1)return ze(D,$,Y);let J=Y.transform||((z)=>String.fromCharCode(z)),Q=`${D}`.charCodeAt(0),F=`${$}`.charCodeAt(0),w=Q>F,Z=Math.min(Q,F),G=Math.max(Q,F);if(Y.toRegex&&X===1)return Oe(Z,G,!1,Y);let O=[],U=0;while(w?Q>=F:Q<=F)O.push(J(Q,U)),Q=w?Q-X:Q+X,U++;if(Y.toRegex===!0)return Ue(O,null,{wrap:!1,options:Y});return O},bZ=(D,$,X,Y={})=>{if($==null&&ML(D))return[D];if(!ML(D)||!ML($))return ze(D,$,Y);if(typeof X==="function")return bZ(D,$,1,{transform:X});if(Ze(X))return bZ(D,$,0,X);let J={...Y};if(J.capture===!0)J.wrap=!0;if(X=X||J.step||1,!I2(X)){if(X!=null&&!Ze(X))return XxD(X,J);return bZ(D,$,1,X)}if(I2(D)&&I2($))return JxD(D,$,X,J);return YxD(D,$,Math.max(Math.abs(X),1),J)};Be.exports=bZ});var He=T((AaD,We)=>{var QxD=IL(),Ke=fZ(),FxD=(D,$={})=>{let X=(Y,J={})=>{let Q=Ke.isInvalidBrace(J),F=Y.invalid===!0&&$.escapeInvalid===!0,w=Q===!0||F===!0,Z=$.escapeInvalid===!0?"\\":"",G="";if(Y.isOpen===!0)return Z+Y.value;if(Y.isClose===!0)return console.log("node.isClose",Z,Y.value),Z+Y.value;if(Y.type==="open")return w?Z+Y.value:"(";if(Y.type==="close")return w?Z+Y.value:")";if(Y.type==="comma")return Y.prev.type==="comma"?"":w?Y.value:"|";if(Y.value)return Y.value;if(Y.nodes&&Y.ranges>0){let O=Ke.reduce(Y.nodes),U=QxD(...O,{...$,wrap:!1,toRegex:!0,strictZeros:!0});if(U.length!==0)return O.length>1&&U.length>1?`(${U})`:U}if(Y.nodes)for(let O of Y.nodes)G+=X(O,Y);return G};return X(D)};We.exports=FxD});var Me=T((RaD,Ne)=>{var wxD=IL(),Ve=yZ(),Z7=fZ(),p8=(D="",$="",X=!1)=>{let Y=[];if(D=[].concat(D),$=[].concat($),!$.length)return D;if(!D.length)return X?Z7.flatten($).map((J)=>`{${J}}`):$;for(let J of D)if(Array.isArray(J))for(let Q of J)Y.push(p8(Q,$,X));else for(let Q of $){if(X===!0&&typeof Q==="string")Q=`{${Q}}`;Y.push(Array.isArray(Q)?p8(J,Q,X):J+Q)}return Z7.flatten(Y)},ZxD=(D,$={})=>{let X=$.rangeLimit===void 0?1000:$.rangeLimit,Y=(J,Q={})=>{J.queue=[];let F=Q,w=Q.queue;while(F.type!=="brace"&&F.type!=="root"&&F.parent)F=F.parent,w=F.queue;if(J.invalid||J.dollar){w.push(p8(w.pop(),Ve(J,$)));return}if(J.type==="brace"&&J.invalid!==!0&&J.nodes.length===2){w.push(p8(w.pop(),["{}"]));return}if(J.nodes&&J.ranges>0){let U=Z7.reduce(J.nodes);if(Z7.exceedsLimit(...U,$.step,X))throw RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let z=wxD(...U,$);if(z.length===0)z=Ve(J,$);w.push(p8(w.pop(),z)),J.nodes=[];return}let Z=Z7.encloseBrace(J),G=J.queue,O=J;while(O.type!=="brace"&&O.type!=="root"&&O.parent)O=O.parent,G=O.queue;for(let U=0;U<J.nodes.length;U++){let z=J.nodes[U];if(z.type==="comma"&&J.type==="brace"){if(U===1)G.push("");G.push("");continue}if(z.type==="close"){w.push(p8(w.pop(),G,Z));continue}if(z.value&&z.type!=="open"){G.push(p8(G.pop(),z.value));continue}if(z.nodes)Y(z,J)}return G};return Z7.flatten(Y(D))};Ne.exports=ZxD});var Ie=T((jaD,Le)=>{Le.exports={MAX_LENGTH:1e4,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:`
422
- `,CHAR_NO_BREAK_SPACE:" ",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:"\t",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\uFEFF"}});var Te=T((EaD,Ee)=>{var GxD=yZ(),{MAX_LENGTH:Ae,CHAR_BACKSLASH:AL,CHAR_BACKTICK:OxD,CHAR_COMMA:UxD,CHAR_DOT:qxD,CHAR_LEFT_PARENTHESES:zxD,CHAR_RIGHT_PARENTHESES:BxD,CHAR_LEFT_CURLY_BRACE:KxD,CHAR_RIGHT_CURLY_BRACE:WxD,CHAR_LEFT_SQUARE_BRACKET:Re,CHAR_RIGHT_SQUARE_BRACKET:je,CHAR_DOUBLE_QUOTE:HxD,CHAR_SINGLE_QUOTE:VxD,CHAR_NO_BREAK_SPACE:NxD,CHAR_ZERO_WIDTH_NOBREAK_SPACE:MxD}=Ie(),LxD=(D,$={})=>{if(typeof D!=="string")throw TypeError("Expected a string");let X=$||{},Y=typeof X.maxLength==="number"?Math.min(Ae,X.maxLength):Ae;if(D.length>Y)throw SyntaxError(`Input length (${D.length}), exceeds max characters (${Y})`);let J={type:"root",input:D,nodes:[]},Q=[J],F=J,w=J,Z=0,G=D.length,O=0,U=0,z,q=()=>D[O++],B=(K)=>{if(K.type==="text"&&w.type==="dot")w.type="text";if(w&&w.type==="text"&&K.type==="text"){w.value+=K.value;return}return F.nodes.push(K),K.parent=F,K.prev=w,w=K,K};B({type:"bos"});while(O<G){if(F=Q[Q.length-1],z=q(),z===MxD||z===NxD)continue;if(z===AL){B({type:"text",value:($.keepEscaping?z:"")+q()});continue}if(z===je){B({type:"text",value:"\\"+z});continue}if(z===Re){Z++;let K;while(O<G&&(K=q())){if(z+=K,K===Re){Z++;continue}if(K===AL){z+=q();continue}if(K===je){if(Z--,Z===0)break}}B({type:"text",value:z});continue}if(z===zxD){F=B({type:"paren",nodes:[]}),Q.push(F),B({type:"text",value:z});continue}if(z===BxD){if(F.type!=="paren"){B({type:"text",value:z});continue}F=Q.pop(),B({type:"text",value:z}),F=Q[Q.length-1];continue}if(z===HxD||z===VxD||z===OxD){let K=z,M;if($.keepQuotes!==!0)z="";while(O<G&&(M=q())){if(M===AL){z+=M+q();continue}if(M===K){if($.keepQuotes===!0)z+=M;break}z+=M}B({type:"text",value:z});continue}if(z===KxD){U++;let M={type:"brace",open:!0,close:!1,dollar:w.value&&w.value.slice(-1)==="$"||F.dollar===!0,depth:U,commas:0,ranges:0,nodes:[]};F=B(M),Q.push(F),B({type:"open",value:z});continue}if(z===WxD){if(F.type!=="brace"){B({type:"text",value:z});continue}let K="close";F=Q.pop(),F.close=!0,B({type:K,value:z}),U--,F=Q[Q.length-1];continue}if(z===UxD&&U>0){if(F.ranges>0){F.ranges=0;let K=F.nodes.shift();F.nodes=[K,{type:"text",value:GxD(F)}]}B({type:"comma",value:z}),F.commas++;continue}if(z===qxD&&U>0&&F.commas===0){let K=F.nodes;if(U===0||K.length===0){B({type:"text",value:z});continue}if(w.type==="dot"){if(F.range=[],w.value+=z,w.type="range",F.nodes.length!==3&&F.nodes.length!==5){F.invalid=!0,F.ranges=0,w.type="text";continue}F.ranges++,F.args=[];continue}if(w.type==="range"){K.pop();let M=K[K.length-1];M.value+=w.value+z,w=M,F.ranges--;continue}B({type:"dot",value:z});continue}B({type:"text",value:z})}do if(F=Q.pop(),F.type!=="root"){F.nodes.forEach((L)=>{if(!L.nodes){if(L.type==="open")L.isOpen=!0;if(L.type==="close")L.isClose=!0;if(!L.nodes)L.type="text";L.invalid=!0}});let K=Q[Q.length-1],M=K.nodes.indexOf(F);K.nodes.splice(M,1,...F.nodes)}while(Q.length>0);return B({type:"eos"}),J};Ee.exports=LxD});var xe=T((TaD,Pe)=>{var Ce=yZ(),IxD=He(),AxD=Me(),RxD=Te(),r1=(D,$={})=>{let X=[];if(Array.isArray(D))for(let Y of D){let J=r1.create(Y,$);if(Array.isArray(J))X.push(...J);else X.push(J)}else X=[].concat(r1.create(D,$));if($&&$.expand===!0&&$.nodupes===!0)X=[...new Set(X)];return X};r1.parse=(D,$={})=>RxD(D,$);r1.stringify=(D,$={})=>{if(typeof D==="string")return Ce(r1.parse(D,$),$);return Ce(D,$)};r1.compile=(D,$={})=>{if(typeof D==="string")D=r1.parse(D,$);return IxD(D,$)};r1.expand=(D,$={})=>{if(typeof D==="string")D=r1.parse(D,$);let X=AxD(D,$);if($.noempty===!0)X=X.filter(Boolean);if($.nodupes===!0)X=[...new Set(X)];return X};r1.create=(D,$={})=>{if(D===""||D.length<3)return[D];return $.expand!==!0?r1.compile(D,$):r1.expand(D,$)};Pe.exports=r1});var A2=T((CaD,ue)=>{var jxD=p("path"),Se={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:"(?=.)",QMARK:"[^/]",END_ANCHOR:"(?:\\/|$)",DOTS_SLASH:"\\.{1,2}(?:\\/|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|\\/)\\.{1,2}(?:\\/|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:\\/|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:\\/|$))",QMARK_NO_DOT:"[^.\\/]",STAR:"[^/]*?",START_ANCHOR:"(?:^|\\/)"},ExD={...Se,SLASH_LITERAL:"[\\\\/]",QMARK:"[^\\\\/]",STAR:"[^\\\\/]*?",DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)"},TxD={alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};ue.exports={MAX_LENGTH:65536,POSIX_REGEX_SOURCE:TxD,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:jxD.sep,extglobChars(D){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${D.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(D){return D===!0?ExD:Se}}});var R2=T((_xD)=>{var CxD=p("path"),PxD=process.platform==="win32",{REGEX_BACKSLASH:xxD,REGEX_REMOVE_BACKSLASH:SxD,REGEX_SPECIAL_CHARS:uxD,REGEX_SPECIAL_CHARS_GLOBAL:vxD}=A2();_xD.isObject=(D)=>D!==null&&typeof D==="object"&&!Array.isArray(D);_xD.hasRegexChars=(D)=>uxD.test(D);_xD.isRegexChar=(D)=>D.length===1&&_xD.hasRegexChars(D);_xD.escapeRegex=(D)=>D.replace(vxD,"\\$1");_xD.toPosixSlashes=(D)=>D.replace(xxD,"/");_xD.removeBackslashes=(D)=>{return D.replace(SxD,($)=>{return $==="\\"?"":$})};_xD.supportsLookbehinds=()=>{let D=process.version.slice(1).split(".").map(Number);if(D.length===3&&D[0]>=9||D[0]===8&&D[1]>=10)return!0;return!1};_xD.isWindows=(D)=>{if(D&&typeof D.windows==="boolean")return D.windows;return PxD===!0||CxD.sep==="\\"};_xD.escapeLast=(D,$,X)=>{let Y=D.lastIndexOf($,X);if(Y===-1)return D;if(D[Y-1]==="\\")return _xD.escapeLast(D,$,Y-1);return`${D.slice(0,Y)}\\${D.slice(Y)}`};_xD.removePrefix=(D,$={})=>{let X=D;if(X.startsWith("./"))X=X.slice(2),$.prefix="./";return X};_xD.wrapOutput=(D,$={},X={})=>{let Y=X.contains?"":"^",J=X.contains?"":"$",Q=`${Y}(?:${D})${J}`;if($.negated===!0)Q=`(?:^(?!${Q}).*$)`;return Q}});var de=T((xaD,me)=>{var ke=R2(),{CHAR_ASTERISK:RL,CHAR_AT:lxD,CHAR_BACKWARD_SLASH:j2,CHAR_COMMA:nxD,CHAR_DOT:jL,CHAR_EXCLAMATION_MARK:EL,CHAR_FORWARD_SLASH:he,CHAR_LEFT_CURLY_BRACE:TL,CHAR_LEFT_PARENTHESES:CL,CHAR_LEFT_SQUARE_BRACKET:ixD,CHAR_PLUS:pxD,CHAR_QUESTION_MARK:fe,CHAR_RIGHT_CURLY_BRACE:rxD,CHAR_RIGHT_PARENTHESES:ye,CHAR_RIGHT_SQUARE_BRACKET:oxD}=A2(),be=(D)=>{return D===he||D===j2},ge=(D)=>{if(D.isPrefix!==!0)D.depth=D.isGlobstar?1/0:1},axD=(D,$)=>{let X=$||{},Y=D.length-1,J=X.parts===!0||X.scanToEnd===!0,Q=[],F=[],w=[],Z=D,G=-1,O=0,U=0,z=!1,q=!1,B=!1,K=!1,M=!1,L=!1,I=!1,W=!1,N=!1,V=!1,R=0,P,A,_={value:"",depth:0,isGlob:!1},v=()=>G>=Y,S=()=>Z.charCodeAt(G+1),h=()=>{return P=A,Z.charCodeAt(++G)};while(G<Y){A=h();let x;if(A===j2){if(I=_.backslashes=!0,A=h(),A===TL)L=!0;continue}if(L===!0||A===TL){R++;while(v()!==!0&&(A=h())){if(A===j2){I=_.backslashes=!0,h();continue}if(A===TL){R++;continue}if(L!==!0&&A===jL&&(A=h())===jL){if(z=_.isBrace=!0,B=_.isGlob=!0,V=!0,J===!0)continue;break}if(L!==!0&&A===nxD){if(z=_.isBrace=!0,B=_.isGlob=!0,V=!0,J===!0)continue;break}if(A===rxD){if(R--,R===0){L=!1,z=_.isBrace=!0,V=!0;break}}}if(J===!0)continue;break}if(A===he){if(Q.push(G),F.push(_),_={value:"",depth:0,isGlob:!1},V===!0)continue;if(P===jL&&G===O+1){O+=2;continue}U=G+1;continue}if(X.noext!==!0){if((A===pxD||A===lxD||A===RL||A===fe||A===EL)===!0&&S()===CL){if(B=_.isGlob=!0,K=_.isExtglob=!0,V=!0,A===EL&&G===O)N=!0;if(J===!0){while(v()!==!0&&(A=h())){if(A===j2){I=_.backslashes=!0,A=h();continue}if(A===ye){B=_.isGlob=!0,V=!0;break}}continue}break}}if(A===RL){if(P===RL)M=_.isGlobstar=!0;if(B=_.isGlob=!0,V=!0,J===!0)continue;break}if(A===fe){if(B=_.isGlob=!0,V=!0,J===!0)continue;break}if(A===ixD){while(v()!==!0&&(x=h())){if(x===j2){I=_.backslashes=!0,h();continue}if(x===oxD){q=_.isBracket=!0,B=_.isGlob=!0,V=!0;break}}if(J===!0)continue;break}if(X.nonegate!==!0&&A===EL&&G===O){W=_.negated=!0,O++;continue}if(X.noparen!==!0&&A===CL){if(B=_.isGlob=!0,J===!0){while(v()!==!0&&(A=h())){if(A===CL){I=_.backslashes=!0,A=h();continue}if(A===ye){V=!0;break}}continue}break}if(B===!0){if(V=!0,J===!0)continue;break}}if(X.noext===!0)K=!1,B=!1;let g=Z,l="",f="";if(O>0)l=Z.slice(0,O),Z=Z.slice(O),U-=O;if(g&&B===!0&&U>0)g=Z.slice(0,U),f=Z.slice(U);else if(B===!0)g="",f=Z;else g=Z;if(g&&g!==""&&g!=="/"&&g!==Z){if(be(g.charCodeAt(g.length-1)))g=g.slice(0,-1)}if(X.unescape===!0){if(f)f=ke.removeBackslashes(f);if(g&&I===!0)g=ke.removeBackslashes(g)}let j={prefix:l,input:D,start:O,base:g,glob:f,isBrace:z,isBracket:q,isGlob:B,isExtglob:K,isGlobstar:M,negated:W,negatedExtglob:N};if(X.tokens===!0){if(j.maxDepth=0,!be(A))F.push(_);j.tokens=F}if(X.parts===!0||X.tokens===!0){let x;for(let u=0;u<Q.length;u++){let y=x?x+1:O,d=Q[u],b=D.slice(y,d);if(X.tokens){if(u===0&&O!==0)F[u].isPrefix=!0,F[u].value=l;else F[u].value=b;ge(F[u]),j.maxDepth+=F[u].depth}if(u!==0||b!=="")w.push(b);x=d}if(x&&x+1<D.length){let u=D.slice(x+1);if(w.push(u),X.tokens)F[F.length-1].value=u,ge(F[F.length-1]),j.maxDepth+=F[F.length-1].depth}j.slashes=Q,j.parts=w}return j};me.exports=axD});var ne=T((SaD,le)=>{var hZ=A2(),o1=R2(),{MAX_LENGTH:mZ,POSIX_REGEX_SOURCE:txD,REGEX_NON_SPECIAL_CHARS:sxD,REGEX_SPECIAL_CHARS_BACKREF:exD,REPLACEMENTS:ce}=hZ,DSD=(D,$)=>{if(typeof $.expandRange==="function")return $.expandRange(...D,$);D.sort();let X=`[${D.join("-")}]`;try{new RegExp(X)}catch(Y){return D.map((J)=>o1.escapeRegex(J)).join("..")}return X},G7=(D,$)=>{return`Missing ${D}: "${$}" - use "\\\\${$}" to match literal characters`},PL=(D,$)=>{if(typeof D!=="string")throw TypeError("Expected a string");D=ce[D]||D;let X={...$},Y=typeof X.maxLength==="number"?Math.min(mZ,X.maxLength):mZ,J=D.length;if(J>Y)throw SyntaxError(`Input length: ${J}, exceeds maximum allowed length: ${Y}`);let Q={type:"bos",value:"",output:X.prepend||""},F=[Q],w=X.capture?"":"?:",Z=o1.isWindows($),G=hZ.globChars(Z),O=hZ.extglobChars(G),{DOT_LITERAL:U,PLUS_LITERAL:z,SLASH_LITERAL:q,ONE_CHAR:B,DOTS_SLASH:K,NO_DOT:M,NO_DOT_SLASH:L,NO_DOTS_SLASH:I,QMARK:W,QMARK_NO_DOT:N,STAR:V,START_ANCHOR:R}=G,P=(k)=>{return`(${w}(?:(?!${R}${k.dot?K:U}).)*?)`},A=X.dot?"":M,_=X.dot?W:N,v=X.bash===!0?P(X):V;if(X.capture)v=`(${v})`;if(typeof X.noext==="boolean")X.noextglob=X.noext;let S={input:D,index:-1,start:0,dot:X.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:F};D=o1.removePrefix(D,S),J=D.length;let h=[],g=[],l=[],f=Q,j,x=()=>S.index===J-1,u=S.peek=(k=1)=>D[S.index+k],y=S.advance=()=>D[++S.index]||"",d=()=>D.slice(S.index+1),b=(k="",zD=0)=>{S.consumed+=k,S.index+=zD},a=(k)=>{S.output+=k.output!=null?k.output:k.value,b(k.value)},c=()=>{let k=1;while(u()==="!"&&(u(2)!=="("||u(3)==="?"))y(),S.start++,k++;if(k%2===0)return!1;return S.negated=!0,S.start++,!0},n=(k)=>{S[k]++,l.push(k)},YD=(k)=>{S[k]--,l.pop()},C=(k)=>{if(f.type==="globstar"){let zD=S.braces>0&&(k.type==="comma"||k.type==="brace"),t=k.extglob===!0||h.length&&(k.type==="pipe"||k.type==="paren");if(k.type!=="slash"&&k.type!=="paren"&&!zD&&!t)S.output=S.output.slice(0,-f.output.length),f.type="star",f.value="*",f.output=v,S.output+=f.output}if(h.length&&k.type!=="paren")h[h.length-1].inner+=k.value;if(k.value||k.output)a(k);if(f&&f.type==="text"&&k.type==="text"){f.value+=k.value,f.output=(f.output||"")+k.value;return}k.prev=f,F.push(k),f=k},E=(k,zD)=>{let t={...O[zD],conditions:1,inner:""};t.prev=f,t.parens=S.parens,t.output=S.output;let KD=(X.capture?"(":"")+t.open;n("parens"),C({type:k,value:zD,output:S.output?"":B}),C({type:"paren",extglob:!0,value:y(),output:KD}),h.push(t)},r=(k)=>{let zD=k.close+(X.capture?")":""),t;if(k.type==="negate"){let KD=v;if(k.inner&&k.inner.length>1&&k.inner.includes("/"))KD=P(X);if(KD!==v||x()||/^\)+$/.test(d()))zD=k.close=`)$))${KD}`;if(k.inner.includes("*")&&(t=d())&&/^\.[^\\/.]+$/.test(t)){let uD=PL(t,{...$,fastpaths:!1}).output;zD=k.close=`)${uD})${KD})`}if(k.prev.type==="bos")S.negatedExtglob=!0}C({type:"paren",extglob:!0,value:j,output:zD}),YD("parens")};if(X.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(D)){let k=!1,zD=D.replace(exD,(t,KD,uD,hD,X0,v0)=>{if(hD==="\\")return k=!0,t;if(hD==="?"){if(KD)return KD+hD+(X0?W.repeat(X0.length):"");if(v0===0)return _+(X0?W.repeat(X0.length):"");return W.repeat(uD.length)}if(hD===".")return U.repeat(uD.length);if(hD==="*"){if(KD)return KD+hD+(X0?v:"");return v}return KD?t:`\\${t}`});if(k===!0)if(X.unescape===!0)zD=zD.replace(/\\/g,"");else zD=zD.replace(/\\+/g,(t)=>{return t.length%2===0?"\\\\":t?"\\":""});if(zD===D&&X.contains===!0)return S.output=D,S;return S.output=o1.wrapOutput(zD,S,$),S}while(!x()){if(j=y(),j==="\x00")continue;if(j==="\\"){let t=u();if(t==="/"&&X.bash!==!0)continue;if(t==="."||t===";")continue;if(!t){j+="\\",C({type:"text",value:j});continue}let KD=/^\\+/.exec(d()),uD=0;if(KD&&KD[0].length>2){if(uD=KD[0].length,S.index+=uD,uD%2!==0)j+="\\"}if(X.unescape===!0)j=y();else j+=y();if(S.brackets===0){C({type:"text",value:j});continue}}if(S.brackets>0&&(j!=="]"||f.value==="["||f.value==="[^")){if(X.posix!==!1&&j===":"){let t=f.value.slice(1);if(t.includes("[")){if(f.posix=!0,t.includes(":")){let KD=f.value.lastIndexOf("["),uD=f.value.slice(0,KD),hD=f.value.slice(KD+2),X0=txD[hD];if(X0){if(f.value=uD+X0,S.backtrack=!0,y(),!Q.output&&F.indexOf(f)===1)Q.output=B;continue}}}}if(j==="["&&u()!==":"||j==="-"&&u()==="]")j=`\\${j}`;if(j==="]"&&(f.value==="["||f.value==="[^"))j=`\\${j}`;if(X.posix===!0&&j==="!"&&f.value==="[")j="^";f.value+=j,a({value:j});continue}if(S.quotes===1&&j!=='"'){j=o1.escapeRegex(j),f.value+=j,a({value:j});continue}if(j==='"'){if(S.quotes=S.quotes===1?0:1,X.keepQuotes===!0)C({type:"text",value:j});continue}if(j==="("){n("parens"),C({type:"paren",value:j});continue}if(j===")"){if(S.parens===0&&X.strictBrackets===!0)throw SyntaxError(G7("opening","("));let t=h[h.length-1];if(t&&S.parens===t.parens+1){r(h.pop());continue}C({type:"paren",value:j,output:S.parens?")":"\\)"}),YD("parens");continue}if(j==="["){if(X.nobracket===!0||!d().includes("]")){if(X.nobracket!==!0&&X.strictBrackets===!0)throw SyntaxError(G7("closing","]"));j=`\\${j}`}else n("brackets");C({type:"bracket",value:j});continue}if(j==="]"){if(X.nobracket===!0||f&&f.type==="bracket"&&f.value.length===1){C({type:"text",value:j,output:`\\${j}`});continue}if(S.brackets===0){if(X.strictBrackets===!0)throw SyntaxError(G7("opening","["));C({type:"text",value:j,output:`\\${j}`});continue}YD("brackets");let t=f.value.slice(1);if(f.posix!==!0&&t[0]==="^"&&!t.includes("/"))j=`/${j}`;if(f.value+=j,a({value:j}),X.literalBrackets===!1||o1.hasRegexChars(t))continue;let KD=o1.escapeRegex(f.value);if(S.output=S.output.slice(0,-f.value.length),X.literalBrackets===!0){S.output+=KD,f.value=KD;continue}f.value=`(${w}${KD}|${f.value})`,S.output+=f.value;continue}if(j==="{"&&X.nobrace!==!0){n("braces");let t={type:"brace",value:j,output:"(",outputIndex:S.output.length,tokensIndex:S.tokens.length};g.push(t),C(t);continue}if(j==="}"){let t=g[g.length-1];if(X.nobrace===!0||!t){C({type:"text",value:j,output:j});continue}let KD=")";if(t.dots===!0){let uD=F.slice(),hD=[];for(let X0=uD.length-1;X0>=0;X0--){if(F.pop(),uD[X0].type==="brace")break;if(uD[X0].type!=="dots")hD.unshift(uD[X0].value)}KD=DSD(hD,X),S.backtrack=!0}if(t.comma!==!0&&t.dots!==!0){let uD=S.output.slice(0,t.outputIndex),hD=S.tokens.slice(t.tokensIndex);t.value=t.output="\\{",j=KD="\\}",S.output=uD;for(let X0 of hD)S.output+=X0.output||X0.value}C({type:"brace",value:j,output:KD}),YD("braces"),g.pop();continue}if(j==="|"){if(h.length>0)h[h.length-1].conditions++;C({type:"text",value:j});continue}if(j===","){let t=j,KD=g[g.length-1];if(KD&&l[l.length-1]==="braces")KD.comma=!0,t="|";C({type:"comma",value:j,output:t});continue}if(j==="/"){if(f.type==="dot"&&S.index===S.start+1){S.start=S.index+1,S.consumed="",S.output="",F.pop(),f=Q;continue}C({type:"slash",value:j,output:q});continue}if(j==="."){if(S.braces>0&&f.type==="dot"){if(f.value===".")f.output=U;let t=g[g.length-1];f.type="dots",f.output+=j,f.value+=j,t.dots=!0;continue}if(S.braces+S.parens===0&&f.type!=="bos"&&f.type!=="slash"){C({type:"text",value:j,output:U});continue}C({type:"dot",value:j,output:U});continue}if(j==="?"){if(!(f&&f.value==="(")&&X.noextglob!==!0&&u()==="("&&u(2)!=="?"){E("qmark",j);continue}if(f&&f.type==="paren"){let KD=u(),uD=j;if(KD==="<"&&!o1.supportsLookbehinds())throw Error("Node.js v10 or higher is required for regex lookbehinds");if(f.value==="("&&!/[!=<:]/.test(KD)||KD==="<"&&!/<([!=]|\w+>)/.test(d()))uD=`\\${j}`;C({type:"text",value:j,output:uD});continue}if(X.dot!==!0&&(f.type==="slash"||f.type==="bos")){C({type:"qmark",value:j,output:N});continue}C({type:"qmark",value:j,output:W});continue}if(j==="!"){if(X.noextglob!==!0&&u()==="("){if(u(2)!=="?"||!/[!=<:]/.test(u(3))){E("negate",j);continue}}if(X.nonegate!==!0&&S.index===0){c();continue}}if(j==="+"){if(X.noextglob!==!0&&u()==="("&&u(2)!=="?"){E("plus",j);continue}if(f&&f.value==="("||X.regex===!1){C({type:"plus",value:j,output:z});continue}if(f&&(f.type==="bracket"||f.type==="paren"||f.type==="brace")||S.parens>0){C({type:"plus",value:j});continue}C({type:"plus",value:z});continue}if(j==="@"){if(X.noextglob!==!0&&u()==="("&&u(2)!=="?"){C({type:"at",extglob:!0,value:j,output:""});continue}C({type:"text",value:j});continue}if(j!=="*"){if(j==="$"||j==="^")j=`\\${j}`;let t=sxD.exec(d());if(t)j+=t[0],S.index+=t[0].length;C({type:"text",value:j});continue}if(f&&(f.type==="globstar"||f.star===!0)){f.type="star",f.star=!0,f.value+=j,f.output=v,S.backtrack=!0,S.globstar=!0,b(j);continue}let k=d();if(X.noextglob!==!0&&/^\([^?]/.test(k)){E("star",j);continue}if(f.type==="star"){if(X.noglobstar===!0){b(j);continue}let t=f.prev,KD=t.prev,uD=t.type==="slash"||t.type==="bos",hD=KD&&(KD.type==="star"||KD.type==="globstar");if(X.bash===!0&&(!uD||k[0]&&k[0]!=="/")){C({type:"star",value:j,output:""});continue}let X0=S.braces>0&&(t.type==="comma"||t.type==="brace"),v0=h.length&&(t.type==="pipe"||t.type==="paren");if(!uD&&t.type!=="paren"&&!X0&&!v0){C({type:"star",value:j,output:""});continue}while(k.slice(0,3)==="/**"){let E1=D[S.index+4];if(E1&&E1!=="/")break;k=k.slice(3),b("/**",3)}if(t.type==="bos"&&x()){f.type="globstar",f.value+=j,f.output=P(X),S.output=f.output,S.globstar=!0,b(j);continue}if(t.type==="slash"&&t.prev.type!=="bos"&&!hD&&x()){S.output=S.output.slice(0,-(t.output+f.output).length),t.output=`(?:${t.output}`,f.type="globstar",f.output=P(X)+(X.strictSlashes?")":"|$)"),f.value+=j,S.globstar=!0,S.output+=t.output+f.output,b(j);continue}if(t.type==="slash"&&t.prev.type!=="bos"&&k[0]==="/"){let E1=k[1]!==void 0?"|$":"";S.output=S.output.slice(0,-(t.output+f.output).length),t.output=`(?:${t.output}`,f.type="globstar",f.output=`${P(X)}${q}|${q}${E1})`,f.value+=j,S.output+=t.output+f.output,S.globstar=!0,b(j+y()),C({type:"slash",value:"/",output:""});continue}if(t.type==="bos"&&k[0]==="/"){f.type="globstar",f.value+=j,f.output=`(?:^|${q}|${P(X)}${q})`,S.output=f.output,S.globstar=!0,b(j+y()),C({type:"slash",value:"/",output:""});continue}S.output=S.output.slice(0,-f.output.length),f.type="globstar",f.output=P(X),f.value+=j,S.output+=f.output,S.globstar=!0,b(j);continue}let zD={type:"star",value:j,output:v};if(X.bash===!0){if(zD.output=".*?",f.type==="bos"||f.type==="slash")zD.output=A+zD.output;C(zD);continue}if(f&&(f.type==="bracket"||f.type==="paren")&&X.regex===!0){zD.output=j,C(zD);continue}if(S.index===S.start||f.type==="slash"||f.type==="dot"){if(f.type==="dot")S.output+=L,f.output+=L;else if(X.dot===!0)S.output+=I,f.output+=I;else S.output+=A,f.output+=A;if(u()!=="*")S.output+=B,f.output+=B}C(zD)}while(S.brackets>0){if(X.strictBrackets===!0)throw SyntaxError(G7("closing","]"));S.output=o1.escapeLast(S.output,"["),YD("brackets")}while(S.parens>0){if(X.strictBrackets===!0)throw SyntaxError(G7("closing",")"));S.output=o1.escapeLast(S.output,"("),YD("parens")}while(S.braces>0){if(X.strictBrackets===!0)throw SyntaxError(G7("closing","}"));S.output=o1.escapeLast(S.output,"{"),YD("braces")}if(X.strictSlashes!==!0&&(f.type==="star"||f.type==="bracket"))C({type:"maybe_slash",value:"",output:`${q}?`});if(S.backtrack===!0){S.output="";for(let k of S.tokens)if(S.output+=k.output!=null?k.output:k.value,k.suffix)S.output+=k.suffix}return S};PL.fastpaths=(D,$)=>{let X={...$},Y=typeof X.maxLength==="number"?Math.min(mZ,X.maxLength):mZ,J=D.length;if(J>Y)throw SyntaxError(`Input length: ${J}, exceeds maximum allowed length: ${Y}`);D=ce[D]||D;let Q=o1.isWindows($),{DOT_LITERAL:F,SLASH_LITERAL:w,ONE_CHAR:Z,DOTS_SLASH:G,NO_DOT:O,NO_DOTS:U,NO_DOTS_SLASH:z,STAR:q,START_ANCHOR:B}=hZ.globChars(Q),K=X.dot?U:O,M=X.dot?z:O,L=X.capture?"":"?:",I={negated:!1,prefix:""},W=X.bash===!0?".*?":q;if(X.capture)W=`(${W})`;let N=(A)=>{if(A.noglobstar===!0)return W;return`(${L}(?:(?!${B}${A.dot?G:F}).)*?)`},V=(A)=>{switch(A){case"*":return`${K}${Z}${W}`;case".*":return`${F}${Z}${W}`;case"*.*":return`${K}${W}${F}${Z}${W}`;case"*/*":return`${K}${W}${w}${Z}${M}${W}`;case"**":return K+N(X);case"**/*":return`(?:${K}${N(X)}${w})?${M}${Z}${W}`;case"**/*.*":return`(?:${K}${N(X)}${w})?${M}${W}${F}${Z}${W}`;case"**/.*":return`(?:${K}${N(X)}${w})?${F}${Z}${W}`;default:{let _=/^(.*?)\.(\w+)$/.exec(A);if(!_)return;let v=V(_[1]);if(!v)return;return v+F+_[2]}}},R=o1.removePrefix(D,I),P=V(R);if(P&&X.strictSlashes!==!0)P+=`${w}?`;return P};le.exports=PL});var pe=T((uaD,ie)=>{var $SD=p("path"),XSD=de(),xL=ne(),SL=R2(),JSD=A2(),YSD=(D)=>D&&typeof D==="object"&&!Array.isArray(D),y0=(D,$,X=!1)=>{if(Array.isArray(D)){let O=D.map((z)=>y0(z,$,X));return(z)=>{for(let q of O){let B=q(z);if(B)return B}return!1}}let Y=YSD(D)&&D.tokens&&D.input;if(D===""||typeof D!=="string"&&!Y)throw TypeError("Expected pattern to be a non-empty string");let J=$||{},Q=SL.isWindows($),F=Y?y0.compileRe(D,$):y0.makeRe(D,$,!1,!0),w=F.state;delete F.state;let Z=()=>!1;if(J.ignore){let O={...$,ignore:null,onMatch:null,onResult:null};Z=y0(J.ignore,O,X)}let G=(O,U=!1)=>{let{isMatch:z,match:q,output:B}=y0.test(O,F,$,{glob:D,posix:Q}),K={glob:D,state:w,regex:F,posix:Q,input:O,output:B,match:q,isMatch:z};if(typeof J.onResult==="function")J.onResult(K);if(z===!1)return K.isMatch=!1,U?K:!1;if(Z(O)){if(typeof J.onIgnore==="function")J.onIgnore(K);return K.isMatch=!1,U?K:!1}if(typeof J.onMatch==="function")J.onMatch(K);return U?K:!0};if(X)G.state=w;return G};y0.test=(D,$,X,{glob:Y,posix:J}={})=>{if(typeof D!=="string")throw TypeError("Expected input to be a string");if(D==="")return{isMatch:!1,output:""};let Q=X||{},F=Q.format||(J?SL.toPosixSlashes:null),w=D===Y,Z=w&&F?F(D):D;if(w===!1)Z=F?F(D):D,w=Z===Y;if(w===!1||Q.capture===!0)if(Q.matchBase===!0||Q.basename===!0)w=y0.matchBase(D,$,X,J);else w=$.exec(Z);return{isMatch:Boolean(w),match:w,output:Z}};y0.matchBase=(D,$,X,Y=SL.isWindows(X))=>{return($ instanceof RegExp?$:y0.makeRe($,X)).test($SD.basename(D))};y0.isMatch=(D,$,X)=>y0($,X)(D);y0.parse=(D,$)=>{if(Array.isArray(D))return D.map((X)=>y0.parse(X,$));return xL(D,{...$,fastpaths:!1})};y0.scan=(D,$)=>XSD(D,$);y0.compileRe=(D,$,X=!1,Y=!1)=>{if(X===!0)return D.output;let J=$||{},Q=J.contains?"":"^",F=J.contains?"":"$",w=`${Q}(?:${D.output})${F}`;if(D&&D.negated===!0)w=`^(?!${w}).*$`;let Z=y0.toRegex(w,$);if(Y===!0)Z.state=D;return Z};y0.makeRe=(D,$={},X=!1,Y=!1)=>{if(!D||typeof D!=="string")throw TypeError("Expected a non-empty string");let J={negated:!1,fastpaths:!0};if($.fastpaths!==!1&&(D[0]==="."||D[0]==="*"))J.output=xL.fastpaths(D,$);if(!J.output)J=xL(D,$);return y0.compileRe(J,$,X,Y)};y0.toRegex=(D,$)=>{try{let X=$||{};return new RegExp(D,X.flags||(X.nocase?"i":""))}catch(X){if($&&$.debug===!0)throw X;return/$^/}};y0.constants=JSD;ie.exports=y0});var ee=T((vaD,se)=>{var oe=p("util"),ae=xe(),t$=pe(),uL=R2(),re=(D)=>D===""||D==="./",te=(D)=>{let $=D.indexOf("{");return $>-1&&D.indexOf("}",$)>-1},z0=(D,$,X)=>{$=[].concat($),D=[].concat(D);let Y=new Set,J=new Set,Q=new Set,F=0,w=(O)=>{if(Q.add(O.output),X&&X.onResult)X.onResult(O)};for(let O=0;O<$.length;O++){let U=t$(String($[O]),{...X,onResult:w},!0),z=U.state.negated||U.state.negatedExtglob;if(z)F++;for(let q of D){let B=U(q,!0);if(!(z?!B.isMatch:B.isMatch))continue;if(z)Y.add(B.output);else Y.delete(B.output),J.add(B.output)}}let G=(F===$.length?[...Q]:[...J]).filter((O)=>!Y.has(O));if(X&&G.length===0){if(X.failglob===!0)throw Error(`No matches found for "${$.join(", ")}"`);if(X.nonull===!0||X.nullglob===!0)return X.unescape?$.map((O)=>O.replace(/\\/g,"")):$}return G};z0.match=z0;z0.matcher=(D,$)=>t$(D,$);z0.isMatch=(D,$,X)=>t$($,X)(D);z0.any=z0.isMatch;z0.not=(D,$,X={})=>{$=[].concat($).map(String);let Y=new Set,J=[],F=new Set(z0(D,$,{...X,onResult:(w)=>{if(X.onResult)X.onResult(w);J.push(w.output)}}));for(let w of J)if(!F.has(w))Y.add(w);return[...Y]};z0.contains=(D,$,X)=>{if(typeof D!=="string")throw TypeError(`Expected a string: "${oe.inspect(D)}"`);if(Array.isArray($))return $.some((Y)=>z0.contains(D,Y,X));if(typeof $==="string"){if(re(D)||re($))return!1;if(D.includes($)||D.startsWith("./")&&D.slice(2).includes($))return!0}return z0.isMatch(D,$,{...X,contains:!0})};z0.matchKeys=(D,$,X)=>{if(!uL.isObject(D))throw TypeError("Expected the first argument to be an object");let Y=z0(Object.keys(D),$,X),J={};for(let Q of Y)J[Q]=D[Q];return J};z0.some=(D,$,X)=>{let Y=[].concat(D);for(let J of[].concat($)){let Q=t$(String(J),X);if(Y.some((F)=>Q(F)))return!0}return!1};z0.every=(D,$,X)=>{let Y=[].concat(D);for(let J of[].concat($)){let Q=t$(String(J),X);if(!Y.every((F)=>Q(F)))return!1}return!0};z0.all=(D,$,X)=>{if(typeof D!=="string")throw TypeError(`Expected a string: "${oe.inspect(D)}"`);return[].concat($).every((Y)=>t$(Y,X)(D))};z0.capture=(D,$,X)=>{let Y=uL.isWindows(X),Q=t$.makeRe(String(D),{...X,capture:!0}).exec(Y?uL.toPosixSlashes($):$);if(Q)return Q.slice(1).map((F)=>F===void 0?"":F)};z0.makeRe=(...D)=>t$.makeRe(...D);z0.scan=(...D)=>t$.scan(...D);z0.parse=(D,$)=>{let X=[];for(let Y of[].concat(D||[]))for(let J of ae(String(Y),$))X.push(t$.parse(J,$));return X};z0.braces=(D,$)=>{if(typeof D!=="string")throw TypeError("Expected a string");if($&&$.nobrace===!0||!te(D))return[D];return ae(D,$)};z0.braceExpand=(D,$)=>{if(typeof D!=="string")throw TypeError("Expected a string");return z0.braces(D,{...$,expand:!0})};z0.hasBraces=te;se.exports=z0});import{existsSync as pSD,readFileSync as rSD}from"node:fs";import{dirname as oSD,join as U7}from"node:path";import{cwd as lZ}from"node:process";function yL(D){if(!pSD(D))return;return rSD(D,"utf-8")}function sSD(D){let $=[U7(lZ(),D,"app","build.gradle"),U7(lZ(),D,"app","build.gradle.kts")];for(let X of $){let Y=yL(X);if(!Y)continue;let J=Y.match(/versionName\s*(?:=\s*)?["']([^"']+)["']/)?.[1],Q=Y.match(/versionCode\s*(?:=\s*)?(\d+)/)?.[1];if(J)return{versionName:J,versionCode:Q,source:X}}return}function EDD(D,$){let X=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return D.match(new RegExp(`<key>${X}</key>\\s*<string>([^<]+)</string>`))?.[1]?.trim()}function cZ(D,$){let Y=D.match(new RegExp(`${$}\\s*=\\s*([^;]+);`))?.[1]?.trim();if(!Y)return;return Y.replace(/"/g,"").trim()}function eSD(D){let $=U7(lZ(),D,"App"),X=U7($,"App","Info.plist"),Y=U7($,"App.xcodeproj","project.pbxproj"),J=yL(X),Q=yL(Y);if(!J)return;let F=EDD(J,"CFBundleShortVersionString"),w=EDD(J,"CFBundleVersion");if(F==="$(MARKETING_VERSION)")F=Q?cZ(Q,"MARKETING_VERSION"):void 0;if(w==="$(CURRENT_PROJECT_VERSION)")w=Q?cZ(Q,"CURRENT_PROJECT_VERSION"):void 0;if(!F&&Q)F=cZ(Q,"MARKETING_VERSION");if(!w&&Q)w=cZ(Q,"CURRENT_PROJECT_VERSION");if(!F)return;return{versionName:F,versionCode:w,source:X}}function DuD(D){let $=D?.plugins?.CapacitorUpdater?.version;if(typeof $==="string"&&$.trim().length>0)return $.trim();return}function $uD(D){let $=D?.plugins?.CapacitorUpdater?.defaultChannel;if(typeof $==="string"&&$.trim().length>0)return $.trim();return""}function XuD(D){let $=D?.plugins?.CapacitorUpdater?.updateUrl;if(typeof $==="string"&&$.trim().length>0)return $.trim();return aSD}async function CDD(D,$){let X=$?.plugins?.CapacitorUpdater?.appId,Y=$?.appId,J=X||Y;if(!J)return{ok:!1,error:"Could not resolve app ID from capacitor config. Ensure appId is set in capacitor.config.ts or CapacitorUpdater.appId is configured."};let Q=X?"CapacitorUpdater.appId from capacitor config":"top-level appId from capacitor config",F=K2($,D),w=D==="android"?sSD(F):eSD(F);if(!w)return{ok:!1,error:`Unable to resolve native ${D.toUpperCase()} version values from platform files in "${F}".`};let Z=DuD($),G=Z||w.versionName,O=Z?"CapacitorUpdater.version from capacitor config":`native ${D.toUpperCase()} versionName`,U=U7(lZ(),"package.json"),z=oSD(U),q=await y1("@capgo/capacitor-updater",z,U);if(!q)return{ok:!1,error:"Unable to resolve installed @capgo/capacitor-updater version from this project."};return{ok:!0,context:{endpoint:XuD($),payload:{app_id:J,device_id:tSD,version_name:"builtin",version_build:G,is_emulator:!1,is_prod:!1,platform:D,plugin_version:q,defaultChannel:$uD($)},nativeSource:w.source,versionBuildSource:O,appIdSource:Q}}}function PDD(D){let $={};if(D&&typeof D==="object"){for(let[X,Y]of Object.entries(D))if(X!=="error"&&X!=="message")$[X]=Y}return $}function JuD(D,$){let X=typeof D?.error==="string"?D.error:void 0,Y=typeof D?.message==="string"?D.message:void 0,J=typeof D?.version==="string"?D.version:void 0;if(X==="no_new_version_available"||J&&J===$)return{status:"retry",detail:Y||"No new version available yet"};if(X)return{status:"failed",detail:`${X}: ${Y??"Unknown backend message"}`,errorCode:X,backendMessage:Y,extra:PDD(D)};if(J&&J!==$)return{status:"available",detail:`Update ${J} is available`,responseVersion:J};return{status:"failed",detail:`Unexpected response format: ${JSON.stringify(D)}`}}async function xDD(D,$){let X;try{X=await fetch(D,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($),signal:AbortSignal.timeout(TDD)})}catch(Q){if(Q instanceof DOMException&&Q.name==="TimeoutError")return{success:!1,reason:`Request timed out after ${TDD/1000}s — the endpoint did not respond in time.`,backendRefusal:!1};return{success:!1,reason:`Network error: ${Q instanceof Error?Q.message:String(Q)}`,backendRefusal:!1}}let Y;try{Y=await X.json()}catch{Y={error:"invalid_json_response",message:"Non-JSON response from updates endpoint"}}if(!X.ok){let Q=typeof Y?.error==="string"?Y.error:void 0,F=typeof Y?.message==="string"?Y.message:void 0;return{success:!1,reason:`HTTP ${X.status}: ${JSON.stringify(Y)}`,backendRefusal:!!Q,errorCode:Q,backendMessage:F,extra:PDD(Y)}}let J=JuD(Y,$.version_name);if(J.status==="available")return{success:!0,availableVersion:J.responseVersion??""};if(J.status==="retry")return{success:!1,reason:J.detail,backendRefusal:!1};return{success:!1,reason:J.detail,backendRefusal:!!J.errorCode,errorCode:J.errorCode,backendMessage:J.backendMessage,extra:J.extra}}function SDD(D){if(!D.errorCode)return[];let $=[];if(D.errorCode==="disable_auto_update_to_major"){let Y=typeof D.extra?.version==="string"?D.extra.version:"unknown",J=typeof D.extra?.old==="string"?D.extra.old:"unknown";$.push(`Channel policy blocks major upgrades (target ${Y}, device baseline ${J}).`)}let X=YuD[D.errorCode];if(X)$.push(X.cause),$.push(`Fix: ${X.fix}`),$.push(`Details: ${X.docsUrl||b0}`);else $.push(`Backend returned ${D.errorCode}.`),$.push("Check channel restrictions, app/plugin configuration, and device version values."),$.push(`Troubleshooting guide: ${b0}`);return $}var aSD="https://plugin.capgo.app/updates",tSD="00000000-0000-0000-0000-000000000000",b0="https://capgo.app/docs/plugins/updater/commonproblems/",TDD=1e4,YuD;var uDD=o(()=>{fD();YuD={disable_auto_update_to_major:{cause:"Channel blocks major upgrades and device baseline major does not match the target bundle major.",fix:"Set plugins.CapacitorUpdater.version so its MAJOR matches the bundle MAJOR (e.g. 1.0.0 for bundle 1.x.x), run npx cap sync, and reinstall the native build.",docsUrl:`${b0}#disable_auto_update_to_major`},disable_auto_update_to_minor:{cause:"Channel blocks minor upgrades and the target bundle minor is above the device baseline.",fix:"Upload a bundle within the allowed minor range, or change the channel disable_auto_update policy in the dashboard.",docsUrl:`${b0}#disable_auto_update_to_minor--disable_auto_update_to_patch`},disable_auto_update_to_patch:{cause:"Channel blocks patch upgrades and the target bundle patch is above the device baseline.",fix:"Upload a bundle within the allowed patch range, or change the channel disable_auto_update policy in the dashboard.",docsUrl:`${b0}#disable_auto_update_to_minor--disable_auto_update_to_patch`},disable_auto_update_to_metadata:{cause:"Channel uses metadata-based targeting (version_number) and the device baseline is below the required min_update_version.",fix:"Set plugins.CapacitorUpdater.version to match the installed native version, or adjust min_update_version on the channel.",docsUrl:`${b0}#disable_auto_update_to_metadata`},disable_auto_update_under_native:{cause:"Channel prevents downgrades below the native app version.",fix:"Upload a bundle with version >= native baseline, or disable the under-native downgrade protection on the channel.",docsUrl:`${b0}#disable_auto_update_under_native`},misconfigured_channel:{cause:"Channel has disable_auto_update=version_number but min_update_version is missing.",fix:"Set a valid min_update_version on the channel, or change disable_auto_update to a different mode."},cannot_update_via_private_channel:{cause:"The selected channel does not allow device self-assignment.",fix:"Use a channel with self-assignment enabled, or enable self-assignment / make the channel public.",docsUrl:`${b0}#cannot_update_via_private_channel`},semver_error:{cause:"version_build sent to the backend is not valid semver (expected x.y.z).",fix:"Set plugins.CapacitorUpdater.version to a valid semver like 1.2.3, run npx cap sync, and rebuild native.",docsUrl:`${b0}#unknown_version_build--semver_error`},unknown_version_build:{cause:"Backend received version_build=unknown (device baseline version is missing).",fix:"Set plugins.CapacitorUpdater.version in capacitor.config.*, run npx cap sync, and rebuild native.",docsUrl:`${b0}#unknown_version_build--semver_error`},unsupported_plugin_version:{cause:"Installed @capgo/capacitor-updater is too old for the current backend.",fix:"Run npm install @capgo/capacitor-updater@latest, then npx cap sync, and rebuild native.",docsUrl:`${b0}#unsupported_plugin_version`},key_id_mismatch:{cause:"Bundle encryption key and device key differ.",fix:"Ensure the same public key is used in app config and when encrypting bundles, then re-upload the bundle.",docsUrl:`${b0}#key_id_mismatch`},disabled_platform_ios:{cause:"Channel has iOS updates disabled.",fix:"Enable the iOS platform toggle on the target channel in the dashboard.",docsUrl:`${b0}#disabled_platform_ios--disabled_platform_android`},disabled_platform_android:{cause:"Channel has Android updates disabled.",fix:"Enable the Android platform toggle on the target channel in the dashboard.",docsUrl:`${b0}#disabled_platform_ios--disabled_platform_android`},disabled_platform_electron:{cause:"Channel has Electron updates disabled.",fix:"Enable the Electron platform toggle on the target channel in the dashboard."},disable_prod_build:{cause:"Channel blocks production builds (allow_prod is off).",fix:"Enable allow_prod on the channel, or test with a development build.",docsUrl:`${b0}#disable_prod_build--disable_dev_build--disable_device--disable_emulator`},disable_dev_build:{cause:"Channel blocks development builds (allow_dev is off).",fix:"Enable allow_dev on the channel, or test with a production build.",docsUrl:`${b0}#disable_prod_build--disable_dev_build--disable_device--disable_emulator`},disable_device:{cause:"Channel blocks physical devices (allow_device is off).",fix:"Enable allow_device on the channel, or test on an emulator.",docsUrl:`${b0}#disable_prod_build--disable_dev_build--disable_device--disable_emulator`},disable_emulator:{cause:"Channel blocks emulators (allow_emulator is off).",fix:"Enable allow_emulator on the channel, or test on a physical device.",docsUrl:`${b0}#disable_prod_build--disable_dev_build--disable_device--disable_emulator`},no_channel:{cause:"No channel was resolved for this device.",fix:"Set defaultChannel in capacitor.config.* plugins.CapacitorUpdater section, or create a default channel in the dashboard.",docsUrl:`${b0}#no_channel--null_channel_data`},null_channel_data:{cause:"Channel was resolved but contains no usable data.",fix:"Set defaultChannel in capacitor.config.* plugins.CapacitorUpdater section, or verify the channel has a bundle assigned.",docsUrl:`${b0}#no_channel--null_channel_data`},missing_info:{cause:"Request is missing required fields (app_id, device_id, version_build, or platform).",fix:"Check capacitor.config.* for a valid appId and verify the probe payload."},no_bundle:{cause:"Channel resolved a version but no downloadable bundle artifact exists.",fix:"Re-upload the bundle with npx @capgo/cli@latest bundle upload and verify channel assignment."},no_bundle_url:{cause:"Bundle was resolved but its download URL is missing.",fix:"Re-upload the bundle — the storage artifact may be corrupted or missing."},no_url_or_manifest:{cause:"Bundle was resolved but neither URL nor manifest is available.",fix:"Re-upload the bundle — the storage artifact may be corrupted or missing."},already_on_builtin:{cause:"Device is already running the builtin bundle.",fix:"Upload and assign a bundle to the channel for OTA updates to be delivered."},revert_to_builtin_plugin_version_too_old:{cause:"Plugin version is too old for safe builtin revert.",fix:"Run npm install @capgo/capacitor-updater@latest, then npx cap sync, and rebuild native."},on_premise_app:{cause:"App is either flagged as on-premise or does not exist in Capgo Cloud.",fix:"Check that the app_id is registered in Capgo (capgo app add). If it is an on-premise app, configure plugins.CapacitorUpdater.updateUrl to point to your on-prem update endpoint."},need_plan_upgrade:{cause:"Update checks are blocked by plan limits.",fix:"Upgrade your Capgo plan or contact your organization admin."},invalid_json_body:{cause:"Updates endpoint rejected the request body as invalid JSON.",fix:"This is likely a CLI bug — please report it at https://github.com/Cap-go/CLI/issues."},invalid_query_parameters:{cause:"Updates endpoint rejected the query parameters.",fix:"This is likely a CLI bug — please report it at https://github.com/Cap-go/CLI/issues."}}});var fDD={};a1(fDD,{probeInternal:()=>kDD,probe:()=>FuD});import{exit as QuD,stdin as vDD,stdout as _DD}from"node:process";async function kDD(D){let $;try{$=(await ID()).config}catch{return{success:!1,error:"Failed to load Capacitor config."}}let X;if(D.platform==="ios"||D.platform==="android")X=D.platform;else if(D.platform)return{success:!1,error:`Invalid platform "${D.platform}". Must be "ios" or "android".`};else{if(!(!!vDD.isTTY&&!!_DD.isTTY))return{success:!1,error:"Platform is required in non-interactive environments. Use --platform ios or --platform android."};let Z=await t1({message:"Which platform do you want to probe?",options:[{value:"ios",label:"iOS"},{value:"android",label:"Android"}]});if(yD(Z))return{success:!1,error:"Probe cancelled."};X=Z}let Y=await CDD(X,$);if(!Y.ok)return{success:!1,error:`Probe setup failed: ${Y.error}`};let J=Y.context,Q=await xDD(J.endpoint,J.payload),F={success:Q.success,probeResult:Q,endpoint:J.endpoint,platform:X,versionBuild:J.payload.version_build,versionBuildSource:J.versionBuildSource,appId:J.payload.app_id,appIdSource:J.appIdSource,nativeSource:J.nativeSource};if(!Q.success)F.hints=SDD(Q);return F}async function FuD(D){VD("Probe Capgo updates endpoint");let $=await kDD(D);if($.error)H.error($.error),QuD(1);H.info(`Endpoint: ${$.endpoint}`),H.info(`Platform: ${$.platform}, version_build: ${$.versionBuild}`),H.info(`version_build source: ${$.versionBuildSource}`),H.info(`app_id: ${$.appId} (${$.appIdSource})`),H.info(`Native values source: ${$.nativeSource}`);let X=$.probeResult;if(X.success)H.success(`Update available: ${X.availableVersion}`);else{if(H.warn(`Reason: ${X.reason}`),X.backendRefusal)H.warn("The backend actively refused the request (not a cache/propagation issue).");if(X.errorCode)H.warn(`Error code: ${X.errorCode}`);if(X.backendMessage)H.warn(`Backend message: ${X.backendMessage}`);if($.hints)for(let Y of $.hints)H.warn(` ${Y}`)}}var yDD=o(()=>{vD();uDD();fD()});vD();s$();fD();vD();s$();fD();async function ua(D,$,X,Y={}){let{silent:J=!1,autoUnlink:Q=!1}=Y,{data:F,error:w}=await D.from("channels").select().eq("app_id",$).eq("version",X.id);if(w){if(!J)H.error(`Cannot check Version ${$}@${X.name}: ${s(w)}`);throw Error(`Cannot check version ${$}@${X.name}: ${s(w)}`)}if(!F?.length)return;if(J)throw Error(`Version ${$}@${X.name} is used in ${F.length} channel(s)`);VD(`❌ Version ${$}@${X.name} is used in ${F.length} channel${F.length>1?"s":""}`);let Z=Q;if(!Q)Z=await c0({message:"unlink it?"})===!0;if(!Z)throw H.error("Unlink it first"),Error(`Version ${$}@${X.name} is still linked to channel(s)`);for(let G of F){let O=A0();O.start(`Unlinking channel ${G.name}`);let U=await kM(D,$,{silent:J});if(!U)throw O.stop(`Cannot find unknown version for ${$}`),Error(`Cannot find unknown version for ${$}`);let{error:z}=await D.from("channels").update({version:U.id}).eq("id",G.id);if(z)throw O.stop(`Cannot update channel ${G.name} ${s(z)}`),Error(`Cannot update channel ${G.name}: ${s(z)}`);O.stop(`✅ Channel ${G.name} unlinked`)}ND(`Version unlinked from ${F.length} channel${F.length>1?"s":""}`)}async function kM(D,$,X={}){let{silent:Y=!1}=X,{data:J,error:Q}=await D.from("app_versions").select("id").eq("app_id",$).eq("name","unknown").single();if(!Q)return J;try{let F=await o0(D,$),{data:w,error:Z}=await D.from("app_versions").insert({owner_org:F,deleted:!0,name:"unknown",app_id:$}).select("id").single();if(Z){if(!Y)H.error(`Cannot find or create unknown version for ${$}. Find error: ${s(Q)}, Create error: ${s(Z)}`);throw Error(`Cannot find or create unknown version for app ${$}: ${s(Z)}`)}return w}catch(F){if(!Y)H.error(`Cannot find or create unknown version for ${$}. Find error: ${s(Q)}, Create error: ${s(F)}`);throw Error(`Cannot retrieve or create unknown version for app ${$}: ${s(F)}`)}}function va(D,$){return D.from("channels").insert($).select().single()}function _a(D,$,X,Y){return D.from("channels").delete().eq("name",$).eq("app_id",X).single()}function ka(D,$,X){return D.from("channels").select().eq("app_id",$).eq("name",X).single()}function fa(D,$,X){return D.from("channel_devices").delete().eq("app_id",$).eq("channel_id",X)}function ya(D,$,X){return D.from("channels").select(`
422
+ `,CHAR_NO_BREAK_SPACE:" ",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:"\t",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\uFEFF"}});var Te=T((EaD,Ee)=>{var GxD=yZ(),{MAX_LENGTH:Ae,CHAR_BACKSLASH:AL,CHAR_BACKTICK:OxD,CHAR_COMMA:UxD,CHAR_DOT:qxD,CHAR_LEFT_PARENTHESES:zxD,CHAR_RIGHT_PARENTHESES:BxD,CHAR_LEFT_CURLY_BRACE:KxD,CHAR_RIGHT_CURLY_BRACE:WxD,CHAR_LEFT_SQUARE_BRACKET:Re,CHAR_RIGHT_SQUARE_BRACKET:je,CHAR_DOUBLE_QUOTE:HxD,CHAR_SINGLE_QUOTE:VxD,CHAR_NO_BREAK_SPACE:NxD,CHAR_ZERO_WIDTH_NOBREAK_SPACE:MxD}=Ie(),LxD=(D,$={})=>{if(typeof D!=="string")throw TypeError("Expected a string");let X=$||{},Y=typeof X.maxLength==="number"?Math.min(Ae,X.maxLength):Ae;if(D.length>Y)throw SyntaxError(`Input length (${D.length}), exceeds max characters (${Y})`);let J={type:"root",input:D,nodes:[]},Q=[J],F=J,w=J,Z=0,G=D.length,O=0,U=0,z,q=()=>D[O++],B=(K)=>{if(K.type==="text"&&w.type==="dot")w.type="text";if(w&&w.type==="text"&&K.type==="text"){w.value+=K.value;return}return F.nodes.push(K),K.parent=F,K.prev=w,w=K,K};B({type:"bos"});while(O<G){if(F=Q[Q.length-1],z=q(),z===MxD||z===NxD)continue;if(z===AL){B({type:"text",value:($.keepEscaping?z:"")+q()});continue}if(z===je){B({type:"text",value:"\\"+z});continue}if(z===Re){Z++;let K;while(O<G&&(K=q())){if(z+=K,K===Re){Z++;continue}if(K===AL){z+=q();continue}if(K===je){if(Z--,Z===0)break}}B({type:"text",value:z});continue}if(z===zxD){F=B({type:"paren",nodes:[]}),Q.push(F),B({type:"text",value:z});continue}if(z===BxD){if(F.type!=="paren"){B({type:"text",value:z});continue}F=Q.pop(),B({type:"text",value:z}),F=Q[Q.length-1];continue}if(z===HxD||z===VxD||z===OxD){let K=z,M;if($.keepQuotes!==!0)z="";while(O<G&&(M=q())){if(M===AL){z+=M+q();continue}if(M===K){if($.keepQuotes===!0)z+=M;break}z+=M}B({type:"text",value:z});continue}if(z===KxD){U++;let M={type:"brace",open:!0,close:!1,dollar:w.value&&w.value.slice(-1)==="$"||F.dollar===!0,depth:U,commas:0,ranges:0,nodes:[]};F=B(M),Q.push(F),B({type:"open",value:z});continue}if(z===WxD){if(F.type!=="brace"){B({type:"text",value:z});continue}let K="close";F=Q.pop(),F.close=!0,B({type:K,value:z}),U--,F=Q[Q.length-1];continue}if(z===UxD&&U>0){if(F.ranges>0){F.ranges=0;let K=F.nodes.shift();F.nodes=[K,{type:"text",value:GxD(F)}]}B({type:"comma",value:z}),F.commas++;continue}if(z===qxD&&U>0&&F.commas===0){let K=F.nodes;if(U===0||K.length===0){B({type:"text",value:z});continue}if(w.type==="dot"){if(F.range=[],w.value+=z,w.type="range",F.nodes.length!==3&&F.nodes.length!==5){F.invalid=!0,F.ranges=0,w.type="text";continue}F.ranges++,F.args=[];continue}if(w.type==="range"){K.pop();let M=K[K.length-1];M.value+=w.value+z,w=M,F.ranges--;continue}B({type:"dot",value:z});continue}B({type:"text",value:z})}do if(F=Q.pop(),F.type!=="root"){F.nodes.forEach((L)=>{if(!L.nodes){if(L.type==="open")L.isOpen=!0;if(L.type==="close")L.isClose=!0;if(!L.nodes)L.type="text";L.invalid=!0}});let K=Q[Q.length-1],M=K.nodes.indexOf(F);K.nodes.splice(M,1,...F.nodes)}while(Q.length>0);return B({type:"eos"}),J};Ee.exports=LxD});var xe=T((TaD,Pe)=>{var Ce=yZ(),IxD=He(),AxD=Me(),RxD=Te(),r1=(D,$={})=>{let X=[];if(Array.isArray(D))for(let Y of D){let J=r1.create(Y,$);if(Array.isArray(J))X.push(...J);else X.push(J)}else X=[].concat(r1.create(D,$));if($&&$.expand===!0&&$.nodupes===!0)X=[...new Set(X)];return X};r1.parse=(D,$={})=>RxD(D,$);r1.stringify=(D,$={})=>{if(typeof D==="string")return Ce(r1.parse(D,$),$);return Ce(D,$)};r1.compile=(D,$={})=>{if(typeof D==="string")D=r1.parse(D,$);return IxD(D,$)};r1.expand=(D,$={})=>{if(typeof D==="string")D=r1.parse(D,$);let X=AxD(D,$);if($.noempty===!0)X=X.filter(Boolean);if($.nodupes===!0)X=[...new Set(X)];return X};r1.create=(D,$={})=>{if(D===""||D.length<3)return[D];return $.expand!==!0?r1.compile(D,$):r1.expand(D,$)};Pe.exports=r1});var A2=T((CaD,ue)=>{var jxD=p("path"),Se={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:"(?=.)",QMARK:"[^/]",END_ANCHOR:"(?:\\/|$)",DOTS_SLASH:"\\.{1,2}(?:\\/|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|\\/)\\.{1,2}(?:\\/|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:\\/|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:\\/|$))",QMARK_NO_DOT:"[^.\\/]",STAR:"[^/]*?",START_ANCHOR:"(?:^|\\/)"},ExD={...Se,SLASH_LITERAL:"[\\\\/]",QMARK:"[^\\\\/]",STAR:"[^\\\\/]*?",DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)"},TxD={alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};ue.exports={MAX_LENGTH:65536,POSIX_REGEX_SOURCE:TxD,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:jxD.sep,extglobChars(D){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${D.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(D){return D===!0?ExD:Se}}});var R2=T((_xD)=>{var CxD=p("path"),PxD=process.platform==="win32",{REGEX_BACKSLASH:xxD,REGEX_REMOVE_BACKSLASH:SxD,REGEX_SPECIAL_CHARS:uxD,REGEX_SPECIAL_CHARS_GLOBAL:vxD}=A2();_xD.isObject=(D)=>D!==null&&typeof D==="object"&&!Array.isArray(D);_xD.hasRegexChars=(D)=>uxD.test(D);_xD.isRegexChar=(D)=>D.length===1&&_xD.hasRegexChars(D);_xD.escapeRegex=(D)=>D.replace(vxD,"\\$1");_xD.toPosixSlashes=(D)=>D.replace(xxD,"/");_xD.removeBackslashes=(D)=>{return D.replace(SxD,($)=>{return $==="\\"?"":$})};_xD.supportsLookbehinds=()=>{let D=process.version.slice(1).split(".").map(Number);if(D.length===3&&D[0]>=9||D[0]===8&&D[1]>=10)return!0;return!1};_xD.isWindows=(D)=>{if(D&&typeof D.windows==="boolean")return D.windows;return PxD===!0||CxD.sep==="\\"};_xD.escapeLast=(D,$,X)=>{let Y=D.lastIndexOf($,X);if(Y===-1)return D;if(D[Y-1]==="\\")return _xD.escapeLast(D,$,Y-1);return`${D.slice(0,Y)}\\${D.slice(Y)}`};_xD.removePrefix=(D,$={})=>{let X=D;if(X.startsWith("./"))X=X.slice(2),$.prefix="./";return X};_xD.wrapOutput=(D,$={},X={})=>{let Y=X.contains?"":"^",J=X.contains?"":"$",Q=`${Y}(?:${D})${J}`;if($.negated===!0)Q=`(?:^(?!${Q}).*$)`;return Q}});var de=T((xaD,me)=>{var ke=R2(),{CHAR_ASTERISK:RL,CHAR_AT:lxD,CHAR_BACKWARD_SLASH:j2,CHAR_COMMA:nxD,CHAR_DOT:jL,CHAR_EXCLAMATION_MARK:EL,CHAR_FORWARD_SLASH:he,CHAR_LEFT_CURLY_BRACE:TL,CHAR_LEFT_PARENTHESES:CL,CHAR_LEFT_SQUARE_BRACKET:ixD,CHAR_PLUS:pxD,CHAR_QUESTION_MARK:fe,CHAR_RIGHT_CURLY_BRACE:rxD,CHAR_RIGHT_PARENTHESES:ye,CHAR_RIGHT_SQUARE_BRACKET:oxD}=A2(),be=(D)=>{return D===he||D===j2},ge=(D)=>{if(D.isPrefix!==!0)D.depth=D.isGlobstar?1/0:1},axD=(D,$)=>{let X=$||{},Y=D.length-1,J=X.parts===!0||X.scanToEnd===!0,Q=[],F=[],w=[],Z=D,G=-1,O=0,U=0,z=!1,q=!1,B=!1,K=!1,M=!1,L=!1,I=!1,W=!1,N=!1,V=!1,R=0,C,A,_={value:"",depth:0,isGlob:!1},v=()=>G>=Y,S=()=>Z.charCodeAt(G+1),h=()=>{return C=A,Z.charCodeAt(++G)};while(G<Y){A=h();let x;if(A===j2){if(I=_.backslashes=!0,A=h(),A===TL)L=!0;continue}if(L===!0||A===TL){R++;while(v()!==!0&&(A=h())){if(A===j2){I=_.backslashes=!0,h();continue}if(A===TL){R++;continue}if(L!==!0&&A===jL&&(A=h())===jL){if(z=_.isBrace=!0,B=_.isGlob=!0,V=!0,J===!0)continue;break}if(L!==!0&&A===nxD){if(z=_.isBrace=!0,B=_.isGlob=!0,V=!0,J===!0)continue;break}if(A===rxD){if(R--,R===0){L=!1,z=_.isBrace=!0,V=!0;break}}}if(J===!0)continue;break}if(A===he){if(Q.push(G),F.push(_),_={value:"",depth:0,isGlob:!1},V===!0)continue;if(C===jL&&G===O+1){O+=2;continue}U=G+1;continue}if(X.noext!==!0){if((A===pxD||A===lxD||A===RL||A===fe||A===EL)===!0&&S()===CL){if(B=_.isGlob=!0,K=_.isExtglob=!0,V=!0,A===EL&&G===O)N=!0;if(J===!0){while(v()!==!0&&(A=h())){if(A===j2){I=_.backslashes=!0,A=h();continue}if(A===ye){B=_.isGlob=!0,V=!0;break}}continue}break}}if(A===RL){if(C===RL)M=_.isGlobstar=!0;if(B=_.isGlob=!0,V=!0,J===!0)continue;break}if(A===fe){if(B=_.isGlob=!0,V=!0,J===!0)continue;break}if(A===ixD){while(v()!==!0&&(x=h())){if(x===j2){I=_.backslashes=!0,h();continue}if(x===oxD){q=_.isBracket=!0,B=_.isGlob=!0,V=!0;break}}if(J===!0)continue;break}if(X.nonegate!==!0&&A===EL&&G===O){W=_.negated=!0,O++;continue}if(X.noparen!==!0&&A===CL){if(B=_.isGlob=!0,J===!0){while(v()!==!0&&(A=h())){if(A===CL){I=_.backslashes=!0,A=h();continue}if(A===ye){V=!0;break}}continue}break}if(B===!0){if(V=!0,J===!0)continue;break}}if(X.noext===!0)K=!1,B=!1;let g=Z,l="",f="";if(O>0)l=Z.slice(0,O),Z=Z.slice(O),U-=O;if(g&&B===!0&&U>0)g=Z.slice(0,U),f=Z.slice(U);else if(B===!0)g="",f=Z;else g=Z;if(g&&g!==""&&g!=="/"&&g!==Z){if(be(g.charCodeAt(g.length-1)))g=g.slice(0,-1)}if(X.unescape===!0){if(f)f=ke.removeBackslashes(f);if(g&&I===!0)g=ke.removeBackslashes(g)}let j={prefix:l,input:D,start:O,base:g,glob:f,isBrace:z,isBracket:q,isGlob:B,isExtglob:K,isGlobstar:M,negated:W,negatedExtglob:N};if(X.tokens===!0){if(j.maxDepth=0,!be(A))F.push(_);j.tokens=F}if(X.parts===!0||X.tokens===!0){let x;for(let u=0;u<Q.length;u++){let y=x?x+1:O,d=Q[u],b=D.slice(y,d);if(X.tokens){if(u===0&&O!==0)F[u].isPrefix=!0,F[u].value=l;else F[u].value=b;ge(F[u]),j.maxDepth+=F[u].depth}if(u!==0||b!=="")w.push(b);x=d}if(x&&x+1<D.length){let u=D.slice(x+1);if(w.push(u),X.tokens)F[F.length-1].value=u,ge(F[F.length-1]),j.maxDepth+=F[F.length-1].depth}j.slashes=Q,j.parts=w}return j};me.exports=axD});var ne=T((SaD,le)=>{var hZ=A2(),o1=R2(),{MAX_LENGTH:mZ,POSIX_REGEX_SOURCE:txD,REGEX_NON_SPECIAL_CHARS:sxD,REGEX_SPECIAL_CHARS_BACKREF:exD,REPLACEMENTS:ce}=hZ,DSD=(D,$)=>{if(typeof $.expandRange==="function")return $.expandRange(...D,$);D.sort();let X=`[${D.join("-")}]`;try{new RegExp(X)}catch(Y){return D.map((J)=>o1.escapeRegex(J)).join("..")}return X},G7=(D,$)=>{return`Missing ${D}: "${$}" - use "\\\\${$}" to match literal characters`},PL=(D,$)=>{if(typeof D!=="string")throw TypeError("Expected a string");D=ce[D]||D;let X={...$},Y=typeof X.maxLength==="number"?Math.min(mZ,X.maxLength):mZ,J=D.length;if(J>Y)throw SyntaxError(`Input length: ${J}, exceeds maximum allowed length: ${Y}`);let Q={type:"bos",value:"",output:X.prepend||""},F=[Q],w=X.capture?"":"?:",Z=o1.isWindows($),G=hZ.globChars(Z),O=hZ.extglobChars(G),{DOT_LITERAL:U,PLUS_LITERAL:z,SLASH_LITERAL:q,ONE_CHAR:B,DOTS_SLASH:K,NO_DOT:M,NO_DOT_SLASH:L,NO_DOTS_SLASH:I,QMARK:W,QMARK_NO_DOT:N,STAR:V,START_ANCHOR:R}=G,C=(k)=>{return`(${w}(?:(?!${R}${k.dot?K:U}).)*?)`},A=X.dot?"":M,_=X.dot?W:N,v=X.bash===!0?C(X):V;if(X.capture)v=`(${v})`;if(typeof X.noext==="boolean")X.noextglob=X.noext;let S={input:D,index:-1,start:0,dot:X.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:F};D=o1.removePrefix(D,S),J=D.length;let h=[],g=[],l=[],f=Q,j,x=()=>S.index===J-1,u=S.peek=(k=1)=>D[S.index+k],y=S.advance=()=>D[++S.index]||"",d=()=>D.slice(S.index+1),b=(k="",zD=0)=>{S.consumed+=k,S.index+=zD},a=(k)=>{S.output+=k.output!=null?k.output:k.value,b(k.value)},c=()=>{let k=1;while(u()==="!"&&(u(2)!=="("||u(3)==="?"))y(),S.start++,k++;if(k%2===0)return!1;return S.negated=!0,S.start++,!0},n=(k)=>{S[k]++,l.push(k)},YD=(k)=>{S[k]--,l.pop()},P=(k)=>{if(f.type==="globstar"){let zD=S.braces>0&&(k.type==="comma"||k.type==="brace"),t=k.extglob===!0||h.length&&(k.type==="pipe"||k.type==="paren");if(k.type!=="slash"&&k.type!=="paren"&&!zD&&!t)S.output=S.output.slice(0,-f.output.length),f.type="star",f.value="*",f.output=v,S.output+=f.output}if(h.length&&k.type!=="paren")h[h.length-1].inner+=k.value;if(k.value||k.output)a(k);if(f&&f.type==="text"&&k.type==="text"){f.value+=k.value,f.output=(f.output||"")+k.value;return}k.prev=f,F.push(k),f=k},E=(k,zD)=>{let t={...O[zD],conditions:1,inner:""};t.prev=f,t.parens=S.parens,t.output=S.output;let KD=(X.capture?"(":"")+t.open;n("parens"),P({type:k,value:zD,output:S.output?"":B}),P({type:"paren",extglob:!0,value:y(),output:KD}),h.push(t)},r=(k)=>{let zD=k.close+(X.capture?")":""),t;if(k.type==="negate"){let KD=v;if(k.inner&&k.inner.length>1&&k.inner.includes("/"))KD=C(X);if(KD!==v||x()||/^\)+$/.test(d()))zD=k.close=`)$))${KD}`;if(k.inner.includes("*")&&(t=d())&&/^\.[^\\/.]+$/.test(t)){let uD=PL(t,{...$,fastpaths:!1}).output;zD=k.close=`)${uD})${KD})`}if(k.prev.type==="bos")S.negatedExtglob=!0}P({type:"paren",extglob:!0,value:j,output:zD}),YD("parens")};if(X.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(D)){let k=!1,zD=D.replace(exD,(t,KD,uD,hD,X0,v0)=>{if(hD==="\\")return k=!0,t;if(hD==="?"){if(KD)return KD+hD+(X0?W.repeat(X0.length):"");if(v0===0)return _+(X0?W.repeat(X0.length):"");return W.repeat(uD.length)}if(hD===".")return U.repeat(uD.length);if(hD==="*"){if(KD)return KD+hD+(X0?v:"");return v}return KD?t:`\\${t}`});if(k===!0)if(X.unescape===!0)zD=zD.replace(/\\/g,"");else zD=zD.replace(/\\+/g,(t)=>{return t.length%2===0?"\\\\":t?"\\":""});if(zD===D&&X.contains===!0)return S.output=D,S;return S.output=o1.wrapOutput(zD,S,$),S}while(!x()){if(j=y(),j==="\x00")continue;if(j==="\\"){let t=u();if(t==="/"&&X.bash!==!0)continue;if(t==="."||t===";")continue;if(!t){j+="\\",P({type:"text",value:j});continue}let KD=/^\\+/.exec(d()),uD=0;if(KD&&KD[0].length>2){if(uD=KD[0].length,S.index+=uD,uD%2!==0)j+="\\"}if(X.unescape===!0)j=y();else j+=y();if(S.brackets===0){P({type:"text",value:j});continue}}if(S.brackets>0&&(j!=="]"||f.value==="["||f.value==="[^")){if(X.posix!==!1&&j===":"){let t=f.value.slice(1);if(t.includes("[")){if(f.posix=!0,t.includes(":")){let KD=f.value.lastIndexOf("["),uD=f.value.slice(0,KD),hD=f.value.slice(KD+2),X0=txD[hD];if(X0){if(f.value=uD+X0,S.backtrack=!0,y(),!Q.output&&F.indexOf(f)===1)Q.output=B;continue}}}}if(j==="["&&u()!==":"||j==="-"&&u()==="]")j=`\\${j}`;if(j==="]"&&(f.value==="["||f.value==="[^"))j=`\\${j}`;if(X.posix===!0&&j==="!"&&f.value==="[")j="^";f.value+=j,a({value:j});continue}if(S.quotes===1&&j!=='"'){j=o1.escapeRegex(j),f.value+=j,a({value:j});continue}if(j==='"'){if(S.quotes=S.quotes===1?0:1,X.keepQuotes===!0)P({type:"text",value:j});continue}if(j==="("){n("parens"),P({type:"paren",value:j});continue}if(j===")"){if(S.parens===0&&X.strictBrackets===!0)throw SyntaxError(G7("opening","("));let t=h[h.length-1];if(t&&S.parens===t.parens+1){r(h.pop());continue}P({type:"paren",value:j,output:S.parens?")":"\\)"}),YD("parens");continue}if(j==="["){if(X.nobracket===!0||!d().includes("]")){if(X.nobracket!==!0&&X.strictBrackets===!0)throw SyntaxError(G7("closing","]"));j=`\\${j}`}else n("brackets");P({type:"bracket",value:j});continue}if(j==="]"){if(X.nobracket===!0||f&&f.type==="bracket"&&f.value.length===1){P({type:"text",value:j,output:`\\${j}`});continue}if(S.brackets===0){if(X.strictBrackets===!0)throw SyntaxError(G7("opening","["));P({type:"text",value:j,output:`\\${j}`});continue}YD("brackets");let t=f.value.slice(1);if(f.posix!==!0&&t[0]==="^"&&!t.includes("/"))j=`/${j}`;if(f.value+=j,a({value:j}),X.literalBrackets===!1||o1.hasRegexChars(t))continue;let KD=o1.escapeRegex(f.value);if(S.output=S.output.slice(0,-f.value.length),X.literalBrackets===!0){S.output+=KD,f.value=KD;continue}f.value=`(${w}${KD}|${f.value})`,S.output+=f.value;continue}if(j==="{"&&X.nobrace!==!0){n("braces");let t={type:"brace",value:j,output:"(",outputIndex:S.output.length,tokensIndex:S.tokens.length};g.push(t),P(t);continue}if(j==="}"){let t=g[g.length-1];if(X.nobrace===!0||!t){P({type:"text",value:j,output:j});continue}let KD=")";if(t.dots===!0){let uD=F.slice(),hD=[];for(let X0=uD.length-1;X0>=0;X0--){if(F.pop(),uD[X0].type==="brace")break;if(uD[X0].type!=="dots")hD.unshift(uD[X0].value)}KD=DSD(hD,X),S.backtrack=!0}if(t.comma!==!0&&t.dots!==!0){let uD=S.output.slice(0,t.outputIndex),hD=S.tokens.slice(t.tokensIndex);t.value=t.output="\\{",j=KD="\\}",S.output=uD;for(let X0 of hD)S.output+=X0.output||X0.value}P({type:"brace",value:j,output:KD}),YD("braces"),g.pop();continue}if(j==="|"){if(h.length>0)h[h.length-1].conditions++;P({type:"text",value:j});continue}if(j===","){let t=j,KD=g[g.length-1];if(KD&&l[l.length-1]==="braces")KD.comma=!0,t="|";P({type:"comma",value:j,output:t});continue}if(j==="/"){if(f.type==="dot"&&S.index===S.start+1){S.start=S.index+1,S.consumed="",S.output="",F.pop(),f=Q;continue}P({type:"slash",value:j,output:q});continue}if(j==="."){if(S.braces>0&&f.type==="dot"){if(f.value===".")f.output=U;let t=g[g.length-1];f.type="dots",f.output+=j,f.value+=j,t.dots=!0;continue}if(S.braces+S.parens===0&&f.type!=="bos"&&f.type!=="slash"){P({type:"text",value:j,output:U});continue}P({type:"dot",value:j,output:U});continue}if(j==="?"){if(!(f&&f.value==="(")&&X.noextglob!==!0&&u()==="("&&u(2)!=="?"){E("qmark",j);continue}if(f&&f.type==="paren"){let KD=u(),uD=j;if(KD==="<"&&!o1.supportsLookbehinds())throw Error("Node.js v10 or higher is required for regex lookbehinds");if(f.value==="("&&!/[!=<:]/.test(KD)||KD==="<"&&!/<([!=]|\w+>)/.test(d()))uD=`\\${j}`;P({type:"text",value:j,output:uD});continue}if(X.dot!==!0&&(f.type==="slash"||f.type==="bos")){P({type:"qmark",value:j,output:N});continue}P({type:"qmark",value:j,output:W});continue}if(j==="!"){if(X.noextglob!==!0&&u()==="("){if(u(2)!=="?"||!/[!=<:]/.test(u(3))){E("negate",j);continue}}if(X.nonegate!==!0&&S.index===0){c();continue}}if(j==="+"){if(X.noextglob!==!0&&u()==="("&&u(2)!=="?"){E("plus",j);continue}if(f&&f.value==="("||X.regex===!1){P({type:"plus",value:j,output:z});continue}if(f&&(f.type==="bracket"||f.type==="paren"||f.type==="brace")||S.parens>0){P({type:"plus",value:j});continue}P({type:"plus",value:z});continue}if(j==="@"){if(X.noextglob!==!0&&u()==="("&&u(2)!=="?"){P({type:"at",extglob:!0,value:j,output:""});continue}P({type:"text",value:j});continue}if(j!=="*"){if(j==="$"||j==="^")j=`\\${j}`;let t=sxD.exec(d());if(t)j+=t[0],S.index+=t[0].length;P({type:"text",value:j});continue}if(f&&(f.type==="globstar"||f.star===!0)){f.type="star",f.star=!0,f.value+=j,f.output=v,S.backtrack=!0,S.globstar=!0,b(j);continue}let k=d();if(X.noextglob!==!0&&/^\([^?]/.test(k)){E("star",j);continue}if(f.type==="star"){if(X.noglobstar===!0){b(j);continue}let t=f.prev,KD=t.prev,uD=t.type==="slash"||t.type==="bos",hD=KD&&(KD.type==="star"||KD.type==="globstar");if(X.bash===!0&&(!uD||k[0]&&k[0]!=="/")){P({type:"star",value:j,output:""});continue}let X0=S.braces>0&&(t.type==="comma"||t.type==="brace"),v0=h.length&&(t.type==="pipe"||t.type==="paren");if(!uD&&t.type!=="paren"&&!X0&&!v0){P({type:"star",value:j,output:""});continue}while(k.slice(0,3)==="/**"){let E1=D[S.index+4];if(E1&&E1!=="/")break;k=k.slice(3),b("/**",3)}if(t.type==="bos"&&x()){f.type="globstar",f.value+=j,f.output=C(X),S.output=f.output,S.globstar=!0,b(j);continue}if(t.type==="slash"&&t.prev.type!=="bos"&&!hD&&x()){S.output=S.output.slice(0,-(t.output+f.output).length),t.output=`(?:${t.output}`,f.type="globstar",f.output=C(X)+(X.strictSlashes?")":"|$)"),f.value+=j,S.globstar=!0,S.output+=t.output+f.output,b(j);continue}if(t.type==="slash"&&t.prev.type!=="bos"&&k[0]==="/"){let E1=k[1]!==void 0?"|$":"";S.output=S.output.slice(0,-(t.output+f.output).length),t.output=`(?:${t.output}`,f.type="globstar",f.output=`${C(X)}${q}|${q}${E1})`,f.value+=j,S.output+=t.output+f.output,S.globstar=!0,b(j+y()),P({type:"slash",value:"/",output:""});continue}if(t.type==="bos"&&k[0]==="/"){f.type="globstar",f.value+=j,f.output=`(?:^|${q}|${C(X)}${q})`,S.output=f.output,S.globstar=!0,b(j+y()),P({type:"slash",value:"/",output:""});continue}S.output=S.output.slice(0,-f.output.length),f.type="globstar",f.output=C(X),f.value+=j,S.output+=f.output,S.globstar=!0,b(j);continue}let zD={type:"star",value:j,output:v};if(X.bash===!0){if(zD.output=".*?",f.type==="bos"||f.type==="slash")zD.output=A+zD.output;P(zD);continue}if(f&&(f.type==="bracket"||f.type==="paren")&&X.regex===!0){zD.output=j,P(zD);continue}if(S.index===S.start||f.type==="slash"||f.type==="dot"){if(f.type==="dot")S.output+=L,f.output+=L;else if(X.dot===!0)S.output+=I,f.output+=I;else S.output+=A,f.output+=A;if(u()!=="*")S.output+=B,f.output+=B}P(zD)}while(S.brackets>0){if(X.strictBrackets===!0)throw SyntaxError(G7("closing","]"));S.output=o1.escapeLast(S.output,"["),YD("brackets")}while(S.parens>0){if(X.strictBrackets===!0)throw SyntaxError(G7("closing",")"));S.output=o1.escapeLast(S.output,"("),YD("parens")}while(S.braces>0){if(X.strictBrackets===!0)throw SyntaxError(G7("closing","}"));S.output=o1.escapeLast(S.output,"{"),YD("braces")}if(X.strictSlashes!==!0&&(f.type==="star"||f.type==="bracket"))P({type:"maybe_slash",value:"",output:`${q}?`});if(S.backtrack===!0){S.output="";for(let k of S.tokens)if(S.output+=k.output!=null?k.output:k.value,k.suffix)S.output+=k.suffix}return S};PL.fastpaths=(D,$)=>{let X={...$},Y=typeof X.maxLength==="number"?Math.min(mZ,X.maxLength):mZ,J=D.length;if(J>Y)throw SyntaxError(`Input length: ${J}, exceeds maximum allowed length: ${Y}`);D=ce[D]||D;let Q=o1.isWindows($),{DOT_LITERAL:F,SLASH_LITERAL:w,ONE_CHAR:Z,DOTS_SLASH:G,NO_DOT:O,NO_DOTS:U,NO_DOTS_SLASH:z,STAR:q,START_ANCHOR:B}=hZ.globChars(Q),K=X.dot?U:O,M=X.dot?z:O,L=X.capture?"":"?:",I={negated:!1,prefix:""},W=X.bash===!0?".*?":q;if(X.capture)W=`(${W})`;let N=(A)=>{if(A.noglobstar===!0)return W;return`(${L}(?:(?!${B}${A.dot?G:F}).)*?)`},V=(A)=>{switch(A){case"*":return`${K}${Z}${W}`;case".*":return`${F}${Z}${W}`;case"*.*":return`${K}${W}${F}${Z}${W}`;case"*/*":return`${K}${W}${w}${Z}${M}${W}`;case"**":return K+N(X);case"**/*":return`(?:${K}${N(X)}${w})?${M}${Z}${W}`;case"**/*.*":return`(?:${K}${N(X)}${w})?${M}${W}${F}${Z}${W}`;case"**/.*":return`(?:${K}${N(X)}${w})?${F}${Z}${W}`;default:{let _=/^(.*?)\.(\w+)$/.exec(A);if(!_)return;let v=V(_[1]);if(!v)return;return v+F+_[2]}}},R=o1.removePrefix(D,I),C=V(R);if(C&&X.strictSlashes!==!0)C+=`${w}?`;return C};le.exports=PL});var pe=T((uaD,ie)=>{var $SD=p("path"),XSD=de(),xL=ne(),SL=R2(),JSD=A2(),YSD=(D)=>D&&typeof D==="object"&&!Array.isArray(D),y0=(D,$,X=!1)=>{if(Array.isArray(D)){let O=D.map((z)=>y0(z,$,X));return(z)=>{for(let q of O){let B=q(z);if(B)return B}return!1}}let Y=YSD(D)&&D.tokens&&D.input;if(D===""||typeof D!=="string"&&!Y)throw TypeError("Expected pattern to be a non-empty string");let J=$||{},Q=SL.isWindows($),F=Y?y0.compileRe(D,$):y0.makeRe(D,$,!1,!0),w=F.state;delete F.state;let Z=()=>!1;if(J.ignore){let O={...$,ignore:null,onMatch:null,onResult:null};Z=y0(J.ignore,O,X)}let G=(O,U=!1)=>{let{isMatch:z,match:q,output:B}=y0.test(O,F,$,{glob:D,posix:Q}),K={glob:D,state:w,regex:F,posix:Q,input:O,output:B,match:q,isMatch:z};if(typeof J.onResult==="function")J.onResult(K);if(z===!1)return K.isMatch=!1,U?K:!1;if(Z(O)){if(typeof J.onIgnore==="function")J.onIgnore(K);return K.isMatch=!1,U?K:!1}if(typeof J.onMatch==="function")J.onMatch(K);return U?K:!0};if(X)G.state=w;return G};y0.test=(D,$,X,{glob:Y,posix:J}={})=>{if(typeof D!=="string")throw TypeError("Expected input to be a string");if(D==="")return{isMatch:!1,output:""};let Q=X||{},F=Q.format||(J?SL.toPosixSlashes:null),w=D===Y,Z=w&&F?F(D):D;if(w===!1)Z=F?F(D):D,w=Z===Y;if(w===!1||Q.capture===!0)if(Q.matchBase===!0||Q.basename===!0)w=y0.matchBase(D,$,X,J);else w=$.exec(Z);return{isMatch:Boolean(w),match:w,output:Z}};y0.matchBase=(D,$,X,Y=SL.isWindows(X))=>{return($ instanceof RegExp?$:y0.makeRe($,X)).test($SD.basename(D))};y0.isMatch=(D,$,X)=>y0($,X)(D);y0.parse=(D,$)=>{if(Array.isArray(D))return D.map((X)=>y0.parse(X,$));return xL(D,{...$,fastpaths:!1})};y0.scan=(D,$)=>XSD(D,$);y0.compileRe=(D,$,X=!1,Y=!1)=>{if(X===!0)return D.output;let J=$||{},Q=J.contains?"":"^",F=J.contains?"":"$",w=`${Q}(?:${D.output})${F}`;if(D&&D.negated===!0)w=`^(?!${w}).*$`;let Z=y0.toRegex(w,$);if(Y===!0)Z.state=D;return Z};y0.makeRe=(D,$={},X=!1,Y=!1)=>{if(!D||typeof D!=="string")throw TypeError("Expected a non-empty string");let J={negated:!1,fastpaths:!0};if($.fastpaths!==!1&&(D[0]==="."||D[0]==="*"))J.output=xL.fastpaths(D,$);if(!J.output)J=xL(D,$);return y0.compileRe(J,$,X,Y)};y0.toRegex=(D,$)=>{try{let X=$||{};return new RegExp(D,X.flags||(X.nocase?"i":""))}catch(X){if($&&$.debug===!0)throw X;return/$^/}};y0.constants=JSD;ie.exports=y0});var ee=T((vaD,se)=>{var oe=p("util"),ae=xe(),t$=pe(),uL=R2(),re=(D)=>D===""||D==="./",te=(D)=>{let $=D.indexOf("{");return $>-1&&D.indexOf("}",$)>-1},z0=(D,$,X)=>{$=[].concat($),D=[].concat(D);let Y=new Set,J=new Set,Q=new Set,F=0,w=(O)=>{if(Q.add(O.output),X&&X.onResult)X.onResult(O)};for(let O=0;O<$.length;O++){let U=t$(String($[O]),{...X,onResult:w},!0),z=U.state.negated||U.state.negatedExtglob;if(z)F++;for(let q of D){let B=U(q,!0);if(!(z?!B.isMatch:B.isMatch))continue;if(z)Y.add(B.output);else Y.delete(B.output),J.add(B.output)}}let G=(F===$.length?[...Q]:[...J]).filter((O)=>!Y.has(O));if(X&&G.length===0){if(X.failglob===!0)throw Error(`No matches found for "${$.join(", ")}"`);if(X.nonull===!0||X.nullglob===!0)return X.unescape?$.map((O)=>O.replace(/\\/g,"")):$}return G};z0.match=z0;z0.matcher=(D,$)=>t$(D,$);z0.isMatch=(D,$,X)=>t$($,X)(D);z0.any=z0.isMatch;z0.not=(D,$,X={})=>{$=[].concat($).map(String);let Y=new Set,J=[],F=new Set(z0(D,$,{...X,onResult:(w)=>{if(X.onResult)X.onResult(w);J.push(w.output)}}));for(let w of J)if(!F.has(w))Y.add(w);return[...Y]};z0.contains=(D,$,X)=>{if(typeof D!=="string")throw TypeError(`Expected a string: "${oe.inspect(D)}"`);if(Array.isArray($))return $.some((Y)=>z0.contains(D,Y,X));if(typeof $==="string"){if(re(D)||re($))return!1;if(D.includes($)||D.startsWith("./")&&D.slice(2).includes($))return!0}return z0.isMatch(D,$,{...X,contains:!0})};z0.matchKeys=(D,$,X)=>{if(!uL.isObject(D))throw TypeError("Expected the first argument to be an object");let Y=z0(Object.keys(D),$,X),J={};for(let Q of Y)J[Q]=D[Q];return J};z0.some=(D,$,X)=>{let Y=[].concat(D);for(let J of[].concat($)){let Q=t$(String(J),X);if(Y.some((F)=>Q(F)))return!0}return!1};z0.every=(D,$,X)=>{let Y=[].concat(D);for(let J of[].concat($)){let Q=t$(String(J),X);if(!Y.every((F)=>Q(F)))return!1}return!0};z0.all=(D,$,X)=>{if(typeof D!=="string")throw TypeError(`Expected a string: "${oe.inspect(D)}"`);return[].concat($).every((Y)=>t$(Y,X)(D))};z0.capture=(D,$,X)=>{let Y=uL.isWindows(X),Q=t$.makeRe(String(D),{...X,capture:!0}).exec(Y?uL.toPosixSlashes($):$);if(Q)return Q.slice(1).map((F)=>F===void 0?"":F)};z0.makeRe=(...D)=>t$.makeRe(...D);z0.scan=(...D)=>t$.scan(...D);z0.parse=(D,$)=>{let X=[];for(let Y of[].concat(D||[]))for(let J of ae(String(Y),$))X.push(t$.parse(J,$));return X};z0.braces=(D,$)=>{if(typeof D!=="string")throw TypeError("Expected a string");if($&&$.nobrace===!0||!te(D))return[D];return ae(D,$)};z0.braceExpand=(D,$)=>{if(typeof D!=="string")throw TypeError("Expected a string");return z0.braces(D,{...$,expand:!0})};z0.hasBraces=te;se.exports=z0});import{existsSync as pSD,readFileSync as rSD}from"node:fs";import{dirname as oSD,join as U7}from"node:path";import{cwd as lZ}from"node:process";function yL(D){if(!pSD(D))return;return rSD(D,"utf-8")}function sSD(D){let $=[U7(lZ(),D,"app","build.gradle"),U7(lZ(),D,"app","build.gradle.kts")];for(let X of $){let Y=yL(X);if(!Y)continue;let J=Y.match(/versionName\s*(?:=\s*)?["']([^"']+)["']/)?.[1],Q=Y.match(/versionCode\s*(?:=\s*)?(\d+)/)?.[1];if(J)return{versionName:J,versionCode:Q,source:X}}return}function EDD(D,$){let X=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return D.match(new RegExp(`<key>${X}</key>\\s*<string>([^<]+)</string>`))?.[1]?.trim()}function cZ(D,$){let Y=D.match(new RegExp(`${$}\\s*=\\s*([^;]+);`))?.[1]?.trim();if(!Y)return;return Y.replace(/"/g,"").trim()}function eSD(D){let $=U7(lZ(),D,"App"),X=U7($,"App","Info.plist"),Y=U7($,"App.xcodeproj","project.pbxproj"),J=yL(X),Q=yL(Y);if(!J)return;let F=EDD(J,"CFBundleShortVersionString"),w=EDD(J,"CFBundleVersion");if(F==="$(MARKETING_VERSION)")F=Q?cZ(Q,"MARKETING_VERSION"):void 0;if(w==="$(CURRENT_PROJECT_VERSION)")w=Q?cZ(Q,"CURRENT_PROJECT_VERSION"):void 0;if(!F&&Q)F=cZ(Q,"MARKETING_VERSION");if(!w&&Q)w=cZ(Q,"CURRENT_PROJECT_VERSION");if(!F)return;return{versionName:F,versionCode:w,source:X}}function DuD(D){let $=D?.plugins?.CapacitorUpdater?.version;if(typeof $==="string"&&$.trim().length>0)return $.trim();return}function $uD(D){let $=D?.plugins?.CapacitorUpdater?.defaultChannel;if(typeof $==="string"&&$.trim().length>0)return $.trim();return""}function XuD(D){let $=D?.plugins?.CapacitorUpdater?.updateUrl;if(typeof $==="string"&&$.trim().length>0)return $.trim();return aSD}async function CDD(D,$){let X=$?.plugins?.CapacitorUpdater?.appId,Y=$?.appId,J=X||Y;if(!J)return{ok:!1,error:"Could not resolve app ID from capacitor config. Ensure appId is set in capacitor.config.ts or CapacitorUpdater.appId is configured."};let Q=X?"CapacitorUpdater.appId from capacitor config":"top-level appId from capacitor config",F=K2($,D),w=D==="android"?sSD(F):eSD(F);if(!w)return{ok:!1,error:`Unable to resolve native ${D.toUpperCase()} version values from platform files in "${F}".`};let Z=DuD($),G=Z||w.versionName,O=Z?"CapacitorUpdater.version from capacitor config":`native ${D.toUpperCase()} versionName`,U=U7(lZ(),"package.json"),z=oSD(U),q=await y1("@capgo/capacitor-updater",z,U);if(!q)return{ok:!1,error:"Unable to resolve installed @capgo/capacitor-updater version from this project."};return{ok:!0,context:{endpoint:XuD($),payload:{app_id:J,device_id:tSD,version_name:"builtin",version_build:G,is_emulator:!1,is_prod:!1,platform:D,plugin_version:q,defaultChannel:$uD($)},nativeSource:w.source,versionBuildSource:O,appIdSource:Q}}}function PDD(D){let $={};if(D&&typeof D==="object"){for(let[X,Y]of Object.entries(D))if(X!=="error"&&X!=="message")$[X]=Y}return $}function JuD(D,$){let X=typeof D?.error==="string"?D.error:void 0,Y=typeof D?.message==="string"?D.message:void 0,J=typeof D?.version==="string"?D.version:void 0;if(X==="no_new_version_available"||J&&J===$)return{status:"retry",detail:Y||"No new version available yet"};if(X)return{status:"failed",detail:`${X}: ${Y??"Unknown backend message"}`,errorCode:X,backendMessage:Y,extra:PDD(D)};if(J&&J!==$)return{status:"available",detail:`Update ${J} is available`,responseVersion:J};return{status:"failed",detail:`Unexpected response format: ${JSON.stringify(D)}`}}async function xDD(D,$){let X;try{X=await fetch(D,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($),signal:AbortSignal.timeout(TDD)})}catch(Q){if(Q instanceof DOMException&&Q.name==="TimeoutError")return{success:!1,reason:`Request timed out after ${TDD/1000}s — the endpoint did not respond in time.`,backendRefusal:!1};return{success:!1,reason:`Network error: ${Q instanceof Error?Q.message:String(Q)}`,backendRefusal:!1}}let Y;try{Y=await X.json()}catch{Y={error:"invalid_json_response",message:"Non-JSON response from updates endpoint"}}if(!X.ok){let Q=typeof Y?.error==="string"?Y.error:void 0,F=typeof Y?.message==="string"?Y.message:void 0;return{success:!1,reason:`HTTP ${X.status}: ${JSON.stringify(Y)}`,backendRefusal:!!Q,errorCode:Q,backendMessage:F,extra:PDD(Y)}}let J=JuD(Y,$.version_name);if(J.status==="available")return{success:!0,availableVersion:J.responseVersion??""};if(J.status==="retry")return{success:!1,reason:J.detail,backendRefusal:!1};return{success:!1,reason:J.detail,backendRefusal:!!J.errorCode,errorCode:J.errorCode,backendMessage:J.backendMessage,extra:J.extra}}function SDD(D){if(!D.errorCode)return[];let $=[];if(D.errorCode==="disable_auto_update_to_major"){let Y=typeof D.extra?.version==="string"?D.extra.version:"unknown",J=typeof D.extra?.old==="string"?D.extra.old:"unknown";$.push(`Channel policy blocks major upgrades (target ${Y}, device baseline ${J}).`)}let X=YuD[D.errorCode];if(X)$.push(X.cause),$.push(`Fix: ${X.fix}`),$.push(`Details: ${X.docsUrl||g0}`);else $.push(`Backend returned ${D.errorCode}.`),$.push("Check channel restrictions, app/plugin configuration, and device version values."),$.push(`Troubleshooting guide: ${g0}`);return $}var aSD="https://plugin.capgo.app/updates",tSD="00000000-0000-0000-0000-000000000000",g0="https://capgo.app/docs/plugins/updater/commonproblems/",TDD=1e4,YuD;var uDD=o(()=>{fD();YuD={disable_auto_update_to_major:{cause:"Channel blocks major upgrades and device baseline major does not match the target bundle major.",fix:"Set plugins.CapacitorUpdater.version so its MAJOR matches the bundle MAJOR (e.g. 1.0.0 for bundle 1.x.x), run npx cap sync, and reinstall the native build.",docsUrl:`${g0}#disable_auto_update_to_major`},disable_auto_update_to_minor:{cause:"Channel blocks minor upgrades and the target bundle minor is above the device baseline.",fix:"Upload a bundle within the allowed minor range, or change the channel disable_auto_update policy in the dashboard.",docsUrl:`${g0}#disable_auto_update_to_minor--disable_auto_update_to_patch`},disable_auto_update_to_patch:{cause:"Channel blocks patch upgrades and the target bundle patch is above the device baseline.",fix:"Upload a bundle within the allowed patch range, or change the channel disable_auto_update policy in the dashboard.",docsUrl:`${g0}#disable_auto_update_to_minor--disable_auto_update_to_patch`},disable_auto_update_to_metadata:{cause:"Channel uses metadata-based targeting (version_number) and the device baseline is below the required min_update_version.",fix:"Set plugins.CapacitorUpdater.version to match the installed native version, or adjust min_update_version on the channel.",docsUrl:`${g0}#disable_auto_update_to_metadata`},disable_auto_update_under_native:{cause:"Channel prevents downgrades below the native app version.",fix:"Upload a bundle with version >= native baseline, or disable the under-native downgrade protection on the channel.",docsUrl:`${g0}#disable_auto_update_under_native`},misconfigured_channel:{cause:"Channel has disable_auto_update=version_number but min_update_version is missing.",fix:"Set a valid min_update_version on the channel, or change disable_auto_update to a different mode."},cannot_update_via_private_channel:{cause:"The selected channel does not allow device self-assignment.",fix:"Use a channel with self-assignment enabled, or enable self-assignment / make the channel public.",docsUrl:`${g0}#cannot_update_via_private_channel`},semver_error:{cause:"version_build sent to the backend is not valid semver (expected x.y.z).",fix:"Set plugins.CapacitorUpdater.version to a valid semver like 1.2.3, run npx cap sync, and rebuild native.",docsUrl:`${g0}#unknown_version_build--semver_error`},unknown_version_build:{cause:"Backend received version_build=unknown (device baseline version is missing).",fix:"Set plugins.CapacitorUpdater.version in capacitor.config.*, run npx cap sync, and rebuild native.",docsUrl:`${g0}#unknown_version_build--semver_error`},unsupported_plugin_version:{cause:"Installed @capgo/capacitor-updater is too old for the current backend.",fix:"Run npm install @capgo/capacitor-updater@latest, then npx cap sync, and rebuild native.",docsUrl:`${g0}#unsupported_plugin_version`},key_id_mismatch:{cause:"Bundle encryption key and device key differ.",fix:"Ensure the same public key is used in app config and when encrypting bundles, then re-upload the bundle.",docsUrl:`${g0}#key_id_mismatch`},disabled_platform_ios:{cause:"Channel has iOS updates disabled.",fix:"Enable the iOS platform toggle on the target channel in the dashboard.",docsUrl:`${g0}#disabled_platform_ios--disabled_platform_android`},disabled_platform_android:{cause:"Channel has Android updates disabled.",fix:"Enable the Android platform toggle on the target channel in the dashboard.",docsUrl:`${g0}#disabled_platform_ios--disabled_platform_android`},disabled_platform_electron:{cause:"Channel has Electron updates disabled.",fix:"Enable the Electron platform toggle on the target channel in the dashboard."},disable_prod_build:{cause:"Channel blocks production builds (allow_prod is off).",fix:"Enable allow_prod on the channel, or test with a development build.",docsUrl:`${g0}#disable_prod_build--disable_dev_build--disable_device--disable_emulator`},disable_dev_build:{cause:"Channel blocks development builds (allow_dev is off).",fix:"Enable allow_dev on the channel, or test with a production build.",docsUrl:`${g0}#disable_prod_build--disable_dev_build--disable_device--disable_emulator`},disable_device:{cause:"Channel blocks physical devices (allow_device is off).",fix:"Enable allow_device on the channel, or test on an emulator.",docsUrl:`${g0}#disable_prod_build--disable_dev_build--disable_device--disable_emulator`},disable_emulator:{cause:"Channel blocks emulators (allow_emulator is off).",fix:"Enable allow_emulator on the channel, or test on a physical device.",docsUrl:`${g0}#disable_prod_build--disable_dev_build--disable_device--disable_emulator`},no_channel:{cause:"No channel was resolved for this device.",fix:"Set defaultChannel in capacitor.config.* plugins.CapacitorUpdater section, or create a default channel in the dashboard.",docsUrl:`${g0}#no_channel--null_channel_data`},null_channel_data:{cause:"Channel was resolved but contains no usable data.",fix:"Set defaultChannel in capacitor.config.* plugins.CapacitorUpdater section, or verify the channel has a bundle assigned.",docsUrl:`${g0}#no_channel--null_channel_data`},missing_info:{cause:"Request is missing required fields (app_id, device_id, version_build, or platform).",fix:"Check capacitor.config.* for a valid appId and verify the probe payload."},no_bundle:{cause:"Channel resolved a version but no downloadable bundle artifact exists.",fix:"Re-upload the bundle with npx @capgo/cli@latest bundle upload and verify channel assignment."},no_bundle_url:{cause:"Bundle was resolved but its download URL is missing.",fix:"Re-upload the bundle — the storage artifact may be corrupted or missing."},no_url_or_manifest:{cause:"Bundle was resolved but neither URL nor manifest is available.",fix:"Re-upload the bundle — the storage artifact may be corrupted or missing."},already_on_builtin:{cause:"Device is already running the builtin bundle.",fix:"Upload and assign a bundle to the channel for OTA updates to be delivered."},revert_to_builtin_plugin_version_too_old:{cause:"Plugin version is too old for safe builtin revert.",fix:"Run npm install @capgo/capacitor-updater@latest, then npx cap sync, and rebuild native."},on_premise_app:{cause:"App is either flagged as on-premise or does not exist in Capgo Cloud.",fix:"Check that the app_id is registered in Capgo (capgo app add). If it is an on-premise app, configure plugins.CapacitorUpdater.updateUrl to point to your on-prem update endpoint."},need_plan_upgrade:{cause:"Update checks are blocked by plan limits.",fix:"Upgrade your Capgo plan or contact your organization admin."},invalid_json_body:{cause:"Updates endpoint rejected the request body as invalid JSON.",fix:"This is likely a CLI bug — please report it at https://github.com/Cap-go/CLI/issues."},invalid_query_parameters:{cause:"Updates endpoint rejected the query parameters.",fix:"This is likely a CLI bug — please report it at https://github.com/Cap-go/CLI/issues."}}});var fDD={};a1(fDD,{probeInternal:()=>kDD,probe:()=>FuD});import{exit as QuD,stdin as vDD,stdout as _DD}from"node:process";async function kDD(D){let $;try{$=(await ID()).config}catch{return{success:!1,error:"Failed to load Capacitor config."}}let X;if(D.platform==="ios"||D.platform==="android")X=D.platform;else if(D.platform)return{success:!1,error:`Invalid platform "${D.platform}". Must be "ios" or "android".`};else{if(!(!!vDD.isTTY&&!!_DD.isTTY))return{success:!1,error:"Platform is required in non-interactive environments. Use --platform ios or --platform android."};let Z=await t1({message:"Which platform do you want to probe?",options:[{value:"ios",label:"iOS"},{value:"android",label:"Android"}]});if(yD(Z))return{success:!1,error:"Probe cancelled."};X=Z}let Y=await CDD(X,$);if(!Y.ok)return{success:!1,error:`Probe setup failed: ${Y.error}`};let J=Y.context,Q=await xDD(J.endpoint,J.payload),F={success:Q.success,probeResult:Q,endpoint:J.endpoint,platform:X,versionBuild:J.payload.version_build,versionBuildSource:J.versionBuildSource,appId:J.payload.app_id,appIdSource:J.appIdSource,nativeSource:J.nativeSource};if(!Q.success)F.hints=SDD(Q);return F}async function FuD(D){VD("Probe Capgo updates endpoint");let $=await kDD(D);if($.error)H.error($.error),QuD(1);H.info(`Endpoint: ${$.endpoint}`),H.info(`Platform: ${$.platform}, version_build: ${$.versionBuild}`),H.info(`version_build source: ${$.versionBuildSource}`),H.info(`app_id: ${$.appId} (${$.appIdSource})`),H.info(`Native values source: ${$.nativeSource}`);let X=$.probeResult;if(X.success)H.success(`Update available: ${X.availableVersion}`);else{if(H.warn(`Reason: ${X.reason}`),X.backendRefusal)H.warn("The backend actively refused the request (not a cache/propagation issue).");if(X.errorCode)H.warn(`Error code: ${X.errorCode}`);if(X.backendMessage)H.warn(`Backend message: ${X.backendMessage}`);if($.hints)for(let Y of $.hints)H.warn(` ${Y}`)}}var yDD=o(()=>{vD();uDD();fD()});vD();s$();fD();vD();s$();fD();async function ua(D,$,X,Y={}){let{silent:J=!1,autoUnlink:Q=!1}=Y,{data:F,error:w}=await D.from("channels").select().eq("app_id",$).eq("version",X.id);if(w){if(!J)H.error(`Cannot check Version ${$}@${X.name}: ${s(w)}`);throw Error(`Cannot check version ${$}@${X.name}: ${s(w)}`)}if(!F?.length)return;if(J)throw Error(`Version ${$}@${X.name} is used in ${F.length} channel(s)`);VD(`❌ Version ${$}@${X.name} is used in ${F.length} channel${F.length>1?"s":""}`);let Z=Q;if(!Q)Z=await c0({message:"unlink it?"})===!0;if(!Z)throw H.error("Unlink it first"),Error(`Version ${$}@${X.name} is still linked to channel(s)`);for(let G of F){let O=A0();O.start(`Unlinking channel ${G.name}`);let U=await kM(D,$,{silent:J});if(!U)throw O.stop(`Cannot find unknown version for ${$}`),Error(`Cannot find unknown version for ${$}`);let{error:z}=await D.from("channels").update({version:U.id}).eq("id",G.id);if(z)throw O.stop(`Cannot update channel ${G.name} ${s(z)}`),Error(`Cannot update channel ${G.name}: ${s(z)}`);O.stop(`✅ Channel ${G.name} unlinked`)}ND(`Version unlinked from ${F.length} channel${F.length>1?"s":""}`)}async function kM(D,$,X={}){let{silent:Y=!1}=X,{data:J,error:Q}=await D.from("app_versions").select("id").eq("app_id",$).eq("name","unknown").single();if(!Q)return J;try{let F=await o0(D,$),{data:w,error:Z}=await D.from("app_versions").insert({owner_org:F,deleted:!0,name:"unknown",app_id:$}).select("id").single();if(Z){if(!Y)H.error(`Cannot find or create unknown version for ${$}. Find error: ${s(Q)}, Create error: ${s(Z)}`);throw Error(`Cannot find or create unknown version for app ${$}: ${s(Z)}`)}return w}catch(F){if(!Y)H.error(`Cannot find or create unknown version for ${$}. Find error: ${s(Q)}, Create error: ${s(F)}`);throw Error(`Cannot retrieve or create unknown version for app ${$}: ${s(F)}`)}}function va(D,$){return D.from("channels").insert($).select().single()}function _a(D,$,X,Y){return D.from("channels").delete().eq("name",$).eq("app_id",X).single()}function ka(D,$,X){return D.from("channels").select().eq("app_id",$).eq("name",X).single()}function fa(D,$,X){return D.from("channel_devices").delete().eq("app_id",$).eq("channel_id",X)}function ya(D,$,X){return D.from("channels").select(`
423
423
  id,
424
424
  version (id, name)
425
425
  `).eq("app_id",$).eq("name",X).single().throwOnError().then(({data:Y})=>Y?.version)}function ba(D,$=!1){if($)return;let X=new R0;X.theme=R0.roundTheme,X.headers=["Name","Version","Public","iOS","Android","Auto Update","Native Auto Update","Device Self Set","Progressive Deploy","Secondary Version","Secondary Version Percentage","AB Testing","AB Testing Version","AB Testing Percentage","Emulator","Device","Dev","Prod"],X.rows=[];for(let Y of D.toReversed())X.rows.push([Y.name,Y.version?.name,Y.public?"✅":"❌",Y.ios?"✅":"❌",Y.android?"✅":"❌",Y.disable_auto_update,Y.disable_auto_update_under_native?"❌":"✅",Y.allow_device_self_set?"✅":"❌",Y.allow_emulator?"✅":"❌",Y.allow_device?"✅":"❌",Y.allow_dev?"✅":"❌",Y.allow_prod?"✅":"❌"]);H.success("Channels"),H.success(X.toString())}async function ga(D,$,X=!1){let{data:Y,error:J}=await D.from("channels").select(`
@@ -439,7 +439,7 @@ PS: You can ignore this check with "--ignore-checksum-check"`),Error("Cannot upl
439
439
  created_by,
440
440
  app_id,
441
441
  version (id, name)
442
- `).eq("app_id",$).order("created_at",{ascending:!1});if(J){if(!X)H.error(`App ${$} not found in database`);throw Error(`App ${$} not found in database: ${s(J)}`)}return Y}async function fM(D,$,X,Y={}){let{silent:J=!1}=Y,{error:Q}=await D.from("app_versions").update({deleted:!0}).eq("app_id",$).eq("deleted",!1).eq("name",X);if(Q){let F=`App version ${$}@${X} not found in database`;if(!J)H.error(F);throw Error(`${F}: ${s(Q)}`)}}async function UZ(D,$,X,Y={}){let{silent:J=!1,autoUnlink:Q=!1}=Y,F=await gED(D,$,X,{silent:J});await ua(D,$,F,{silent:J,autoUnlink:Q}),await fM(D,$,X,{silent:J})}function ha(D,$=!1){if($)return;if(!D.length)throw Error("No bundle found");let X=new R0;X.theme=R0.roundTheme,X.headers=["Version","Created","Keep"],X.rows=[];for(let Y of D.toReversed())X.rows.push([Y.name,o5(Y.created_at),Y.keep??""]);H.success("Bundles"),H.success(X.toString())}async function qZ(D,$,X={}){let{silent:Y=!1}=X,{data:J,error:Q}=await D.from("app_versions").select().eq("app_id",$).eq("deleted",!1).order("created_at",{ascending:!1});if(Q){let F=`App ${$} not found in database`;if(!Y)H.error(F);throw Error(`${F}: ${s(Q)}`)}return J??[]}async function ma(D,$,X={}){let{silent:Y=!1}=X,{data:J,error:Q}=await D.from("channels").select("version").eq("app_id",$);if(Q){let F=`App ${$} not found in database`;if(!Y)H.error(F);throw Error(`${F}: ${s(Q)}`)}return(J??[]).map((F)=>F.version)}async function gED(D,$,X,Y={}){let{silent:J=!1}=Y,{data:Q,error:F}=await D.from("app_versions").select().eq("app_id",$).eq("name",X).eq("deleted",!1).single();if(!Q||F){let w=`App version ${$}@${X} doesn't exist`;if(!J)H.error(w);throw Error(`${w}${F?`: ${s(F)}`:""}`)}return Q}vD();import{existsSync as ca,readFileSync as la}from"node:fs";vD();fD();async function da(D,$){let{data:X}=await D.rpc("exist_app_v2",{appid:$}).single();return!!X}async function m0(D,$,X=!1){let{data:Y,error:J}=await D.rpc("reject_access_due_to_2fa_for_app",{app_id:$});if(J){if(!X)H.error(`Cannot check 2FA compliance: ${J.message}`);throw Error(`Cannot check 2FA compliance: ${J.message}`)}if(Y){if(X)throw Error("2FA required for this organization");uM()}}async function u0(D,$,X,Y,J=!1,Q=!1){let F=_8();if(!Q)await m0(D,X,J);let w=await Va(D,$,X);if(!w.okay)switch(w.error){case"INVALID_APIKEY":{if(!J)H.error("Invalid apikey, such apikey does not exists!");throw Error("Invalid apikey, such apikey does not exists!")}case"NO_APP":{let O=`App ${X} does not exist, run first \`${F.runner} @capgo/cli app add ${X}\` to create it`;if(!J)H.error(O);throw Error(O)}case"NO_ORG":{if(!J)H.error("Could not find organization, please contact support to resolve this!");throw Error("Could not find organization, please contact support to resolve this!")}}let Z=w.data;if(Y>Z){let O=`Insuficcent permissions for app ${X}. Current permission: ${R1[w.data]}, required for this action: ${R1[Y]}.`;if(!J)H.error(O);throw Error(O)}return w.data}var G$="assets/icon.png";q1();fD();var hED=/^[a-z0-9]+(\.[\w-]+)+$/i;function mED(D,$,X){if(!$.apikey){if(!X)H.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!D){if(!X)H.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}if(D.includes("--")){if(!X)H.error('The app id includes illegal symbols. You cannot use "--" in the app id');throw Error("App id includes illegal symbols")}if(!hED.test(D)){if(!X)H.error(`Invalid app ID format: "${D}"`),H.info("App ID must be in reverse domain notation (e.g., com.example.app)"),H.info("Valid format: lowercase letters, numbers, dots, hyphens, and underscores"),H.info("Examples: com.mycompany.myapp, io.capgo.app, com.example.my-app");throw Error("Invalid app ID format")}}async function dED(D,$,X){if(!await da(D,$))return;if($==="io.ionic.starter"){if(!X)H.error(`This appId ${$} cannot be used it's reserved, please change it in your capacitor config.`);throw Error("Reserved appId, please change it in capacitor config")}if(!X)H.error(`App ${$} already exist`);throw Error(`App ${$} already exists`)}async function na(D,$,X,Y=!1){if(!Y)VD("Adding");await F0(),$.apikey=$.apikey||BD();let J=await ID(),Q=iD(D,J?.config);mED(Q,$,Y);let F=await jD($.apikey,$.supaHost,$.supaAnon),w=await xD(F,$.apikey,["write","all"]);if(await dED(F,Q,Y),!X)X=await GZ(F,["admin","super_admin"]);let Z=X.gid,{name:G,icon:O}=$;if(G=G||J.config?.appName||"Unknown",O=O||"resources/icon.png",!O||!G){if(!Y)H.error("Missing argument, you need to provide a appId and a name, or be in a capacitor project");throw Error("Missing app name or icon path")}if(!Y)H.info(`Adding ${Q} to Capgo`);let U=null,z=null;if(O&&ca(O)){if(U=la(O),z=M4(O)||"image/png",!Y)H.warn(`Found app icon ${O}`)}else if(ca(G$)){if(U=la(G$),z=M4(G$)||"image/png",!Y)H.warn(`Found app icon ${G$}`)}else if(!Y)H.warn(`Cannot find app icon in any of the following locations: ${O}, ${G$}`);let q="icon",B="https://xvwzpoazmxkqosrdewyv.supabase.co/storage/v1/object/public/images/capgo.png";if(U&&z){let{error:M}=await F.storage.from(`images/org/${Z}/${Q}`).upload(q,U,{contentType:z});if(M){if(!Y)console.error(M);if(!Y)H.error(`Could not add app ${s(M)}`);throw Error(`Could not add app ${s(M)}`)}let{data:L}=await F.storage.from(`images/org/${Z}/${Q}`).getPublicUrl(q);B=L?.publicUrl||B}let{error:K}=await F.from("apps").insert({icon_url:B,owner_org:Z,user_id:w,name:G,app_id:Q});if(K){if(!Y)H.error(`Could not add app ${s(K)}`);throw Error(`Could not add app ${s(K)}`)}if(await RD($.apikey,{channel:"app",event:"App Created",icon:"\uD83C\uDD95",user_id:Z,tags:{"app-id":Q},notify:!1,notifyConsole:!0}).catch(()=>{}),!Y)H.success(`App ${Q} added to Capgo`),H.info("This app is accessible to all members of your organization based on their permissions"),H.info(`Next step: upload a bundle with "npx @capgo/cli bundle upload ${Q}"`),ND("Done ✅");return{appId:Q,organizationUid:Z,userId:w,name:G,signedURL:B}}vD();fD();async function ia(D,$,X=!1,Y=!1){if(!X)VD("Deleting");$.apikey=$.apikey||BD();let J=await ID(),Q=iD(D,J?.config);if(!$.apikey){if(!X)H.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!Q){if(!X)H.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}let F=await jD($.apikey,$.supaHost,$.supaAnon),w=await xD(F,$.apikey,["write","all"]);await u0(F,$.apikey,Q,5,X);let{data:Z,error:G}=await F.from("apps").select("owner_org ( created_by, id )").eq("app_id",Q).single(),O=Z;if(!Y&&!G&&(O?.owner_org.created_by??"")!==w)if(!X){H.warn("Deleting the app is not recommended for users that are not the organization owner"),H.warn("You are invited as a super_admin but your are not the owner"),H.warn("It's strongly recommended that you do not continue!");let K=await t1({message:"Do you want to continue?",options:[{label:"Yes",value:"yes"},{label:"No",value:"no"}]});if(yD(K)||K==="no")throw H.error("Canceled deleting the app, exiting"),Error("App deletion cancelled")}else throw Error("Cannot delete app: you are not the organization owner");else if(G&&!X)H.warn(`Cannot get the app owner ${s(G)}`);let{error:U}=await F.storage.from("images").remove([`org/${O?.owner_org.id}/${Q}/icon`]);if(U&&!X)H.error("Could not delete app logo");let{error:z}=await F.storage.from(`apps/${Q}/${w}`).remove(["versions"]);if(z&&!X)H.error("Could not delete app version");let{error:q}=await F.from("apps").delete().eq("app_id",Q);if(q){if(!X)H.error("Could not delete app");throw Error(`Could not delete app: ${s(q)}`)}let B=await o0(F,Q);if(await RD($.apikey,{channel:"app",event:"App Deleted",icon:"\uD83D\uDDD1️",user_id:B,tags:{"app-id":Q},notify:!1}).catch(()=>{}),!X)H.success("App deleted in Capgo"),ND("Done ✅");return!0}vD();MY();fD();import{platform as cED,version as lED}from"node:os";import{version as nED}from"node:process";async function pa(D){let $={},X=Object.keys(D);return(await Promise.all(X.map((J)=>LY(J)))).forEach((J,Q)=>{if(J)$[X[Q]]=J}),$}async function iED(){let D=await JZ(),$={"@capgo/cli":F6.version};for(let[X,Y]of D)if(X.startsWith("@capgo/")||X.startsWith("@capawesome/")||X.startsWith("capacitor"))$[X]=Y;return $}async function ra(D,$=!1){if(!$)H.warn(" \uD83D\uDC8A Capgo Doctor \uD83D\uDC8A");let X=await ID(),Y=N4("",D.packageJson),J=X?.config?.plugins?.CapacitorUpdater?.version||Y,Q=X?.config?.appName||"",F=iD("",X?.config),w=X?.config?.webDir||"";if(!$)H.info(` App Name: ${Q}`),H.info(` App ID: ${F}`),H.info(` App Version: ${J}`),H.info(` Web Dir: ${w}`),H.info(` OS: ${cED()} ${lED()}`),H.info(` Node: ${nED}`),H.info(" Installed Dependencies:");let Z=await iED();if(Object.keys(Z).length===0){if(!$)H.warning("\x1B[31m%s\x1B[0m \uD83D\uDEA8 No dependencies found");throw Error("No dependencies found")}if(!$)for(let O of Object.keys(Z))H.info(` ${O}: ${Z[O]}`);let G={};if(!$){let O=A0();O.start("Running: Loading latest dependencies"),G=await pa(Z),O.stop("Latest Dependencies:");for(let U of Object.keys(G))H.info(` ${U}: ${G[U]}`)}else G=await pa(Z);if(JSON.stringify(Z)!==JSON.stringify(G)){if(!$)H.warn("\x1B[31m\uD83D\uDEA8 Some dependencies are not up to date\x1B[0m");throw Error("Some dependencies are not up to date")}if(!$)H.success("\x1B[32m✅ All dependencies are up to date\x1B[0m");return{appName:Q,appId:F,appVersion:J,webDir:w,installedDependencies:Z,latestDependencies:G}}vD();s$();q1();fD();function pED(D){let $=new R0;$.headers=["Name","id","Created"],$.rows=[];for(let X of D.toReversed())$.rows.push([X.name??"",X.app_id,o5(X.created_at)]);H.success("Apps"),H.success($.toString())}async function rED(D,$){let{data:X,error:Y}=await D.from("apps").select().order("created_at",{ascending:!1});if(Y){if(!$)H.error("Apps not found");throw Error("Apps not found")}return X??[]}async function oa(D,$=!1){if(!$)VD("List apps in Capgo");await F0(),D.apikey=D.apikey||BD();let X=await jD(D.apikey,D.supaHost,D.supaAnon);if(await xD(X,D.apikey,["write","all","read","upload"]),!$)H.info("Getting active bundle in Capgo");let Y=await rED(X,$);if(!Y.length){if(!$)H.error("No apps found");throw Error("No apps found")}if(!$)H.info(`Active app in Capgo: ${Y.length}`),pED(Y),ND("Done ✅");return Y}vD();import{randomUUID as oED}from"node:crypto";import{existsSync as aa,readFileSync as ta}from"node:fs";fD();async function sa(D,$,X=!1){if(!X)VD("Set app");$.apikey=$.apikey||BD();let Y=await ID();if(D=iD(D,Y?.config),!$.apikey){if(!X)H.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!D){if(!X)H.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}let J=await jD($.apikey,$.supaHost,$.supaAnon),F=(await GZ(J,["admin","super_admin"])).gid,w=await xD(J,$.apikey,["write","all"]);await u0(J,$.apikey,D,4,X);let{name:Z,icon:G,retention:O,exposeMetadata:U}=$;if(O&&Number.isNaN(Number(O))){if(!X)H.error("retention value must be a number");throw Error("Retention value must be a number")}else if(O&&O<0){if(!X)H.error("retention value cannot be less than 0");throw Error("Retention value cannot be less than 0")}else if(O&&O>=63113904){if(!X)H.error("retention value cannot be greater than 63113904 seconds (2 years)");throw Error("Retention value cannot be greater than 63113904 seconds (2 years)")}let z,q,B=`icon_${oED()}`,K="https://xvwzpoazmxkqosrdewyv.supabase.co/storage/v1/object/public/images/capgo.png";if(G&&aa(G)){if(z=ta(G),q=M4(G)||"image/png",!X)H.warn(`Found app icon ${G}`)}else if(aa(G$)){if(z=ta(G$),q=M4(G$)||"image/png",!X)H.warn(`Found app icon ${G$}`)}else if(!X)H.warn(`Cannot find app icon in any of the following locations: ${G}, ${G$}`);if(z&&q){let{error:L}=await J.storage.from(`images/org/${F}/${D}`).upload(B,z,{contentType:q});if(L){if(!X)H.error(`Could not set app ${s(L)}`);throw Error(`Could not set app: ${s(L)}`)}let{data:I}=await J.storage.from(`images/org/${F}/${D}`).getPublicUrl(B);K=I?.publicUrl||K}let{error:M}=await J.from("apps").update({icon_url:K,name:Z,retention:!O?void 0:O*24*60*60,expose_metadata:U}).eq("app_id",D).eq("user_id",w);if(M){if(!X)H.error(`Could not set app ${s(M)}`);throw Error(`Could not set app: ${s(M)}`)}if(await RD($.apikey,{channel:"app",event:"App Updated",icon:"\uD83D\uDCDD",user_id:F,tags:{"app-id":D},notify:!1,notifyConsole:!0}).catch(()=>{}),!X)ND("Done ✅");return!0}vD();GF();fD();async function ea(D,$,X=!1){if(!X)VD("Set a specific setting in capacitor config");if($.bool&&$.string){if(!X)H.error("Bool and string CANNOT be set at the same time");throw Error("Bool and string cannot both be provided")}if(!$.bool&&!$.string){if(!X)H.error("You MUST provide either bool or string as the value");throw Error("Either bool or string value is required")}if($.bool&&$.bool!=="true"&&$.bool!=="false"){if(!X)H.error("Invalid bool");throw Error("Invalid bool value; expected true or false")}try{let Y=await ID(),J=Y.config,Q=D.split(".");if(Q.length===0){if(!X)H.error("Invalid path");throw Error("Invalid config path")}for(let w of Q.slice(0,-1)){if(!Object.prototype.hasOwnProperty.call(J,w))J[w]={};J=J[w]}let F=$.bool?$.bool==="true":$.string;if(J[Q.at(-1)]=F,await U5(Y,!0),!X)H.success(`Set "${D}" to "${F}"`)}catch(Y){if(!X)H.error(`Cannot set config in capacitor settings ${s(Y)}`);throw Error(`Cannot set capacitor config: ${s(Y)}`)}if(!X)ND("Done ✅")}vD();var Hs=V0(KO(),1);import{Buffer as Os}from"node:buffer";import{existsSync as W2,readdirSync as Ks,readFileSync as kCD,statSync as fCD}from"node:fs";import{mkdir as yCD,readFile as $L,rm as bCD,stat as gCD,writeFile as hCD}from"node:fs/promises";import{tmpdir as mCD}from"node:os";import{basename as Us,join as a$,resolve as dCD}from"node:path";import XL,{chdir as qs,cwd as Ws,exit as $oD}from"node:process";if(!globalThis.EventTarget||!globalThis.Event)console.error(`
442
+ `).eq("app_id",$).order("created_at",{ascending:!1});if(J){if(!X)H.error(`App ${$} not found in database`);throw Error(`App ${$} not found in database: ${s(J)}`)}return Y}async function fM(D,$,X,Y={}){let{silent:J=!1}=Y,{error:Q}=await D.from("app_versions").update({deleted:!0}).eq("app_id",$).eq("deleted",!1).eq("name",X);if(Q){let F=`App version ${$}@${X} not found in database`;if(!J)H.error(F);throw Error(`${F}: ${s(Q)}`)}}async function UZ(D,$,X,Y={}){let{silent:J=!1,autoUnlink:Q=!1}=Y,F=await gED(D,$,X,{silent:J});await ua(D,$,F,{silent:J,autoUnlink:Q}),await fM(D,$,X,{silent:J})}function ha(D,$=!1){if($)return;if(!D.length)throw Error("No bundle found");let X=new R0;X.theme=R0.roundTheme,X.headers=["Version","Created","Keep"],X.rows=[];for(let Y of D.toReversed())X.rows.push([Y.name,o5(Y.created_at),Y.keep??""]);H.success("Bundles"),H.success(X.toString())}async function qZ(D,$,X={}){let{silent:Y=!1}=X,{data:J,error:Q}=await D.from("app_versions").select().eq("app_id",$).eq("deleted",!1).order("created_at",{ascending:!1});if(Q){let F=`App ${$} not found in database`;if(!Y)H.error(F);throw Error(`${F}: ${s(Q)}`)}return J??[]}async function ma(D,$,X={}){let{silent:Y=!1}=X,{data:J,error:Q}=await D.from("channels").select("version").eq("app_id",$);if(Q){let F=`App ${$} not found in database`;if(!Y)H.error(F);throw Error(`${F}: ${s(Q)}`)}return(J??[]).map((F)=>F.version)}async function gED(D,$,X,Y={}){let{silent:J=!1}=Y,{data:Q,error:F}=await D.from("app_versions").select().eq("app_id",$).eq("name",X).eq("deleted",!1).single();if(!Q||F){let w=`App version ${$}@${X} doesn't exist`;if(!J)H.error(w);throw Error(`${w}${F?`: ${s(F)}`:""}`)}return Q}vD();import{existsSync as ca,readFileSync as la}from"node:fs";vD();fD();async function da(D,$){let{data:X}=await D.rpc("exist_app_v2",{appid:$}).single();return!!X}async function d0(D,$,X=!1){let{data:Y,error:J}=await D.rpc("reject_access_due_to_2fa_for_app",{app_id:$});if(J){if(!X)H.error(`Cannot check 2FA compliance: ${J.message}`);throw Error(`Cannot check 2FA compliance: ${J.message}`)}if(Y){if(X)throw Error("2FA required for this organization");uM()}}async function u0(D,$,X,Y,J=!1,Q=!1){let F=_8();if(!Q)await d0(D,X,J);let w=await Va(D,$,X);if(!w.okay)switch(w.error){case"INVALID_APIKEY":{if(!J)H.error("Invalid apikey, such apikey does not exists!");throw Error("Invalid apikey, such apikey does not exists!")}case"NO_APP":{let O=`App ${X} does not exist, run first \`${F.runner} @capgo/cli app add ${X}\` to create it`;if(!J)H.error(O);throw Error(O)}case"NO_ORG":{if(!J)H.error("Could not find organization, please contact support to resolve this!");throw Error("Could not find organization, please contact support to resolve this!")}}let Z=w.data;if(Y>Z){let O=`Insuficcent permissions for app ${X}. Current permission: ${R1[w.data]}, required for this action: ${R1[Y]}.`;if(!J)H.error(O);throw Error(O)}return w.data}var G$="assets/icon.png";q1();fD();var hED=/^[a-z0-9]+(\.[\w-]+)+$/i;function mED(D,$,X){if(!$.apikey){if(!X)H.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!D){if(!X)H.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}if(D.includes("--")){if(!X)H.error('The app id includes illegal symbols. You cannot use "--" in the app id');throw Error("App id includes illegal symbols")}if(!hED.test(D)){if(!X)H.error(`Invalid app ID format: "${D}"`),H.info("App ID must be in reverse domain notation (e.g., com.example.app)"),H.info("Valid format: lowercase letters, numbers, dots, hyphens, and underscores"),H.info("Examples: com.mycompany.myapp, io.capgo.app, com.example.my-app");throw Error("Invalid app ID format")}}async function dED(D,$,X){if(!await da(D,$))return;if($==="io.ionic.starter"){if(!X)H.error(`This appId ${$} cannot be used it's reserved, please change it in your capacitor config.`);throw Error("Reserved appId, please change it in capacitor config")}if(!X)H.error(`App ${$} already exist`);throw Error(`App ${$} already exists`)}async function na(D,$,X,Y=!1){if(!Y)VD("Adding");await F0(),$.apikey=$.apikey||BD();let J=await ID(),Q=iD(D,J?.config);mED(Q,$,Y);let F=await jD($.apikey,$.supaHost,$.supaAnon),w=await xD(F,$.apikey,["write","all"]);if(await dED(F,Q,Y),!X)X=await GZ(F,["admin","super_admin"]);let Z=X.gid,{name:G,icon:O}=$;if(G=G||J.config?.appName||"Unknown",O=O||"resources/icon.png",!O||!G){if(!Y)H.error("Missing argument, you need to provide a appId and a name, or be in a capacitor project");throw Error("Missing app name or icon path")}if(!Y)H.info(`Adding ${Q} to Capgo`);let U=null,z=null;if(O&&ca(O)){if(U=la(O),z=M4(O)||"image/png",!Y)H.warn(`Found app icon ${O}`)}else if(ca(G$)){if(U=la(G$),z=M4(G$)||"image/png",!Y)H.warn(`Found app icon ${G$}`)}else if(!Y)H.warn(`Cannot find app icon in any of the following locations: ${O}, ${G$}`);let q="icon",B="https://xvwzpoazmxkqosrdewyv.supabase.co/storage/v1/object/public/images/capgo.png";if(U&&z){let{error:M}=await F.storage.from(`images/org/${Z}/${Q}`).upload(q,U,{contentType:z});if(M){if(!Y)console.error(M);if(!Y)H.error(`Could not add app ${s(M)}`);throw Error(`Could not add app ${s(M)}`)}let{data:L}=await F.storage.from(`images/org/${Z}/${Q}`).getPublicUrl(q);B=L?.publicUrl||B}let{error:K}=await F.from("apps").insert({icon_url:B,owner_org:Z,user_id:w,name:G,app_id:Q});if(K){if(!Y)H.error(`Could not add app ${s(K)}`);throw Error(`Could not add app ${s(K)}`)}if(await RD($.apikey,{channel:"app",event:"App Created",icon:"\uD83C\uDD95",user_id:Z,tags:{"app-id":Q},notify:!1,notifyConsole:!0}).catch(()=>{}),!Y)H.success(`App ${Q} added to Capgo`),H.info("This app is accessible to all members of your organization based on their permissions"),H.info(`Next step: upload a bundle with "npx @capgo/cli bundle upload ${Q}"`),ND("Done ✅");return{appId:Q,organizationUid:Z,userId:w,name:G,signedURL:B}}vD();fD();async function ia(D,$,X=!1,Y=!1){if(!X)VD("Deleting");$.apikey=$.apikey||BD();let J=await ID(),Q=iD(D,J?.config);if(!$.apikey){if(!X)H.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!Q){if(!X)H.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}let F=await jD($.apikey,$.supaHost,$.supaAnon),w=await xD(F,$.apikey,["write","all"]);await u0(F,$.apikey,Q,5,X);let{data:Z,error:G}=await F.from("apps").select("owner_org ( created_by, id )").eq("app_id",Q).single(),O=Z;if(!Y&&!G&&(O?.owner_org.created_by??"")!==w)if(!X){H.warn("Deleting the app is not recommended for users that are not the organization owner"),H.warn("You are invited as a super_admin but your are not the owner"),H.warn("It's strongly recommended that you do not continue!");let K=await t1({message:"Do you want to continue?",options:[{label:"Yes",value:"yes"},{label:"No",value:"no"}]});if(yD(K)||K==="no")throw H.error("Canceled deleting the app, exiting"),Error("App deletion cancelled")}else throw Error("Cannot delete app: you are not the organization owner");else if(G&&!X)H.warn(`Cannot get the app owner ${s(G)}`);let{error:U}=await F.storage.from("images").remove([`org/${O?.owner_org.id}/${Q}/icon`]);if(U&&!X)H.error("Could not delete app logo");let{error:z}=await F.storage.from(`apps/${Q}/${w}`).remove(["versions"]);if(z&&!X)H.error("Could not delete app version");let{error:q}=await F.from("apps").delete().eq("app_id",Q);if(q){if(!X)H.error("Could not delete app");throw Error(`Could not delete app: ${s(q)}`)}let B=await o0(F,Q);if(await RD($.apikey,{channel:"app",event:"App Deleted",icon:"\uD83D\uDDD1️",user_id:B,tags:{"app-id":Q},notify:!1}).catch(()=>{}),!X)H.success("App deleted in Capgo"),ND("Done ✅");return!0}vD();MY();fD();import{platform as cED,version as lED}from"node:os";import{version as nED}from"node:process";async function pa(D){let $={},X=Object.keys(D);return(await Promise.all(X.map((J)=>LY(J)))).forEach((J,Q)=>{if(J)$[X[Q]]=J}),$}async function iED(){let D=await JZ(),$={"@capgo/cli":F6.version};for(let[X,Y]of D)if(X.startsWith("@capgo/")||X.startsWith("@capawesome/")||X.startsWith("capacitor"))$[X]=Y;return $}async function ra(D,$=!1){if(!$)H.warn(" \uD83D\uDC8A Capgo Doctor \uD83D\uDC8A");let X=await ID(),Y=N4("",D.packageJson),J=X?.config?.plugins?.CapacitorUpdater?.version||Y,Q=X?.config?.appName||"",F=iD("",X?.config),w=X?.config?.webDir||"";if(!$)H.info(` App Name: ${Q}`),H.info(` App ID: ${F}`),H.info(` App Version: ${J}`),H.info(` Web Dir: ${w}`),H.info(` OS: ${cED()} ${lED()}`),H.info(` Node: ${nED}`),H.info(" Installed Dependencies:");let Z=await iED();if(Object.keys(Z).length===0){if(!$)H.warning("\x1B[31m%s\x1B[0m \uD83D\uDEA8 No dependencies found");throw Error("No dependencies found")}if(!$)for(let O of Object.keys(Z))H.info(` ${O}: ${Z[O]}`);let G={};if(!$){let O=A0();O.start("Running: Loading latest dependencies"),G=await pa(Z),O.stop("Latest Dependencies:");for(let U of Object.keys(G))H.info(` ${U}: ${G[U]}`)}else G=await pa(Z);if(JSON.stringify(Z)!==JSON.stringify(G)){if(!$)H.warn("\x1B[31m\uD83D\uDEA8 Some dependencies are not up to date\x1B[0m");throw Error("Some dependencies are not up to date")}if(!$)H.success("\x1B[32m✅ All dependencies are up to date\x1B[0m");return{appName:Q,appId:F,appVersion:J,webDir:w,installedDependencies:Z,latestDependencies:G}}vD();s$();q1();fD();function pED(D){let $=new R0;$.headers=["Name","id","Created"],$.rows=[];for(let X of D.toReversed())$.rows.push([X.name??"",X.app_id,o5(X.created_at)]);H.success("Apps"),H.success($.toString())}async function rED(D,$){let{data:X,error:Y}=await D.from("apps").select().order("created_at",{ascending:!1});if(Y){if(!$)H.error("Apps not found");throw Error("Apps not found")}return X??[]}async function oa(D,$=!1){if(!$)VD("List apps in Capgo");await F0(),D.apikey=D.apikey||BD();let X=await jD(D.apikey,D.supaHost,D.supaAnon);if(await xD(X,D.apikey,["write","all","read","upload"]),!$)H.info("Getting active bundle in Capgo");let Y=await rED(X,$);if(!Y.length){if(!$)H.error("No apps found");throw Error("No apps found")}if(!$)H.info(`Active app in Capgo: ${Y.length}`),pED(Y),ND("Done ✅");return Y}vD();import{randomUUID as oED}from"node:crypto";import{existsSync as aa,readFileSync as ta}from"node:fs";fD();async function sa(D,$,X=!1){if(!X)VD("Set app");$.apikey=$.apikey||BD();let Y=await ID();if(D=iD(D,Y?.config),!$.apikey){if(!X)H.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!D){if(!X)H.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}let J=await jD($.apikey,$.supaHost,$.supaAnon),F=(await GZ(J,["admin","super_admin"])).gid,w=await xD(J,$.apikey,["write","all"]);await u0(J,$.apikey,D,4,X);let{name:Z,icon:G,retention:O,exposeMetadata:U}=$;if(O&&Number.isNaN(Number(O))){if(!X)H.error("retention value must be a number");throw Error("Retention value must be a number")}else if(O&&O<0){if(!X)H.error("retention value cannot be less than 0");throw Error("Retention value cannot be less than 0")}else if(O&&O>=63113904){if(!X)H.error("retention value cannot be greater than 63113904 seconds (2 years)");throw Error("Retention value cannot be greater than 63113904 seconds (2 years)")}let z,q,B=`icon_${oED()}`,K="https://xvwzpoazmxkqosrdewyv.supabase.co/storage/v1/object/public/images/capgo.png";if(G&&aa(G)){if(z=ta(G),q=M4(G)||"image/png",!X)H.warn(`Found app icon ${G}`)}else if(aa(G$)){if(z=ta(G$),q=M4(G$)||"image/png",!X)H.warn(`Found app icon ${G$}`)}else if(!X)H.warn(`Cannot find app icon in any of the following locations: ${G}, ${G$}`);if(z&&q){let{error:L}=await J.storage.from(`images/org/${F}/${D}`).upload(B,z,{contentType:q});if(L){if(!X)H.error(`Could not set app ${s(L)}`);throw Error(`Could not set app: ${s(L)}`)}let{data:I}=await J.storage.from(`images/org/${F}/${D}`).getPublicUrl(B);K=I?.publicUrl||K}let{error:M}=await J.from("apps").update({icon_url:K,name:Z,retention:!O?void 0:O*24*60*60,expose_metadata:U}).eq("app_id",D).eq("user_id",w);if(M){if(!X)H.error(`Could not set app ${s(M)}`);throw Error(`Could not set app: ${s(M)}`)}if(await RD($.apikey,{channel:"app",event:"App Updated",icon:"\uD83D\uDCDD",user_id:F,tags:{"app-id":D},notify:!1,notifyConsole:!0}).catch(()=>{}),!X)ND("Done ✅");return!0}vD();GF();fD();async function ea(D,$,X=!1){if(!X)VD("Set a specific setting in capacitor config");if($.bool&&$.string){if(!X)H.error("Bool and string CANNOT be set at the same time");throw Error("Bool and string cannot both be provided")}if(!$.bool&&!$.string){if(!X)H.error("You MUST provide either bool or string as the value");throw Error("Either bool or string value is required")}if($.bool&&$.bool!=="true"&&$.bool!=="false"){if(!X)H.error("Invalid bool");throw Error("Invalid bool value; expected true or false")}try{let Y=await ID(),J=Y.config,Q=D.split(".");if(Q.length===0){if(!X)H.error("Invalid path");throw Error("Invalid config path")}for(let w of Q.slice(0,-1)){if(!Object.prototype.hasOwnProperty.call(J,w))J[w]={};J=J[w]}let F=$.bool?$.bool==="true":$.string;if(J[Q.at(-1)]=F,await U5(Y,!0),!X)H.success(`Set "${D}" to "${F}"`)}catch(Y){if(!X)H.error(`Cannot set config in capacitor settings ${s(Y)}`);throw Error(`Cannot set capacitor config: ${s(Y)}`)}if(!X)ND("Done ✅")}vD();var Hs=V0(KO(),1);import{Buffer as Os}from"node:buffer";import{existsSync as W2,readdirSync as Ks,readFileSync as kCD,statSync as fCD}from"node:fs";import{mkdir as yCD,readFile as $L,rm as bCD,stat as gCD,writeFile as hCD}from"node:fs/promises";import{tmpdir as mCD}from"node:os";import{basename as Us,join as a$,resolve as dCD}from"node:path";import XL,{chdir as qs,cwd as Ws,exit as $oD}from"node:process";if(!globalThis.EventTarget||!globalThis.Event)console.error(`
443
443
  PartySocket requires a global 'EventTarget' class to be available!
444
444
  You can polyfill this global by adding this to your code before any partysocket imports:
445
445
 
@@ -460,12 +460,12 @@ const partysocket = new PartySocket({
460
460
  WebSocket: WS
461
461
  });
462
462
 
463
- `),Dt=!0;let Q=this._options.WebSocket||WebSocket;this._debug("connect",{url:Y,protocols:J}),this._ws=J?new Q(Y,J):new Q(Y),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),X)}).catch((Y)=>{this._connectLock=!1,this._handleError(new yM.ErrorEvent(Error(Y.message),this))})}_handleTimeout(){this._debug("timeout event"),this._handleError(new yM.ErrorEvent(Error("TIMEOUT"),this))}_disconnect($=1000,X){if(this._clearTimeouts(),!this._ws)return;this._removeListeners();try{if(this._ws.readyState===this.OPEN||this._ws.readyState===this.CONNECTING)this._ws.close($,X);this._handleClose(new yM.CloseEvent($,X,this))}catch(Y){}}_acceptOpen(){this._debug("accept open"),this._retryCount=0}_handleOpen=($)=>{this._debug("open event");let{minUptime:X=f8.minUptime}=this._options;if(clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),X),aED(this._ws,"WebSocket is not defined"),this._ws.binaryType=this._binaryType,this._messageQueue.forEach((Y)=>{this._ws?.send(Y)}),this._messageQueue=[],this.onopen)this.onopen($);this.dispatchEvent(zZ($))};_handleMessage=($)=>{if(this._debug("message event"),this.onmessage)this.onmessage($);this.dispatchEvent(zZ($))};_handleError=($)=>{if(this._debug("error event",$.message),this._disconnect(void 0,$.message==="TIMEOUT"?"timeout":void 0),this.onerror)this.onerror($);this._debug("exec error listeners"),this.dispatchEvent(zZ($)),this._connect()};_handleClose=($)=>{if(this._debug("close event"),this._clearTimeouts(),this._shouldReconnect)this._connect();if(this.onclose)this.onclose($);this.dispatchEvent(zZ($))};_removeListeners(){if(!this._ws)return;this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError)}_addListeners(){if(!this._ws)return;this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError)}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}};var CZ=V0(NY(),1);var MCD=V0(tt(),1),LCD=V0(cM(),1),ICD=V0(nM(),1),Qs=V0(RZ(),1),ACD=V0(Ys(),1);var Fs=Qs.default;fD();import{mkdir as drD,readFile as RCD,writeFile as crD}from"node:fs/promises";import{homedir as jCD}from"node:os";import{join as eM}from"node:path";import{cwd as ECD,env as TCD}from"node:process";var CCD=eM(jCD(),".capgo-credentials"),PCD=eM(CCD,"credentials.json"),xCD=".capgo-credentials.json",ws=3600,Zs=604800;function SCD(D){return D?eM(ECD(),xCD):PCD}function DL(D){let X=D.trim().match(/^(\d+)\s*([smhd])?$/i);if(!X)throw Error("output-retention must be a number with optional unit: s, m, h, d (examples: 1h, 3600s, 2d)");let Y=Number.parseInt(X[1],10),J=(X[2]||"s").toLowerCase(),F=Y*(J==="s"?1:J==="m"?60:J==="h"?3600:86400);if(F<ws)throw Error(`output-retention must be at least ${ws} seconds (1h)`);if(F>Zs)throw Error(`output-retention must be at most ${Zs} seconds (7d)`);return F}function B2(D){if(D===void 0)return!0;if(typeof D==="boolean")return D;let $=D.trim().toLowerCase();if($==="true"||$==="1"||$==="yes")return!0;if($==="false"||$==="0"||$==="no")return!1;throw Error("output-upload must be true/false (examples: --output-upload, --output-upload false)")}async function sM(D){try{let $=SCD(D),X=await RCD($,"utf-8");return JSON.parse(X)}catch{return{}}}async function uCD(D,$){if($!==void 0){let J=await sM($);if(!D){let Q=Object.keys(J);if(Q.length===0)return null;return J[Q[0]]||null}return J[D]||null}let X=await sM(!0),Y=await sM(!1);if(!D){let J=Object.keys(X);if(J.length>0)return X[J[0]]||null;let Q=Object.keys(Y);if(Q.length===0)return null;return Y[Q[0]]||null}return X[D]||Y[D]||null}function d0(D){return TCD[D]}function vCD(){let D={},$=d0("BUILD_CERTIFICATE_BASE64"),X=d0("BUILD_PROVISION_PROFILE_BASE64"),Y=d0("BUILD_PROVISION_PROFILE_BASE64_PROD"),J=d0("P12_PASSWORD"),Q=d0("APPLE_KEY_ID"),F=d0("APPLE_ISSUER_ID"),w=d0("APPLE_KEY_CONTENT"),Z=d0("APPLE_PROFILE_NAME"),G=d0("APP_STORE_CONNECT_TEAM_ID"),O=d0("CAPGO_IOS_SCHEME"),U=d0("CAPGO_IOS_TARGET"),z=d0("ANDROID_KEYSTORE_FILE"),q=d0("KEYSTORE_KEY_ALIAS"),B=d0("KEYSTORE_KEY_PASSWORD"),K=d0("KEYSTORE_STORE_PASSWORD"),M=d0("PLAY_CONFIG_JSON"),L=d0("BUILD_OUTPUT_UPLOAD_ENABLED"),I=d0("BUILD_OUTPUT_RETENTION_SECONDS"),W=d0("SKIP_BUILD_NUMBER_BUMP");if($)D.BUILD_CERTIFICATE_BASE64=$;if(X)D.BUILD_PROVISION_PROFILE_BASE64=X;if(Y)D.BUILD_PROVISION_PROFILE_BASE64_PROD=Y;if(J)D.P12_PASSWORD=J;if(Q)D.APPLE_KEY_ID=Q;if(F)D.APPLE_ISSUER_ID=F;if(w)D.APPLE_KEY_CONTENT=w;if(Z)D.APPLE_PROFILE_NAME=Z;if(G)D.APP_STORE_CONNECT_TEAM_ID=G;if(O)D.CAPGO_IOS_SCHEME=O;if(U)D.CAPGO_IOS_TARGET=U;if(z)D.ANDROID_KEYSTORE_FILE=z;if(q)D.KEYSTORE_KEY_ALIAS=q;if(B)D.KEYSTORE_KEY_PASSWORD=B;if(K)D.KEYSTORE_STORE_PASSWORD=K;if(M)D.PLAY_CONFIG_JSON=M;if(L)D.BUILD_OUTPUT_UPLOAD_ENABLED=B2(L)?"true":"false";if(I)D.BUILD_OUTPUT_RETENTION_SECONDS=String(DL(I));if(W)D.SKIP_BUILD_NUMBER_BUMP=B2(W)?"true":"false";return D}async function Gs(D,$,X){let Y=await uCD(D),J=vCD(),Q={...Y?.[$]||{}};if(Object.assign(Q,J),X)Object.assign(Q,X);if($==="android"){let F=!!Q.KEYSTORE_KEY_PASSWORD,w=!!Q.KEYSTORE_STORE_PASSWORD;if(F&&!w)Q.KEYSTORE_STORE_PASSWORD=Q.KEYSTORE_KEY_PASSWORD;else if(!F&&w)Q.KEYSTORE_KEY_PASSWORD=Q.KEYSTORE_STORE_PASSWORD}return Object.keys(Q).length>0?Q:void 0}var zs=Promise.resolve();async function cCD(D,$){let X=async()=>{let J=Ws();try{qs(D)}catch(Q){throw Error(`Failed to change working directory to "${D}": ${Q.message}`)}try{return await $()}finally{try{qs(J)}catch{}}},Y=zs.then(X,X);return zs=Y.then(()=>{return},()=>{return}),Y}async function lCD(D,$,X=3,Y=!1){let J=[1000,3000,5000];for(let Q=1;Q<=X;Q++)try{let F=await fetch(D,$);if(F.ok||F.status>=400&&F.status<500)return F;let w=await F.text().catch(()=>"unknown error");if(!Y)H.warn(`Build request attempt ${Q}/${X} failed: ${F.status} - ${w}`);if(Q<X){let Z=J[Q-1]||5000;if(!Y)H.info(`Retrying in ${Z/1000}s...`);await new Promise((G)=>setTimeout(G,Z))}else throw Error(`Failed to request build after ${X} attempts: ${F.status} - ${w}`)}catch(F){let w=F instanceof Error?F.message:String(F);if(w.startsWith("Failed to request build after"))throw F;if(!Y)H.warn(`Build request attempt ${Q}/${X} failed: ${w}`);if(Q<X){let Z=J[Q-1]||5000;if(!Y)H.info(`Retrying in ${Z/1000}s...`);await new Promise((G)=>setTimeout(G,Z))}else throw Error(`Failed to request build after ${X} attempts: ${w}`)}throw Error("Unexpected error in fetchWithRetry")}var nCD=["succeeded","failed","expired","released","cancelled"],TZ=new Set(nCD);async function iCD(D,$=!1,X,Y,J,Q,F){if(D)return null;let w=null,Z=!1,G=(U)=>{if(!U.trim())return;if(w)return;if(!Z)Z=!0,console.log("");console.log(U)},O=async()=>{if(!X||!Y)return null;let U=X.replace(/\/+$/,""),z=`${U}/start`,B=`${U}/stream?token=${encodeURIComponent(Y)}`.replace(/^https:/,"wss:").replace(/^http:/,"ws:");if(!D)console.log("Connecting to log streaming...");let K=await fetch(z,{method:"POST",headers:{"x-capgo-log-token":Y}});if(!K.ok){let M=await K.text().catch(()=>"unknown error");if(!D)console.warn(`Could not start log session (${K.status}): ${M}`);return null}return await new Promise((M)=>{let L=!1,I=10,W=0,N=!1,V=new a5(B,void 0,{maxRetries:I,WebSocket:Fs}),R=null,P=0,A=Date.now(),_=!1,v=2000,S=4,h=TZ,g=null,l=null,f=(x)=>{if(L)return;if(L=!0,l)clearTimeout(l),l=null;if(R)clearInterval(R),R=null;if(Q&&g)Q.removeEventListener("abort",g),g=null;try{V.close()}catch{}M(x)};if(l=setTimeout(()=>{if(!L){if(!D)console.warn("Log streaming timed out after 3 hours");f(null)}},10800000),(()=>{if(R)return;R=setInterval(async()=>{try{if(V.readyState===a5.OPEN)V.send(JSON.stringify({type:"heartbeat",lastId:P}));let x=Date.now();if(J&&!_&&x-A>=v*S){_=!0;try{let u=await J();if(u&&h.has(u))w=u,f(w)}finally{_=!1}}}catch(x){if(!D)H.warn(`Heartbeat encountered an error, continuing... ${String(x)}`)}},v)})(),Q){if(g=()=>{if(!L)f("cancelled")},Q.aborted){f("cancelled");return}Q.addEventListener("abort",g)}V.addEventListener("message",(x)=>{let u="";if(typeof x.data==="string")u=x.data;else if(x.data instanceof ArrayBuffer)u=new TextDecoder().decode(x.data);else if(ArrayBuffer.isView(x.data)){let b=x.data;u=new TextDecoder().decode(new Uint8Array(b.buffer,b.byteOffset,b.byteLength))}else if(x.data&&typeof x.data.toString==="function")u=x.data.toString();let y=null;try{y=JSON.parse(u)}catch{y=null}let d=(b)=>{if(b.type==="status"&&typeof b.status==="string"){let a=b.status.toLowerCase();if(A=Date.now(),h.has(a))w=a;return}if(b.type==="log"&&typeof b.message==="string"){A=Date.now(),G(b.message);return}if(typeof b.message==="string")A=Date.now(),G(b.message)};if(y?.type==="heartbeat_response")return;if(y?.type==="batch_messages"&&Array.isArray(y.messages)){let b=P;for(let a of y.messages)if(d(a),typeof a.id==="number")b=Math.max(b,a.id);if(b>P){if(P=b,V.readyState===a5.OPEN)try{V.send(JSON.stringify({type:"confirmed_received",lastId:b}))}catch(a){if(!D)H.warn(`Failed to send log confirmation, continuing... ${String(a)}`)}}}else{if(y)d(y);else if(u)A=Date.now(),G(u);if(y&&typeof y.id==="number"){if(P=y.id,V.readyState===a5.OPEN)try{V.send(JSON.stringify({type:"confirmed_received",lastId:y.id}))}catch(b){if(!D)H.warn(`Failed to send log confirmation, continuing... ${String(b)}`)}}}if(w)f(w)}),V.addEventListener("error",()=>{if(W+=1,!D)console.warn(`Log stream encountered an error, retrying (${W}/${I})...`);if(!N&&W>=I){if(N=!0,!D)H.warn("Log stream retry limit reached. Falling back to status checks.");if(F)F();f(null)}}),V.addEventListener("close",()=>{if(L)return;if(w){f(w);return}if(!D)H.warn("Log stream closed, waiting for reconnect...")})})};try{let U=await O();if(U||w)return U||w}catch(U){if(!D)H.warn(`Direct log streaming failed${U instanceof Error?`: ${U.message}`:""}`)}return w}async function pCD(D,$,X,Y,J,Q,F=!1,w){let G=0;while(G<120){if(w?.aborted)return"cancelled";try{let O=await fetch(`${D}/build/status?job_id=${encodeURIComponent($)}&app_id=${encodeURIComponent(X)}&platform=${Y}`,{headers:{authorization:J},signal:w});if(!O.ok){if(!Q)H.warn(`Status check failed: ${O.status}`);await new Promise((q)=>setTimeout(q,5000)),G++;continue}let U=await O.json(),z=U.status?.toLowerCase?.()??"";if(!Q&&F)H.info(`Build status: ${z||U.status}`);if(TZ.has(z))return z;await new Promise((q)=>setTimeout(q,5000)),G++}catch(O){if(w?.aborted)return"cancelled";if(!Q)H.warn(`Status check error: ${O}`);await new Promise((U)=>setTimeout(U,5000)),G++}}if(!Q)H.warn("Build status polling timed out");return"timeout"}async function rCD(D,$,X){let Y=new Set,J=!1,Q=!1;if($==="ios"){let F=a$(D,X,"App","CapApp-SPM","Package.swift");if(W2(F)){J=!0;let G=(await $L(F,"utf-8")).matchAll(/\.package\s*\([^)]*path:\s*["'](?:\.\.\/)*node_modules\/([^"']+)["']\s*\)/g);for(let O of G){let U=O[1],z=U.lastIndexOf("node_modules/");if(z!==-1)U=U.substring(z+13);Y.add(U)}}let w=a$(D,X);if(W2(w)){let Z=[a$(w,"App","Podfile"),a$(w,"Podfile")];for(let O of Ks(w,{withFileTypes:!0}))if(O.isDirectory())Z.push(a$(w,O.name,"Podfile"));let G=[...new Set(Z)].filter((O)=>W2(O));if(G.length>0)Q=!0;for(let O of G){let z=(await $L(O,"utf-8")).matchAll(/pod\s+['"][^'"]+['"],\s*:path\s*=>\s*['"](?:\.\.\/)+node_modules\/([^'"]+)['"]/g);for(let q of z){let B=q[1],K=B.lastIndexOf("node_modules/");if(K!==-1)B=B.substring(K+13);Y.add(B)}}}}else if($==="android"){let F=a$(D,X,"capacitor.settings.gradle");if(W2(F)){let Z=(await $L(F,"utf-8")).matchAll(/new\s+File\s*\(\s*['"]\.\.\/node_modules\/([^'"]+)['"]\s*\)/g);for(let G of Z){let O=G[1],U=O.lastIndexOf("node_modules/");if(U!==-1)O=O.substring(U+13);let z=O.replace(/\/(android|capacitor)$/,"");Y.add(z)}}}return{packages:Y,usesSPM:J,usesCocoaPods:Q}}function Bs(D,$,X,Y){let J=D.replace(/\\/g,"/");if(J.startsWith(`${Y}/`))return!0;if(J==="package.json"||J==="package-lock.json"||J.startsWith("capacitor.config."))return!0;if(J.startsWith("resources/"))return!0;if($==="ios"&&J.startsWith("node_modules/@capacitor/ios/"))return!0;if($==="android"&&J.startsWith("node_modules/@capacitor/android/"))return!0;for(let Q of X.packages){let F=`node_modules/${Q}/`;if(J===`${F}package.json`)return!0;if($==="android"){if(J.startsWith(`${F}android/`))return!0}else if($==="ios"){if(J.startsWith(`${F}ios/`))return!0;if(X.usesSPM){if(J===`${F}Package.swift`)return!0}if(X.usesCocoaPods||!X.usesSPM){if(J.startsWith(F)&&J.endsWith(".podspec"))return!0}}}return!1}function EZ(D,$,X,Y,J,Q){let F=Ks($);for(let w of F){let Z=a$($,w),G=X?`${X}/${w}`:w,O=fCD(Z);if(O.isDirectory()){if(w===".git"||w==="dist"||w==="build"||w===".angular"||w===".vite"||w===".gradle"||w===".idea"||w===".swiftpm")continue;if(w==="node_modules"){EZ(D,Z,G,Y,J,Q);continue}if(w==="resources"){EZ(D,Z,G,Y,J,Q);continue}let U=G.replace(/\\/g,"/");if(Bs(G,Y,J,Q)||Q===U||Q.startsWith(`${U}/`)||Array.from(J.packages).some((q)=>{return`node_modules/${q}/`.startsWith(`${U}/`)||U.startsWith(`node_modules/${q}`)}))EZ(D,Z,G,Y,J,Q)}else if(O.isFile()){if(w===".DS_Store"||w.endsWith(".log"))continue;if(Bs(G,Y,J,Q))D.addLocalFile(Z,X||void 0)}}}async function oCD(D,$,X,Y){let J=K2(Y,X),Q=await rCD(D,X,J),F=new Hs.default;EZ(F,D,"",X,Q,J);let w=/node_modules\/\.pnpm\/[^/\n\r]+(?:\/[^/\n\r]+)*\/node_modules\//g,Z=new Set(["",".gradle",".swift",".json",".lock",".xml",".properties",".pbxproj",".xcconfig",".plist",".podspec",".rb",".yaml",".yml"]);for(let O of F.getEntries()){if(O.isDirectory)continue;let U=O.entryName.includes(".")?`.${O.entryName.split(".").pop()}`:"",z=O.entryName.split("/").pop()||"";if(!Z.has(U)&&z!=="Podfile")continue;let q=O.getData().toString("utf-8"),B=q.replace(w,"node_modules/");if(X==="ios")B=B.replace(/(?:\.\.\/){4,}(ios\/)/g,"../../../$1");if(B!==q)F.updateFile(O.entryName,Os.from(B,"utf-8"))}let G=a$(D,"capacitor.config.json");if(Y&&!W2(G)){let O=`${JSON.stringify(Y,null,2)}
463
+ `),Dt=!0;let Q=this._options.WebSocket||WebSocket;this._debug("connect",{url:Y,protocols:J}),this._ws=J?new Q(Y,J):new Q(Y),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),X)}).catch((Y)=>{this._connectLock=!1,this._handleError(new yM.ErrorEvent(Error(Y.message),this))})}_handleTimeout(){this._debug("timeout event"),this._handleError(new yM.ErrorEvent(Error("TIMEOUT"),this))}_disconnect($=1000,X){if(this._clearTimeouts(),!this._ws)return;this._removeListeners();try{if(this._ws.readyState===this.OPEN||this._ws.readyState===this.CONNECTING)this._ws.close($,X);this._handleClose(new yM.CloseEvent($,X,this))}catch(Y){}}_acceptOpen(){this._debug("accept open"),this._retryCount=0}_handleOpen=($)=>{this._debug("open event");let{minUptime:X=f8.minUptime}=this._options;if(clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),X),aED(this._ws,"WebSocket is not defined"),this._ws.binaryType=this._binaryType,this._messageQueue.forEach((Y)=>{this._ws?.send(Y)}),this._messageQueue=[],this.onopen)this.onopen($);this.dispatchEvent(zZ($))};_handleMessage=($)=>{if(this._debug("message event"),this.onmessage)this.onmessage($);this.dispatchEvent(zZ($))};_handleError=($)=>{if(this._debug("error event",$.message),this._disconnect(void 0,$.message==="TIMEOUT"?"timeout":void 0),this.onerror)this.onerror($);this._debug("exec error listeners"),this.dispatchEvent(zZ($)),this._connect()};_handleClose=($)=>{if(this._debug("close event"),this._clearTimeouts(),this._shouldReconnect)this._connect();if(this.onclose)this.onclose($);this.dispatchEvent(zZ($))};_removeListeners(){if(!this._ws)return;this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError)}_addListeners(){if(!this._ws)return;this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError)}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}};var CZ=V0(NY(),1);var MCD=V0(tt(),1),LCD=V0(cM(),1),ICD=V0(nM(),1),Qs=V0(RZ(),1),ACD=V0(Ys(),1);var Fs=Qs.default;fD();import{mkdir as drD,readFile as RCD,writeFile as crD}from"node:fs/promises";import{homedir as jCD}from"node:os";import{join as eM}from"node:path";import{cwd as ECD,env as TCD}from"node:process";var CCD=eM(jCD(),".capgo-credentials"),PCD=eM(CCD,"credentials.json"),xCD=".capgo-credentials.json",ws=3600,Zs=604800;function SCD(D){return D?eM(ECD(),xCD):PCD}function DL(D){let X=D.trim().match(/^(\d+)\s*([smhd])?$/i);if(!X)throw Error("output-retention must be a number with optional unit: s, m, h, d (examples: 1h, 3600s, 2d)");let Y=Number.parseInt(X[1],10),J=(X[2]||"s").toLowerCase(),F=Y*(J==="s"?1:J==="m"?60:J==="h"?3600:86400);if(F<ws)throw Error(`output-retention must be at least ${ws} seconds (1h)`);if(F>Zs)throw Error(`output-retention must be at most ${Zs} seconds (7d)`);return F}function B2(D){if(D===void 0)return!0;if(typeof D==="boolean")return D;let $=D.trim().toLowerCase();if($==="true"||$==="1"||$==="yes")return!0;if($==="false"||$==="0"||$==="no")return!1;throw Error("output-upload must be true/false (examples: --output-upload, --output-upload false)")}async function sM(D){try{let $=SCD(D),X=await RCD($,"utf-8");return JSON.parse(X)}catch{return{}}}async function uCD(D,$){if($!==void 0){let J=await sM($);if(!D){let Q=Object.keys(J);if(Q.length===0)return null;return J[Q[0]]||null}return J[D]||null}let X=await sM(!0),Y=await sM(!1);if(!D){let J=Object.keys(X);if(J.length>0)return X[J[0]]||null;let Q=Object.keys(Y);if(Q.length===0)return null;return Y[Q[0]]||null}return X[D]||Y[D]||null}function b0(D){return TCD[D]}function vCD(){let D={},$=b0("BUILD_CERTIFICATE_BASE64"),X=b0("BUILD_PROVISION_PROFILE_BASE64"),Y=b0("BUILD_PROVISION_PROFILE_BASE64_PROD"),J=b0("P12_PASSWORD"),Q=b0("APPLE_KEY_ID"),F=b0("APPLE_ISSUER_ID"),w=b0("APPLE_KEY_CONTENT"),Z=b0("APPLE_PROFILE_NAME"),G=b0("APP_STORE_CONNECT_TEAM_ID"),O=b0("CAPGO_IOS_SCHEME"),U=b0("CAPGO_IOS_TARGET"),z=b0("ANDROID_KEYSTORE_FILE"),q=b0("KEYSTORE_KEY_ALIAS"),B=b0("KEYSTORE_KEY_PASSWORD"),K=b0("KEYSTORE_STORE_PASSWORD"),M=b0("PLAY_CONFIG_JSON"),L=b0("BUILD_OUTPUT_UPLOAD_ENABLED"),I=b0("BUILD_OUTPUT_RETENTION_SECONDS"),W=b0("SKIP_BUILD_NUMBER_BUMP"),N=b0("CAPGO_IOS_DISTRIBUTION");if($)D.BUILD_CERTIFICATE_BASE64=$;if(X)D.BUILD_PROVISION_PROFILE_BASE64=X;if(Y)D.BUILD_PROVISION_PROFILE_BASE64_PROD=Y;if(J)D.P12_PASSWORD=J;if(Q)D.APPLE_KEY_ID=Q;if(F)D.APPLE_ISSUER_ID=F;if(w)D.APPLE_KEY_CONTENT=w;if(Z)D.APPLE_PROFILE_NAME=Z;if(G)D.APP_STORE_CONNECT_TEAM_ID=G;if(O)D.CAPGO_IOS_SCHEME=O;if(U)D.CAPGO_IOS_TARGET=U;if(N)D.CAPGO_IOS_DISTRIBUTION=N;if(z)D.ANDROID_KEYSTORE_FILE=z;if(q)D.KEYSTORE_KEY_ALIAS=q;if(B)D.KEYSTORE_KEY_PASSWORD=B;if(K)D.KEYSTORE_STORE_PASSWORD=K;if(M)D.PLAY_CONFIG_JSON=M;if(L)D.BUILD_OUTPUT_UPLOAD_ENABLED=B2(L)?"true":"false";if(I)D.BUILD_OUTPUT_RETENTION_SECONDS=String(DL(I));if(W)D.SKIP_BUILD_NUMBER_BUMP=B2(W)?"true":"false";return D}async function Gs(D,$,X){let Y=await uCD(D),J=vCD(),Q={...Y?.[$]||{}};if(Object.assign(Q,J),X)Object.assign(Q,X);if($==="android"){let F=!!Q.KEYSTORE_KEY_PASSWORD,w=!!Q.KEYSTORE_STORE_PASSWORD;if(F&&!w)Q.KEYSTORE_STORE_PASSWORD=Q.KEYSTORE_KEY_PASSWORD;else if(!F&&w)Q.KEYSTORE_KEY_PASSWORD=Q.KEYSTORE_STORE_PASSWORD}return Object.keys(Q).length>0?Q:void 0}var zs=Promise.resolve();async function cCD(D,$){let X=async()=>{let J=Ws();try{qs(D)}catch(Q){throw Error(`Failed to change working directory to "${D}": ${Q.message}`)}try{return await $()}finally{try{qs(J)}catch{}}},Y=zs.then(X,X);return zs=Y.then(()=>{return},()=>{return}),Y}async function lCD(D,$,X=3,Y=!1){let J=[1000,3000,5000];for(let Q=1;Q<=X;Q++)try{let F=await fetch(D,$);if(F.ok||F.status>=400&&F.status<500)return F;let w=await F.text().catch(()=>"unknown error");if(!Y)H.warn(`Build request attempt ${Q}/${X} failed: ${F.status} - ${w}`);if(Q<X){let Z=J[Q-1]||5000;if(!Y)H.info(`Retrying in ${Z/1000}s...`);await new Promise((G)=>setTimeout(G,Z))}else throw Error(`Failed to request build after ${X} attempts: ${F.status} - ${w}`)}catch(F){let w=F instanceof Error?F.message:String(F);if(w.startsWith("Failed to request build after"))throw F;if(!Y)H.warn(`Build request attempt ${Q}/${X} failed: ${w}`);if(Q<X){let Z=J[Q-1]||5000;if(!Y)H.info(`Retrying in ${Z/1000}s...`);await new Promise((G)=>setTimeout(G,Z))}else throw Error(`Failed to request build after ${X} attempts: ${w}`)}throw Error("Unexpected error in fetchWithRetry")}var nCD=["succeeded","failed","expired","released","cancelled"],TZ=new Set(nCD);async function iCD(D,$=!1,X,Y,J,Q,F){if(D)return null;let w=null,Z=!1,G=(U)=>{if(!U.trim())return;if(w)return;if(!Z)Z=!0,console.log("");console.log(U)},O=async()=>{if(!X||!Y)return null;let U=X.replace(/\/+$/,""),z=`${U}/start`,B=`${U}/stream?token=${encodeURIComponent(Y)}`.replace(/^https:/,"wss:").replace(/^http:/,"ws:");if(!D)console.log("Connecting to log streaming...");let K=await fetch(z,{method:"POST",headers:{"x-capgo-log-token":Y}});if(!K.ok){let M=await K.text().catch(()=>"unknown error");if(!D)console.warn(`Could not start log session (${K.status}): ${M}`);return null}return await new Promise((M)=>{let L=!1,I=10,W=0,N=!1,V=new a5(B,void 0,{maxRetries:I,WebSocket:Fs}),R=null,C=0,A=Date.now(),_=!1,v=2000,S=4,h=TZ,g=null,l=null,f=(x)=>{if(L)return;if(L=!0,l)clearTimeout(l),l=null;if(R)clearInterval(R),R=null;if(Q&&g)Q.removeEventListener("abort",g),g=null;try{V.close()}catch{}M(x)};if(l=setTimeout(()=>{if(!L){if(!D)console.warn("Log streaming timed out after 3 hours");f(null)}},10800000),(()=>{if(R)return;R=setInterval(async()=>{try{if(V.readyState===a5.OPEN)V.send(JSON.stringify({type:"heartbeat",lastId:C}));let x=Date.now();if(J&&!_&&x-A>=v*S){_=!0;try{let u=await J();if(u&&h.has(u))w=u,f(w)}finally{_=!1}}}catch(x){if(!D)H.warn(`Heartbeat encountered an error, continuing... ${String(x)}`)}},v)})(),Q){if(g=()=>{if(!L)f("cancelled")},Q.aborted){f("cancelled");return}Q.addEventListener("abort",g)}V.addEventListener("message",(x)=>{let u="";if(typeof x.data==="string")u=x.data;else if(x.data instanceof ArrayBuffer)u=new TextDecoder().decode(x.data);else if(ArrayBuffer.isView(x.data)){let b=x.data;u=new TextDecoder().decode(new Uint8Array(b.buffer,b.byteOffset,b.byteLength))}else if(x.data&&typeof x.data.toString==="function")u=x.data.toString();let y=null;try{y=JSON.parse(u)}catch{y=null}let d=(b)=>{if(b.type==="status"&&typeof b.status==="string"){let a=b.status.toLowerCase();if(A=Date.now(),h.has(a))w=a;return}if(b.type==="log"&&typeof b.message==="string"){A=Date.now(),G(b.message);return}if(typeof b.message==="string")A=Date.now(),G(b.message)};if(y?.type==="heartbeat_response")return;if(y?.type==="batch_messages"&&Array.isArray(y.messages)){let b=C;for(let a of y.messages)if(d(a),typeof a.id==="number")b=Math.max(b,a.id);if(b>C){if(C=b,V.readyState===a5.OPEN)try{V.send(JSON.stringify({type:"confirmed_received",lastId:b}))}catch(a){if(!D)H.warn(`Failed to send log confirmation, continuing... ${String(a)}`)}}}else{if(y)d(y);else if(u)A=Date.now(),G(u);if(y&&typeof y.id==="number"){if(C=y.id,V.readyState===a5.OPEN)try{V.send(JSON.stringify({type:"confirmed_received",lastId:y.id}))}catch(b){if(!D)H.warn(`Failed to send log confirmation, continuing... ${String(b)}`)}}}if(w)f(w)}),V.addEventListener("error",()=>{if(W+=1,!D)console.warn(`Log stream encountered an error, retrying (${W}/${I})...`);if(!N&&W>=I){if(N=!0,!D)H.warn("Log stream retry limit reached. Falling back to status checks.");if(F)F();f(null)}}),V.addEventListener("close",()=>{if(L)return;if(w){f(w);return}if(!D)H.warn("Log stream closed, waiting for reconnect...")})})};try{let U=await O();if(U||w)return U||w}catch(U){if(!D)H.warn(`Direct log streaming failed${U instanceof Error?`: ${U.message}`:""}`)}return w}async function pCD(D,$,X,Y,J,Q,F=!1,w){let G=0;while(G<120){if(w?.aborted)return"cancelled";try{let O=await fetch(`${D}/build/status?job_id=${encodeURIComponent($)}&app_id=${encodeURIComponent(X)}&platform=${Y}`,{headers:{authorization:J},signal:w});if(!O.ok){if(!Q)H.warn(`Status check failed: ${O.status}`);await new Promise((q)=>setTimeout(q,5000)),G++;continue}let U=await O.json(),z=U.status?.toLowerCase?.()??"";if(!Q&&F)H.info(`Build status: ${z||U.status}`);if(TZ.has(z))return z;await new Promise((q)=>setTimeout(q,5000)),G++}catch(O){if(w?.aborted)return"cancelled";if(!Q)H.warn(`Status check error: ${O}`);await new Promise((U)=>setTimeout(U,5000)),G++}}if(!Q)H.warn("Build status polling timed out");return"timeout"}async function rCD(D,$,X){let Y=new Set,J=!1,Q=!1;if($==="ios"){let F=a$(D,X,"App","CapApp-SPM","Package.swift");if(W2(F)){J=!0;let G=(await $L(F,"utf-8")).matchAll(/\.package\s*\([^)]*path:\s*["'](?:\.\.\/)*node_modules\/([^"']+)["']\s*\)/g);for(let O of G){let U=O[1],z=U.lastIndexOf("node_modules/");if(z!==-1)U=U.substring(z+13);Y.add(U)}}let w=a$(D,X);if(W2(w)){let Z=[a$(w,"App","Podfile"),a$(w,"Podfile")];for(let O of Ks(w,{withFileTypes:!0}))if(O.isDirectory())Z.push(a$(w,O.name,"Podfile"));let G=[...new Set(Z)].filter((O)=>W2(O));if(G.length>0)Q=!0;for(let O of G){let z=(await $L(O,"utf-8")).matchAll(/pod\s+['"][^'"]+['"],\s*:path\s*=>\s*['"](?:\.\.\/)+node_modules\/([^'"]+)['"]/g);for(let q of z){let B=q[1],K=B.lastIndexOf("node_modules/");if(K!==-1)B=B.substring(K+13);Y.add(B)}}}}else if($==="android"){let F=a$(D,X,"capacitor.settings.gradle");if(W2(F)){let Z=(await $L(F,"utf-8")).matchAll(/new\s+File\s*\(\s*['"]\.\.\/node_modules\/([^'"]+)['"]\s*\)/g);for(let G of Z){let O=G[1],U=O.lastIndexOf("node_modules/");if(U!==-1)O=O.substring(U+13);let z=O.replace(/\/(android|capacitor)$/,"");Y.add(z)}}}return{packages:Y,usesSPM:J,usesCocoaPods:Q}}function Bs(D,$,X,Y){let J=D.replace(/\\/g,"/");if(J.startsWith(`${Y}/`))return!0;if(J==="package.json"||J==="package-lock.json"||J.startsWith("capacitor.config."))return!0;if(J.startsWith("resources/"))return!0;if($==="ios"&&J.startsWith("node_modules/@capacitor/ios/"))return!0;if($==="android"&&J.startsWith("node_modules/@capacitor/android/"))return!0;for(let Q of X.packages){let F=`node_modules/${Q}/`;if(J===`${F}package.json`)return!0;if($==="android"){if(J.startsWith(`${F}android/`))return!0}else if($==="ios"){if(J.startsWith(`${F}ios/`))return!0;if(X.usesSPM){if(J===`${F}Package.swift`)return!0}if(X.usesCocoaPods||!X.usesSPM){if(J.startsWith(F)&&J.endsWith(".podspec"))return!0}}}return!1}function EZ(D,$,X,Y,J,Q){let F=Ks($);for(let w of F){let Z=a$($,w),G=X?`${X}/${w}`:w,O=fCD(Z);if(O.isDirectory()){if(w===".git"||w==="dist"||w==="build"||w===".angular"||w===".vite"||w===".gradle"||w===".idea"||w===".swiftpm")continue;if(w==="node_modules"){EZ(D,Z,G,Y,J,Q);continue}if(w==="resources"){EZ(D,Z,G,Y,J,Q);continue}let U=G.replace(/\\/g,"/");if(Bs(G,Y,J,Q)||Q===U||Q.startsWith(`${U}/`)||Array.from(J.packages).some((q)=>{return`node_modules/${q}/`.startsWith(`${U}/`)||U.startsWith(`node_modules/${q}`)}))EZ(D,Z,G,Y,J,Q)}else if(O.isFile()){if(w===".DS_Store"||w.endsWith(".log"))continue;if(Bs(G,Y,J,Q))D.addLocalFile(Z,X||void 0)}}}async function oCD(D,$,X,Y){let J=K2(Y,X),Q=await rCD(D,X,J),F=new Hs.default;EZ(F,D,"",X,Q,J);let w=/node_modules\/\.pnpm\/[^/\n\r]+(?:\/[^/\n\r]+)*\/node_modules\//g,Z=new Set(["",".gradle",".swift",".json",".lock",".xml",".properties",".pbxproj",".xcconfig",".plist",".podspec",".rb",".yaml",".yml"]);for(let O of F.getEntries()){if(O.isDirectory)continue;let U=O.entryName.includes(".")?`.${O.entryName.split(".").pop()}`:"",z=O.entryName.split("/").pop()||"";if(!Z.has(U)&&z!=="Podfile")continue;let q=O.getData().toString("utf-8"),B=q.replace(w,"node_modules/");if(X==="ios")B=B.replace(/(?:\.\.\/){4,}(ios\/)/g,"../../../$1");if(B!==q)F.updateFile(O.entryName,Os.from(B,"utf-8"))}let G=a$(D,"capacitor.config.json");if(Y&&!W2(G)){let O=`${JSON.stringify(Y,null,2)}
464
464
  `;F.addFile("capacitor.config.json",Os.from(O,"utf-8"))}await hCD($,F.toBuffer())}async function Vs(D,$,X=!1){let Y=Date.now(),J=$.verbose??!1;try{$.apikey=$.apikey||BD(X);let Q=dCD($.path||Ws()),F=await cCD(Q,()=>ID());if(D=D||F?.config?.appId,!D)throw Error("Missing argument, you need to provide a appId, or be in a capacitor project");if(!$.platform)throw Error("Missing required argument: --platform <ios|android>");if($.platform!=="ios"&&$.platform!=="android")throw Error(`Invalid platform "${$.platform}". Must be "ios" or "android"`);let w=$.supaHost||"https://api.capgo.app",Z=await jD($.apikey,$.supaHost,$.supaAnon);await xD(Z,$.apikey,["write","all"]);let G=await o0(Z,D);if(!X)H.info(`Requesting native build for ${D}`),H.info(`Platform: ${$.platform}`),H.info(`Project: ${Q}`),H.info(`
465
465
  \uD83D\uDD12 Security: Credentials are never stored on Capgo servers`),H.info(" They are used only during build and deleted after"),H.info(` Build outputs can optionally be uploaded for time-limited download links
466
- `);if(J)H.info(`API host: ${w}`);let O={};if($.buildCertificateBase64)O.BUILD_CERTIFICATE_BASE64=$.buildCertificateBase64;if($.buildProvisionProfileBase64)O.BUILD_PROVISION_PROFILE_BASE64=$.buildProvisionProfileBase64;if($.buildProvisionProfileBase64Prod)O.BUILD_PROVISION_PROFILE_BASE64_PROD=$.buildProvisionProfileBase64Prod;if($.p12Password)O.P12_PASSWORD=$.p12Password;if($.appleKeyId)O.APPLE_KEY_ID=$.appleKeyId;if($.appleIssuerId)O.APPLE_ISSUER_ID=$.appleIssuerId;if($.appleKeyContent)O.APPLE_KEY_CONTENT=$.appleKeyContent;if($.appleProfileName)O.APPLE_PROFILE_NAME=$.appleProfileName;if($.appStoreConnectTeamId)O.APP_STORE_CONNECT_TEAM_ID=$.appStoreConnectTeamId;if($.iosScheme)O.CAPGO_IOS_SCHEME=$.iosScheme;if($.iosTarget)O.CAPGO_IOS_TARGET=$.iosTarget;if($.androidKeystoreFile)O.ANDROID_KEYSTORE_FILE=$.androidKeystoreFile;if($.keystoreKeyAlias)O.KEYSTORE_KEY_ALIAS=$.keystoreKeyAlias;let U=!!$.keystoreKeyPassword,z=!!$.keystoreStorePassword;if(U&&!z)O.KEYSTORE_KEY_PASSWORD=$.keystoreKeyPassword,O.KEYSTORE_STORE_PASSWORD=$.keystoreKeyPassword;else if(!U&&z)O.KEYSTORE_KEY_PASSWORD=$.keystoreStorePassword,O.KEYSTORE_STORE_PASSWORD=$.keystoreStorePassword;else if(U&&z)O.KEYSTORE_KEY_PASSWORD=$.keystoreKeyPassword,O.KEYSTORE_STORE_PASSWORD=$.keystoreStorePassword;if($.playConfigJson)O.PLAY_CONFIG_JSON=$.playConfigJson;if($.outputUpload!==void 0)O.BUILD_OUTPUT_UPLOAD_ENABLED=B2($.outputUpload)?"true":"false";if($.outputRetention)O.BUILD_OUTPUT_RETENTION_SECONDS=String(DL($.outputRetention));if($.skipBuildNumberBump!==void 0)O.SKIP_BUILD_NUMBER_BUMP=B2($.skipBuildNumberBump)?"true":"false";let q=await Gs(D,$.platform,Object.keys(O).length>0?O:void 0),B=K2(F?.config,$.platform);if(q&&B)if($.platform==="ios")q.CAPGO_IOS_SOURCE_DIR=B,q.CAPGO_IOS_APP_DIR=B,q.CAPGO_IOS_PROJECT_DIR=B,q.IOS_PROJECT_DIR=B;else q.CAPGO_ANDROID_SOURCE_DIR=B,q.CAPGO_ANDROID_APP_DIR=B,q.CAPGO_ANDROID_PROJECT_DIR=B,q.ANDROID_PROJECT_DIR=B;let K={app_id:D,platform:$.platform,build_mode:$.buildMode};if(!q){if(!X)H.error("❌ No credentials found for this app and platform"),H.error(""),H.error("You must provide credentials via:"),H.error(" 1. CLI arguments (--apple-key-id, --p12-password, etc.)"),H.error(" 2. Environment variables (APPLE_KEY_ID, P12_PASSWORD, etc.)"),H.error(" 3. Saved credentials file:"),H.error(` npx @capgo/cli build credentials save --appId ${D} --platform ${$.platform}`),H.error(""),H.error("Documentation:"),H.error(" https://capgo.app/docs/cli/cloud-build/credentials/");throw Error("No credentials found. Please provide credentials before building.")}let M=[];if($.platform==="ios"){if(!q.BUILD_CERTIFICATE_BASE64)M.push("BUILD_CERTIFICATE_BASE64 (or --build-certificate-base64)");if(!q.P12_PASSWORD&&!X)H.warn("⚠️ P12_PASSWORD not provided - assuming certificate has no password"),H.warn(" If your certificate requires a password, provide it with --p12-password");if(!q.BUILD_PROVISION_PROFILE_BASE64)M.push("BUILD_PROVISION_PROFILE_BASE64 (or --build-provision-profile-base64)");if(!q.APPLE_KEY_ID)M.push("APPLE_KEY_ID (or --apple-key-id)");if(!q.APPLE_ISSUER_ID)M.push("APPLE_ISSUER_ID (or --apple-issuer-id)");if(!q.APPLE_KEY_CONTENT)M.push("APPLE_KEY_CONTENT (or --apple-key-content)");if(!q.APP_STORE_CONNECT_TEAM_ID)M.push("APP_STORE_CONNECT_TEAM_ID (or --apple-team-id)")}else if($.platform==="android"){if(!q.ANDROID_KEYSTORE_FILE)M.push("ANDROID_KEYSTORE_FILE (or --android-keystore-file)");if(!q.KEYSTORE_KEY_ALIAS)M.push("KEYSTORE_KEY_ALIAS (or --keystore-key-alias)");if(!q.KEYSTORE_KEY_PASSWORD&&!q.KEYSTORE_STORE_PASSWORD)M.push("KEYSTORE_KEY_PASSWORD or KEYSTORE_STORE_PASSWORD (at least one password required)");if(!q.PLAY_CONFIG_JSON){if(q.BUILD_OUTPUT_UPLOAD_ENABLED!=="true")M.push("PLAY_CONFIG_JSON or BUILD_OUTPUT_UPLOAD_ENABLED=true (build has no output destination - enable either Play Store upload or Capgo download link)");else if(!X)H.warn("⚠️ PLAY_CONFIG_JSON not provided - build will succeed but cannot auto-upload to Play Store")}}if(M.length>0){if(!X){H.error(`❌ Missing required credentials for ${$.platform}:`),H.error("");for(let R of M)H.error(` • ${R}`);H.error(""),H.error("Provide credentials via:"),H.error(' 1. CLI arguments: npx @capgo/cli build request --platform ios --apple-id "..." --p12-password "..."'),H.error(' 2. Environment variables: export APPLE_ID="..." P12_PASSWORD="..."'),H.error(" 3. Saved credentials: npx @capgo/cli build credentials save --platform ios ..."),H.error(""),H.error("Documentation:"),H.error(` https://capgo.app/docs/cli/cloud-build/${$.platform}/`)}throw Error(`Missing required credentials for ${$.platform}: ${M.join(", ")}`)}if(K.credentials=q,!X)H.info("✓ Using credentials (merged from CLI args, env vars, and saved file)");if(J){let R=Object.keys(q).filter((P)=>q[P]);H.info(`Credentials provided: ${R.join(", ")}`)}if(!X)H.info("Requesting build from Capgo...");let L=3,I=await lCD(`${w}/build/request`,{method:"POST",headers:{"Content-Type":"application/json",authorization:$.apikey},body:JSON.stringify(K)},L,X);if(!I.ok){let R=await I.text();throw Error(`Failed to request build: ${I.status} - ${R}`)}let W=await I.json();if(!X)H.success(`Build job created: ${W.job_id}`),H.info(`Status: ${W.status}`);if(J)H.info(`Upload URL: ${W.upload_url}`),H.info(`Upload expires: ${W.upload_expires_at}`);await RD($.apikey,{channel:"native-builder",event:"Build requested",icon:"\uD83C\uDFD7️",user_id:G,tags:{"app-id":D,platform:$.platform},notify:!1}).catch();let N=a$(mCD(),`capgo-build-${Date.now()}`);await yCD(N,{recursive:!0});let V=a$(N,`${Us(Q)}.zip`);try{if(!X)H.info(`Zipping ${$.platform} project from ${Q}...`);await oCD(Q,V,$.platform,F?.config);let P=((await gCD(V)).size/1024/1024).toFixed(2);if(!X)H.success(`Created zip: ${V} (${P} MB)`);if(!X)H.info("Uploading to builder...");if(J)H.info(`Upload endpoint: ${W.upload_url}`),H.info(`File size: ${P} MB`),H.info(`Job ID: ${W.job_id}`);let A=kCD(V),_=A0();if(!X)_.start("Uploading bundle");if(await new Promise((b,a)=>{let c=new CZ.Upload(A,{endpoint:W.upload_url,chunkSize:5242880,metadata:{filename:Us(V),filetype:"application/zip"},headers:{authorization:$.apikey},onBeforeRequest(n){if(J){H.info(`[TUS] ${n.getMethod()} ${n.getURL()}`);let YD=n.getHeader("authorization");H.info(`[TUS] Authorization header present: ${!!YD}`)}},onAfterResponse(n,YD){if(J){H.info(`[TUS] Response status: ${YD.getStatus()}`);let C=YD.getHeader("upload-offset"),E=YD.getHeader("tus-resumable");H.info(`[TUS] Upload-Offset: ${C}, Tus-Resumable: ${E}`)}},onError(n){if(!X)_.stop("Upload failed"),H.error(`Upload error: ${n.message}`);if(n instanceof CZ.DetailedError){let YD=n.originalResponse?.getBody(),C=n.originalResponse?.getStatus(),E=n.originalRequest?.getURL();if(J)H.error(`[TUS] Request URL: ${E}`),H.error(`[TUS] Response status: ${C}`),H.error(`[TUS] Response body: ${YD}`);let r="Unknown error";try{let k=JSON.parse(YD||'{"error": "unknown error"}');r=k.status||k.error||k.message||"unknown error"}catch{r=YD||n.message}a(Error(`TUS upload failed: ${r}`))}else a(Error(`TUS upload failed: ${n.message||n.toString()}`))},onProgress(n,YD){let C=(n/YD*100).toFixed(2);if(!X)_.message(`Uploading ${C}%`)},onSuccess(){if(!X)_.stop("Upload complete!");if(J)H.success("TUS upload completed successfully");b()}});if(J)H.info("[TUS] Starting upload...");c.start()}),!X)H.info("Starting build job...");let v=await fetch(`${w}/build/start/${W.job_id}`,{method:"POST",headers:{"Content-Type":"application/json",authorization:$.apikey},body:JSON.stringify({app_id:D})});if(!v.ok){let b=await v.text();throw Error(`Failed to start build: ${v.status} - ${b}`)}let S=await v.json();if(!X)H.success("Build started!"),H.info("Streaming build logs...");let h=new AbortController,g=!1,l=async()=>{if(g)return;g=!0;let b=new AbortController,a=setTimeout(()=>b.abort(),4000);try{await fetch(`${w}/build/cancel/${W.job_id}`,{method:"POST",headers:{"Content-Type":"application/json",authorization:$.apikey},body:JSON.stringify({app_id:D}),signal:b.signal})}catch{}finally{clearTimeout(a)}},f=async()=>{try{if(g)XL.exit(1);if(!X)H.warn("Canceling build... (press Ctrl+C again to force quit)");await l(),h.abort()}catch{}};XL.on("SIGINT",f);let j,x=!1,u=async()=>{try{let b=await fetch(`${w}/build/status?job_id=${encodeURIComponent(W.job_id)}&app_id=${encodeURIComponent(D)}&platform=${$.platform}`,{headers:{authorization:$.apikey}});if(!b.ok)return null;let a=await b.json(),c=a.status?.toLowerCase?.()??"";if(!X&&x)H.info(`Build status: ${c||a.status}`);if(TZ.has(c))return c;return null}catch{return null}},y=null;try{y=await iCD(X,J,S.logs_url,S.logs_token,u,h.signal,()=>{x=!0})}finally{XL.removeListener("SIGINT",f)}if(y){if(j=y,TZ.has(y))await u().catch(()=>{})}else j=await pCD(w,W.job_id,D,$.platform,$.apikey,X,x,h.signal);if(!X)if(j==="succeeded")H.success("Build completed successfully!");else if(j==="failed")H.error("Build failed");else H.warn(`Build finished with status: ${j}`);let d=((Date.now()-Y)/1000).toFixed(2);return await RD($.apikey,{channel:"native-builder",event:j==="succeeded"?"Build succeeded":"Build failed",icon:j==="succeeded"?"✅":"❌",user_id:G,tags:{"app-id":D,platform:$.platform,status:j||"unknown",time:d},notify:!1}).catch(),{success:j==="succeeded",jobId:W.job_id,uploadUrl:W.upload_url,status:j||S.status||W.status}}finally{await bCD(N,{recursive:!0,force:!0})}}catch(Q){let F=Q instanceof Error?Q.message:String(Q);if(!X)H.error(F);return{success:!1,error:F}}}vD();D6();q1();fD();async function aCD(D,$,X,Y){for await(let J of D){if(!Y)H.warn(`Removing ${J.name} created on ${o5(J.created_at)}`);await UZ($,X,J.name)}}function tCD(D,$,X){let Y=[];for(let J of D??[]){let Q=eD(J.name);if(CG(Q,$)&&S4(Q,X))Y.push(J)}return Y}async function Ns(D,$,X=!1){if(!X)VD("Cleanup versions in Capgo");await F0(),$.apikey=$.apikey||BD();let{bundle:Y,keep:J=4}=$,Q=$.force||!1,F=$.ignoreChannel||!1,w=await ID();if(D=iD(D,w?.config),!$.apikey){if(!X)H.error("Missing API key, you need to provide an API key to delete your app");throw Error("Missing API key")}if(!D){if(!X)H.error("Missing argument, you need to provide a appid, or be in a capacitor project");throw Error("Missing appId")}let Z=await jD($.apikey,$.supaHost,$.supaAnon);if(await m0(Z,D,X),await xD(Z,$.apikey,["write","all"]),await u0(Z,$.apikey,D,3,X,!0),!X)H.info("Querying all available versions in Capgo");let G=await qZ(Z,D),O=await ma(Z,D);if(!X)H.info(`Total active versions in Capgo: ${G?.length??0}`);if(!G?.length){if(!X)H.error("No versions found, aborting cleanup");throw Error("No versions found")}if(Y){let q=eD(Y),B=L7(q,"major");if(!X)H.info(`Querying available versions in Capgo between ${z$(q)} and ${z$(B)}`);if(G=tCD(G,q,B),!X)H.info(`Active versions in Capgo between ${z$(q)} and ${z$(B)}: ${G?.length??0}`)}let U=[],z=0;for(let q of G){let B=O.find((K)=>K===q.id);if(z<J||B&&!F)q.keep=B?"✅ (Linked to channel)":"✅",z+=1;else q.keep="❌",U.push(q)}if(!U.length){if(!X)H.warn("Nothing to be removed, aborting removal...");return{removed:0,kept:z}}if(!X)ha(G);if(!Q)if(!X){let q=await c0({message:"Do you want to continue removing the versions specified?"});if(yD(q)||!q)throw H.warn("Not confirmed, aborting removal..."),Error("Cleanup cancelled by user")}else throw Error("Cleanup requires force=true in SDK mode to prevent accidental deletions");if(!X)H.success("You have confirmed removal, removing versions now");if(await aCD(U,Z,D,X),!X)ND("Done ✅");return{removed:U.length,kept:z}}vD();s$();fD();async function Ms(D,$,X=!1){if(!X)VD("Check compatibility");let Y={...$,apikey:$.apikey||BD()},J=D?void 0:await ID(),Q=iD(D,J?.config),F=Y.channel;if(!F){if(!X)H.error("Missing argument, you need to provide a channel");throw Error("Missing channel")}if(!Y.apikey){if(!X)H.error("Missing API key, you need to provide an API key to access Capgo Cloud metadata");throw Error("Missing API key")}if(!Q){if(!X)H.error("Missing argument, you need to provide an appId, or be in a capacitor project");throw Error("Missing appId")}let w=await jD(Y.apikey,Y.supaHost,Y.supaAnon);await m0(w,Q,X),await xD(w,Y.apikey,["write","all","read","upload"]),await u0(w,Y.apikey,Q,1,X,!0);let Z=await OZ(w,Q,F,Y.packageJson,Y.nodeModules),G=Z.finalCompatibility.some((O)=>!L4(O));if(!X){let O=new R0;O.headers=["Package","Local","Remote","Status","Details"],O.theme=R0.roundTheme,O.rows=[];let U=Y.text?"OK":"✅",z=Y.text?"FAIL":"❌";for(let q of Z.finalCompatibility){let{name:B,localVersion:K,remoteVersion:M}=q,L=k8(q),I=L.compatible?U:z;O.rows.push([B,K||"-",M||"-",I,L.message])}if(H.success("Compatibility Check Results"),H.info(O.toString()),G){let q=Z.finalCompatibility.filter((B)=>!L4(B)).length;H.warn(`
466
+ `);if(J)H.info(`API host: ${w}`);let O={};if($.buildCertificateBase64)O.BUILD_CERTIFICATE_BASE64=$.buildCertificateBase64;if($.buildProvisionProfileBase64)O.BUILD_PROVISION_PROFILE_BASE64=$.buildProvisionProfileBase64;if($.buildProvisionProfileBase64Prod)O.BUILD_PROVISION_PROFILE_BASE64_PROD=$.buildProvisionProfileBase64Prod;if($.p12Password)O.P12_PASSWORD=$.p12Password;if($.appleKeyId)O.APPLE_KEY_ID=$.appleKeyId;if($.appleIssuerId)O.APPLE_ISSUER_ID=$.appleIssuerId;if($.appleKeyContent)O.APPLE_KEY_CONTENT=$.appleKeyContent;if($.appleProfileName)O.APPLE_PROFILE_NAME=$.appleProfileName;if($.appStoreConnectTeamId)O.APP_STORE_CONNECT_TEAM_ID=$.appStoreConnectTeamId;if($.iosScheme)O.CAPGO_IOS_SCHEME=$.iosScheme;if($.iosTarget)O.CAPGO_IOS_TARGET=$.iosTarget;if($.iosDistribution)O.CAPGO_IOS_DISTRIBUTION=$.iosDistribution;if($.androidKeystoreFile)O.ANDROID_KEYSTORE_FILE=$.androidKeystoreFile;if($.keystoreKeyAlias)O.KEYSTORE_KEY_ALIAS=$.keystoreKeyAlias;let U=!!$.keystoreKeyPassword,z=!!$.keystoreStorePassword;if(U&&!z)O.KEYSTORE_KEY_PASSWORD=$.keystoreKeyPassword,O.KEYSTORE_STORE_PASSWORD=$.keystoreKeyPassword;else if(!U&&z)O.KEYSTORE_KEY_PASSWORD=$.keystoreStorePassword,O.KEYSTORE_STORE_PASSWORD=$.keystoreStorePassword;else if(U&&z)O.KEYSTORE_KEY_PASSWORD=$.keystoreKeyPassword,O.KEYSTORE_STORE_PASSWORD=$.keystoreStorePassword;if($.playConfigJson)O.PLAY_CONFIG_JSON=$.playConfigJson;if($.outputUpload!==void 0)O.BUILD_OUTPUT_UPLOAD_ENABLED=B2($.outputUpload)?"true":"false";if($.outputRetention)O.BUILD_OUTPUT_RETENTION_SECONDS=String(DL($.outputRetention));if($.skipBuildNumberBump!==void 0)O.SKIP_BUILD_NUMBER_BUMP=B2($.skipBuildNumberBump)?"true":"false";let q=await Gs(D,$.platform,Object.keys(O).length>0?O:void 0),B=K2(F?.config,$.platform);if(q&&B)if($.platform==="ios")q.CAPGO_IOS_SOURCE_DIR=B,q.CAPGO_IOS_APP_DIR=B,q.CAPGO_IOS_PROJECT_DIR=B,q.IOS_PROJECT_DIR=B;else q.CAPGO_ANDROID_SOURCE_DIR=B,q.CAPGO_ANDROID_APP_DIR=B,q.CAPGO_ANDROID_PROJECT_DIR=B,q.ANDROID_PROJECT_DIR=B;let K={app_id:D,platform:$.platform,build_mode:$.buildMode};if(!q){if(!X)H.error("❌ No credentials found for this app and platform"),H.error(""),H.error("You must provide credentials via:"),H.error(" 1. CLI arguments (--apple-key-id, --p12-password, etc.)"),H.error(" 2. Environment variables (APPLE_KEY_ID, P12_PASSWORD, etc.)"),H.error(" 3. Saved credentials file:"),H.error(` npx @capgo/cli build credentials save --appId ${D} --platform ${$.platform}`),H.error(""),H.error("Documentation:"),H.error(" https://capgo.app/docs/cli/cloud-build/credentials/");throw Error("No credentials found. Please provide credentials before building.")}let M=[];if($.platform==="ios"){let R=q.CAPGO_IOS_DISTRIBUTION||"app_store",C=["app_store","ad_hoc"];if(!C.includes(R))M.push(`Invalid CAPGO_IOS_DISTRIBUTION value: '${R}'. Must be one of: ${C.join(", ")}`);let A=C.includes(R)?R:"app_store";if(!q.BUILD_CERTIFICATE_BASE64)M.push("BUILD_CERTIFICATE_BASE64 (or --build-certificate-base64)");if(!q.P12_PASSWORD&&!X)H.warn("⚠️ P12_PASSWORD not provided - assuming certificate has no password"),H.warn(" If your certificate requires a password, provide it with --p12-password");if(!q.BUILD_PROVISION_PROFILE_BASE64)M.push("BUILD_PROVISION_PROFILE_BASE64 (or --build-provision-profile-base64)");if(A==="app_store"){let _=!!q.APPLE_KEY_ID,v=!!q.APPLE_ISSUER_ID,S=!!q.APPLE_KEY_CONTENT,h=_||v||S;if(!(_&&v&&S)){if(h){let l=[];if(!_)l.push("APPLE_KEY_ID (or --apple-key-id)");if(!v)l.push("APPLE_ISSUER_ID (or --apple-issuer-id)");if(!S)l.push("APPLE_KEY_CONTENT (or --apple-key-content)");M.push(`Incomplete App Store Connect API key - missing: ${l.join(", ")}`)}else if(q.BUILD_OUTPUT_UPLOAD_ENABLED!=="true")M.push("APPLE_KEY_ID/APPLE_ISSUER_ID/APPLE_KEY_CONTENT or BUILD_OUTPUT_UPLOAD_ENABLED=true (or --output-upload) (build has no output destination - enable either TestFlight upload or Capgo download link)");else if(q.SKIP_BUILD_NUMBER_BUMP!=="true")M.push("APPLE_KEY_ID/APPLE_ISSUER_ID/APPLE_KEY_CONTENT or --skip-build-number-bump (App Store Connect API key not provided - build numbers cannot be auto-incremented without it)");else if(!X)H.warn("⚠️ App Store Connect API key not provided - build will succeed but cannot auto-upload to TestFlight")}}else if(A==="ad_hoc"){if(!X)H.info("\uD83D\uDCE6 Ad-hoc distribution mode: App Store Connect API key not required"),H.info(" Build number will use timestamp-based fallback")}if(!q.APP_STORE_CONNECT_TEAM_ID)M.push("APP_STORE_CONNECT_TEAM_ID (or --app-store-connect-team-id)")}else if($.platform==="android"){if(!q.ANDROID_KEYSTORE_FILE)M.push("ANDROID_KEYSTORE_FILE (or --android-keystore-file)");if(!q.KEYSTORE_KEY_ALIAS)M.push("KEYSTORE_KEY_ALIAS (or --keystore-key-alias)");if(!q.KEYSTORE_KEY_PASSWORD&&!q.KEYSTORE_STORE_PASSWORD)M.push("KEYSTORE_KEY_PASSWORD or KEYSTORE_STORE_PASSWORD (at least one password required)");if(!q.PLAY_CONFIG_JSON){if(q.BUILD_OUTPUT_UPLOAD_ENABLED!=="true")M.push("PLAY_CONFIG_JSON or BUILD_OUTPUT_UPLOAD_ENABLED=true (build has no output destination - enable either Play Store upload or Capgo download link)");else if(!X)H.warn("⚠️ PLAY_CONFIG_JSON not provided - build will succeed but cannot auto-upload to Play Store")}}if(M.length>0){if(!X){H.error(`❌ Missing required credentials for ${$.platform}:`),H.error("");for(let R of M)H.error(` • ${R}`);H.error(""),H.error("Provide credentials via:"),H.error(' 1. CLI arguments: npx @capgo/cli build request --platform ios --apple-id "..." --p12-password "..."'),H.error(' 2. Environment variables: export APPLE_ID="..." P12_PASSWORD="..."'),H.error(" 3. Saved credentials: npx @capgo/cli build credentials save --platform ios ..."),H.error(""),H.error("Documentation:"),H.error(` https://capgo.app/docs/cli/cloud-build/${$.platform}/`)}throw Error(`Missing required credentials for ${$.platform}: ${M.join(", ")}`)}if(K.credentials=q,!X)H.info("✓ Using credentials (merged from CLI args, env vars, and saved file)");if(J){let R=Object.keys(q).filter((C)=>q[C]);H.info(`Credentials provided: ${R.join(", ")}`)}if(!X)H.info("Requesting build from Capgo...");let L=3,I=await lCD(`${w}/build/request`,{method:"POST",headers:{"Content-Type":"application/json",authorization:$.apikey},body:JSON.stringify(K)},L,X);if(!I.ok){let R=await I.text();throw Error(`Failed to request build: ${I.status} - ${R}`)}let W=await I.json();if(!X)H.success(`Build job created: ${W.job_id}`),H.info(`Status: ${W.status}`);if(J)H.info(`Upload URL: ${W.upload_url}`),H.info(`Upload expires: ${W.upload_expires_at}`);await RD($.apikey,{channel:"native-builder",event:"Build requested",icon:"\uD83C\uDFD7️",user_id:G,tags:{"app-id":D,platform:$.platform},notify:!1}).catch();let N=a$(mCD(),`capgo-build-${Date.now()}`);await yCD(N,{recursive:!0});let V=a$(N,`${Us(Q)}.zip`);try{if(!X)H.info(`Zipping ${$.platform} project from ${Q}...`);await oCD(Q,V,$.platform,F?.config);let C=((await gCD(V)).size/1024/1024).toFixed(2);if(!X)H.success(`Created zip: ${V} (${C} MB)`);if(!X)H.info("Uploading to builder...");if(J)H.info(`Upload endpoint: ${W.upload_url}`),H.info(`File size: ${C} MB`),H.info(`Job ID: ${W.job_id}`);let A=kCD(V),_=A0();if(!X)_.start("Uploading bundle");if(await new Promise((b,a)=>{let c=new CZ.Upload(A,{endpoint:W.upload_url,chunkSize:5242880,metadata:{filename:Us(V),filetype:"application/zip"},headers:{authorization:$.apikey},onBeforeRequest(n){if(J){H.info(`[TUS] ${n.getMethod()} ${n.getURL()}`);let YD=n.getHeader("authorization");H.info(`[TUS] Authorization header present: ${!!YD}`)}},onAfterResponse(n,YD){if(J){H.info(`[TUS] Response status: ${YD.getStatus()}`);let P=YD.getHeader("upload-offset"),E=YD.getHeader("tus-resumable");H.info(`[TUS] Upload-Offset: ${P}, Tus-Resumable: ${E}`)}},onError(n){if(!X)_.stop("Upload failed"),H.error(`Upload error: ${n.message}`);if(n instanceof CZ.DetailedError){let YD=n.originalResponse?.getBody(),P=n.originalResponse?.getStatus(),E=n.originalRequest?.getURL();if(J)H.error(`[TUS] Request URL: ${E}`),H.error(`[TUS] Response status: ${P}`),H.error(`[TUS] Response body: ${YD}`);let r="Unknown error";try{let k=JSON.parse(YD||'{"error": "unknown error"}');r=k.status||k.error||k.message||"unknown error"}catch{r=YD||n.message}a(Error(`TUS upload failed: ${r}`))}else a(Error(`TUS upload failed: ${n.message||n.toString()}`))},onProgress(n,YD){let P=(n/YD*100).toFixed(2);if(!X)_.message(`Uploading ${P}%`)},onSuccess(){if(!X)_.stop("Upload complete!");if(J)H.success("TUS upload completed successfully");b()}});if(J)H.info("[TUS] Starting upload...");c.start()}),!X)H.info("Starting build job...");let v=await fetch(`${w}/build/start/${W.job_id}`,{method:"POST",headers:{"Content-Type":"application/json",authorization:$.apikey},body:JSON.stringify({app_id:D})});if(!v.ok){let b=await v.text();throw Error(`Failed to start build: ${v.status} - ${b}`)}let S=await v.json();if(!X)H.success("Build started!"),H.info("Streaming build logs...");let h=new AbortController,g=!1,l=async()=>{if(g)return;g=!0;let b=new AbortController,a=setTimeout(()=>b.abort(),4000);try{await fetch(`${w}/build/cancel/${W.job_id}`,{method:"POST",headers:{"Content-Type":"application/json",authorization:$.apikey},body:JSON.stringify({app_id:D}),signal:b.signal})}catch{}finally{clearTimeout(a)}},f=async()=>{try{if(g)XL.exit(1);if(!X)H.warn("Canceling build... (press Ctrl+C again to force quit)");await l(),h.abort()}catch{}};XL.on("SIGINT",f);let j,x=!1,u=async()=>{try{let b=await fetch(`${w}/build/status?job_id=${encodeURIComponent(W.job_id)}&app_id=${encodeURIComponent(D)}&platform=${$.platform}`,{headers:{authorization:$.apikey}});if(!b.ok)return null;let a=await b.json(),c=a.status?.toLowerCase?.()??"";if(!X&&x)H.info(`Build status: ${c||a.status}`);if(TZ.has(c))return c;return null}catch{return null}},y=null;try{y=await iCD(X,J,S.logs_url,S.logs_token,u,h.signal,()=>{x=!0})}finally{XL.removeListener("SIGINT",f)}if(y){if(j=y,TZ.has(y))await u().catch(()=>{})}else j=await pCD(w,W.job_id,D,$.platform,$.apikey,X,x,h.signal);if(!X)if(j==="succeeded")H.success("Build completed successfully!");else if(j==="failed")H.error("Build failed");else H.warn(`Build finished with status: ${j}`);let d=((Date.now()-Y)/1000).toFixed(2);return await RD($.apikey,{channel:"native-builder",event:j==="succeeded"?"Build succeeded":"Build failed",icon:j==="succeeded"?"✅":"❌",user_id:G,tags:{"app-id":D,platform:$.platform,status:j||"unknown",time:d},notify:!1}).catch(),{success:j==="succeeded",jobId:W.job_id,uploadUrl:W.upload_url,status:j||S.status||W.status}}finally{await bCD(N,{recursive:!0,force:!0})}}catch(Q){let F=Q instanceof Error?Q.message:String(Q);if(!X)H.error(F);return{success:!1,error:F}}}vD();D6();q1();fD();async function aCD(D,$,X,Y){for await(let J of D){if(!Y)H.warn(`Removing ${J.name} created on ${o5(J.created_at)}`);await UZ($,X,J.name)}}function tCD(D,$,X){let Y=[];for(let J of D??[]){let Q=eD(J.name);if(CG(Q,$)&&S4(Q,X))Y.push(J)}return Y}async function Ns(D,$,X=!1){if(!X)VD("Cleanup versions in Capgo");await F0(),$.apikey=$.apikey||BD();let{bundle:Y,keep:J=4}=$,Q=$.force||!1,F=$.ignoreChannel||!1,w=await ID();if(D=iD(D,w?.config),!$.apikey){if(!X)H.error("Missing API key, you need to provide an API key to delete your app");throw Error("Missing API key")}if(!D){if(!X)H.error("Missing argument, you need to provide a appid, or be in a capacitor project");throw Error("Missing appId")}let Z=await jD($.apikey,$.supaHost,$.supaAnon);if(await d0(Z,D,X),await xD(Z,$.apikey,["write","all"]),await u0(Z,$.apikey,D,3,X,!0),!X)H.info("Querying all available versions in Capgo");let G=await qZ(Z,D),O=await ma(Z,D);if(!X)H.info(`Total active versions in Capgo: ${G?.length??0}`);if(!G?.length){if(!X)H.error("No versions found, aborting cleanup");throw Error("No versions found")}if(Y){let q=eD(Y),B=L7(q,"major");if(!X)H.info(`Querying available versions in Capgo between ${z$(q)} and ${z$(B)}`);if(G=tCD(G,q,B),!X)H.info(`Active versions in Capgo between ${z$(q)} and ${z$(B)}: ${G?.length??0}`)}let U=[],z=0;for(let q of G){let B=O.find((K)=>K===q.id);if(z<J||B&&!F)q.keep=B?"✅ (Linked to channel)":"✅",z+=1;else q.keep="❌",U.push(q)}if(!U.length){if(!X)H.warn("Nothing to be removed, aborting removal...");return{removed:0,kept:z}}if(!X)ha(G);if(!Q)if(!X){let q=await c0({message:"Do you want to continue removing the versions specified?"});if(yD(q)||!q)throw H.warn("Not confirmed, aborting removal..."),Error("Cleanup cancelled by user")}else throw Error("Cleanup requires force=true in SDK mode to prevent accidental deletions");if(!X)H.success("You have confirmed removal, removing versions now");if(await aCD(U,Z,D,X),!X)ND("Done ✅");return{removed:U.length,kept:z}}vD();s$();fD();async function Ms(D,$,X=!1){if(!X)VD("Check compatibility");let Y={...$,apikey:$.apikey||BD()},J=D?void 0:await ID(),Q=iD(D,J?.config),F=Y.channel;if(!F){if(!X)H.error("Missing argument, you need to provide a channel");throw Error("Missing channel")}if(!Y.apikey){if(!X)H.error("Missing API key, you need to provide an API key to access Capgo Cloud metadata");throw Error("Missing API key")}if(!Q){if(!X)H.error("Missing argument, you need to provide an appId, or be in a capacitor project");throw Error("Missing appId")}let w=await jD(Y.apikey,Y.supaHost,Y.supaAnon);await d0(w,Q,X),await xD(w,Y.apikey,["write","all","read","upload"]),await u0(w,Y.apikey,Q,1,X,!0);let Z=await OZ(w,Q,F,Y.packageJson,Y.nodeModules),G=Z.finalCompatibility.some((O)=>!L4(O));if(!X){let O=new R0;O.headers=["Package","Local","Remote","Status","Details"],O.theme=R0.roundTheme,O.rows=[];let U=Y.text?"OK":"✅",z=Y.text?"FAIL":"❌";for(let q of Z.finalCompatibility){let{name:B,localVersion:K,remoteVersion:M}=q,L=k8(q),I=L.compatible?U:z;O.rows.push([B,K||"-",M||"-",I,L.message])}if(H.success("Compatibility Check Results"),H.info(O.toString()),G){let q=Z.finalCompatibility.filter((B)=>!L4(B)).length;H.warn(`
467
467
  ${q} package(s) are incompatible with channel "${F}"`),H.warn("An app store update may be required for these changes to take effect.")}else H.success(`
468
- All packages are compatible with channel "${F}"`)}return{finalCompatibility:Z.finalCompatibility,hasIncompatible:G,resolvedAppId:Q,channel:F}}vD();D6();import{existsSync as QL,readFileSync as Cs,writeFileSync as XPD}from"node:fs";import{cwd as JPD}from"node:process";import{Buffer as C6}from"node:buffer";import{constants as sCD,createCipheriv as eCD,createDecipheriv as DPD,generateKeyPairSync as $PD,privateEncrypt as JL,publicDecrypt as YL,randomBytes as Ls}from"node:crypto";var Is="aes-128-cbc",P6="base64",PZ="hex",Y7=sCD.RSA_PKCS1_PADDING;function xZ(D){let $=Ls(16),X=Ls(16),Y=$.toString(P6),J=JL({key:D,padding:Y7},X).toString(P6);return{sessionKey:X,ivSessionKey:`${Y}:${J}`}}function Q7(D,$,X){let[Y]=X.split(":"),J=C6.from(Y,P6),Q=eCD(Is,$,J);return Q.setAutoPadding(!0),C6.concat([Q.update(D),Q.final()])}function As(D,$,X){let[Y,J]=$.split(":"),Q=YL({key:X,padding:Y7},C6.from(J,P6)),F=C6.from(Y,P6),w=DPD(Is,Q,F);return w.setAutoPadding(!0),C6.concat([w.update(D),w.final()])}function F7(D,$){return JL({key:$,padding:Y7},C6.from(D,P6)).toString(P6)}function w7(D,$){return JL({key:$,padding:Y7},C6.from(D,PZ)).toString(PZ)}function Rs(D,$){return YL({key:$,padding:Y7},C6.from(D,P6)).toString(P6)}function js(D,$){return YL({key:$,padding:Y7},C6.from(D,PZ)).toString(PZ)}function Es(){let{publicKey:D,privateKey:$}=$PD("rsa",{modulusLength:2048});return{publicKey:D.export({type:"pkcs1",format:"pem"}),privateKey:$.export({type:"pkcs1",format:"pem"})}}function Ts(D){if(!D)return"";return D.replace(/-----BEGIN RSA PUBLIC KEY-----/g,"").replace(/-----END RSA PUBLIC KEY-----/g,"").replace(/\n/g,"").replace(/\r/g,"").replace(/ /g,"").substring(0,20)}q1();q3();fD();var YPD="5.30.0",QPD="6.30.0",FPD="7.30.0";function wPD(D,$){let X=D.key||R6,Y=$.config.plugins?.CapacitorUpdater?.publicKey;if(QL(X))Y=Cs(X,"utf8");else if(!Y&&D.keyData)Y=D.keyData;return{publicKey:Y,fallbackKeyPath:X}}async function Ps(D,$,X,Y=!1){if(!Y)VD("Decrypt zip file");try{if(await F0(),!QL(D)){let U=`Zip not found at the path ${D}`;if(!Y)H.error(U);throw Error(U)}let J=await ID();if(!X.key&&!QL(R6)&&!J.config.plugins?.CapacitorUpdater?.publicKey){let U=`Public Key not found at the path ${R6} or in ${J.path}`;if(!Y)H.error(U);throw Error(U)}let{publicKey:Q,fallbackKeyPath:F}=wPD(X,J);if(!Q){let U=`Cannot find public key ${F} or as keyData option or in ${J.path}`;if(!Y)H.error(U);throw Error(U)}let w=Cs(D),Z=As(w,$,X.keyData??Q),G=`${D}_decrypted.zip`;if(XPD(G,Z),!Y)H.info(`Decrypted zip file at ${G}`);let O;if(X.checksum){let U=await p6(Z,"sha256"),z=e0(JPD()),q=await y1("@capgo/capacitor-updater",z,X.packageJson),B=!1,K;try{K=q?eD(q):void 0}catch{K=void 0}if(K)B=!Z$(K,YPD,QPD,FPD);if(!Y)H.info(`Decrypting checksum with ${B?"V3":"V2"} (based on updater version ${q||"unknown"})`);let M=B?js(X.checksum,X.keyData??Q):Rs(X.checksum,X.keyData??Q);if(O=U===M,!O){let L=`Checksum does not match ${U} !== ${M}`;if(!Y)H.error(L);throw Error(L)}if(!Y)H.info("Checksum matches")}if(!Y)ND("✅ done");return{outputPath:G,checksumMatches:O}}catch(J){if(!Y)H.error(`Error decrypting zip file ${s(J)}`);throw J instanceof Error?J:Error(String(J))}}vD();fD();async function xs(D,$,X,Y=!1){if(!Y)VD("Delete bundle");X.apikey=X.apikey||BD();let J=await ID();if($=iD($,J?.config),!X.apikey){if(!Y)H.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!$){if(!Y)H.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}if(!D){if(!Y)H.error("Missing argument, you need to provide a bundleId, or be in a capacitor project");throw Error("Missing bundleId")}let Q=await jD(X.apikey,X.supaHost,X.supaAnon);if(await m0(Q,$,Y),await xD(Q,X.apikey,["write","all"]),await u0(Q,X.apikey,$,3,Y,!0),!Y)H.info(`Deleting bundle ${$}@${D} from Capgo`),H.info("Keep in mind that you will not be able to reuse this bundle version, it's gone forever");await UZ(Q,$,D);let F=await o0(Q,$);if(await RD(X.apikey,{channel:"app",event:"Bundle Deleted",icon:"\uD83D\uDDD1️",user_id:F,tags:{"app-id":$,bundle:D},notify:!1,notifyConsole:!0}).catch(()=>{}),!Y)H.success(`Bundle ${$}@${D} deleted in Capgo`),ND("Done");return!0}vD();D6();import{existsSync as FL,readFileSync as Ss,writeFileSync as ZPD}from"node:fs";import{cwd as GPD}from"node:process";q1();fD();var OPD="5.30.0",UPD="6.30.0",qPD="7.30.0";function H2(D){console.error(s(D))}async function us(D,$,X,Y=!1){let{json:J}=X,Q=!J&&!Y;if(Q)VD("Encryption"),await F0();try{let F=await ID(),w=!!F.config.plugins?.CapacitorUpdater?.privateKey,Z=!!F.config.plugins?.CapacitorUpdater?.publicKey;if(w&&Q)H.warning("There is still a privateKey in the config");if(!FL(D)){let V=`Zip not found at the path ${D}`;if(!Y)if(J)H2({error:"zip_not_found"});else H.error(`Error: ${V}`);throw Error(V)}if(!Z){if(!Y)if(J)H2({error:"missing_public_key"});else H.warning("Warning: Missing Public Key in config");throw Error("Missing public key in config")}let G=X.key||i1,O=X.keyData||"";if(!FL(G)&&!O){if(!Y)if(J)H2({error:"missing_key"});else H.warning(`Cannot find a private key at ${G} or as a keyData option`),H.error("Error: Missing key");throw Error("Missing private key")}else if(FL(G))O=Ss(G,"utf8");if(O&&!O.startsWith("-----BEGIN RSA PRIVATE KEY-----")){if(!Y)if(J)H2({error:"invalid_private_key"});else H.error("The private key provided is not a valid RSA Private key");throw Error("Invalid private key format")}let U=Ss(D),{sessionKey:z,ivSessionKey:q}=xZ(O),B=Q7(U,z,q),K=e0(GPD()),M=await y1("@capgo/capacitor-updater",K,X.packageJson),L=!1,I;try{I=M?eD(M):void 0}catch{I=void 0}if(I)L=!Z$(I,OPD,UPD,qPD);let W=L?w7($,O):F7($,O);if(Q)H.info(`Encrypting checksum with ${L?"V3":"V2"} (based on updater version ${M||"unknown"})`);let N=`${D}_encrypted.zip`;if(ZPD(N,B),!Y)if(J)console.log(JSON.stringify({checksum:W,filename:N,ivSessionKey:q},null,2));else H.success(`Encoded Checksum: ${W}`),H.success(`ivSessionKey: ${q}`),H.success(`Encrypted zip saved at ${N}`),ND("Done ✅");return{checksum:W,filename:N,ivSessionKey:q}}catch(F){if(!Y)if(X.json)H2(F);else H.error(`Error encrypting zip file ${s(F)}`);throw F instanceof Error?F:Error(String(F))}}import{randomUUID as MSD}from"node:crypto";import{existsSync as dZ,readFileSync as LSD}from"node:fs";import{cwd as kL,stdin as ISD,stdout as ASD}from"node:process";class wL extends TransformStream{outChunkSize;constructor(D){let $=new Uint8Array(D),X=0;super({transform(Y,J){let Q=0;while(Q<Y.length){let F=D-X,w=Math.min(F,Y.length-Q);if($.set(Y.subarray(Q,Q+w),X),Q+=w,X+=w,X===D)J.enqueue($),$=new Uint8Array(D),X=0}},flush(Y){if(X>0)Y.enqueue($.subarray(0,X))}}),this.outChunkSize=D}}function E4(D){return D=D.trim(),D=D.replace(/<!--[\s\S]*?-->/g,""),$();function $(){return{declaration:X(),root:Y()}}function X(){if(!Z(/^<\?xml\s*/))return;let z={attributes:{}};while(!(G()||O("?>"))){let q=Q();if(!q)return z;z.attributes[q.name]=q.value}return Z(/\?>\s*/),z}function Y(){let U=Z(/^<([\w-:.]+)\s*/);if(!U)return;let z={name:U[1],attributes:{},children:[]};while(!(G()||O(">")||O("?>")||O("/>"))){let B=Q();if(!B)return z;z.attributes[B.name]=B.value}if(Z(/^\s*\/>\s*/))return z;Z(/\??>\s*/),z.content=J();let q;while(q=Y())z.children.push(q);return Z(/^<\/[\w-:.]+>\s*/),z}function J(){let U=Z(/^([^<]*)/);if(U)return w(U[1]);return""}function Q(){let U=Z(/([\w:-]+)\s*=\s*("[^"]*"|'[^']*'|\w+)\s*/);if(!U)return;return{name:U[1],value:w(F(U[2]))}}function F(U){return U.replace(/^['"]|['"]$/g,"")}function w(U){return U.replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&amp;","&")}function Z(U){let z=D.match(U);if(!z)return;return D=D.slice(z[0].length),z}function G(){return D.length===0}function O(U){return D.startsWith(U)}}class x6 extends Error{}class j1 extends x6{}class SZ extends x6{}class ZL extends x6{bucketName;constructor(D){super(`Invalid bucket name: ${D}`),this.bucketName=D}}class S6 extends x6{objectName;constructor(D){super(`Invalid object name: ${D}`),this.objectName=D}}class m8 extends x6{constructor(){super("accessKey is required")}}class V2 extends x6{constructor(){super("secretKey is required")}}class uZ extends x6{constructor(){super("expirySeconds cannot be less than 1 second or more than 7 days")}}class T4 extends x6{statusCode;code;key;bucketName;resource;region;constructor(D,$,X,Y={}){super(X),this.statusCode=D,this.code=$,this.key=Y.key,this.bucketName=Y.bucketName,this.resource=Y.resource,this.region=Y.region}}async function vs(D){try{let X=E4(await D.text()).root;if(X?.name!=="Error")throw Error("Invalid root, expected <Error>");let Y=X.children.find((G)=>G.name==="Code")?.content??"UnknownErrorCode",J=X.children.find((G)=>G.name==="Message")?.content??"The error message could not be determined.",Q=X.children.find((G)=>G.name==="Key")?.content,F=X.children.find((G)=>G.name==="BucketName")?.content,w=X.children.find((G)=>G.name==="Resource")?.content,Z=X.children.find((G)=>G.name==="Region")?.content;return new T4(D.status,Y,J,{key:Q,bucketName:F,resource:w,region:Z})}catch{return new T4(D.status,"UnrecognizedError",`Error: Unexpected response code ${D.status} ${D.statusText}. Unable to parse response as XML.`)}}function _s(D){if(typeof D!=="number"||isNaN(D))return!1;return D>=1&&D<=65535}function ks(D){if(typeof D!=="string")return!1;if(D.length<3||D.length>63)return!1;if(D.includes(".."))return!1;if(D.match(/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/))return!1;if(D.match(/^[a-z0-9][a-z0-9.-]+[a-z0-9]$/))return!0;return!1}function C4(D){if(!zPD(D))return!1;if(D.length===0)return!1;return!0}function zPD(D){if(typeof D!=="string")return!1;if(D.length>1024)return!1;return!0}function N2(D){return Array.from(D).map(($)=>$.toString(16).padStart(2,"0")).join("")}function d8(D=""){let $={'"':"","&quot;":"","&#34;":"","&QUOT;":"","&#x00022":""};return D.replace(/^("|&quot;|&#34;)|("|&quot;|&#34;)$/g,(X)=>$[X])}function OL(D){return D.get("x-amz-version-id")??null}function c8(D){let $=D.toISOString();return $.slice(0,4)+$.slice(5,7)+$.slice(8,13)+$.slice(14,16)+$.slice(17,19)+"Z"}function UL(D){return c8(D).slice(0,8)}function qL(D,$){return`${UL($)}/${D}/s3/aws4_request`}async function vZ(D){if(!(D instanceof Uint8Array))D=new TextEncoder().encode(D);return N2(new Uint8Array(await crypto.subtle.digest("SHA-256",D)))}var BPD=["x-amz-server-side-encryption-customer-algorithm","x-amz-server-side-encryption-customer-key","x-amz-server-side-encryption-customer-key-MD5"];class zL extends WritableStream{getResult;constructor({client:D,bucketName:$,objectName:X,partSize:Y,metadata:J}){let Q,F=1,w,Z=[],G,O=[];super({start(){},async write(U,z){let B=F++;try{if(B==1&&U.length<Y){let L=await D.makeRequest({method:"PUT",headers:new Headers({...J,"Content-Length":String(U.length)}),bucketName:$,objectName:X,payload:U});Q={etag:d8(L.headers.get("etag")??void 0),versionId:OL(L.headers)};return}if(B===1)w=(await KPD({client:D,bucketName:$,objectName:X,metadata:J})).uploadId;let K={"Content-Length":String(U.length)};for(let L of BPD){let I=J[L];if(I)K[L]=I}let M=D.makeRequest({method:"PUT",query:{partNumber:B.toString(),uploadId:w},headers:new Headers(K),bucketName:$,objectName:X,payload:U}).then((L)=>{let I=L.headers.get("etag")??"";if(I)I=I.replace(/^"/,"").replace(/"$/,"");return Z.push({part:B,etag:I}),L});O.push(M.catch((L)=>{if(!G)G=L}))}catch(K){throw K}},async close(){if(Q);else if(w){if(await Promise.all(O),G)throw G;Z.sort((U,z)=>U.part>z.part?1:-1),Q=await WPD({client:D,bucketName:$,objectName:X,uploadId:w,etags:Z})}else throw Error("Stream was closed without uploading any data.")}});this.getResult=()=>{if(Q===void 0)throw Error("Result is not ready. await the stream first.");return Q}}}async function KPD(D){let X=new Headers(D.metadata),Y="uploads",Q=await(await D.client.makeRequest({method:"POST",bucketName:D.bucketName,objectName:D.objectName,query:"uploads",headers:X,returnBody:!0})).text(),F=E4(Q).root;if(!F||F.name!=="InitiateMultipartUploadResult")throw Error(`Unexpected response: ${Q}`);let w=F.children.find((Z)=>Z.name==="UploadId")?.content;if(!w)throw Error(`Unable to get UploadId from response: ${Q}`);return{uploadId:w}}async function WPD({client:D,bucketName:$,objectName:X,uploadId:Y,etags:J}){let Q=`
468
+ All packages are compatible with channel "${F}"`)}return{finalCompatibility:Z.finalCompatibility,hasIncompatible:G,resolvedAppId:Q,channel:F}}vD();D6();import{existsSync as QL,readFileSync as Cs,writeFileSync as XPD}from"node:fs";import{cwd as JPD}from"node:process";import{Buffer as C6}from"node:buffer";import{constants as sCD,createCipheriv as eCD,createDecipheriv as DPD,generateKeyPairSync as $PD,privateEncrypt as JL,publicDecrypt as YL,randomBytes as Ls}from"node:crypto";var Is="aes-128-cbc",P6="base64",PZ="hex",Y7=sCD.RSA_PKCS1_PADDING;function xZ(D){let $=Ls(16),X=Ls(16),Y=$.toString(P6),J=JL({key:D,padding:Y7},X).toString(P6);return{sessionKey:X,ivSessionKey:`${Y}:${J}`}}function Q7(D,$,X){let[Y]=X.split(":"),J=C6.from(Y,P6),Q=eCD(Is,$,J);return Q.setAutoPadding(!0),C6.concat([Q.update(D),Q.final()])}function As(D,$,X){let[Y,J]=$.split(":"),Q=YL({key:X,padding:Y7},C6.from(J,P6)),F=C6.from(Y,P6),w=DPD(Is,Q,F);return w.setAutoPadding(!0),C6.concat([w.update(D),w.final()])}function F7(D,$){return JL({key:$,padding:Y7},C6.from(D,P6)).toString(P6)}function w7(D,$){return JL({key:$,padding:Y7},C6.from(D,PZ)).toString(PZ)}function Rs(D,$){return YL({key:$,padding:Y7},C6.from(D,P6)).toString(P6)}function js(D,$){return YL({key:$,padding:Y7},C6.from(D,PZ)).toString(PZ)}function Es(){let{publicKey:D,privateKey:$}=$PD("rsa",{modulusLength:2048});return{publicKey:D.export({type:"pkcs1",format:"pem"}),privateKey:$.export({type:"pkcs1",format:"pem"})}}function Ts(D){if(!D)return"";return D.replace(/-----BEGIN RSA PUBLIC KEY-----/g,"").replace(/-----END RSA PUBLIC KEY-----/g,"").replace(/\n/g,"").replace(/\r/g,"").replace(/ /g,"").substring(0,20)}q1();q3();fD();var YPD="5.30.0",QPD="6.30.0",FPD="7.30.0";function wPD(D,$){let X=D.key||R6,Y=$.config.plugins?.CapacitorUpdater?.publicKey;if(QL(X))Y=Cs(X,"utf8");else if(!Y&&D.keyData)Y=D.keyData;return{publicKey:Y,fallbackKeyPath:X}}async function Ps(D,$,X,Y=!1){if(!Y)VD("Decrypt zip file");try{if(await F0(),!QL(D)){let U=`Zip not found at the path ${D}`;if(!Y)H.error(U);throw Error(U)}let J=await ID();if(!X.key&&!QL(R6)&&!J.config.plugins?.CapacitorUpdater?.publicKey){let U=`Public Key not found at the path ${R6} or in ${J.path}`;if(!Y)H.error(U);throw Error(U)}let{publicKey:Q,fallbackKeyPath:F}=wPD(X,J);if(!Q){let U=`Cannot find public key ${F} or as keyData option or in ${J.path}`;if(!Y)H.error(U);throw Error(U)}let w=Cs(D),Z=As(w,$,X.keyData??Q),G=`${D}_decrypted.zip`;if(XPD(G,Z),!Y)H.info(`Decrypted zip file at ${G}`);let O;if(X.checksum){let U=await p6(Z,"sha256"),z=e0(JPD()),q=await y1("@capgo/capacitor-updater",z,X.packageJson),B=!1,K;try{K=q?eD(q):void 0}catch{K=void 0}if(K)B=!Z$(K,YPD,QPD,FPD);if(!Y)H.info(`Decrypting checksum with ${B?"V3":"V2"} (based on updater version ${q||"unknown"})`);let M=B?js(X.checksum,X.keyData??Q):Rs(X.checksum,X.keyData??Q);if(O=U===M,!O){let L=`Checksum does not match ${U} !== ${M}`;if(!Y)H.error(L);throw Error(L)}if(!Y)H.info("Checksum matches")}if(!Y)ND("✅ done");return{outputPath:G,checksumMatches:O}}catch(J){if(!Y)H.error(`Error decrypting zip file ${s(J)}`);throw J instanceof Error?J:Error(String(J))}}vD();fD();async function xs(D,$,X,Y=!1){if(!Y)VD("Delete bundle");X.apikey=X.apikey||BD();let J=await ID();if($=iD($,J?.config),!X.apikey){if(!Y)H.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!$){if(!Y)H.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}if(!D){if(!Y)H.error("Missing argument, you need to provide a bundleId, or be in a capacitor project");throw Error("Missing bundleId")}let Q=await jD(X.apikey,X.supaHost,X.supaAnon);if(await d0(Q,$,Y),await xD(Q,X.apikey,["write","all"]),await u0(Q,X.apikey,$,3,Y,!0),!Y)H.info(`Deleting bundle ${$}@${D} from Capgo`),H.info("Keep in mind that you will not be able to reuse this bundle version, it's gone forever");await UZ(Q,$,D);let F=await o0(Q,$);if(await RD(X.apikey,{channel:"app",event:"Bundle Deleted",icon:"\uD83D\uDDD1️",user_id:F,tags:{"app-id":$,bundle:D},notify:!1,notifyConsole:!0}).catch(()=>{}),!Y)H.success(`Bundle ${$}@${D} deleted in Capgo`),ND("Done");return!0}vD();D6();import{existsSync as FL,readFileSync as Ss,writeFileSync as ZPD}from"node:fs";import{cwd as GPD}from"node:process";q1();fD();var OPD="5.30.0",UPD="6.30.0",qPD="7.30.0";function H2(D){console.error(s(D))}async function us(D,$,X,Y=!1){let{json:J}=X,Q=!J&&!Y;if(Q)VD("Encryption"),await F0();try{let F=await ID(),w=!!F.config.plugins?.CapacitorUpdater?.privateKey,Z=!!F.config.plugins?.CapacitorUpdater?.publicKey;if(w&&Q)H.warning("There is still a privateKey in the config");if(!FL(D)){let V=`Zip not found at the path ${D}`;if(!Y)if(J)H2({error:"zip_not_found"});else H.error(`Error: ${V}`);throw Error(V)}if(!Z){if(!Y)if(J)H2({error:"missing_public_key"});else H.warning("Warning: Missing Public Key in config");throw Error("Missing public key in config")}let G=X.key||i1,O=X.keyData||"";if(!FL(G)&&!O){if(!Y)if(J)H2({error:"missing_key"});else H.warning(`Cannot find a private key at ${G} or as a keyData option`),H.error("Error: Missing key");throw Error("Missing private key")}else if(FL(G))O=Ss(G,"utf8");if(O&&!O.startsWith("-----BEGIN RSA PRIVATE KEY-----")){if(!Y)if(J)H2({error:"invalid_private_key"});else H.error("The private key provided is not a valid RSA Private key");throw Error("Invalid private key format")}let U=Ss(D),{sessionKey:z,ivSessionKey:q}=xZ(O),B=Q7(U,z,q),K=e0(GPD()),M=await y1("@capgo/capacitor-updater",K,X.packageJson),L=!1,I;try{I=M?eD(M):void 0}catch{I=void 0}if(I)L=!Z$(I,OPD,UPD,qPD);let W=L?w7($,O):F7($,O);if(Q)H.info(`Encrypting checksum with ${L?"V3":"V2"} (based on updater version ${M||"unknown"})`);let N=`${D}_encrypted.zip`;if(ZPD(N,B),!Y)if(J)console.log(JSON.stringify({checksum:W,filename:N,ivSessionKey:q},null,2));else H.success(`Encoded Checksum: ${W}`),H.success(`ivSessionKey: ${q}`),H.success(`Encrypted zip saved at ${N}`),ND("Done ✅");return{checksum:W,filename:N,ivSessionKey:q}}catch(F){if(!Y)if(X.json)H2(F);else H.error(`Error encrypting zip file ${s(F)}`);throw F instanceof Error?F:Error(String(F))}}import{randomUUID as MSD}from"node:crypto";import{existsSync as dZ,readFileSync as LSD}from"node:fs";import{cwd as kL,stdin as ISD,stdout as ASD}from"node:process";class wL extends TransformStream{outChunkSize;constructor(D){let $=new Uint8Array(D),X=0;super({transform(Y,J){let Q=0;while(Q<Y.length){let F=D-X,w=Math.min(F,Y.length-Q);if($.set(Y.subarray(Q,Q+w),X),Q+=w,X+=w,X===D)J.enqueue($),$=new Uint8Array(D),X=0}},flush(Y){if(X>0)Y.enqueue($.subarray(0,X))}}),this.outChunkSize=D}}function E4(D){return D=D.trim(),D=D.replace(/<!--[\s\S]*?-->/g,""),$();function $(){return{declaration:X(),root:Y()}}function X(){if(!Z(/^<\?xml\s*/))return;let z={attributes:{}};while(!(G()||O("?>"))){let q=Q();if(!q)return z;z.attributes[q.name]=q.value}return Z(/\?>\s*/),z}function Y(){let U=Z(/^<([\w-:.]+)\s*/);if(!U)return;let z={name:U[1],attributes:{},children:[]};while(!(G()||O(">")||O("?>")||O("/>"))){let B=Q();if(!B)return z;z.attributes[B.name]=B.value}if(Z(/^\s*\/>\s*/))return z;Z(/\??>\s*/),z.content=J();let q;while(q=Y())z.children.push(q);return Z(/^<\/[\w-:.]+>\s*/),z}function J(){let U=Z(/^([^<]*)/);if(U)return w(U[1]);return""}function Q(){let U=Z(/([\w:-]+)\s*=\s*("[^"]*"|'[^']*'|\w+)\s*/);if(!U)return;return{name:U[1],value:w(F(U[2]))}}function F(U){return U.replace(/^['"]|['"]$/g,"")}function w(U){return U.replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&amp;","&")}function Z(U){let z=D.match(U);if(!z)return;return D=D.slice(z[0].length),z}function G(){return D.length===0}function O(U){return D.startsWith(U)}}class x6 extends Error{}class j1 extends x6{}class SZ extends x6{}class ZL extends x6{bucketName;constructor(D){super(`Invalid bucket name: ${D}`),this.bucketName=D}}class S6 extends x6{objectName;constructor(D){super(`Invalid object name: ${D}`),this.objectName=D}}class m8 extends x6{constructor(){super("accessKey is required")}}class V2 extends x6{constructor(){super("secretKey is required")}}class uZ extends x6{constructor(){super("expirySeconds cannot be less than 1 second or more than 7 days")}}class T4 extends x6{statusCode;code;key;bucketName;resource;region;constructor(D,$,X,Y={}){super(X),this.statusCode=D,this.code=$,this.key=Y.key,this.bucketName=Y.bucketName,this.resource=Y.resource,this.region=Y.region}}async function vs(D){try{let X=E4(await D.text()).root;if(X?.name!=="Error")throw Error("Invalid root, expected <Error>");let Y=X.children.find((G)=>G.name==="Code")?.content??"UnknownErrorCode",J=X.children.find((G)=>G.name==="Message")?.content??"The error message could not be determined.",Q=X.children.find((G)=>G.name==="Key")?.content,F=X.children.find((G)=>G.name==="BucketName")?.content,w=X.children.find((G)=>G.name==="Resource")?.content,Z=X.children.find((G)=>G.name==="Region")?.content;return new T4(D.status,Y,J,{key:Q,bucketName:F,resource:w,region:Z})}catch{return new T4(D.status,"UnrecognizedError",`Error: Unexpected response code ${D.status} ${D.statusText}. Unable to parse response as XML.`)}}function _s(D){if(typeof D!=="number"||isNaN(D))return!1;return D>=1&&D<=65535}function ks(D){if(typeof D!=="string")return!1;if(D.length<3||D.length>63)return!1;if(D.includes(".."))return!1;if(D.match(/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/))return!1;if(D.match(/^[a-z0-9][a-z0-9.-]+[a-z0-9]$/))return!0;return!1}function C4(D){if(!zPD(D))return!1;if(D.length===0)return!1;return!0}function zPD(D){if(typeof D!=="string")return!1;if(D.length>1024)return!1;return!0}function N2(D){return Array.from(D).map(($)=>$.toString(16).padStart(2,"0")).join("")}function d8(D=""){let $={'"':"","&quot;":"","&#34;":"","&QUOT;":"","&#x00022":""};return D.replace(/^("|&quot;|&#34;)|("|&quot;|&#34;)$/g,(X)=>$[X])}function OL(D){return D.get("x-amz-version-id")??null}function c8(D){let $=D.toISOString();return $.slice(0,4)+$.slice(5,7)+$.slice(8,13)+$.slice(14,16)+$.slice(17,19)+"Z"}function UL(D){return c8(D).slice(0,8)}function qL(D,$){return`${UL($)}/${D}/s3/aws4_request`}async function vZ(D){if(!(D instanceof Uint8Array))D=new TextEncoder().encode(D);return N2(new Uint8Array(await crypto.subtle.digest("SHA-256",D)))}var BPD=["x-amz-server-side-encryption-customer-algorithm","x-amz-server-side-encryption-customer-key","x-amz-server-side-encryption-customer-key-MD5"];class zL extends WritableStream{getResult;constructor({client:D,bucketName:$,objectName:X,partSize:Y,metadata:J}){let Q,F=1,w,Z=[],G,O=[];super({start(){},async write(U,z){let B=F++;try{if(B==1&&U.length<Y){let L=await D.makeRequest({method:"PUT",headers:new Headers({...J,"Content-Length":String(U.length)}),bucketName:$,objectName:X,payload:U});Q={etag:d8(L.headers.get("etag")??void 0),versionId:OL(L.headers)};return}if(B===1)w=(await KPD({client:D,bucketName:$,objectName:X,metadata:J})).uploadId;let K={"Content-Length":String(U.length)};for(let L of BPD){let I=J[L];if(I)K[L]=I}let M=D.makeRequest({method:"PUT",query:{partNumber:B.toString(),uploadId:w},headers:new Headers(K),bucketName:$,objectName:X,payload:U}).then((L)=>{let I=L.headers.get("etag")??"";if(I)I=I.replace(/^"/,"").replace(/"$/,"");return Z.push({part:B,etag:I}),L});O.push(M.catch((L)=>{if(!G)G=L}))}catch(K){throw K}},async close(){if(Q);else if(w){if(await Promise.all(O),G)throw G;Z.sort((U,z)=>U.part>z.part?1:-1),Q=await WPD({client:D,bucketName:$,objectName:X,uploadId:w,etags:Z})}else throw Error("Stream was closed without uploading any data.")}});this.getResult=()=>{if(Q===void 0)throw Error("Result is not ready. await the stream first.");return Q}}}async function KPD(D){let X=new Headers(D.metadata),Y="uploads",Q=await(await D.client.makeRequest({method:"POST",bucketName:D.bucketName,objectName:D.objectName,query:"uploads",headers:X,returnBody:!0})).text(),F=E4(Q).root;if(!F||F.name!=="InitiateMultipartUploadResult")throw Error(`Unexpected response: ${Q}`);let w=F.children.find((Z)=>Z.name==="UploadId")?.content;if(!w)throw Error(`Unable to get UploadId from response: ${Q}`);return{uploadId:w}}async function WPD({client:D,bucketName:$,objectName:X,uploadId:Y,etags:J}){let Q=`
469
469
  <CompleteMultipartUpload xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
470
470
  ${J.map((U)=>` <Part><PartNumber>${U.part}</PartNumber><ETag>${U.etag}</ETag></Part>`).join(`
471
471
  `)}
@@ -474,21 +474,21 @@ All packages are compatible with channel "${F}"`)}return{finalCompatibility:Z.fi
474
474
  `)+`
475
475
  `,Y.join(";").toLowerCase(),J].join(`
476
476
  `)}async function hs(D,$,X){let Y=await vZ(D),J=qL(X,$);return[M2,c8($),J,Y].join(`
477
- `)}async function KL(D,$,X){let Y=UL(D),J=await n8("AWS4"+X,Y),Q=await n8(J,$),F=await n8(Q,"s3");return await n8(F,"aws4_request")}function WL(D,$,X){return`${D}/${qL($,X)}`}async function n8(D,$){let X=new TextEncoder,Y=await crypto.subtle.importKey("raw",D instanceof Uint8Array?D:X.encode(D),{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign","verify"]),J=await crypto.subtle.sign("HMAC",Y,$ instanceof Uint8Array?$:X.encode($));return new Uint8Array(J)}async function ms(D){if(!D.accessKey)throw new m8;if(!D.secretKey)throw new V2;if(D.expirySeconds<1||D.expirySeconds>604800)throw new uZ;let $=new Date(D.date);$.setSeconds($.getSeconds()+D.expirySeconds);let X=WL(D.accessKey,D.region,D.date),Y=c8(D.date),J={"X-Amz-Algorithm":M2,"X-Amz-Credential":X,"X-Amz-Date":Y,key:D.objectKey,...D.fields},Q=[{bucket:D.bucket},{key:D.objectKey},{"X-Amz-Algorithm":M2},{"X-Amz-Credential":X},{"X-Amz-Date":Y}];if(D.conditions)Q.push(...D.conditions);for(let[q,B]of Object.entries(D.fields||{})){if(["key","X-Amz-Algorithm","X-Amz-Credential","X-Amz-Date"].includes(q))continue;Q.push({[q]:B})}let F={expiration:$.toISOString(),conditions:Q},w=new TextEncoder().encode(JSON.stringify(F)),Z=btoa(String.fromCharCode(...w));J.policy=Z;let G=Z,O=await KL(D.date,D.region,D.secretKey),U=N2(await n8(O,G)).toLowerCase();return J["X-Amz-Signature"]=U,{url:`${D.protocol}//${D.host}/${D.bucket}`,fields:J}}var VPD=["Content-Type","Cache-Control","Content-Disposition","Content-Encoding","Content-Language","Expires","x-amz-checksum-sha256","x-amz-grant-full-control","x-amz-grant-read","x-amz-grant-read-acp","x-amz-grant-write-acp","x-amz-server-side-encryption","x-amz-storage-class","x-amz-website-redirect-location","x-amz-server-side-encryption-customer-algorithm","x-amz-server-side-encryption-customer-key","x-amz-server-side-encryption-customer-key-MD5","x-amz-server-side-encryption-aws-kms-key-id","x-amz-server-side-encryption-context","x-amz-server-side-encryption-bucket-key-enabled","x-amz-request-payer","x-amz-tagging","x-amz-object-lock-mode","x-amz-object-lock-retain-until-date","x-amz-object-lock-legal-hold","x-amz-expected-bucket-owner"],NPD=5242880,MPD=5368709120,HL=5497558138880;class _Z{host;port;protocol;accessKey;#D;sessionToken;defaultBucket;region;userAgent="s3-lite-client";pathStyle;pathPrefix;constructor({endPoint:D,useSSL:$,port:X,pathPrefix:Y,...J}){if(/^https?:\/\//i.test(D)){if($!==void 0||X!==void 0||Y!==void 0)throw new j1("useSSL/port/pathPrefix cannot be specified if endPoint is a URL.");try{let F=new URL(D);if(D=F.hostname,$=F.protocol==="https:",X=F.port?parseInt(F.port,10):$?443:80,F.pathname&&F.pathname!=="/")Y=F.pathname.endsWith("/")?F.pathname.slice(0,-1):F.pathname}catch{throw new SZ(`Invalid endPoint URL: ${D}`)}}if(typeof D!=="string"||D.length===0)throw new SZ(`Invalid endPoint: ${D}`);if($===void 0)$=!0;if(X!==void 0&&!_s(X))throw new j1(`Invalid port: ${X}`);if(J.accessKey&&!J.secretKey)throw new j1("If specifying access key, secret key must also be provided.");if(J.accessKey&&J.accessKey.startsWith("ASIA")&&!J.sessionToken)throw new j1("If specifying temporary access key, session token must also be provided.");let Q=$?443:80;if(this.port=X??Q,this.host=D.toLowerCase()+(this.port!==Q?`:${this.port}`:""),this.protocol=$?"https:":"http:",this.accessKey=J.accessKey,this.#D=J.secretKey??"",this.sessionToken=J.sessionToken,this.pathStyle=J.pathStyle??!0,this.pathPrefix=Y??"",this.defaultBucket=J.bucket,this.region=J.region,this.pathPrefix){if(!this.pathStyle)throw new j1("pathPrefix is incompatible with pathStyle=false");if(!this.pathPrefix.startsWith("/"))throw new j1("pathPrefix should start with /");if(this.pathPrefix.endsWith("/"))throw new j1("pathPrefix should not end with /")}}getBucketName(D){let $=D?.bucketName??this.defaultBucket;if($===void 0||!ks($))throw new ZL($??"");return $}buildRequestOptions(D){let $=this.getBucketName(D),X=this.pathStyle?this.host:`${$}.${this.host}`,Y=D.headers??new Headers;Y.set("host",X);let J=typeof D.query==="object"?new URLSearchParams(D.query).toString().replace("+","%20"):D.query,Q=this.pathStyle?`${this.pathPrefix}/${$}/${D.objectName}`:`/${D.objectName}`,F=J?`?${J}`:"",w=Q+F,Z=Q.split("/").map((G)=>encodeURIComponent(G)).join("/")+F;return{headers:Y,host:X,path:w,encodedPath:Z}}async makeRequest({method:D,payload:$,...X}){let Y=new Date,{headers:J,host:Q,path:F,encodedPath:w}=this.buildRequestOptions(X),Z=X.statusCode??200;if(D==="POST"||D==="PUT"||D==="DELETE"){if($===void 0)$=new Uint8Array;else if(typeof $==="string")$=new TextEncoder().encode($);J.set("Content-Length",String($.length))}else if($)throw Error(`Unexpected payload on ${D} request.`);let G=await vZ($??new Uint8Array);if(J.set("x-amz-date",c8(Y)),J.set("x-amz-content-sha256",G),this.accessKey){if(this.sessionToken)J.set("x-amz-security-token",this.sessionToken);J.set("authorization",await fs({headers:J,method:D,path:F,accessKey:this.accessKey,secretKey:this.#D,region:this.region,date:Y}))}let O=`${this.protocol}//${Q}${w}`,U=await fetch(O,{method:D,headers:J,body:$});if(U.status!==Z){if(U.status>=400)throw await vs(U);else if(U.status===301)throw new T4(U.status,"UnexpectedRedirect",'The server unexpectedly returned a redirect response. With AWS S3, this usually means you need to use a region-specific endpoint like "s3.us-west-2.amazonaws.com" instead of "s3.amazonaws.com"');throw new T4(U.status,"UnexpectedStatusCode",`Unexpected response code from the server (expected ${Z}, got ${U.status} ${U.statusText}).`)}if(!X.returnBody)await U.body?.getReader().read();return U}async deleteObject(D,$={}){let X=this.getBucketName($);if(!C4(D))throw new S6(D);let Y=$.versionId?{versionId:$.versionId}:{},J=new Headers;if($.governanceBypass)J.set("X-Amz-Bypass-Governance-Retention","true");await this.makeRequest({method:"DELETE",bucketName:X,objectName:D,headers:J,query:Y,statusCode:204})}async exists(D,$){try{return await this.statObject(D,$),!0}catch(X){if(X instanceof T4&&X.statusCode===404)return!1;throw X}}getObject(D,$){return this.getPartialObject(D,{...$,offset:0,length:0})}async getPartialObject(D,{offset:$,length:X,...Y}){let J=this.getBucketName(Y);if(!C4(D))throw new S6(D);let Q=new Headers(Object.entries(Y.metadata??{})),F=200;if($||X){let Z="";if($)Z=`bytes=${+$}-`;else Z="bytes=0-",$=0;if(X)Z+=`${+X+$-1}`;Q.set("Range",Z),F=206}let w={...Y.responseParams,...Y.versionId?{versionId:Y.versionId}:{}};return await this.makeRequest({method:"GET",bucketName:J,objectName:D,headers:Q,query:w,statusCode:F,returnBody:!0})}getPresignedUrl(D,$,X={}){if(!this.accessKey)throw new m8;if(!C4($))throw new S6($);let{headers:Y,path:J}=this.buildRequestOptions({objectName:$,bucketName:X.bucketName,query:X.parameters}),Q=X.requestDate??new Date,F=X.expirySeconds??604800;return ys({protocol:this.protocol,headers:Y,method:D,path:J,accessKey:this.accessKey,secretKey:this.#D,sessionToken:this.sessionToken,region:this.region,date:Q,expirySeconds:F})}presignedGetObject(D,$={}){let{versionId:X,responseParams:Y,...J}=$,Q={...Y,...X?{versionId:X}:{}};return this.getPresignedUrl("GET",D,{parameters:Q,...J})}async*listObjects(D={}){for await(let $ of this.listObjectsGrouped({...D,delimiter:""}))if($.type==="Object")yield $;else throw Error(`Unexpected result from listObjectsGrouped(): ${$}`)}async*listObjectsGrouped(D){let $=this.getBucketName(D),X="",Y=D.pageSize??1000;if(Y<1||Y>1000)throw new j1("pageSize must be between 1 and 1,000.");let J=0;while(!0){let Q=D.maxResults?Math.min(Y,D.maxResults-J):Y;if(Q===0)return;let w=await(await this.makeRequest({method:"GET",bucketName:$,objectName:"",query:{"list-type":"2",prefix:D.prefix??"",delimiter:D.delimiter,"max-keys":String(Q),...X?{"continuation-token":X}:{}},returnBody:!0})).text(),Z=E4(w).root;if(!Z||Z.name!=="ListBucketResult")throw Error(`Unexpected response: ${w}`);let G=Z.children.filter((z)=>z.name==="CommonPrefixes").flatMap((z)=>z.children),O=[];for(let z of G)O.push({type:"CommonPrefix",prefix:z.content??""}),J++;for(let z of Z.children.filter((q)=>q.name==="Contents"))O.push({type:"Object",key:z.children.find((q)=>q.name==="Key")?.content??"",etag:d8(z.children.find((q)=>q.name==="ETag")?.content??""),size:parseInt(z.children.find((q)=>q.name==="Size")?.content??"",10),lastModified:new Date(z.children.find((q)=>q.name==="LastModified")?.content??"invalid")}),J++;O.sort((z,q)=>{let B=z.type==="Object"?z.key:z.prefix,K=q.type==="Object"?q.key:q.prefix;return B>K?1:B<K?-1:0});for(let z of O)yield z;if(Z.children.find((z)=>z.name==="IsTruncated")?.content==="true"){let z=Z.children.find((q)=>q.name==="NextContinuationToken")?.content;if(!z)throw Error("Unexpectedly missing continuation token, but server said there are more results.");X=z}else return}}async putObject(D,$,X){let Y=this.getBucketName(X);if(!C4(D))throw new S6(D);let J,Q;if(typeof $==="string"){let G=new TextEncoder().encode($);if(typeof ReadableStream.from<"u")Q=ReadableStream.from([G]);else Q=new ReadableStream({start(O){O.enqueue(G),O.close()}});J=G.length}else if($ instanceof Uint8Array){if(typeof ReadableStream.from<"u")Q=ReadableStream.from([$]);else Q=new ReadableStream({start(G){G.enqueue($),G.close()}});J=$.byteLength}else if($ instanceof ReadableStream)Q=$;else throw new j1("Invalid stream/data type provided.");if(X?.size!==void 0){if(J!==void 0&&X?.size!==J)throw new j1(`size was specified (${X.size}) but doesn't match auto-detected size (${J}).`);if(typeof X.size!=="number"||X.size<0||isNaN(X.size))throw new j1(`invalid size specified: ${X.size}`);else J=X.size}let F=X?.partSize??this.calculatePartSize(J);if(F<NPD)throw new j1("Part size should be greater than 5MB");else if(F>MPD)throw new j1("Part size should be less than 6MB");let w=new wL(F),Z=new zL({client:this,bucketName:Y,objectName:D,partSize:F,metadata:X?.metadata??{}});return await Q.pipeThrough(w).pipeTo(Z),Z.getResult()}calculatePartSize(D){if(D===void 0)D=HL;if(D>HL)throw TypeError(`size should not be more than ${HL}`);let $=67108864;while(!0){if($*1e4>D)return $;$+=16777216}}async statObject(D,$){let X=this.getBucketName($);if(!C4(D))throw new S6(D);let Y={};if($?.versionId)Y.versionId=$.versionId;let J=await this.makeRequest({method:"HEAD",bucketName:X,objectName:D,query:Y,headers:new Headers($?.headers)}),Q={};for(let F of VPD)if(J.headers.has(F))Q[F]=J.headers.get(F);return J.headers.forEach((F,w)=>{if(w.startsWith("x-amz-meta-"))Q[w]=J.headers.get(w)}),{type:"Object",key:D,size:parseInt(J.headers.get("content-length")??"",10),metadata:Q,lastModified:new Date(J.headers.get("Last-Modified")??"error: missing last modified"),versionId:J.headers.get("x-amz-version-id")||null,etag:d8(J.headers.get("ETag")??"")}}async copyObject(D,$,X){let Y=this.getBucketName(X),J=D.sourceBucketName??Y;if(!C4($))throw new S6($);let Q=`${J}/${D.sourceKey}`;if(D.sourceVersionId)Q+=`?versionId=${D.sourceVersionId}`;let F=new Headers(X?.metadata);if(X?.metadata!==void 0)F.set("x-amz-metadata-directive","REPLACE");F.set("x-amz-copy-source",Q);let w=await this.makeRequest({method:"PUT",bucketName:Y,objectName:$,headers:F,returnBody:!0}),Z=await w.text(),G=E4(Z).root;if(!G||G.name!=="CopyObjectResult")throw Error(`Unexpected response: ${Z}`);let O=G.children.find((z)=>z.name==="ETag")?.content??"",U=G.children.find((z)=>z.name==="LastModified")?.content;if(U===void 0)throw Error("Unable to find <LastModified>...</LastModified> from the server.");return{copySourceVersionId:w.headers.get("x-amz-copy-source-version-id")||null,etag:d8(O),lastModified:new Date(U),versionId:w.headers.get("x-amz-version-id")||null}}async bucketExists(D){try{return await this.listObjects({bucketName:D}).next(),!0}catch($){if($ instanceof T4&&$.statusCode===404)return!1;throw $}}async makeBucket(D){await this.makeRequest({method:"PUT",bucketName:this.getBucketName({bucketName:D}),objectName:"",statusCode:200})}async removeBucket(D){await this.makeRequest({method:"DELETE",bucketName:this.getBucketName({bucketName:D}),objectName:"",statusCode:204})}presignedPostObject(D,$={}){if(!C4(D))throw new S6(D);let X=this.getBucketName($);if(!X)throw Error("Bucket name is required for presignedPost, but none was provided either to this method nor to the client constructor");let Y=$.requestDate||new Date,J=$.expirySeconds??3600;return ms({protocol:this.protocol,host:this.host,bucket:X,objectKey:D,accessKey:this.accessKey||"",secretKey:this.#D||"",region:this.region,date:Y,expirySeconds:J,conditions:$.conditions,fields:$.fields})}}vD();s$();D6();MY();q1();q3();vD();import ds from"node:process";var LPD=[{code:"aws:eu-central-1",label:"EU (Frankfurt)"},{code:"gcp:me-central1",label:"Middle East (Riyadh)"},{code:"gcp:asia-east2",label:"Hong Kong"},{code:"aws:ap-northeast-1",label:"Japan (Tokyo)"},{code:"aws:ap-south-1",label:"India (Mumbai)"},{code:"aws:us-east-1",label:"North America (Virginia)"},{code:"gcp:africa-south1",label:"Africa (South Africa)"},{code:"aws:ap-southeast-2",label:"Oceania (Sydney)"},{code:"aws:sa-east-1",label:"South America (São Paulo)"}],IPD=60000,APD=1000,cs=20;function RPD(){if(typeof Intl>"u")return null;return Intl.DateTimeFormat().resolvedOptions().timeZone||null}function jPD(){let D=RPD();if(!D)return null;if(/^America\//.test(D))return"aws:us-east-1";if(/^Europe\//.test(D)||/^Atlantic\//.test(D))return"aws:eu-central-1";if(/^Africa\//.test(D))return"gcp:africa-south1";if(/^Asia\//.test(D)){let $=(D.split("/")[1]??"").toLowerCase();if(["tokyo","osaka","seoul","pyongyang"].includes($))return"aws:ap-northeast-1";if(["kolkata","mumbai","calcutta","chennai","bangalore","hyderabad","delhi","dhaka","colombo","karachi"].includes($))return"aws:ap-south-1";if(["hong_kong","singapore","manila","jakarta","kuala_lumpur","beijing","shanghai","hongkong","taipei"].includes($))return"gcp:asia-east2";if(["sydney","melbourne","canberra","perth","brisbane","darwin","adelaide"].includes($))return"aws:ap-southeast-2";return"gcp:asia-east2"}if(/^Pacific\//.test(D)||/^Australia\//.test(D))return"aws:ap-southeast-2";return null}function EPD(){let D=[...LPD],$=jPD();if(!$)return D;let X=D.findIndex((J)=>J.code===$);if(X<0)return D;let[Y]=D.splice(X,1);return D.push(Y),D}function TPD(D,$,X){let Y=Math.min(Math.max(D,0),X);return Math.floor(Y/X*$)}function CPD(D){let $=Math.min(Math.max(D,0),100),X=Math.round($/100*cs);return`${"█".repeat(X)}${"░".repeat(cs-X)}`}function PPD(D){return`${Math.max(0,D)}s`}function ls({interactive:D=ds.stdout.isTTY&&ds.stderr.isTTY,totalMs:$=IPD,updateIntervalMs:X=APD,title:Y="Replicating your bundle in all regions...",completeMessage:J="Your update is now available worldwide."}={}){if(!D||$<=0)return Promise.resolve();let Q=EPD();if(!Q.length)return Promise.resolve();H.info(Y),H.info(`Regions: ${Q.map((O)=>O.label).join(" • ")}`);let F=A0(),w=Date.now(),Z=Q.length,G=null;return new Promise((O)=>{let U=()=>{let z=Date.now()-w,q=Math.max(0,$-z),B=TPD(z,Z,$),K=Math.min(100,Math.round(z/$*100)),M=CPD(K),L=B<Z?Q[B]?.label||"Finalizing":"Complete",I=`${B}/${Z} regions updated • ${PPD(Math.ceil(q/1000))} left • ${M} • Next: ${L}`;F.message(I)};F.start(Y),U(),G=setInterval(U,X),setTimeout(()=>{if(G)clearInterval(G);F.stop(J),O()},$)})}fD();vD();D6();function ns(D){try{let $=eD(D);return z$(L7($,"patch"))}catch{let $=D.match(/^(\d+)\.(\d+)\.(\d+)/);if($){let[,X,Y,J]=$;return`${X}.${Y}.${Number.parseInt(J)+1}`}return"1.0.1"}}async function is(D,$){let X=ns(D),Y=$?` for ${$}`:"",J=await t1({message:`How do you want to handle the version${Y}?`,options:[{value:"auto",label:`Auto: Bump patch version (${D} → ${X})`},{value:"manual",label:"Manual: I'll provide the version number"}]});if(yD(J))return null;if(J==="auto")return H.info(`\uD83D\uDD22 Auto-bumped version from ${D} to ${X}`),X;let Q=await _6({message:`Current version is ${D}. Enter new version:`,validate:(F)=>{if(!F)return"Version is required";if(!F.match(/^\d+\.\d+\.\d+/))return"Please enter a valid version (x.y.z)"}});if(yD(Q))return null;return Q}function ps(D){let $=ns(D);try{let X=eD(D);return[$,z$(L7(X,"minor")),`${D}-beta.1`,`${D}.1`]}catch{return[$,`${D}.1`,`${D}-beta.1`,`${D}-rc.1`]}}import{readdirSync as rs,readFileSync as xPD,statSync as SPD}from"node:fs";import{extname as uPD,join as vPD}from"node:path";function _PD(D,$){return xPD(D,"utf8").includes($)}function L2(D,$){let X=rs(D);for(let Y of X){let J=vPD(D,Y),Q=SPD(J);if(Q.isDirectory()){if(L2(J,$))return!0}else if(Q.isFile()&&uPD(J)===".js"){if(_PD(J,$))return!0}}return!1}function kZ(D){if(rs(D).indexOf("index.html")>-1)return!0;return!1}vD();D6();var $DD=V0(ee(),1),XDD=V0(NY(),1);import{Buffer as QSD}from"node:buffer";import{createHash as FSD}from"node:crypto";import{createReadStream as vL,statSync as wSD}from"node:fs";import{platform as ZSD}from"node:os";import{join as GSD,posix as OSD,win32 as DDD}from"node:path";import{cwd as USD}from"node:process";import{buffer as _L}from"node:stream/consumers";import{createBrotliCompress as qSD}from"node:zlib";fD();async function zSD(D,$){try{let X=new URL(`${D.hostFilesApi}/files/read/attachments/${encodeURIComponent($)}`);return X.searchParams.set("nocache",`${Date.now()}`),(await fetch(X.toString(),{method:"GET",headers:{range:"bytes=0-0","cache-control":"no-cache"}})).ok}catch{return!1}}var BSD=8192;async function KSD(D){let $=e0(USD()),X=await y1("@capgo/capacitor-updater",$,D.packageJson),Y;try{Y=X?eD(X):void 0}catch{Y=void 0}if(!X||!Y)return{version:null,supportsBrotliV2:!1};let J=!Z$(Y,void 0,void 0,Q2);return{version:`${Y.major}.${Y.minor}.${Y.patch}`,supportsBrotliV2:J}}function WSD(D,$){if(!$)return!1;let X=$.split(",").map((Y)=>Y.trim()).filter((Y)=>!!Y);if(X.length===0)return!1;return $DD.isMatch(D,X)}async function HSD(D,$,X){let J=wSD(D).size,Q=await _L(vL(D));if(J===0)return{buffer:Q,useBrotli:!1};if(WSD($,X.noBrotliPatterns))return{buffer:Q,useBrotli:!1};if(J<BSD)return{buffer:Q,useBrotli:!1};try{let F=await _L(vL(D).pipe(qSD({})));if(F.length>=J-10)return{buffer:Q,useBrotli:!1};return{buffer:F,useBrotli:!0}}catch(F){return H.warn(`Brotli compression failed for ${D}: ${F}, using original file`),{buffer:Q,useBrotli:!1}}}async function JDD(D,$,X,Y,J,Q,F=!1){let w=A0();w.start(J!=="v2"?"Generating the update manifest":`Generating the update manifest with ${F?"V3":"V2"} encryption`);let Z=await Ra(D);if(J==="v2")for(let G of Z)G.hash=F?w7(G.hash,Q):F7(G.hash,Q);return w.stop("Manifest generated successfully"),await RD($,{channel:"partial-update",event:"Generate manifest",icon:"\uD83D\uDCC2",user_id:X,tags:{"app-id":Y},notify:!1}),Z}function VSD(D){if(ZSD()!=="win32")return D;return DDD.normalize(D).split(DDD.sep).join(OSD.sep)}function NSD(D){let $=D.split("/").map((X)=>encodeURIComponent(X)).join("/");if(D.includes(" "))H.warn(`File "${D}" contains spaces in its name.`);return $}async function YDD(D,$,X,Y,J,Q,F){let w=A0();w.start("Preparing partial update with TUS protocol");let Z=performance.now(),G=await u$(),O=!!(F.partial||F.delta||F.partialOnly||F.deltaOnly),{version:U,supportsBrotliV2:z}=await KSD(F);if(!z)throw Error(`Your project is using an older version of @capgo/capacitor-updater (${U||"unknown"}). To use Delta updates, please upgrade to version ${QZ} (v5), ${FZ} (v6) or ${Q2} (v7) or higher.`);else if(F.disableBrotli)H.info("Brotli compression disabled by user request");else if(F.noBrotliPatterns)H.info(`Files matching patterns (${F.noBrotliPatterns}) will be excluded from brotli compression`);let q=$.filter((L)=>L.file.includes(" "));if(q.length>0)throw Error(`Files with spaces in their names (${q.map((L)=>L.file).join(", ")}). Please rename the files.`);let B=0,K=$.length,M=0;try{w.message(`Uploading ${K} files using TUS protocol`);let L=async(R)=>{let P=GSD(X,R.file),A=VSD(R.file),_,v=!1;if(F.disableBrotli)_=await _L(vL(P)),v=!1;else{let j=await HSD(P,A,F);_=j.buffer,v=j.useBrotli}let S=_;if(Q)S=Q7(_,Q.sessionKey,Q.ivSessionKey);let h=A;if(v)h=`${A}.br`,M++;let g=NSD(h),l=FSD("sha256").update(R.hash).digest("hex"),f;if(Q){let j=QSD.from(Q.ivSessionKey).toString("hex");f=`orgs/${J}/apps/${Y}/delta/${j}/${l}_${g}`}else f=`orgs/${J}/apps/${Y}/delta/${l}_${g}`;if(!Q&&await zSD(G,f))return B++,Promise.resolve({file_name:g,s3_path:f,file_hash:R.hash});return new Promise((j,x)=>{w.message(`Prepare upload partial file: ${A}`);let u=M4(h);new XDD.Upload(S,{endpoint:`${G.hostFilesApi}/files/upload/attachments/`,chunkSize:F.tusChunkSize,retryDelays:[0,1000,3000,5000,1e4],removeFingerprintOnSuccess:!0,metadata:{filename:f,filetype:u},headers:{Authorization:D},onError:(d)=>{let b=d.toString(),a;try{let n=b.match(/response text: (\{.*?\})/);if(n&&n[1])a=JSON.parse(n[1]).moreInfo?.requestId}catch{}let c=a?` [requestId: ${a}]`:"";H.error(`Failed to upload ${A}: ${b}${c}`),x(d)},onProgress(){let d=(B/K*100).toFixed(2);w.message(`Uploading partial update: ${d}%`)},onSuccess(){B++,j({file_name:g,s3_path:f,file_hash:R.hash})}}).start()})},I=500,W=[];for(let R=0;R<$.length;R+=I){let P=$.slice(R,R+I),A=Math.floor(R/I)+1,_=Math.ceil($.length/I);if(_>1)w.message(`Processing batch ${A}/${_} (${P.length} files)`);let v=await Promise.all(P.map((S)=>L(S)));W.push(...v)}let V=((performance.now()-Z)/1000).toFixed(2);if(w.stop(`Partial update uploaded successfully \uD83D\uDCAA in (${V} seconds)`),M>0)H.info(`${M} of ${K} files were compressed with brotli and use .br extension`);return await RD(D,{channel:"app",event:`App Partial TUS done${M>0?" with .br extension":""}`,icon:"⏫",user_id:J,tags:{"app-id":Y},notify:!1}),await RD(D,{channel:"performance",event:"Partial upload performance",icon:"\uD83D\uDE84",user_id:J,tags:{"app-id":Y,time:V},notify:!1}),W}catch(L){let W=((performance.now()-Z)/1000).toFixed(2);if(w.error(`Failed to upload Partial bundle (after ${W} seconds)`),O)throw H.error(`Error uploading partial update: ${L}`),H.error("Delta/partial upload was explicitly requested but failed. Upload aborted."),L;else return H.info(`Error uploading partial update: ${L}, This is not a critical error, the bundle has been uploaded without the partial files`),null}}function W0(D){throw H.error(D),Error(D)}function RSD(D){let $=new R0;$.headers=["Package","Local","Remote","Status","Details"],$.theme=R0.roundTheme,$.rows=[];for(let X of D){let{name:Y,localVersion:J,remoteVersion:Q}=X,F=k8(X),w=F.compatible?"✅":"❌";$.rows.push([Y,J||"-",Q||"-",w,F.message])}H.info($.toString())}async function jSD(D,$){let X=N4("",$.packageJson),Y=$.bundle||D?.plugins?.CapacitorUpdater?.version||X||`0.0.1-beta.${MSD().split("-")[0]}`;if(!p5.test(Y))W0(`Your bundle name ${Y}, is not valid it should follow semver convention : https://semver.org/`);return Y}function ESD(D){let $=D.apikey||BD();if(!$)W0("Missing API key, you need to provide an API key to upload your bundle");return $}function TSD(D,$,X){let Y=iD(D,X),J=$.path||X?.webDir;if(!Y)W0("Missing argument, you need to provide a appid or be in a capacitor project");if(!J)W0("Missing argument, you need to provide a path (--path), or be in a capacitor project");if(!dZ(J))W0(`Path ${J} does not exist, build your app first, or provide a valid path`);return{appid:Y,path:J}}function CSD(D,$){let X=D.codeCheck;if(typeof X>"u"||X){if(!L2($,"notifyAppReady"))W0(`notifyAppReady() is missing in the build folder of your app. see: https://capgo.app/docs/plugin/api/#notifyappready
478
- If you are sure your app has this code, you can use the --no-code-check option`);if(!kZ($))W0(`index.html is missing in the root folder of ${$}`)}}async function PSD(D,$,X,Y,J,Q){let{ignoreMetadataCheck:F,autoMinUpdateVersion:w,minUpdateVersion:Z}=X,{data:G,error:O}=await D.from("channels").select("disable_auto_update, version ( min_update_version, native_packages )").eq("name",Y).eq("app_id",J).single(),U=!!G&&G.disable_auto_update==="version_number",z,q;if(!O&&G&&G.version&&G.version.native_packages&&!F){let M=A0();M.start(`Checking bundle compatibility with channel ${Y}`);let{finalCompatibility:L,localDependencies:I}=await OZ(D,J,Y,X.packageJson,X.nodeModules);if(q=L,z=I,q.filter((N)=>!L4(N)).length>0){if(M.error(`Bundle NOT compatible with ${Y} channel`),H.warn(""),RSD(q),H.warn(""),H.warn("An app store update may be required for these changes to take effect."),w)Z=Q,H.info(`Auto set min-update-version to ${Z}`)}else if(w)try{let{min_update_version:N}=G.version;if(!N||!p5.test(N))W0("Invalid remote min update version, skipping auto setting compatibility");Z=N,M.stop(`Auto set min-update-version to ${Z}`)}catch{W0(`Cannot auto set compatibility, invalid data ${G}`)}else M.stop(`Bundle compatible with ${Y} channel`)}else if(!F){if(H.warn(`Channel ${Y} is new or it's your first upload with compatibility check, it will be ignored this time`),z=await vM(X.packageJson,X.nodeModules),w)Z=Q,H.info(`Auto set min-update-version to ${Z}`)}if(U&&!Z&&!F)W0("You need to provide a min-update-version to upload a bundle to this channel");if(Z){if(!p5.test(Z))W0(`Your minimal version update ${Z}, is not valid it should follow semver convention : https://semver.org/`)}let B=z?new Map(z.filter((M)=>!!M.native&&M.native!==void 0).map((M)=>[M.name,M])):new Map;return{nativePackages:B.size>0||!X.ignoreMetadataCheck?Array.from(B,([M,L])=>({name:M,version:L.version,...L.ios_checksum&&{ios_checksum:L.ios_checksum},...L.android_checksum&&{android_checksum:L.android_checksum}})):void 0,minUpdateVersion:Z}}async function xSD(D,$,X,Y=!1,J=!1){let{data:Q,error:F}=await D.rpc("exist_app_versions",{appid:$,name_version:X}).single();if(Q||F){if(Y)return H.warn(`Version ${X} already exists - exiting gracefully due to --silent-fail option`),ND("Bundle version already exists - exiting gracefully \uD83C\uDF89"),!0;if(J){H.error(`❌ Version ${X} already exists`);let w=ps(X);H.info("\uD83D\uDCA1 Here are some suggestions:"),w.forEach((O,U)=>{H.info(` ${U+1}. ${O}`)});let Z=await t1({message:"What would you like to do?",options:[{value:"suggest1",label:`Use ${w[0]}`},{value:"suggest2",label:`Use ${w[1]}`},{value:"suggest3",label:`Use ${w[2]}`},{value:"suggest4",label:`Use ${w[3]}`},{value:"custom",label:"Enter a custom version"},{value:"cancel",label:"Cancel upload"}]});if(yD(Z)||Z==="cancel")W0("Upload cancelled by user");let G;if(Z==="custom"){let O=await is(X,"upload");if(!O)W0("Upload cancelled by user");G=O}else{let O=Number.parseInt(Z.replace("suggest",""))-1;G=w[O]}return H.info(`\uD83D\uDD04 Retrying with new version: ${G}`),G}W0(`Version ${X} already exists ${s(F)}`)}return!1}async function SSD(D,$,X,Y,J,Q,F,w){let Z,G,O="",U=null,z="none",q="",B="",K=$.keyV2,M=$.key===!1,L=A0();L.start(`Zipping bundle from ${D}`),U=await wZ(D),L.message("Calculating checksum");let I=e0(kL()),W=await y1("@capgo/capacitor-updater",I,$.packageJson),N=!1,V;try{V=W?eD(W):void 0}catch{V=void 0}if(!W)W0("Cannot find @capgo/capacitor-updater in node_modules, please install it first with your package manager");else if(V)N=!Z$(V,QZ,FZ,Q2);else if(W==="link:@capgo/capacitor-updater"||W==="file:.."||W==="file:../")H.warn("Using local @capgo/capacitor-updater. Assuming latest version for checksum calculation."),N=!0;let R=$.forceCrc32Checksum===!0,P=!R&&((K||$.keyDataV2||dZ(i1))&&!M||N);if(O=await p6(U,P?"sha256":"crc32"),L.stop(`Checksum ${P?"SHA256":"CRC32"}${R?" (forced)":""}: ${O}`),M)H.info("Encryption ignored");else if((K||dZ(i1)||$.keyDataV2)&&!$.oldEncryption){let v=typeof K==="string"?K:i1,S=$.keyDataV2||"";if(!S&&!dZ(v))W0(`Cannot find private key ${v}`);if(await RD(X,{channel:"app",event:"App encryption v2",icon:"\uD83D\uDD11",user_id:Y,tags:{"app-id":J},notify:!1},$.verbose),!S)S=LSD(v).toString();let h=V&&!Z$(V,"5.30.0","6.30.0","7.30.0");H.info(`Encrypting your bundle with ${h?"V3":"V2"}`);let{sessionKey:g,ivSessionKey:l}=xZ(S),f=Q7(U,g,l);if(O=h?w7(O,S):F7(O,S),Z=l,G=g,z="v2",q=S,w){if(B=Ts(w),$.verbose)H.info(`[Verbose] Encryption key_id: ${B}`)}if($.displayIvSession)H.info(`Your Iv Session key is ${Z},
477
+ `)}async function KL(D,$,X){let Y=UL(D),J=await n8("AWS4"+X,Y),Q=await n8(J,$),F=await n8(Q,"s3");return await n8(F,"aws4_request")}function WL(D,$,X){return`${D}/${qL($,X)}`}async function n8(D,$){let X=new TextEncoder,Y=await crypto.subtle.importKey("raw",D instanceof Uint8Array?D:X.encode(D),{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign","verify"]),J=await crypto.subtle.sign("HMAC",Y,$ instanceof Uint8Array?$:X.encode($));return new Uint8Array(J)}async function ms(D){if(!D.accessKey)throw new m8;if(!D.secretKey)throw new V2;if(D.expirySeconds<1||D.expirySeconds>604800)throw new uZ;let $=new Date(D.date);$.setSeconds($.getSeconds()+D.expirySeconds);let X=WL(D.accessKey,D.region,D.date),Y=c8(D.date),J={"X-Amz-Algorithm":M2,"X-Amz-Credential":X,"X-Amz-Date":Y,key:D.objectKey,...D.fields},Q=[{bucket:D.bucket},{key:D.objectKey},{"X-Amz-Algorithm":M2},{"X-Amz-Credential":X},{"X-Amz-Date":Y}];if(D.conditions)Q.push(...D.conditions);for(let[q,B]of Object.entries(D.fields||{})){if(["key","X-Amz-Algorithm","X-Amz-Credential","X-Amz-Date"].includes(q))continue;Q.push({[q]:B})}let F={expiration:$.toISOString(),conditions:Q},w=new TextEncoder().encode(JSON.stringify(F)),Z=btoa(String.fromCharCode(...w));J.policy=Z;let G=Z,O=await KL(D.date,D.region,D.secretKey),U=N2(await n8(O,G)).toLowerCase();return J["X-Amz-Signature"]=U,{url:`${D.protocol}//${D.host}/${D.bucket}`,fields:J}}var VPD=["Content-Type","Cache-Control","Content-Disposition","Content-Encoding","Content-Language","Expires","x-amz-checksum-sha256","x-amz-grant-full-control","x-amz-grant-read","x-amz-grant-read-acp","x-amz-grant-write-acp","x-amz-server-side-encryption","x-amz-storage-class","x-amz-website-redirect-location","x-amz-server-side-encryption-customer-algorithm","x-amz-server-side-encryption-customer-key","x-amz-server-side-encryption-customer-key-MD5","x-amz-server-side-encryption-aws-kms-key-id","x-amz-server-side-encryption-context","x-amz-server-side-encryption-bucket-key-enabled","x-amz-request-payer","x-amz-tagging","x-amz-object-lock-mode","x-amz-object-lock-retain-until-date","x-amz-object-lock-legal-hold","x-amz-expected-bucket-owner"],NPD=5242880,MPD=5368709120,HL=5497558138880;class _Z{host;port;protocol;accessKey;#D;sessionToken;defaultBucket;region;userAgent="s3-lite-client";pathStyle;pathPrefix;constructor({endPoint:D,useSSL:$,port:X,pathPrefix:Y,...J}){if(/^https?:\/\//i.test(D)){if($!==void 0||X!==void 0||Y!==void 0)throw new j1("useSSL/port/pathPrefix cannot be specified if endPoint is a URL.");try{let F=new URL(D);if(D=F.hostname,$=F.protocol==="https:",X=F.port?parseInt(F.port,10):$?443:80,F.pathname&&F.pathname!=="/")Y=F.pathname.endsWith("/")?F.pathname.slice(0,-1):F.pathname}catch{throw new SZ(`Invalid endPoint URL: ${D}`)}}if(typeof D!=="string"||D.length===0)throw new SZ(`Invalid endPoint: ${D}`);if($===void 0)$=!0;if(X!==void 0&&!_s(X))throw new j1(`Invalid port: ${X}`);if(J.accessKey&&!J.secretKey)throw new j1("If specifying access key, secret key must also be provided.");if(J.accessKey&&J.accessKey.startsWith("ASIA")&&!J.sessionToken)throw new j1("If specifying temporary access key, session token must also be provided.");let Q=$?443:80;if(this.port=X??Q,this.host=D.toLowerCase()+(this.port!==Q?`:${this.port}`:""),this.protocol=$?"https:":"http:",this.accessKey=J.accessKey,this.#D=J.secretKey??"",this.sessionToken=J.sessionToken,this.pathStyle=J.pathStyle??!0,this.pathPrefix=Y??"",this.defaultBucket=J.bucket,this.region=J.region,this.pathPrefix){if(!this.pathStyle)throw new j1("pathPrefix is incompatible with pathStyle=false");if(!this.pathPrefix.startsWith("/"))throw new j1("pathPrefix should start with /");if(this.pathPrefix.endsWith("/"))throw new j1("pathPrefix should not end with /")}}getBucketName(D){let $=D?.bucketName??this.defaultBucket;if($===void 0||!ks($))throw new ZL($??"");return $}buildRequestOptions(D){let $=this.getBucketName(D),X=this.pathStyle?this.host:`${$}.${this.host}`,Y=D.headers??new Headers;Y.set("host",X);let J=typeof D.query==="object"?new URLSearchParams(D.query).toString().replace("+","%20"):D.query,Q=this.pathStyle?`${this.pathPrefix}/${$}/${D.objectName}`:`/${D.objectName}`,F=J?`?${J}`:"",w=Q+F,Z=Q.split("/").map((G)=>encodeURIComponent(G)).join("/")+F;return{headers:Y,host:X,path:w,encodedPath:Z}}async makeRequest({method:D,payload:$,...X}){let Y=new Date,{headers:J,host:Q,path:F,encodedPath:w}=this.buildRequestOptions(X),Z=X.statusCode??200;if(D==="POST"||D==="PUT"||D==="DELETE"){if($===void 0)$=new Uint8Array;else if(typeof $==="string")$=new TextEncoder().encode($);J.set("Content-Length",String($.length))}else if($)throw Error(`Unexpected payload on ${D} request.`);let G=await vZ($??new Uint8Array);if(J.set("x-amz-date",c8(Y)),J.set("x-amz-content-sha256",G),this.accessKey){if(this.sessionToken)J.set("x-amz-security-token",this.sessionToken);J.set("authorization",await fs({headers:J,method:D,path:F,accessKey:this.accessKey,secretKey:this.#D,region:this.region,date:Y}))}let O=`${this.protocol}//${Q}${w}`,U=await fetch(O,{method:D,headers:J,body:$});if(U.status!==Z){if(U.status>=400)throw await vs(U);else if(U.status===301)throw new T4(U.status,"UnexpectedRedirect",'The server unexpectedly returned a redirect response. With AWS S3, this usually means you need to use a region-specific endpoint like "s3.us-west-2.amazonaws.com" instead of "s3.amazonaws.com"');throw new T4(U.status,"UnexpectedStatusCode",`Unexpected response code from the server (expected ${Z}, got ${U.status} ${U.statusText}).`)}if(!X.returnBody)await U.body?.getReader().read();return U}async deleteObject(D,$={}){let X=this.getBucketName($);if(!C4(D))throw new S6(D);let Y=$.versionId?{versionId:$.versionId}:{},J=new Headers;if($.governanceBypass)J.set("X-Amz-Bypass-Governance-Retention","true");await this.makeRequest({method:"DELETE",bucketName:X,objectName:D,headers:J,query:Y,statusCode:204})}async exists(D,$){try{return await this.statObject(D,$),!0}catch(X){if(X instanceof T4&&X.statusCode===404)return!1;throw X}}getObject(D,$){return this.getPartialObject(D,{...$,offset:0,length:0})}async getPartialObject(D,{offset:$,length:X,...Y}){let J=this.getBucketName(Y);if(!C4(D))throw new S6(D);let Q=new Headers(Object.entries(Y.metadata??{})),F=200;if($||X){let Z="";if($)Z=`bytes=${+$}-`;else Z="bytes=0-",$=0;if(X)Z+=`${+X+$-1}`;Q.set("Range",Z),F=206}let w={...Y.responseParams,...Y.versionId?{versionId:Y.versionId}:{}};return await this.makeRequest({method:"GET",bucketName:J,objectName:D,headers:Q,query:w,statusCode:F,returnBody:!0})}getPresignedUrl(D,$,X={}){if(!this.accessKey)throw new m8;if(!C4($))throw new S6($);let{headers:Y,path:J}=this.buildRequestOptions({objectName:$,bucketName:X.bucketName,query:X.parameters}),Q=X.requestDate??new Date,F=X.expirySeconds??604800;return ys({protocol:this.protocol,headers:Y,method:D,path:J,accessKey:this.accessKey,secretKey:this.#D,sessionToken:this.sessionToken,region:this.region,date:Q,expirySeconds:F})}presignedGetObject(D,$={}){let{versionId:X,responseParams:Y,...J}=$,Q={...Y,...X?{versionId:X}:{}};return this.getPresignedUrl("GET",D,{parameters:Q,...J})}async*listObjects(D={}){for await(let $ of this.listObjectsGrouped({...D,delimiter:""}))if($.type==="Object")yield $;else throw Error(`Unexpected result from listObjectsGrouped(): ${$}`)}async*listObjectsGrouped(D){let $=this.getBucketName(D),X="",Y=D.pageSize??1000;if(Y<1||Y>1000)throw new j1("pageSize must be between 1 and 1,000.");let J=0;while(!0){let Q=D.maxResults?Math.min(Y,D.maxResults-J):Y;if(Q===0)return;let w=await(await this.makeRequest({method:"GET",bucketName:$,objectName:"",query:{"list-type":"2",prefix:D.prefix??"",delimiter:D.delimiter,"max-keys":String(Q),...X?{"continuation-token":X}:{}},returnBody:!0})).text(),Z=E4(w).root;if(!Z||Z.name!=="ListBucketResult")throw Error(`Unexpected response: ${w}`);let G=Z.children.filter((z)=>z.name==="CommonPrefixes").flatMap((z)=>z.children),O=[];for(let z of G)O.push({type:"CommonPrefix",prefix:z.content??""}),J++;for(let z of Z.children.filter((q)=>q.name==="Contents"))O.push({type:"Object",key:z.children.find((q)=>q.name==="Key")?.content??"",etag:d8(z.children.find((q)=>q.name==="ETag")?.content??""),size:parseInt(z.children.find((q)=>q.name==="Size")?.content??"",10),lastModified:new Date(z.children.find((q)=>q.name==="LastModified")?.content??"invalid")}),J++;O.sort((z,q)=>{let B=z.type==="Object"?z.key:z.prefix,K=q.type==="Object"?q.key:q.prefix;return B>K?1:B<K?-1:0});for(let z of O)yield z;if(Z.children.find((z)=>z.name==="IsTruncated")?.content==="true"){let z=Z.children.find((q)=>q.name==="NextContinuationToken")?.content;if(!z)throw Error("Unexpectedly missing continuation token, but server said there are more results.");X=z}else return}}async putObject(D,$,X){let Y=this.getBucketName(X);if(!C4(D))throw new S6(D);let J,Q;if(typeof $==="string"){let G=new TextEncoder().encode($);if(typeof ReadableStream.from<"u")Q=ReadableStream.from([G]);else Q=new ReadableStream({start(O){O.enqueue(G),O.close()}});J=G.length}else if($ instanceof Uint8Array){if(typeof ReadableStream.from<"u")Q=ReadableStream.from([$]);else Q=new ReadableStream({start(G){G.enqueue($),G.close()}});J=$.byteLength}else if($ instanceof ReadableStream)Q=$;else throw new j1("Invalid stream/data type provided.");if(X?.size!==void 0){if(J!==void 0&&X?.size!==J)throw new j1(`size was specified (${X.size}) but doesn't match auto-detected size (${J}).`);if(typeof X.size!=="number"||X.size<0||isNaN(X.size))throw new j1(`invalid size specified: ${X.size}`);else J=X.size}let F=X?.partSize??this.calculatePartSize(J);if(F<NPD)throw new j1("Part size should be greater than 5MB");else if(F>MPD)throw new j1("Part size should be less than 6MB");let w=new wL(F),Z=new zL({client:this,bucketName:Y,objectName:D,partSize:F,metadata:X?.metadata??{}});return await Q.pipeThrough(w).pipeTo(Z),Z.getResult()}calculatePartSize(D){if(D===void 0)D=HL;if(D>HL)throw TypeError(`size should not be more than ${HL}`);let $=67108864;while(!0){if($*1e4>D)return $;$+=16777216}}async statObject(D,$){let X=this.getBucketName($);if(!C4(D))throw new S6(D);let Y={};if($?.versionId)Y.versionId=$.versionId;let J=await this.makeRequest({method:"HEAD",bucketName:X,objectName:D,query:Y,headers:new Headers($?.headers)}),Q={};for(let F of VPD)if(J.headers.has(F))Q[F]=J.headers.get(F);return J.headers.forEach((F,w)=>{if(w.startsWith("x-amz-meta-"))Q[w]=J.headers.get(w)}),{type:"Object",key:D,size:parseInt(J.headers.get("content-length")??"",10),metadata:Q,lastModified:new Date(J.headers.get("Last-Modified")??"error: missing last modified"),versionId:J.headers.get("x-amz-version-id")||null,etag:d8(J.headers.get("ETag")??"")}}async copyObject(D,$,X){let Y=this.getBucketName(X),J=D.sourceBucketName??Y;if(!C4($))throw new S6($);let Q=`${J}/${D.sourceKey}`;if(D.sourceVersionId)Q+=`?versionId=${D.sourceVersionId}`;let F=new Headers(X?.metadata);if(X?.metadata!==void 0)F.set("x-amz-metadata-directive","REPLACE");F.set("x-amz-copy-source",Q);let w=await this.makeRequest({method:"PUT",bucketName:Y,objectName:$,headers:F,returnBody:!0}),Z=await w.text(),G=E4(Z).root;if(!G||G.name!=="CopyObjectResult")throw Error(`Unexpected response: ${Z}`);let O=G.children.find((z)=>z.name==="ETag")?.content??"",U=G.children.find((z)=>z.name==="LastModified")?.content;if(U===void 0)throw Error("Unable to find <LastModified>...</LastModified> from the server.");return{copySourceVersionId:w.headers.get("x-amz-copy-source-version-id")||null,etag:d8(O),lastModified:new Date(U),versionId:w.headers.get("x-amz-version-id")||null}}async bucketExists(D){try{return await this.listObjects({bucketName:D}).next(),!0}catch($){if($ instanceof T4&&$.statusCode===404)return!1;throw $}}async makeBucket(D){await this.makeRequest({method:"PUT",bucketName:this.getBucketName({bucketName:D}),objectName:"",statusCode:200})}async removeBucket(D){await this.makeRequest({method:"DELETE",bucketName:this.getBucketName({bucketName:D}),objectName:"",statusCode:204})}presignedPostObject(D,$={}){if(!C4(D))throw new S6(D);let X=this.getBucketName($);if(!X)throw Error("Bucket name is required for presignedPost, but none was provided either to this method nor to the client constructor");let Y=$.requestDate||new Date,J=$.expirySeconds??3600;return ms({protocol:this.protocol,host:this.host,bucket:X,objectKey:D,accessKey:this.accessKey||"",secretKey:this.#D||"",region:this.region,date:Y,expirySeconds:J,conditions:$.conditions,fields:$.fields})}}vD();s$();D6();MY();q1();q3();vD();import ds from"node:process";var LPD=[{code:"aws:eu-central-1",label:"EU (Frankfurt)"},{code:"gcp:me-central1",label:"Middle East (Riyadh)"},{code:"gcp:asia-east2",label:"Hong Kong"},{code:"aws:ap-northeast-1",label:"Japan (Tokyo)"},{code:"aws:ap-south-1",label:"India (Mumbai)"},{code:"aws:us-east-1",label:"North America (Virginia)"},{code:"gcp:africa-south1",label:"Africa (South Africa)"},{code:"aws:ap-southeast-2",label:"Oceania (Sydney)"},{code:"aws:sa-east-1",label:"South America (São Paulo)"}],IPD=60000,APD=1000,cs=20;function RPD(){if(typeof Intl>"u")return null;return Intl.DateTimeFormat().resolvedOptions().timeZone||null}function jPD(){let D=RPD();if(!D)return null;if(/^America\//.test(D))return"aws:us-east-1";if(/^Europe\//.test(D)||/^Atlantic\//.test(D))return"aws:eu-central-1";if(/^Africa\//.test(D))return"gcp:africa-south1";if(/^Asia\//.test(D)){let $=(D.split("/")[1]??"").toLowerCase();if(["tokyo","osaka","seoul","pyongyang"].includes($))return"aws:ap-northeast-1";if(["kolkata","mumbai","calcutta","chennai","bangalore","hyderabad","delhi","dhaka","colombo","karachi"].includes($))return"aws:ap-south-1";if(["hong_kong","singapore","manila","jakarta","kuala_lumpur","beijing","shanghai","hongkong","taipei"].includes($))return"gcp:asia-east2";if(["sydney","melbourne","canberra","perth","brisbane","darwin","adelaide"].includes($))return"aws:ap-southeast-2";return"gcp:asia-east2"}if(/^Pacific\//.test(D)||/^Australia\//.test(D))return"aws:ap-southeast-2";return null}function EPD(){let D=[...LPD],$=jPD();if(!$)return D;let X=D.findIndex((J)=>J.code===$);if(X<0)return D;let[Y]=D.splice(X,1);return D.push(Y),D}function TPD(D,$,X){let Y=Math.min(Math.max(D,0),X);return Math.floor(Y/X*$)}function CPD(D){let $=Math.min(Math.max(D,0),100),X=Math.round($/100*cs);return`${"█".repeat(X)}${"░".repeat(cs-X)}`}function PPD(D){return`${Math.max(0,D)}s`}function ls({interactive:D=ds.stdout.isTTY&&ds.stderr.isTTY,totalMs:$=IPD,updateIntervalMs:X=APD,title:Y="Replicating your bundle in all regions...",completeMessage:J="Your update is now available worldwide."}={}){if(!D||$<=0)return Promise.resolve();let Q=EPD();if(!Q.length)return Promise.resolve();H.info(Y),H.info(`Regions: ${Q.map((O)=>O.label).join(" • ")}`);let F=A0(),w=Date.now(),Z=Q.length,G=null;return new Promise((O)=>{let U=()=>{let z=Date.now()-w,q=Math.max(0,$-z),B=TPD(z,Z,$),K=Math.min(100,Math.round(z/$*100)),M=CPD(K),L=B<Z?Q[B]?.label||"Finalizing":"Complete",I=`${B}/${Z} regions updated • ${PPD(Math.ceil(q/1000))} left • ${M} • Next: ${L}`;F.message(I)};F.start(Y),U(),G=setInterval(U,X),setTimeout(()=>{if(G)clearInterval(G);F.stop(J),O()},$)})}fD();vD();D6();function ns(D){try{let $=eD(D);return z$(L7($,"patch"))}catch{let $=D.match(/^(\d+)\.(\d+)\.(\d+)/);if($){let[,X,Y,J]=$;return`${X}.${Y}.${Number.parseInt(J)+1}`}return"1.0.1"}}async function is(D,$){let X=ns(D),Y=$?` for ${$}`:"",J=await t1({message:`How do you want to handle the version${Y}?`,options:[{value:"auto",label:`Auto: Bump patch version (${D} → ${X})`},{value:"manual",label:"Manual: I'll provide the version number"}]});if(yD(J))return null;if(J==="auto")return H.info(`\uD83D\uDD22 Auto-bumped version from ${D} to ${X}`),X;let Q=await _6({message:`Current version is ${D}. Enter new version:`,validate:(F)=>{if(!F)return"Version is required";if(!F.match(/^\d+\.\d+\.\d+/))return"Please enter a valid version (x.y.z)"}});if(yD(Q))return null;return Q}function ps(D){let $=ns(D);try{let X=eD(D);return[$,z$(L7(X,"minor")),`${D}-beta.1`,`${D}.1`]}catch{return[$,`${D}.1`,`${D}-beta.1`,`${D}-rc.1`]}}import{readdirSync as rs,readFileSync as xPD,statSync as SPD}from"node:fs";import{extname as uPD,join as vPD}from"node:path";function _PD(D,$){return xPD(D,"utf8").includes($)}function L2(D,$){let X=rs(D);for(let Y of X){let J=vPD(D,Y),Q=SPD(J);if(Q.isDirectory()){if(L2(J,$))return!0}else if(Q.isFile()&&uPD(J)===".js"){if(_PD(J,$))return!0}}return!1}function kZ(D){if(rs(D).indexOf("index.html")>-1)return!0;return!1}vD();D6();var $DD=V0(ee(),1),XDD=V0(NY(),1);import{Buffer as QSD}from"node:buffer";import{createHash as FSD}from"node:crypto";import{createReadStream as vL,statSync as wSD}from"node:fs";import{platform as ZSD}from"node:os";import{join as GSD,posix as OSD,win32 as DDD}from"node:path";import{cwd as USD}from"node:process";import{buffer as _L}from"node:stream/consumers";import{createBrotliCompress as qSD}from"node:zlib";fD();async function zSD(D,$){try{let X=new URL(`${D.hostFilesApi}/files/read/attachments/${encodeURIComponent($)}`);return X.searchParams.set("nocache",`${Date.now()}`),(await fetch(X.toString(),{method:"GET",headers:{range:"bytes=0-0","cache-control":"no-cache"}})).ok}catch{return!1}}var BSD=8192;async function KSD(D){let $=e0(USD()),X=await y1("@capgo/capacitor-updater",$,D.packageJson),Y;try{Y=X?eD(X):void 0}catch{Y=void 0}if(!X||!Y)return{version:null,supportsBrotliV2:!1};let J=!Z$(Y,void 0,void 0,Q2);return{version:`${Y.major}.${Y.minor}.${Y.patch}`,supportsBrotliV2:J}}function WSD(D,$){if(!$)return!1;let X=$.split(",").map((Y)=>Y.trim()).filter((Y)=>!!Y);if(X.length===0)return!1;return $DD.isMatch(D,X)}async function HSD(D,$,X){let J=wSD(D).size,Q=await _L(vL(D));if(J===0)return{buffer:Q,useBrotli:!1};if(WSD($,X.noBrotliPatterns))return{buffer:Q,useBrotli:!1};if(J<BSD)return{buffer:Q,useBrotli:!1};try{let F=await _L(vL(D).pipe(qSD({})));if(F.length>=J-10)return{buffer:Q,useBrotli:!1};return{buffer:F,useBrotli:!0}}catch(F){return H.warn(`Brotli compression failed for ${D}: ${F}, using original file`),{buffer:Q,useBrotli:!1}}}async function JDD(D,$,X,Y,J,Q,F=!1){let w=A0();w.start(J!=="v2"?"Generating the update manifest":`Generating the update manifest with ${F?"V3":"V2"} encryption`);let Z=await Ra(D);if(J==="v2")for(let G of Z)G.hash=F?w7(G.hash,Q):F7(G.hash,Q);return w.stop("Manifest generated successfully"),await RD($,{channel:"partial-update",event:"Generate manifest",icon:"\uD83D\uDCC2",user_id:X,tags:{"app-id":Y},notify:!1}),Z}function VSD(D){if(ZSD()!=="win32")return D;return DDD.normalize(D).split(DDD.sep).join(OSD.sep)}function NSD(D){let $=D.split("/").map((X)=>encodeURIComponent(X)).join("/");if(D.includes(" "))H.warn(`File "${D}" contains spaces in its name.`);return $}async function YDD(D,$,X,Y,J,Q,F){let w=A0();w.start("Preparing partial update with TUS protocol");let Z=performance.now(),G=await u$(),O=!!(F.partial||F.delta||F.partialOnly||F.deltaOnly),{version:U,supportsBrotliV2:z}=await KSD(F);if(!z)throw Error(`Your project is using an older version of @capgo/capacitor-updater (${U||"unknown"}). To use Delta updates, please upgrade to version ${QZ} (v5), ${FZ} (v6) or ${Q2} (v7) or higher.`);else if(F.disableBrotli)H.info("Brotli compression disabled by user request");else if(F.noBrotliPatterns)H.info(`Files matching patterns (${F.noBrotliPatterns}) will be excluded from brotli compression`);let q=$.filter((L)=>L.file.includes(" "));if(q.length>0)throw Error(`Files with spaces in their names (${q.map((L)=>L.file).join(", ")}). Please rename the files.`);let B=0,K=$.length,M=0;try{w.message(`Uploading ${K} files using TUS protocol`);let L=async(R)=>{let C=GSD(X,R.file),A=VSD(R.file),_,v=!1;if(F.disableBrotli)_=await _L(vL(C)),v=!1;else{let j=await HSD(C,A,F);_=j.buffer,v=j.useBrotli}let S=_;if(Q)S=Q7(_,Q.sessionKey,Q.ivSessionKey);let h=A;if(v)h=`${A}.br`,M++;let g=NSD(h),l=FSD("sha256").update(R.hash).digest("hex"),f;if(Q){let j=QSD.from(Q.ivSessionKey).toString("hex");f=`orgs/${J}/apps/${Y}/delta/${j}/${l}_${g}`}else f=`orgs/${J}/apps/${Y}/delta/${l}_${g}`;if(!Q&&await zSD(G,f))return B++,Promise.resolve({file_name:g,s3_path:f,file_hash:R.hash});return new Promise((j,x)=>{w.message(`Prepare upload partial file: ${A}`);let u=M4(h);new XDD.Upload(S,{endpoint:`${G.hostFilesApi}/files/upload/attachments/`,chunkSize:F.tusChunkSize,retryDelays:[0,1000,3000,5000,1e4],removeFingerprintOnSuccess:!0,metadata:{filename:f,filetype:u},headers:{Authorization:D},onError:(d)=>{let b=d.toString(),a;try{let n=b.match(/response text: (\{.*?\})/);if(n&&n[1])a=JSON.parse(n[1]).moreInfo?.requestId}catch{}let c=a?` [requestId: ${a}]`:"";H.error(`Failed to upload ${A}: ${b}${c}`),x(d)},onProgress(){let d=(B/K*100).toFixed(2);w.message(`Uploading partial update: ${d}%`)},onSuccess(){B++,j({file_name:g,s3_path:f,file_hash:R.hash})}}).start()})},I=500,W=[];for(let R=0;R<$.length;R+=I){let C=$.slice(R,R+I),A=Math.floor(R/I)+1,_=Math.ceil($.length/I);if(_>1)w.message(`Processing batch ${A}/${_} (${C.length} files)`);let v=await Promise.all(C.map((S)=>L(S)));W.push(...v)}let V=((performance.now()-Z)/1000).toFixed(2);if(w.stop(`Partial update uploaded successfully \uD83D\uDCAA in (${V} seconds)`),M>0)H.info(`${M} of ${K} files were compressed with brotli and use .br extension`);return await RD(D,{channel:"app",event:`App Partial TUS done${M>0?" with .br extension":""}`,icon:"⏫",user_id:J,tags:{"app-id":Y},notify:!1}),await RD(D,{channel:"performance",event:"Partial upload performance",icon:"\uD83D\uDE84",user_id:J,tags:{"app-id":Y,time:V},notify:!1}),W}catch(L){let W=((performance.now()-Z)/1000).toFixed(2);if(w.error(`Failed to upload Partial bundle (after ${W} seconds)`),O)throw H.error(`Error uploading partial update: ${L}`),H.error("Delta/partial upload was explicitly requested but failed. Upload aborted."),L;else return H.info(`Error uploading partial update: ${L}, This is not a critical error, the bundle has been uploaded without the partial files`),null}}function W0(D){throw H.error(D),Error(D)}function RSD(D){let $=new R0;$.headers=["Package","Local","Remote","Status","Details"],$.theme=R0.roundTheme,$.rows=[];for(let X of D){let{name:Y,localVersion:J,remoteVersion:Q}=X,F=k8(X),w=F.compatible?"✅":"❌";$.rows.push([Y,J||"-",Q||"-",w,F.message])}H.info($.toString())}async function jSD(D,$){let X=N4("",$.packageJson),Y=$.bundle||D?.plugins?.CapacitorUpdater?.version||X||`0.0.1-beta.${MSD().split("-")[0]}`;if(!p5.test(Y))W0(`Your bundle name ${Y}, is not valid it should follow semver convention : https://semver.org/`);return Y}function ESD(D){let $=D.apikey||BD();if(!$)W0("Missing API key, you need to provide an API key to upload your bundle");return $}function TSD(D,$,X){let Y=iD(D,X),J=$.path||X?.webDir;if(!Y)W0("Missing argument, you need to provide a appid or be in a capacitor project");if(!J)W0("Missing argument, you need to provide a path (--path), or be in a capacitor project");if(!dZ(J))W0(`Path ${J} does not exist, build your app first, or provide a valid path`);return{appid:Y,path:J}}function CSD(D,$){let X=D.codeCheck;if(typeof X>"u"||X){if(!L2($,"notifyAppReady"))W0(`notifyAppReady() is missing in the build folder of your app. see: https://capgo.app/docs/plugin/api/#notifyappready
478
+ If you are sure your app has this code, you can use the --no-code-check option`);if(!kZ($))W0(`index.html is missing in the root folder of ${$}`)}}async function PSD(D,$,X,Y,J,Q){let{ignoreMetadataCheck:F,autoMinUpdateVersion:w,minUpdateVersion:Z}=X,{data:G,error:O}=await D.from("channels").select("disable_auto_update, version ( min_update_version, native_packages )").eq("name",Y).eq("app_id",J).single(),U=!!G&&G.disable_auto_update==="version_number",z,q;if(!O&&G&&G.version&&G.version.native_packages&&!F){let M=A0();M.start(`Checking bundle compatibility with channel ${Y}`);let{finalCompatibility:L,localDependencies:I}=await OZ(D,J,Y,X.packageJson,X.nodeModules);if(q=L,z=I,q.filter((N)=>!L4(N)).length>0){if(M.error(`Bundle NOT compatible with ${Y} channel`),H.warn(""),RSD(q),H.warn(""),H.warn("An app store update may be required for these changes to take effect."),w)Z=Q,H.info(`Auto set min-update-version to ${Z}`)}else if(w)try{let{min_update_version:N}=G.version;if(!N||!p5.test(N))W0("Invalid remote min update version, skipping auto setting compatibility");Z=N,M.stop(`Auto set min-update-version to ${Z}`)}catch{W0(`Cannot auto set compatibility, invalid data ${G}`)}else M.stop(`Bundle compatible with ${Y} channel`)}else if(!F){if(H.warn(`Channel ${Y} is new or it's your first upload with compatibility check, it will be ignored this time`),z=await vM(X.packageJson,X.nodeModules),w)Z=Q,H.info(`Auto set min-update-version to ${Z}`)}if(U&&!Z&&!F)W0("You need to provide a min-update-version to upload a bundle to this channel");if(Z){if(!p5.test(Z))W0(`Your minimal version update ${Z}, is not valid it should follow semver convention : https://semver.org/`)}let B=z?new Map(z.filter((M)=>!!M.native&&M.native!==void 0).map((M)=>[M.name,M])):new Map;return{nativePackages:B.size>0||!X.ignoreMetadataCheck?Array.from(B,([M,L])=>({name:M,version:L.version,...L.ios_checksum&&{ios_checksum:L.ios_checksum},...L.android_checksum&&{android_checksum:L.android_checksum}})):void 0,minUpdateVersion:Z}}async function xSD(D,$,X,Y=!1,J=!1){let{data:Q,error:F}=await D.rpc("exist_app_versions",{appid:$,name_version:X}).single();if(Q||F){if(Y)return H.warn(`Version ${X} already exists - exiting gracefully due to --silent-fail option`),ND("Bundle version already exists - exiting gracefully \uD83C\uDF89"),!0;if(J){H.error(`❌ Version ${X} already exists`);let w=ps(X);H.info("\uD83D\uDCA1 Here are some suggestions:"),w.forEach((O,U)=>{H.info(` ${U+1}. ${O}`)});let Z=await t1({message:"What would you like to do?",options:[{value:"suggest1",label:`Use ${w[0]}`},{value:"suggest2",label:`Use ${w[1]}`},{value:"suggest3",label:`Use ${w[2]}`},{value:"suggest4",label:`Use ${w[3]}`},{value:"custom",label:"Enter a custom version"},{value:"cancel",label:"Cancel upload"}]});if(yD(Z)||Z==="cancel")W0("Upload cancelled by user");let G;if(Z==="custom"){let O=await is(X,"upload");if(!O)W0("Upload cancelled by user");G=O}else{let O=Number.parseInt(Z.replace("suggest",""))-1;G=w[O]}return H.info(`\uD83D\uDD04 Retrying with new version: ${G}`),G}W0(`Version ${X} already exists ${s(F)}`)}return!1}async function SSD(D,$,X,Y,J,Q,F,w){let Z,G,O="",U=null,z="none",q="",B="",K=$.keyV2,M=$.key===!1,L=A0();L.start(`Zipping bundle from ${D}`),U=await wZ(D),L.message("Calculating checksum");let I=e0(kL()),W=await y1("@capgo/capacitor-updater",I,$.packageJson),N=!1,V;try{V=W?eD(W):void 0}catch{V=void 0}if(!W)W0("Cannot find @capgo/capacitor-updater in node_modules, please install it first with your package manager");else if(V)N=!Z$(V,QZ,FZ,Q2);else if(W==="link:@capgo/capacitor-updater"||W==="file:.."||W==="file:../")H.warn("Using local @capgo/capacitor-updater. Assuming latest version for checksum calculation."),N=!0;let R=$.forceCrc32Checksum===!0,C=!R&&((K||$.keyDataV2||dZ(i1))&&!M||N);if(O=await p6(U,C?"sha256":"crc32"),L.stop(`Checksum ${C?"SHA256":"CRC32"}${R?" (forced)":""}: ${O}`),M)H.info("Encryption ignored");else if((K||dZ(i1)||$.keyDataV2)&&!$.oldEncryption){let v=typeof K==="string"?K:i1,S=$.keyDataV2||"";if(!S&&!dZ(v))W0(`Cannot find private key ${v}`);if(await RD(X,{channel:"app",event:"App encryption v2",icon:"\uD83D\uDD11",user_id:Y,tags:{"app-id":J},notify:!1},$.verbose),!S)S=LSD(v).toString();let h=V&&!Z$(V,"5.30.0","6.30.0","7.30.0");H.info(`Encrypting your bundle with ${h?"V3":"V2"}`);let{sessionKey:g,ivSessionKey:l}=xZ(S),f=Q7(U,g,l);if(O=h?w7(O,S):F7(O,S),Z=l,G=g,z="v2",q=S,w){if(B=Ts(w),$.verbose)H.info(`[Verbose] Encryption key_id: ${B}`)}if($.displayIvSession)H.info(`Your Iv Session key is ${Z},
479
479
  keep it safe, you will need it to decrypt your bundle.
480
480
  It will be also visible in your dashboard
481
481
  `);U=f}let A=Math.floor((U?.byteLength??0)/1024/1024),_=Math.floor(Q/1024/1024);if(U?.byteLength>Q)W0(`The bundle size is ${A} Mb, this is greater than the maximum upload length ${_} Mb, please reduce the size of your bundle`);else if(U?.byteLength>F){if(H.warn(`WARNING !!
482
482
  The bundle size is ${A} Mb, this may take a while to download for users
483
483
  `),H.info(`Learn how to optimize your assets https://capgo.app/blog/optimise-your-images-for-updates/
484
484
  `),$.verbose)H.info("[Verbose] Bundle size details:"),H.info(` - Actual size: ${A} MB (${U?.byteLength} bytes)`),H.info(` - Alert threshold: ${Math.floor(F/1024/1024)} MB`),H.info(` - Maximum allowed: ${_} MB`),H.info("[Verbose] Sending 'App Too Large' event to analytics...");if(await RD(X,{channel:"app-error",event:"App Too Large",icon:"\uD83D\uDE9B",user_id:Y,tags:{"app-id":J},notify:!1},$.verbose),$.verbose)H.info("[Verbose] Event sent successfully")}else if($.verbose)H.info(`[Verbose] Bundle size OK: ${A} MB (under ${Math.floor(F/1024/1024)} MB alert threshold)`);if($.verbose)H.info("[Verbose] Bundle preparation complete, returning bundle data");return{zipped:U,ivSessionKey:Z,sessionKey:G,checksum:O,encryptionMethod:z,finalKeyData:q,keyId:B}}async function uSD(D,$,X,Y,J,Q,F,w){let Z=A0();Z.start("Uploading Bundle");let G=performance.now(),O=!1;if(F.verbose)H.info("[Verbose] uploadBundleToCapgoCloud called:"),H.info(` - Bundle size: ${Math.floor(Q.byteLength/1024)} KB`),H.info(` - App ID: ${X}`),H.info(` - Bundle version: ${Y}`),H.info(` - Chunk size: ${Math.floor(w/1024/1024)} MB`);if(F.dryUpload){if(Z.stop(`Dry run, bundle not uploaded
485
- Bundle uploaded \uD83D\uDCAA in 0 seconds`),F.verbose)H.info("[Verbose] Dry upload mode - skipping actual upload");return}try{let q=await u$();if(F.verbose)H.info("[Verbose] Local config retrieved for upload");if(F.multipart!==void 0&&F.multipart||F.tus!==void 0&&F.tus){if(F.multipart)H.info("Uploading bundle with multipart is deprecated, we upload with TUS instead");else H.info("Uploading bundle with TUS protocol");if(F.verbose)H.info("[Verbose] Starting TUS resumable upload..."),H.info(` - Host: ${q.hostWeb}`),H.info(` - Chunk size: ${Math.floor(w/1024/1024)} MB`);if(await ja(D,Q,J,X,Y,Z,q,w),O=!0,F.verbose)H.info("[Verbose] TUS upload completed, updating database with R2 path...");let B=`orgs/${J}/apps/${X}/${Y}.zip`,{error:K}=await $.from("app_versions").update({r2_path:B}).eq("name",Y).eq("app_id",X);if(K){if(H.error(`Cannot finish TUS upload ${s(K)}`),F.verbose)H.info(`[Verbose] Database update failed: ${s(K)}`);return Promise.reject(Error("Cannot finish TUS upload"))}if(F.verbose)H.info(`[Verbose] Database updated with R2 path: ${B}`)}else{if(F.verbose)H.info("[Verbose] Using standard upload (non-TUS), getting presigned URL...");let B=await Ia($,X,Y);if(!B){if(H.error("Cannot get upload url"),F.verbose)H.info("[Verbose] Failed to retrieve presigned upload URL from database");return Promise.reject(Error("Cannot get upload url"))}if(F.verbose)H.info("[Verbose] Presigned URL obtained, uploading via HTTP PUT..."),H.info(` - Timeout: ${F.timeout||xM}ms`),H.info(" - Retry attempts: 5"),H.info(" - Content-Type: application/zip");let K=new AbortController,M=setTimeout(()=>K.abort(),F.timeout||xM);try{let L=await fetch(B,{method:"PUT",body:Q,headers:{"Content-Type":"application/zip"},signal:K.signal});if(!L.ok)throw Error(`HTTP error! status: ${L.status}`)}finally{clearTimeout(M)}if(F.verbose)H.info("[Verbose] HTTP PUT upload completed successfully")}}catch(q){let K=((performance.now()-G)/1000).toFixed(2);if(Z.error(`Failed to upload bundle ( after ${K} seconds)`),F.verbose)H.info(`[Verbose] Upload failed after ${K} seconds`),H.info(`[Verbose] Error type: ${q instanceof Error?"Error":typeof q}`);if(q instanceof Error&&q.message.includes("HTTP error"))try{let M=q.message.match(/status: (\d+)/),L=M?M[1]:"unknown";H.error(`Upload failed with status ${L}: ${q.message}`)}catch{H.error(`Upload failed: ${q.message}`)}else{if(F.verbose)H.info(`[Verbose] Non-HTTP error: ${s(q)}`);if(!F.tus)H.error(`Cannot upload bundle ( try again with --tus option) ${s(q)}`);else H.error(`Cannot upload bundle please contact support if the issue persists ${s(q)}`)}if(F.verbose)H.info("[Verbose] Cleaning up failed version from database...");if(await Ea($,X,Y),F.verbose)H.info("[Verbose] Failed version cleaned up");throw q instanceof Error?q:Error(String(q))}let z=((performance.now()-G)/1000).toFixed(2);if(Z.stop(`Bundle uploaded \uD83D\uDCAA in (${z} seconds)`),F.verbose)H.info("[Verbose] Upload successful:"),H.info(` - Upload time: ${z} seconds`),H.info(` - Upload method: ${O?"TUS (resumable)":"Standard HTTP PUT"}`),H.info(` - Bundle size: ${Math.floor(Q.byteLength/1024)} KB`),H.info("[Verbose] Sending performance event...");if(await RD(D,{channel:"performance",event:O?"TUS upload zip performance":"Upload zip performance",icon:"\uD83D\uDE84",user_id:J,tags:{"app-id":X,time:z},notify:!1},F.verbose),F.verbose)H.info("[Verbose] Performance event sent successfully")}async function vSD(D,$,X){let{data:Y,error:J}=await D.from("channels").select("version ( id, name, deleted )").eq("app_id",$).eq("name",X);if(J){H.error(`Cannot delete linked bundle on upload ${s(J)}`);return}if(Y.length===0){H.warn("No linked bundle found in the channel you are trying to upload to");return}let Q=Y[0].version;if(Q.deleted){H.warn("The linked bundle is already deleted");return}let{error:F}=await D.from("app_versions").update({deleted:!0}).eq("id",Q.id);if(F){H.error(`Cannot delete linked bundle on upload ${s(F)}`);return}H.info("Linked bundle deleted")}async function _SD(D,$,X,Y,J,Q,F,w,Z,G){let{data:O}=await D.rpc("get_app_versions",{apikey:$,name_version:Y,appid:w}).single();if(!O)W0("Cannot get version id, cannot set channel");let{data:U}=await D.rpc("is_allowed_capgkey",{apikey:$,keymode:["write","all"]}).single();if(U){let{error:z,data:q}=await ZZ(D,{name:J,app_id:w,created_by:Q,version:O,owner_org:F,...G?{allow_device_self_set:!0}:{}});if(z)W0(`Cannot set channel, the upload key is not allowed to do that, use the "all" for this. ${s(z)}`);let B=`${Z.hostWeb}/app/${w}/channel/${q.id}`;if(q?.public)H.info("Your update is now available in your public channel \uD83C\uDF89");else if(q?.id)H.info(`Link device to this bundle to try it: ${B}`);if(X)H.info(`Bundle url: ${B}`)}else H.warn("The upload key is not allowed to set the version in the channel")}async function kSD(D,$,X){let{error:Y,data:J}=await $.from("apps").select("default_upload_channel").eq("app_id",D).single();if(Y)return H.warn("Cannot find default upload channel"),H.info(`You can set it here: ${X}/app/${D}/info`),null;return J.default_upload_channel}async function fL(D,$,X=!1){if(!X)VD(`Uploading with CLI version ${F6.version}`);let Y,J=_8();await F0();let{s3Region:Q,s3Apikey:F,s3Apisecret:w,s3BucketName:Z,s3Endpoint:G,s3Port:O,s3SSL:U}=$;if($.verbose)H.info("[Verbose] Starting upload process with options:"),H.info(` - API key: ${$.apikey?"provided":"from saved key"}`),H.info(` - Path: ${$.path||"from capacitor config"}`),H.info(` - Channel: ${$.channel||"from default upload channel"}`),H.info(` - Bundle: ${$.bundle||"auto-detected"}`),H.info(` - External: ${$.external||"false"}`),H.info(` - Encryption: ${$.keyV2||$.keyDataV2?"v2":$.key===!1?"disabled":"auto"}`),H.info(` - Upload method: ${$.tus?"TUS":$.zip?"ZIP":"auto"}`),H.info(` - Delta updates: ${$.delta||$.partial?"enabled":"disabled"}`);let z=ESD($);if($.verbose)H.info("[Verbose] API key retrieved successfully");let q=await ID();if($.verbose)H.info("[Verbose] Capacitor config loaded successfully");let B=q?.config?.plugins?.CapacitorUpdater?.directUpdate==="always",K=!X&&!!ISD.isTTY&&!!ASD.isTTY;if(B&&$.delta===void 0){if(K){H.info("\uD83D\uDCA1 Direct Update (instant updates) is enabled in your config"),H.info(" Delta updates send only changed files instead of the full bundle");let YD=await c0({message:"Enable delta updates for this upload? (Recommended with Direct Update)",initialValue:!0});if(!yD(YD)&&YD){if($.delta=!0,$.verbose)H.info("[Verbose] Delta updates auto-enabled due to Direct Update configuration")}}else if(!X){if($.delta!==!1){if($.delta=!0,$.verbose)H.info("[Verbose] Delta updates auto-enabled in CI/CD mode due to Direct Update configuration")}}}let M=await Ka();if($.verbose)H.info("[Verbose] Remote file config retrieved:"),H.info(` - Max upload length: ${Math.floor(M.maxUploadLength/1024/1024)} MB`),H.info(` - Alert upload size: ${Math.floor(M.alertUploadSize/1024/1024)} MB`),H.info(` - TUS upload: ${M.TUSUpload?"enabled":"disabled"}`),H.info(` - TUS upload forced: ${M.TUSUploadForced?"yes":"no"}`),H.info(` - Partial upload: ${M.partialUpload?"enabled":"disabled"}`),H.info(` - Max chunk size: ${Math.floor(M.maxChunkSize/1024/1024)} MB`);let{appid:L,path:I}=TSD(D,$,q.config);if($.verbose)H.info(`[Verbose] App ID: ${L}, Build path: ${I}`);let W=await jSD(q.config,$);if($.verbose)H.info(`[Verbose] Bundle version: ${W}`);let N=$.external?"external":"r2-direct",V="none";if($.autoSetBundle){if(await za({version:W}),$.verbose)H.info("[Verbose] Auto-set bundle version in capacitor.config.json")}if(CSD($,I),$.verbose)H.info("[Verbose] Code check passed (notifyAppReady found and index.html present)");H.info(`Upload ${L}@${W} started from path "${I}" to Capgo cloud`);let R=await u$();if($.verbose)H.info(`[Verbose] Local config loaded: host=${R.hostWeb}`);if($.supaHost&&$.supaAnon){if(H.info("Using custom supabase instance from provided options"),R.supaHost=$.supaHost,R.supaKey=$.supaAnon,$.verbose)H.info(`[Verbose] Custom Supabase host: ${$.supaHost}`)}let P=await jD(z,$.supaHost,$.supaAnon);if($.verbose)H.info("[Verbose] Supabase client created successfully");await m0(P,L,X);let A=await xD(P,z,["write","all","upload"]);if($.verbose)H.info(`[Verbose] User verified successfully, user_id: ${A}`);let _=$.channel||await kSD(L,P,R.hostWeb)||"production";if($.verbose)H.info(`[Verbose] Target channel: ${_}`);let v=await o0(P,L);if($.verbose)H.info(`[Verbose] Organization ID: ${v}`);if(await Na(P,v,F6.version),$.verbose)H.info("[Verbose] Remote CLI messages checked");if(await La(P,v,z,L,!0),$.verbose)H.info("[Verbose] Plan validation passed");if($.verbose)H.info("[Verbose] Trial check completed");if($.verbose)H.info(`[Verbose] Checking compatibility with channel ${_}...`);let{nativePackages:S,minUpdateVersion:h}=await PSD(P,J,$,_,L,W);if($.verbose)H.info("[Verbose] Compatibility check completed:"),H.info(` - Native packages: ${S?S.length:0}`),H.info(` - Min update version: ${h||"none"}`);if($.verbose)H.info(`[Verbose] Checking if version ${W} already exists...`);let g=await xSD(P,L,W,$.versionExistsOk,K);if($.verbose)H.info(`[Verbose] Version exists check: ${g?typeof g==="string"?`retry with ${g}`:"yes (skipping)":"no (continuing)"}`);if(g===!0)return{success:!0,skipped:!0,reason:"VERSION_EXISTS",bundle:W,checksum:null,encryptionMethod:V,storageProvider:N};if(typeof g==="string")return H.info(`Retrying upload with new version: ${g}`),fL(D,{...$,bundle:g},X);if($.external&&!$.external.startsWith("https://"))W0(`External link should should start with "https://" current is "${$.external}"`);if($.deleteLinkedBundleOnUpload)H.warn("Deleting linked bundle on upload is destructive, it will delete the currently linked bundle in the channel you are trying to upload to."),H.warn("Please make sure you want to do this, if you are not sure, please do not use this option.");let l={name:W,app_id:L,session_key:void 0,external_url:$.external,storage_provider:N,min_update_version:h,native_packages:S,owner_org:v,user_id:A,checksum:void 0,link:$.link||null,comment:$.comment||null,key_id:void 0,cli_version:F6.version},f=null,j="";if(!$.external){if($.verbose)H.info(`[Verbose] Preparing bundle file from path: ${I}`);let YD=q.config?.plugins?.CapacitorUpdater?.publicKey,{zipped:C,ivSessionKey:E,checksum:r,sessionKey:k,encryptionMethod:zD,finalKeyData:t,keyId:KD}=await SSD(I,$,z,v,L,M.maxUploadLength,M.alertUploadSize,YD);if(l.session_key=E,l.checksum=r,l.key_id=KD||void 0,Y=k,f=C,V=zD,j=t,$.verbose)H.info("[Verbose] Bundle prepared:"),H.info(` - Size: ${Math.floor((C?.byteLength??0)/1024)} KB`),H.info(` - Checksum: ${r}`),H.info(` - Encryption: ${zD}`),H.info(` - IV Session Key: ${E?"present":"none"}`),H.info(` - Key ID: ${KD||"none"}`);if(!$.ignoreChecksumCheck){if($.verbose)H.info("[Verbose] Checking for duplicate checksum...");if(await xa(P,L,_,r),$.verbose)H.info("[Verbose] Checksum is unique")}}else{if($.verbose)H.info(`[Verbose] Using external URL: ${$.external}`);if(await RD(z,{channel:"app",event:"App external",icon:"\uD83D\uDCE4",user_id:v,tags:{"app-id":L},notify:!1},$.verbose),l.session_key=$.ivSessionKey,l.checksum=$.encryptedChecksum,$.verbose)H.info("[Verbose] External bundle configured:"),H.info(` - URL: ${$.external}`),H.info(` - IV Session Key: ${$.ivSessionKey?"provided":"none"}`),H.info(` - Encrypted Checksum: ${$.encryptedChecksum?"provided":"none"}`)}if($.zip){if($.tus=!1,$.verbose)H.info("[Verbose] Upload method: ZIP (explicitly set via --zip)")}else if(!M.TUSUpload||$.external){if($.tus=!1,$.verbose)H.info("[Verbose] Upload method: Standard (TUS not available or external URL)")}else if($.tus=$.tus||M.TUSUploadForced,$.verbose)H.info(`[Verbose] Upload method: ${$.tus?"TUS (resumable)":"Standard"}`);if(!M.partialUpload||$.external){if($.delta=!1,$.verbose&&$.external)H.info("[Verbose] Delta updates disabled (not available with external URLs)")}else if($.delta=$.delta||$.partial||$.deltaOnly||$.partialOnly||M.partialUploadForced,$.verbose)H.info(`[Verbose] Delta updates: ${$.delta?"enabled":"disabled"}`);if($.encryptPartial&&V==="v1")W0("You cannot encrypt the partial update if you are not using the v2 encryption method");let x="5.30.0",u="6.30.0",y="7.30.0",d=!1;if($.delta&&V==="v2"&&!$.encryptPartial){let YD=e0(kL()),C=await y1("@capgo/capacitor-updater",YD,$.packageJson),E;try{E=C?eD(C):void 0}catch{E=void 0}if(C&&E&&nI(E,eD("6.14.4"))){if(H.info(`Auto-enabling partial update encryption for updater version ${E} (> 6.14.4)`),$.verbose)H.info("[Verbose] Partial encryption auto-enabled for updater >= 6.14.4");$.encryptPartial=!0}}if($.delta&&($.encryptPartial||V==="v2")){let YD=e0(kL()),C=await y1("@capgo/capacitor-updater",YD,$.packageJson),E;try{E=C?eD(C):void 0}catch{E=void 0}if(C&&E){if(d=!Z$(E,x,u,y),$.verbose&&d)H.info(`[Verbose] Using hex checksum format for updater version ${E}`)}}if($.verbose&&$.delta)H.info("[Verbose] Preparing delta/partial update manifest...");let b=$.delta?await JDD(I,z,v,L,$.encryptPartial?V:"none",j,d):[];if($.verbose&&$.delta)H.info(`[Verbose] Delta manifest prepared with ${b.length} files`);if($.verbose)H.info("[Verbose] Creating version record in database...");let{error:a}=await SM(P,l);if(a)W0(`Cannot add bundle ${s(a)}`);if($.verbose)H.info("[Verbose] Version record created successfully");if($.tusChunkSize&&$.tusChunkSize>M.maxChunkSize)H.error(`Chunk size ${$.tusChunkSize} is greater than the maximum chunk size ${M.maxChunkSize}, using the maximum chunk size`),$.tusChunkSize=M.maxChunkSize;else if(!$.tusChunkSize)$.tusChunkSize=M.maxChunkSize;if($.verbose)H.info(`[Verbose] TUS chunk size: ${Math.floor($.tusChunkSize/1024/1024)} MB`);if(f&&(Z||G||Q||F||w||O||U)){if(!Z||!G||!Q||!F||!w||!O)W0("Missing argument, for S3 upload you need to provide a bucket name, endpoint, region, port, API key, and API secret");if(H.info("Uploading to S3"),$.verbose)H.info("[Verbose] S3 configuration:"),H.info(` - Endpoint: ${G}`),H.info(` - Region: ${Q}`),H.info(` - Bucket: ${Z}`),H.info(` - Port: ${O}`),H.info(` - SSL: ${U?"enabled":"disabled"}`);let YD=U?`https://${G}`:`http://${G}`,C=new _Z({endPoint:G,region:Q,port:O,pathStyle:!0,bucket:Z,accessKey:F,secretKey:w}),E=`${L}-${W}`,r=encodeURIComponent(E);if($.verbose)H.info(`[Verbose] Uploading to S3 as: ${E}`);if(await C.putObject(E,Uint8Array.from(f)),l.external_url=`${YD}/${r}`,l.storage_provider="external",$.verbose)H.info(`[Verbose] S3 upload complete, external URL: ${l.external_url}`)}else if(f){if(!$.partialOnly&&!$.deltaOnly){if($.verbose)H.info("[Verbose] Starting full bundle upload to Capgo Cloud...");await uSD(z,P,L,W,v,f,$,$.tusChunkSize)}else if($.verbose)H.info("[Verbose] Skipping full bundle upload (delta-only mode)");let YD=null;try{if($.dryUpload){if($.delta=!1,$.verbose)H.info("[Verbose] Dry upload mode: skipping delta upload")}let E=l.session_key&&$.encryptPartial&&Y?{sessionKey:Y,ivSessionKey:l.session_key}:void 0;if($.verbose&&$.delta)H.info("[Verbose] Starting delta/partial file upload..."),H.info(` - Manifest entries: ${b.length}`),H.info(` - Encryption: ${E?"enabled":"disabled"}`);if(YD=$.delta?await YDD(z,b,I,L,v,E,$):null,$.verbose&&YD)H.info(`[Verbose] Delta upload complete with ${YD.length} files`)}catch(E){if(!!($.partial||$.delta||$.partialOnly||$.deltaOnly))throw E;if(H.info(`Failed to upload partial files to capgo cloud. Error: ${s(E)}. This is not a critical error, the bundle has been uploaded without the partial files`),$.verbose)H.info(`[Verbose] Delta upload error details: ${s(E)}`)}if(l.storage_provider="r2",l.manifest=YD,$.verbose)H.info("[Verbose] Updating version record with storage provider and manifest...");let{error:C}=await SM(P,l);if(C)W0(`Cannot update bundle ${s(C)}`);if($.verbose)H.info("[Verbose] Version record updated successfully")}if($.verbose)H.info("[Verbose] Checking app permissions...");let c=await u0(P,z,L,2,!1,!0);if($.verbose)H.info("[Verbose] Permissions:"),H.info(` - Upload: ${r5(c,2)?"yes":"no"}`),H.info(` - Write: ${r5(c,3)?"yes":"no"}`),H.info(` - Admin: ${r5(c,4)?"yes":"no"}`);if($.deleteLinkedBundleOnUpload&&r5(c,3)){if($.verbose)H.info(`[Verbose] Deleting linked bundle in channel ${_}...`);await vSD(P,L,_)}else if($.deleteLinkedBundleOnUpload)H.warn("Cannot delete linked bundle on upload as a upload organization member");if(r5(c,3)){if($.verbose)H.info(`[Verbose] Setting bundle ${W} to channel ${_}...`);if(await _SD(P,z,!!$.bundleUrl,W,_,A,v,L,R,$.selfAssign),$.verbose)H.info("[Verbose] Channel updated successfully")}else H.warn("Cannot set channel as a upload organization member");if($.verbose)H.info("[Verbose] Sending upload event...");await RD(z,{channel:"app",event:"App Uploaded",icon:"⏫",user_id:v,tags:{"app-id":L,bundle:W},notify:!1},$.verbose),await RD(z,{channel:"app",event:"Bundle Uploaded",icon:"⏫",user_id:v,tags:{"app-id":L,bundle:W},notify:!1,notifyConsole:!0}).catch(()=>{});let n={success:!0,bundle:W,checksum:l.checksum??null,encryptionMethod:V,sessionKey:Y?Y.toString("base64"):void 0,ivSessionKey:typeof l.session_key==="string"?l.session_key:void 0,storageProvider:l.storage_provider};if($.verbose)H.info("[Verbose] Upload completed successfully:"),H.info(` - Bundle: ${n.bundle}`),H.info(` - Checksum: ${n.checksum}`),H.info(` - Encryption: ${n.encryptionMethod}`),H.info(` - Storage: ${n.storageProvider}`);if(K&&!n.skipped){let YD=$.showReplicationProgress;if(YD===void 0){let C=await c0({message:"Show Capgo global replication progress for this upload so you can confirm rollout in all regions?",initialValue:!1});YD=!yD(C)&&C}if(YD)await ls({title:"Replicating your bundle in all regions to guarantee fast updates.",completeMessage:"Replication complete. Your update is now globally available.",interactive:K})}if(X&&!n.skipped)ND("Time to share your update to the world \uD83C\uDF0D");return n}vD();D6();q1();q3();fD();import{randomUUID as fSD}from"node:crypto";import{existsSync as ySD,writeFileSync as bSD}from"node:fs";import{cwd as gSD}from"node:process";var hSD=20;function mSD(D){console.log(JSON.stringify(D,null,2))}function E2(D){console.error(s(D))}async function QDD(D,$,X=!1){let{json:Y}=$,{bundle:J,path:Q}=$,F=!Y&&!X;try{if(F)await F0();let w=await ID(),Z=iD(D,w?.config),G=fSD().split("-")[0],O=N4("",$.packageJson);if(J=J||O||`0.0.1-beta.${G}`,F)VD(`Zipping ${Z}@${J}`);if(J&&!p5.test(J)){let R=`Your bundle name ${J}, is not valid it should follow semver convention : https://semver.org/`;if(!X)if(Y)E2({error:"invalid_semver"});else H.error(R);throw Error("Invalid bundle version format")}if(Q=Q||w?.config?.webDir,!Z||!J||!Q){if(!X)if(Y)E2({error:"missing_argument"});else H.error("Missing argument, you need to provide a appId and a bundle and a path, or be in a capacitor project");throw Error("Missing argument, you need to provide a appId and a bundle and a path, or be in a capacitor project")}if(F)H.info(`Started from path "${Q}"`);if(typeof $.codeCheck>"u"?!0:$.codeCheck){if(!L2(Q,"notifyAppReady")){if(!X)if(Y)E2({error:"notifyAppReady_not_in_source_code"});else H.error("notifyAppReady() is missing in the build folder of your app. see: https://capgo.app/docs/plugin/api/#notifyappready");throw Error("notifyAppReady() is missing in build folder")}if(!kZ(Q)){if(!X)if(Y)E2({error:"index_html_not_found"});else H.error(`index.html is missing in the root folder of ${Q}`);throw Error("index.html is missing in root folder")}}let z=await wZ(Q);if(F)H.info(`Zipped ${z.byteLength} bytes`);let q=F?A0():null;if(q)q.start("Calculating checksum");let B=e0(gSD()),K=await y1("@capgo/capacitor-updater",B,$.packageJson);if(!K){if(!X)H.warn("Cannot find @capgo/capacitor-updater in node_modules, please install it first with your package manager");throw Error("Cannot find @capgo/capacitor-updater in node_modules, please install it first with your package manager")}let M=!1,L;try{L=K?eD(K):void 0}catch{L=void 0}if(L)M=!Z$(L,void 0,void 0,"7.0.0");else if(K==="link:@capgo/capacitor-updater"){if(!X)H.warn("Using local @capgo/capacitor-updater. Assuming v7");M=!0}let I=await p6(z,$.keyV2||ySD(i1)||M?"sha256":"crc32");if(q)q.stop(`Checksum ${M?"SHA256":"CRC32"}: ${I}`);let W=Math.floor(z.byteLength/1024/1024);if(W>hSD&&F)H.warn(`WARNING !!
485
+ Bundle uploaded \uD83D\uDCAA in 0 seconds`),F.verbose)H.info("[Verbose] Dry upload mode - skipping actual upload");return}try{let q=await u$();if(F.verbose)H.info("[Verbose] Local config retrieved for upload");if(F.multipart!==void 0&&F.multipart||F.tus!==void 0&&F.tus){if(F.multipart)H.info("Uploading bundle with multipart is deprecated, we upload with TUS instead");else H.info("Uploading bundle with TUS protocol");if(F.verbose)H.info("[Verbose] Starting TUS resumable upload..."),H.info(` - Host: ${q.hostWeb}`),H.info(` - Chunk size: ${Math.floor(w/1024/1024)} MB`);if(await ja(D,Q,J,X,Y,Z,q,w),O=!0,F.verbose)H.info("[Verbose] TUS upload completed, updating database with R2 path...");let B=`orgs/${J}/apps/${X}/${Y}.zip`,{error:K}=await $.from("app_versions").update({r2_path:B}).eq("name",Y).eq("app_id",X);if(K){if(H.error(`Cannot finish TUS upload ${s(K)}`),F.verbose)H.info(`[Verbose] Database update failed: ${s(K)}`);return Promise.reject(Error("Cannot finish TUS upload"))}if(F.verbose)H.info(`[Verbose] Database updated with R2 path: ${B}`)}else{if(F.verbose)H.info("[Verbose] Using standard upload (non-TUS), getting presigned URL...");let B=await Ia($,X,Y);if(!B){if(H.error("Cannot get upload url"),F.verbose)H.info("[Verbose] Failed to retrieve presigned upload URL from database");return Promise.reject(Error("Cannot get upload url"))}if(F.verbose)H.info("[Verbose] Presigned URL obtained, uploading via HTTP PUT..."),H.info(` - Timeout: ${F.timeout||xM}ms`),H.info(" - Retry attempts: 5"),H.info(" - Content-Type: application/zip");let K=new AbortController,M=setTimeout(()=>K.abort(),F.timeout||xM);try{let L=await fetch(B,{method:"PUT",body:Q,headers:{"Content-Type":"application/zip"},signal:K.signal});if(!L.ok)throw Error(`HTTP error! status: ${L.status}`)}finally{clearTimeout(M)}if(F.verbose)H.info("[Verbose] HTTP PUT upload completed successfully")}}catch(q){let K=((performance.now()-G)/1000).toFixed(2);if(Z.error(`Failed to upload bundle ( after ${K} seconds)`),F.verbose)H.info(`[Verbose] Upload failed after ${K} seconds`),H.info(`[Verbose] Error type: ${q instanceof Error?"Error":typeof q}`);if(q instanceof Error&&q.message.includes("HTTP error"))try{let M=q.message.match(/status: (\d+)/),L=M?M[1]:"unknown";H.error(`Upload failed with status ${L}: ${q.message}`)}catch{H.error(`Upload failed: ${q.message}`)}else{if(F.verbose)H.info(`[Verbose] Non-HTTP error: ${s(q)}`);if(!F.tus)H.error(`Cannot upload bundle ( try again with --tus option) ${s(q)}`);else H.error(`Cannot upload bundle please contact support if the issue persists ${s(q)}`)}if(F.verbose)H.info("[Verbose] Cleaning up failed version from database...");if(await Ea($,X,Y),F.verbose)H.info("[Verbose] Failed version cleaned up");throw q instanceof Error?q:Error(String(q))}let z=((performance.now()-G)/1000).toFixed(2);if(Z.stop(`Bundle uploaded \uD83D\uDCAA in (${z} seconds)`),F.verbose)H.info("[Verbose] Upload successful:"),H.info(` - Upload time: ${z} seconds`),H.info(` - Upload method: ${O?"TUS (resumable)":"Standard HTTP PUT"}`),H.info(` - Bundle size: ${Math.floor(Q.byteLength/1024)} KB`),H.info("[Verbose] Sending performance event...");if(await RD(D,{channel:"performance",event:O?"TUS upload zip performance":"Upload zip performance",icon:"\uD83D\uDE84",user_id:J,tags:{"app-id":X,time:z},notify:!1},F.verbose),F.verbose)H.info("[Verbose] Performance event sent successfully")}async function vSD(D,$,X){let{data:Y,error:J}=await D.from("channels").select("version ( id, name, deleted )").eq("app_id",$).eq("name",X);if(J){H.error(`Cannot delete linked bundle on upload ${s(J)}`);return}if(Y.length===0){H.warn("No linked bundle found in the channel you are trying to upload to");return}let Q=Y[0].version;if(Q.deleted){H.warn("The linked bundle is already deleted");return}let{error:F}=await D.from("app_versions").update({deleted:!0}).eq("id",Q.id);if(F){H.error(`Cannot delete linked bundle on upload ${s(F)}`);return}H.info("Linked bundle deleted")}async function _SD(D,$,X,Y,J,Q,F,w,Z,G){let{data:O}=await D.rpc("get_app_versions",{apikey:$,name_version:Y,appid:w}).single();if(!O)W0("Cannot get version id, cannot set channel");let{data:U}=await D.rpc("is_allowed_capgkey",{apikey:$,keymode:["write","all"]}).single();if(U){let{error:z,data:q}=await ZZ(D,{name:J,app_id:w,created_by:Q,version:O,owner_org:F,...G?{allow_device_self_set:!0}:{}});if(z)W0(`Cannot set channel, the upload key is not allowed to do that, use the "all" for this. ${s(z)}`);let B=`${Z.hostWeb}/app/${w}/channel/${q.id}`;if(q?.public)H.info("Your update is now available in your public channel \uD83C\uDF89");else if(q?.id)H.info(`Link device to this bundle to try it: ${B}`);if(X)H.info(`Bundle url: ${B}`)}else H.warn("The upload key is not allowed to set the version in the channel")}async function kSD(D,$,X){let{error:Y,data:J}=await $.from("apps").select("default_upload_channel").eq("app_id",D).single();if(Y)return H.warn("Cannot find default upload channel"),H.info(`You can set it here: ${X}/app/${D}/info`),null;return J.default_upload_channel}async function fL(D,$,X=!1){if(!X)VD(`Uploading with CLI version ${F6.version}`);let Y,J=_8();await F0();let{s3Region:Q,s3Apikey:F,s3Apisecret:w,s3BucketName:Z,s3Endpoint:G,s3Port:O,s3SSL:U}=$;if($.verbose)H.info("[Verbose] Starting upload process with options:"),H.info(` - API key: ${$.apikey?"provided":"from saved key"}`),H.info(` - Path: ${$.path||"from capacitor config"}`),H.info(` - Channel: ${$.channel||"from default upload channel"}`),H.info(` - Bundle: ${$.bundle||"auto-detected"}`),H.info(` - External: ${$.external||"false"}`),H.info(` - Encryption: ${$.keyV2||$.keyDataV2?"v2":$.key===!1?"disabled":"auto"}`),H.info(` - Upload method: ${$.tus?"TUS":$.zip?"ZIP":"auto"}`),H.info(` - Delta updates: ${$.delta||$.partial?"enabled":"disabled"}`);let z=ESD($);if($.verbose)H.info("[Verbose] API key retrieved successfully");let q=await ID();if($.verbose)H.info("[Verbose] Capacitor config loaded successfully");let B=q?.config?.plugins?.CapacitorUpdater?.directUpdate==="always",K=!X&&!!ISD.isTTY&&!!ASD.isTTY;if(B&&$.delta===void 0){if(K){H.info("\uD83D\uDCA1 Direct Update (instant updates) is enabled in your config"),H.info(" Delta updates send only changed files instead of the full bundle");let YD=await c0({message:"Enable delta updates for this upload? (Recommended with Direct Update)",initialValue:!0});if(!yD(YD)&&YD){if($.delta=!0,$.verbose)H.info("[Verbose] Delta updates auto-enabled due to Direct Update configuration")}}else if(!X){if($.delta!==!1){if($.delta=!0,$.verbose)H.info("[Verbose] Delta updates auto-enabled in CI/CD mode due to Direct Update configuration")}}}let M=await Ka();if($.verbose)H.info("[Verbose] Remote file config retrieved:"),H.info(` - Max upload length: ${Math.floor(M.maxUploadLength/1024/1024)} MB`),H.info(` - Alert upload size: ${Math.floor(M.alertUploadSize/1024/1024)} MB`),H.info(` - TUS upload: ${M.TUSUpload?"enabled":"disabled"}`),H.info(` - TUS upload forced: ${M.TUSUploadForced?"yes":"no"}`),H.info(` - Partial upload: ${M.partialUpload?"enabled":"disabled"}`),H.info(` - Max chunk size: ${Math.floor(M.maxChunkSize/1024/1024)} MB`);let{appid:L,path:I}=TSD(D,$,q.config);if($.verbose)H.info(`[Verbose] App ID: ${L}, Build path: ${I}`);let W=await jSD(q.config,$);if($.verbose)H.info(`[Verbose] Bundle version: ${W}`);let N=$.external?"external":"r2-direct",V="none";if($.autoSetBundle){if(await za({version:W}),$.verbose)H.info("[Verbose] Auto-set bundle version in capacitor.config.json")}if(CSD($,I),$.verbose)H.info("[Verbose] Code check passed (notifyAppReady found and index.html present)");H.info(`Upload ${L}@${W} started from path "${I}" to Capgo cloud`);let R=await u$();if($.verbose)H.info(`[Verbose] Local config loaded: host=${R.hostWeb}`);if($.supaHost&&$.supaAnon){if(H.info("Using custom supabase instance from provided options"),R.supaHost=$.supaHost,R.supaKey=$.supaAnon,$.verbose)H.info(`[Verbose] Custom Supabase host: ${$.supaHost}`)}let C=await jD(z,$.supaHost,$.supaAnon);if($.verbose)H.info("[Verbose] Supabase client created successfully");await d0(C,L,X);let A=await xD(C,z,["write","all","upload"]);if($.verbose)H.info(`[Verbose] User verified successfully, user_id: ${A}`);let _=$.channel||await kSD(L,C,R.hostWeb)||"production";if($.verbose)H.info(`[Verbose] Target channel: ${_}`);let v=await o0(C,L);if($.verbose)H.info(`[Verbose] Organization ID: ${v}`);if(await Na(C,v,F6.version),$.verbose)H.info("[Verbose] Remote CLI messages checked");if(await La(C,v,z,L,!0),$.verbose)H.info("[Verbose] Plan validation passed");if($.verbose)H.info("[Verbose] Trial check completed");if($.verbose)H.info(`[Verbose] Checking compatibility with channel ${_}...`);let{nativePackages:S,minUpdateVersion:h}=await PSD(C,J,$,_,L,W);if($.verbose)H.info("[Verbose] Compatibility check completed:"),H.info(` - Native packages: ${S?S.length:0}`),H.info(` - Min update version: ${h||"none"}`);if($.verbose)H.info(`[Verbose] Checking if version ${W} already exists...`);let g=await xSD(C,L,W,$.versionExistsOk,K);if($.verbose)H.info(`[Verbose] Version exists check: ${g?typeof g==="string"?`retry with ${g}`:"yes (skipping)":"no (continuing)"}`);if(g===!0)return{success:!0,skipped:!0,reason:"VERSION_EXISTS",bundle:W,checksum:null,encryptionMethod:V,storageProvider:N};if(typeof g==="string")return H.info(`Retrying upload with new version: ${g}`),fL(D,{...$,bundle:g},X);if($.external&&!$.external.startsWith("https://"))W0(`External link should should start with "https://" current is "${$.external}"`);if($.deleteLinkedBundleOnUpload)H.warn("Deleting linked bundle on upload is destructive, it will delete the currently linked bundle in the channel you are trying to upload to."),H.warn("Please make sure you want to do this, if you are not sure, please do not use this option.");let l={name:W,app_id:L,session_key:void 0,external_url:$.external,storage_provider:N,min_update_version:h,native_packages:S,owner_org:v,user_id:A,checksum:void 0,link:$.link||null,comment:$.comment||null,key_id:void 0,cli_version:F6.version},f=null,j="";if(!$.external){if($.verbose)H.info(`[Verbose] Preparing bundle file from path: ${I}`);let YD=q.config?.plugins?.CapacitorUpdater?.publicKey,{zipped:P,ivSessionKey:E,checksum:r,sessionKey:k,encryptionMethod:zD,finalKeyData:t,keyId:KD}=await SSD(I,$,z,v,L,M.maxUploadLength,M.alertUploadSize,YD);if(l.session_key=E,l.checksum=r,l.key_id=KD||void 0,Y=k,f=P,V=zD,j=t,$.verbose)H.info("[Verbose] Bundle prepared:"),H.info(` - Size: ${Math.floor((P?.byteLength??0)/1024)} KB`),H.info(` - Checksum: ${r}`),H.info(` - Encryption: ${zD}`),H.info(` - IV Session Key: ${E?"present":"none"}`),H.info(` - Key ID: ${KD||"none"}`);if(!$.ignoreChecksumCheck){if($.verbose)H.info("[Verbose] Checking for duplicate checksum...");if(await xa(C,L,_,r),$.verbose)H.info("[Verbose] Checksum is unique")}}else{if($.verbose)H.info(`[Verbose] Using external URL: ${$.external}`);if(await RD(z,{channel:"app",event:"App external",icon:"\uD83D\uDCE4",user_id:v,tags:{"app-id":L},notify:!1},$.verbose),l.session_key=$.ivSessionKey,l.checksum=$.encryptedChecksum,$.verbose)H.info("[Verbose] External bundle configured:"),H.info(` - URL: ${$.external}`),H.info(` - IV Session Key: ${$.ivSessionKey?"provided":"none"}`),H.info(` - Encrypted Checksum: ${$.encryptedChecksum?"provided":"none"}`)}if($.zip){if($.tus=!1,$.verbose)H.info("[Verbose] Upload method: ZIP (explicitly set via --zip)")}else if(!M.TUSUpload||$.external){if($.tus=!1,$.verbose)H.info("[Verbose] Upload method: Standard (TUS not available or external URL)")}else if($.tus=$.tus||M.TUSUploadForced,$.verbose)H.info(`[Verbose] Upload method: ${$.tus?"TUS (resumable)":"Standard"}`);if(!M.partialUpload||$.external){if($.delta=!1,$.verbose&&$.external)H.info("[Verbose] Delta updates disabled (not available with external URLs)")}else if($.delta=$.delta||$.partial||$.deltaOnly||$.partialOnly||M.partialUploadForced,$.verbose)H.info(`[Verbose] Delta updates: ${$.delta?"enabled":"disabled"}`);if($.encryptPartial&&V==="v1")W0("You cannot encrypt the partial update if you are not using the v2 encryption method");let x="5.30.0",u="6.30.0",y="7.30.0",d=!1;if($.delta&&V==="v2"&&!$.encryptPartial){let YD=e0(kL()),P=await y1("@capgo/capacitor-updater",YD,$.packageJson),E;try{E=P?eD(P):void 0}catch{E=void 0}if(P&&E&&nI(E,eD("6.14.4"))){if(H.info(`Auto-enabling partial update encryption for updater version ${E} (> 6.14.4)`),$.verbose)H.info("[Verbose] Partial encryption auto-enabled for updater >= 6.14.4");$.encryptPartial=!0}}if($.delta&&($.encryptPartial||V==="v2")){let YD=e0(kL()),P=await y1("@capgo/capacitor-updater",YD,$.packageJson),E;try{E=P?eD(P):void 0}catch{E=void 0}if(P&&E){if(d=!Z$(E,x,u,y),$.verbose&&d)H.info(`[Verbose] Using hex checksum format for updater version ${E}`)}}if($.verbose&&$.delta)H.info("[Verbose] Preparing delta/partial update manifest...");let b=$.delta?await JDD(I,z,v,L,$.encryptPartial?V:"none",j,d):[];if($.verbose&&$.delta)H.info(`[Verbose] Delta manifest prepared with ${b.length} files`);if($.verbose)H.info("[Verbose] Creating version record in database...");let{error:a}=await SM(C,l);if(a)W0(`Cannot add bundle ${s(a)}`);if($.verbose)H.info("[Verbose] Version record created successfully");if($.tusChunkSize&&$.tusChunkSize>M.maxChunkSize)H.error(`Chunk size ${$.tusChunkSize} is greater than the maximum chunk size ${M.maxChunkSize}, using the maximum chunk size`),$.tusChunkSize=M.maxChunkSize;else if(!$.tusChunkSize)$.tusChunkSize=M.maxChunkSize;if($.verbose)H.info(`[Verbose] TUS chunk size: ${Math.floor($.tusChunkSize/1024/1024)} MB`);if(f&&(Z||G||Q||F||w||O||U)){if(!Z||!G||!Q||!F||!w||!O)W0("Missing argument, for S3 upload you need to provide a bucket name, endpoint, region, port, API key, and API secret");if(H.info("Uploading to S3"),$.verbose)H.info("[Verbose] S3 configuration:"),H.info(` - Endpoint: ${G}`),H.info(` - Region: ${Q}`),H.info(` - Bucket: ${Z}`),H.info(` - Port: ${O}`),H.info(` - SSL: ${U?"enabled":"disabled"}`);let YD=U?`https://${G}`:`http://${G}`,P=new _Z({endPoint:G,region:Q,port:O,pathStyle:!0,bucket:Z,accessKey:F,secretKey:w}),E=`${L}-${W}`,r=encodeURIComponent(E);if($.verbose)H.info(`[Verbose] Uploading to S3 as: ${E}`);if(await P.putObject(E,Uint8Array.from(f)),l.external_url=`${YD}/${r}`,l.storage_provider="external",$.verbose)H.info(`[Verbose] S3 upload complete, external URL: ${l.external_url}`)}else if(f){if(!$.partialOnly&&!$.deltaOnly){if($.verbose)H.info("[Verbose] Starting full bundle upload to Capgo Cloud...");await uSD(z,C,L,W,v,f,$,$.tusChunkSize)}else if($.verbose)H.info("[Verbose] Skipping full bundle upload (delta-only mode)");let YD=null;try{if($.dryUpload){if($.delta=!1,$.verbose)H.info("[Verbose] Dry upload mode: skipping delta upload")}let E=l.session_key&&$.encryptPartial&&Y?{sessionKey:Y,ivSessionKey:l.session_key}:void 0;if($.verbose&&$.delta)H.info("[Verbose] Starting delta/partial file upload..."),H.info(` - Manifest entries: ${b.length}`),H.info(` - Encryption: ${E?"enabled":"disabled"}`);if(YD=$.delta?await YDD(z,b,I,L,v,E,$):null,$.verbose&&YD)H.info(`[Verbose] Delta upload complete with ${YD.length} files`)}catch(E){if(!!($.partial||$.delta||$.partialOnly||$.deltaOnly))throw E;if(H.info(`Failed to upload partial files to capgo cloud. Error: ${s(E)}. This is not a critical error, the bundle has been uploaded without the partial files`),$.verbose)H.info(`[Verbose] Delta upload error details: ${s(E)}`)}if(l.storage_provider="r2",l.manifest=YD,$.verbose)H.info("[Verbose] Updating version record with storage provider and manifest...");let{error:P}=await SM(C,l);if(P)W0(`Cannot update bundle ${s(P)}`);if($.verbose)H.info("[Verbose] Version record updated successfully")}if($.verbose)H.info("[Verbose] Checking app permissions...");let c=await u0(C,z,L,2,!1,!0);if($.verbose)H.info("[Verbose] Permissions:"),H.info(` - Upload: ${r5(c,2)?"yes":"no"}`),H.info(` - Write: ${r5(c,3)?"yes":"no"}`),H.info(` - Admin: ${r5(c,4)?"yes":"no"}`);if($.deleteLinkedBundleOnUpload&&r5(c,3)){if($.verbose)H.info(`[Verbose] Deleting linked bundle in channel ${_}...`);await vSD(C,L,_)}else if($.deleteLinkedBundleOnUpload)H.warn("Cannot delete linked bundle on upload as a upload organization member");if(r5(c,3)){if($.verbose)H.info(`[Verbose] Setting bundle ${W} to channel ${_}...`);if(await _SD(C,z,!!$.bundleUrl,W,_,A,v,L,R,$.selfAssign),$.verbose)H.info("[Verbose] Channel updated successfully")}else H.warn("Cannot set channel as a upload organization member");if($.verbose)H.info("[Verbose] Sending upload event...");await RD(z,{channel:"app",event:"App Uploaded",icon:"⏫",user_id:v,tags:{"app-id":L,bundle:W},notify:!1},$.verbose),await RD(z,{channel:"app",event:"Bundle Uploaded",icon:"⏫",user_id:v,tags:{"app-id":L,bundle:W},notify:!1,notifyConsole:!0}).catch(()=>{});let n={success:!0,bundle:W,checksum:l.checksum??null,encryptionMethod:V,sessionKey:Y?Y.toString("base64"):void 0,ivSessionKey:typeof l.session_key==="string"?l.session_key:void 0,storageProvider:l.storage_provider};if($.verbose)H.info("[Verbose] Upload completed successfully:"),H.info(` - Bundle: ${n.bundle}`),H.info(` - Checksum: ${n.checksum}`),H.info(` - Encryption: ${n.encryptionMethod}`),H.info(` - Storage: ${n.storageProvider}`);if(K&&!n.skipped){let YD=$.showReplicationProgress;if(YD===void 0){let P=await c0({message:"Show Capgo global replication progress for this upload so you can confirm rollout in all regions?",initialValue:!1});YD=!yD(P)&&P}if(YD)await ls({title:"Replicating your bundle in all regions to guarantee fast updates.",completeMessage:"Replication complete. Your update is now globally available.",interactive:K})}if(X&&!n.skipped)ND("Time to share your update to the world \uD83C\uDF0D");return n}vD();D6();q1();q3();fD();import{randomUUID as fSD}from"node:crypto";import{existsSync as ySD,writeFileSync as bSD}from"node:fs";import{cwd as gSD}from"node:process";var hSD=20;function mSD(D){console.log(JSON.stringify(D,null,2))}function E2(D){console.error(s(D))}async function QDD(D,$,X=!1){let{json:Y}=$,{bundle:J,path:Q}=$,F=!Y&&!X;try{if(F)await F0();let w=await ID(),Z=iD(D,w?.config),G=fSD().split("-")[0],O=N4("",$.packageJson);if(J=J||O||`0.0.1-beta.${G}`,F)VD(`Zipping ${Z}@${J}`);if(J&&!p5.test(J)){let R=`Your bundle name ${J}, is not valid it should follow semver convention : https://semver.org/`;if(!X)if(Y)E2({error:"invalid_semver"});else H.error(R);throw Error("Invalid bundle version format")}if(Q=Q||w?.config?.webDir,!Z||!J||!Q){if(!X)if(Y)E2({error:"missing_argument"});else H.error("Missing argument, you need to provide a appId and a bundle and a path, or be in a capacitor project");throw Error("Missing argument, you need to provide a appId and a bundle and a path, or be in a capacitor project")}if(F)H.info(`Started from path "${Q}"`);if(typeof $.codeCheck>"u"?!0:$.codeCheck){if(!L2(Q,"notifyAppReady")){if(!X)if(Y)E2({error:"notifyAppReady_not_in_source_code"});else H.error("notifyAppReady() is missing in the build folder of your app. see: https://capgo.app/docs/plugin/api/#notifyappready");throw Error("notifyAppReady() is missing in build folder")}if(!kZ(Q)){if(!X)if(Y)E2({error:"index_html_not_found"});else H.error(`index.html is missing in the root folder of ${Q}`);throw Error("index.html is missing in root folder")}}let z=await wZ(Q);if(F)H.info(`Zipped ${z.byteLength} bytes`);let q=F?A0():null;if(q)q.start("Calculating checksum");let B=e0(gSD()),K=await y1("@capgo/capacitor-updater",B,$.packageJson);if(!K){if(!X)H.warn("Cannot find @capgo/capacitor-updater in node_modules, please install it first with your package manager");throw Error("Cannot find @capgo/capacitor-updater in node_modules, please install it first with your package manager")}let M=!1,L;try{L=K?eD(K):void 0}catch{L=void 0}if(L)M=!Z$(L,void 0,void 0,"7.0.0");else if(K==="link:@capgo/capacitor-updater"){if(!X)H.warn("Using local @capgo/capacitor-updater. Assuming v7");M=!0}let I=await p6(z,$.keyV2||ySD(i1)||M?"sha256":"crc32");if(q)q.stop(`Checksum ${M?"SHA256":"CRC32"}: ${I}`);let W=Math.floor(z.byteLength/1024/1024);if(W>hSD&&F)H.warn(`WARNING !!
486
486
  The bundle size is ${W} Mb, this may take a while to download for users
487
487
  `),H.warn(`Learn how to optimize your assets https://capgo.app/blog/optimise-your-images-for-updates/
488
- `);let N=F?A0():null,V=$.name||`${Z}_${J}.zip`;if(N)N.start(`Saving to ${V}`);if(bSD(V,z),N)N.stop(`Saved to ${V}`);if(F)ND("Done ✅");if(!X&&Y)mSD({bundle:J,filename:V,checksum:I});return{bundle:J,filename:V,checksum:I}}catch(w){if(!X)if(Y)E2(w);else H.error(s(w));throw w instanceof Error?w:Error(String(w))}}vD();fD();async function FDD(D,$,X,Y=!1){if(!Y)VD("Create channel");X.apikey=X.apikey||BD();let J=await ID().catch(()=>{return});if($=iD($,J?.config),!X.apikey){if(!Y)H.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!$){if(!Y)H.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}let Q=await jD(X.apikey,X.supaHost,X.supaAnon);if(await m0(Q,$,Y),await xD(Q,X.apikey,["write","all"]),await u0(Q,X.apikey,$,4,Y,!0),!Y)H.info(`Creating channel ${$}#${D} to Capgo`);let F=await kM(Q,$);if(!F){if(!Y)H.error("Cannot find default version for channel creation, please contact Capgo support \uD83E\uDD28");throw Error("Cannot find default version for channel creation")}let w=await o0(Q,$),Z=await xD(Q,X.apikey,["write","all"]),G=await va(Q,{name:D,app_id:$,version:F.id,created_by:Z,owner_org:w,allow_device_self_set:X.selfAssign??!1,public:X.default??!1});if(G.error){if(!Y)H.error(`Cannot create Channel \uD83D\uDE40
489
- ${s(G.error)}`);throw Error(`Cannot create channel: ${s(G.error)}`)}if(await RD(X.apikey,{channel:"channel",event:"Create channel",icon:"✅",user_id:w,tags:{"app-id":$,channel:D},notify:!1}).catch(()=>{}),!Y)H.success("Channel created ✅"),ND("Done ✅");return G.data??!0}vD();fD();async function wDD(D,$,X,Y=!1){let{quiet:J}=X;if(!J&&!Y)VD("List current bundle");X.apikey=X.apikey||BD(J);let Q=await ID();if($=iD($,Q?.config),!X.apikey){if(!Y)H.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!$){if(!Y)H.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}let F=await jD(X.apikey,X.supaHost,X.supaAnon);if(await m0(F,$,Y),await xD(F,X.apikey,["write","all","read"]),await u0(F,X.apikey,$,1,Y,!0),!D){if(!Y)H.error("Please provide a channel to get the bundle from.");throw Error("Channel name missing")}let{data:w,error:Z}=await F.from("channels").select("version ( name )").eq("name",D).eq("app_id",$).limit(1);if(Z||!w?.length){if(!Y)H.error(`Error retrieving channel ${D} for app ${$}. Perhaps the channel does not exist?`);throw Error(`Channel ${D} not found for app ${$}`)}let{version:G}=w[0];if(!G){if(!Y)H.error(`Error retrieving channel ${D} for app ${$}. Perhaps the channel does not exist?`);throw Error(`Channel ${D} does not have a bundle linked`)}if(!Y)if(!J)H.info(`Current bundle for channel ${D} is ${G.name}`);else H.info(G.name);return G.name}vD();fD();async function ZDD(D,$,X,Y=!1){if(!Y)VD("Delete channel");X.apikey=X.apikey||BD();let J=await ID();if($=iD($,J?.config),!X.apikey){if(!Y)H.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!$){if(!Y)H.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}let Q=await jD(X.apikey,X.supaHost,X.supaAnon);await m0(Q,$,Y);let F=await xD(Q,X.apikey,["all"]);if(await u0(Q,X.apikey,$,4,Y,!0),X.deleteBundle&&!Y)H.info(`Deleting bundle ${$}#${D} from Capgo`);if(X.deleteBundle){let z=await ya(Q,$,D);if(z?.name&&!Y)H.info(`Deleting bundle ${z.name} from Capgo`);if(z?.name)await fM(Q,$,z.name)}let{data:w,error:Z}=await ka(Q,$,D);if(Z||!w){if(!Y)H.error(`Channel ${D} not found`);if(X.successIfNotFound){if(!Y)H.success(`Channel ${D} not found and successIfNotFound is true`);return!0}throw Error(`Channel ${D} not found`)}let{error:G}=await fa(Q,$,w.id);if(G){if(!Y)H.error(`Cannot delete channel devices: ${s(G)}`);throw Error(`Cannot delete channel devices: ${s(G)}`)}if(!Y)H.info(`Deleting channel ${$}#${D} from Capgo`);let O=await _a(Q,D,$,F);if(O.error){if(!Y)H.error(`Cannot delete Channel \uD83D\uDE40 ${s(O.error)}`);throw Error(`Cannot delete channel: ${s(O.error)}`)}let U=await o0(Q,$);if(await RD(X.apikey,{channel:"channel",event:"Delete channel",icon:"✅",user_id:U,tags:{"app-id":$,channel:D},notify:!1}).catch(()=>{}),!Y)H.success("Channel deleted"),ND("Done ✅");return!0}vD();fD();async function GDD(D,$,X=!1){if(!X)VD("List channels");$.apikey=$.apikey||BD();let Y=await ID();if(D=iD(D,Y?.config),!$.apikey){if(!X)H.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!D){if(!X)H.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}let J=await jD($.apikey,$.supaHost,$.supaAnon);await m0(J,D,X);let Q=await xD(J,$.apikey,["write","all","read","upload"]);if(await u0(J,$.apikey,D,1,X,!0),!X)H.info("Querying available channels in Capgo");let F=await ga(J,D);if(!X)H.info(`Active channels in Capgo: ${F?.length??0}`),ba(F);if(await RD($.apikey,{channel:"channel",event:"List channel",icon:"✅",user_id:Q,tags:{"app-id":D},notify:!1}).catch(()=>{}),!X)ND("Done ✅");return F}vD();s$();fD();function ODD(D){let $=new R0;$.headers=["Package","Local","Remote","Status","Details"],$.theme=R0.roundTheme,$.rows=[];for(let X of D){let{name:Y,localVersion:J,remoteVersion:Q}=X,F=k8(X),w=F.compatible?"✅":"❌";$.rows.push([Y,J||"-",Q||"-",w,F.message])}H.info($.toString())}var UDD=["major","minor","metadata","patch","none"];async function qDD(D,$,X,Y=!1){if(!Y)VD("Set channel");X.apikey=X.apikey||BD();let J=await ID();if($=iD($,J?.config),!X.apikey){if(!Y)H.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!$){if(!Y)H.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}if(!D){if(!Y)H.error("Missing argument, you need to provide a channel");throw Error("Missing channel id")}let Q=await jD(X.apikey,X.supaHost,X.supaAnon);await m0(Q,$,Y);let F=await xD(Q,X.apikey,["write","all"]);await u0(Q,X.apikey,$,4,Y,!0);let w=await o0(Q,$),{bundle:Z,state:G,downgrade:O,latest:U,latestRemote:z,ios:q,android:B,selfAssign:K,disableAutoUpdate:M,dev:L,emulator:I,device:W,prod:N}=X;if(U&&Z){if(!Y)H.error("Cannot set latest and bundle at the same time");throw Error("Cannot set both latest and bundle simultaneously")}if(z&&Z){if(!Y)H.error("Cannot set latest remote and bundle at the same time");throw Error("Cannot set both latest remote and bundle simultaneously")}if(z&&U){if(!Y)H.error("Cannot set latest remote and latest at the same time");throw Error("Cannot set both latest remote and latest simultaneously")}if(Z==null&&G==null&&U==null&&z==null&&O==null&&q==null&&B==null&&K==null&&L==null&&I==null&&W==null&&N==null&&M==null){if(!Y)H.error("Missing argument, you need to provide a option to set");throw Error("No channel option provided")}await Ma(Q,w,X.apikey,$);let V={created_by:F,app_id:$,name:D,owner_org:w,version:void 0},{error:R}=await Q.from("channels").select().eq("app_id",$).eq("name",D).single();if(R){if(!Y)H.error(`Cannot find channel ${D}`);throw Error(`Cannot find channel ${D}`)}let P=U?J?.config?.plugins?.CapacitorUpdater?.version||N4("",X.packageJson):Z;if(P!=null){let{data:_,error:v}=await Q.from("app_versions").select().eq("app_id",$).eq("name",P).eq("user_id",F).eq("deleted",!1).single();if(v||!_){if(!Y)H.error(`Cannot find version ${P}`);throw Error(`Cannot find version ${P}`)}if(!X.ignoreMetadataCheck){let{finalCompatibility:S,localDependencies:h}=await _M(Q,$,D,_.native_packages??[]),g=S.filter((l)=>!L4(l));if(h.length>0&&g.length>0){if(!Y)H.warn(`Bundle NOT compatible with ${D} channel`),H.warn(""),ODD(S),H.warn(""),H.warn("An app store update may be required for these changes to take effect.");throw Error(`Bundle is not compatible with ${D} channel`)}if(!Y)if(h.length===0&&S.length>0)H.info(`Ignoring check compatibility with ${D} channel because the bundle does not contain any native packages`);else H.info(`Bundle is compatible with ${D} channel`)}if(!Y)H.info(`Set ${$} channel: ${D} to @${P}`);V.version=_.id}if(z){let{data:_,error:v}=await Q.from("app_versions").select().eq("app_id",$).eq("user_id",F).eq("deleted",!1).order("created_at",{ascending:!1}).single();if(v||!_){if(!Y)H.error("Cannot find latest remote version");throw Error("Cannot find latest remote version")}if(!X.ignoreMetadataCheck){let{finalCompatibility:S}=await _M(Q,$,D,_.native_packages??[]);if(S.filter((g)=>!L4(g)).length>0){if(!Y)H.warn(`Bundle NOT compatible with ${D} channel`),H.warn(""),ODD(S),H.warn(""),H.warn("An app store update may be required for these changes to take effect.");throw Error(`Latest remote bundle is not compatible with ${D} channel`)}}if(!Y)H.info(`Set ${$} channel: ${D} to @${_.name}`);V.version=_.id}if(G!=null){if(G!=="normal"&&G!=="default"){if(!Y)H.error(`State ${G} is not known. The possible values are: normal, default.`);throw Error(`Unknown state ${G}. Expected normal or default`)}if(!Y)H.info(`Set ${$} channel: ${D} to ${G}`);V.public=G==="default"}if(O!=null){if(!Y)H.info(`Set ${$} channel: ${D} to ${O?"allow":"disallow"} downgrade`);V.disable_auto_update_under_native=!O}if(q!=null){if(!Y)H.info(`Set ${$} channel: ${D} to ${q?"allow":"disallow"} ios update`);V.ios=!!q}if(B!=null){if(!Y)H.info(`Set ${$} channel: ${D} to ${B?"allow":"disallow"} android update`);V.android=!!B}if(K!=null){if(!Y)H.info(`Set ${$} channel: ${D} to ${K?"allow":"disallow"} self assign to this channel`);V.allow_device_self_set=!!K}if(L!=null){if(!Y)H.info(`Set ${$} channel: ${D} to ${L?"allow":"disallow"} dev devices`);V.allow_dev=!!L}if(I!=null){if(!Y)H.info(`Set ${$} channel: ${D} to ${I?"allow":"disallow"} emulator devices`);V.allow_emulator=!!I}if(W!=null){if(!Y)H.info(`Set ${$} channel: ${D} to ${W?"allow":"disallow"} physical devices`);V.allow_device=!!W}if(N!=null){if(!Y)H.info(`Set ${$} channel: ${D} to ${N?"allow":"disallow"} prod builds`);V.allow_prod=!!N}if(M!=null){let _=M.toLowerCase();if(!UDD.includes(_)){if(!Y)H.error(`Channel strategy ${_} is not known. The possible values are: ${UDD.join(", ")}.`);throw Error(`Unknown channel strategy ${_}`)}if(_==="metadata")_="version_number";if(V.disable_auto_update=_,!Y)H.info(`Set ${$} channel: ${D} to ${_} disable update strategy to this channel`)}let{error:A}=await ZZ(Q,V);if(A){if(!Y)H.error('Cannot set channel the upload key is not allowed to do that, use the "all" for this.');throw Error("Upload key is not allowed to set this channel")}if(await RD(X.apikey,{channel:"channel",event:"Set channel",icon:"✅",user_id:w,tags:{"app-id":$},notify:!1}).catch(()=>{}),!Y)ND("Done ✅");return!0}vD();import{existsSync as O7,readFileSync as dSD,unlinkSync as zDD,writeFileSync as BDD}from"node:fs";q1();GF();fD();function KDD(D){return D.plugins??={},D.plugins.extConfig??={},D.plugins.CapacitorUpdater??={},D.plugins.CapacitorUpdater}async function WDD(D,$=!1){if(!$)VD("Save keys \uD83D\uDD11");let X=await ID(),Y=D.key||R6,J=D.keyData||"";if(!O7(Y)&&!J){if(!$)H.error(`Cannot find a public key at ${Y} or as keyData option or in ${X.path}`);throw Error("Missing public key")}if(O7(Y))J=dSD(Y,"utf8");if(!J.startsWith("-----BEGIN RSA PUBLIC KEY-----")){if(!$)H.error("The public key provided is not a valid RSA Public key");throw Error("Invalid RSA public key")}if(X?.config){let Q=KDD(X.config);if(Q.privateKey){if(delete Q.privateKey,!$)H.info("Old private key deleted from config file");if($?D.setupChannel??!1:D.setupChannel??await c0({message:"Do you want to setup encryption with the new channel in order to support old apps and facilitate the migration?"}))Q.defaultChannel="encryption_v2"}Q.publicKey=J,await U5(X)}if(!$)H.success(`Public key saved into ${X.path} file in local directory`),H.success("Your app will decode the zip archive with this key");return!0}async function HDD(D,$=!1){if(!$)VD("Deleting old private key \uD83D\uDDD1️");let X=await ID(),Y=X?.config?.plugins?.CapacitorUpdater;if(Y?.privateKey){if(delete Y.privateKey,await U5(X),O7(i5))try{if(zDD(i5),!$)H.success(`Old private key file deleted: ${i5}`)}catch(J){if(!$)H.error(`Failed to delete old private key file: ${i5} (${String(J)})`)}if(O7($Z))try{if(zDD($Z),!$)H.success(`Old public key file deleted: ${$Z}`)}catch(J){if(!$)H.error(`Failed to delete old public key file: ${R6} (${String(J)})`)}if(!$)H.success(`Old private key deleted from ${X.path} file`),ND("Done ✅");return!0}if(!$)H.info("No old private key found in config file");return!1}async function VDD(D,$=!1){if(!$)VD("Create keys \uD83D\uDD11");let{publicKey:X,privateKey:Y}=Es();if(O7(R6)&&!D.force){if(!$)H.error("Public Key already exists, use --force to overwrite");throw Error("Public key already exists")}if(BDD(R6,X),O7(i1)&&!D.force){if(!$)H.error("Private Key already exists, use --force to overwrite");throw Error("Private key already exists")}BDD(i1,Y);let J=await ID();if(J){let Q=KDD(J.config);if(Q.privateKey){if(delete Q.privateKey,!$)H.info("Old private key deleted from config file");if($?D.setupChannel??!1:D.setupChannel??await c0({message:"Do you want to setup encryption with the new channel in order to support old apps and facilitate the migration?"}))Q.defaultChannel="encryption_v2"}Q.publicKey=X,await U5(J)}if(!$){H.success("Your RSA key has been generated"),H.success(`Private key saved in ${i1}`),H.success("This key will be used to encrypt your bundle before sending it to Capgo"),H.success("Keep it safe"),H.success("Then make it unreadable by Capgo and unmodifiable by anyone"),H.success(`Public key saved in ${J.path}`),H.success("Your app will be the only one having it"),H.success("Only your users can decrypt your update"),H.success("Only you can send them an update");try{await Sa(void 0,void 0,void 0,{validateIosUpdater:!0}),ND("Done ✅")}catch(Q){if(Q instanceof Error&&Q.message==="Capacitor sync cancelled")return!0;throw Q}}return!0}vD();q1();fD();import{appendFileSync as cSD,existsSync as lSD,writeFileSync as NDD}from"node:fs";import{homedir as nSD}from"node:os";async function MDD(D,$,X=!1){if(!X)VD("Login to Capgo");if(!D&&!X){let F=await qI({message:"Enter your API key:",mask:"*"});if(yD(F))throw H.error("Login cancelled"),Error("Login cancelled");D=F}if(!D){if(!X)H.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}await F0();let{local:Y}=$;if(Y){if(!lSD(".git")){if(!X)H.error("To use local you should be in a git repository");throw Error("Not in a git repository")}NDD(".capgo",`${D}
488
+ `);let N=F?A0():null,V=$.name||`${Z}_${J}.zip`;if(N)N.start(`Saving to ${V}`);if(bSD(V,z),N)N.stop(`Saved to ${V}`);if(F)ND("Done ✅");if(!X&&Y)mSD({bundle:J,filename:V,checksum:I});return{bundle:J,filename:V,checksum:I}}catch(w){if(!X)if(Y)E2(w);else H.error(s(w));throw w instanceof Error?w:Error(String(w))}}vD();fD();async function FDD(D,$,X,Y=!1){if(!Y)VD("Create channel");X.apikey=X.apikey||BD();let J=await ID().catch(()=>{return});if($=iD($,J?.config),!X.apikey){if(!Y)H.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!$){if(!Y)H.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}let Q=await jD(X.apikey,X.supaHost,X.supaAnon);if(await d0(Q,$,Y),await xD(Q,X.apikey,["write","all"]),await u0(Q,X.apikey,$,4,Y,!0),!Y)H.info(`Creating channel ${$}#${D} to Capgo`);let F=await kM(Q,$);if(!F){if(!Y)H.error("Cannot find default version for channel creation, please contact Capgo support \uD83E\uDD28");throw Error("Cannot find default version for channel creation")}let w=await o0(Q,$),Z=await xD(Q,X.apikey,["write","all"]),G=await va(Q,{name:D,app_id:$,version:F.id,created_by:Z,owner_org:w,allow_device_self_set:X.selfAssign??!1,public:X.default??!1});if(G.error){if(!Y)H.error(`Cannot create Channel \uD83D\uDE40
489
+ ${s(G.error)}`);throw Error(`Cannot create channel: ${s(G.error)}`)}if(await RD(X.apikey,{channel:"channel",event:"Create channel",icon:"✅",user_id:w,tags:{"app-id":$,channel:D},notify:!1}).catch(()=>{}),!Y)H.success("Channel created ✅"),ND("Done ✅");return G.data??!0}vD();fD();async function wDD(D,$,X,Y=!1){let{quiet:J}=X;if(!J&&!Y)VD("List current bundle");X.apikey=X.apikey||BD(J);let Q=await ID();if($=iD($,Q?.config),!X.apikey){if(!Y)H.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!$){if(!Y)H.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}let F=await jD(X.apikey,X.supaHost,X.supaAnon);if(await d0(F,$,Y),await xD(F,X.apikey,["write","all","read"]),await u0(F,X.apikey,$,1,Y,!0),!D){if(!Y)H.error("Please provide a channel to get the bundle from.");throw Error("Channel name missing")}let{data:w,error:Z}=await F.from("channels").select("version ( name )").eq("name",D).eq("app_id",$).limit(1);if(Z||!w?.length){if(!Y)H.error(`Error retrieving channel ${D} for app ${$}. Perhaps the channel does not exist?`);throw Error(`Channel ${D} not found for app ${$}`)}let{version:G}=w[0];if(!G){if(!Y)H.error(`Error retrieving channel ${D} for app ${$}. Perhaps the channel does not exist?`);throw Error(`Channel ${D} does not have a bundle linked`)}if(!Y)if(!J)H.info(`Current bundle for channel ${D} is ${G.name}`);else H.info(G.name);return G.name}vD();fD();async function ZDD(D,$,X,Y=!1){if(!Y)VD("Delete channel");X.apikey=X.apikey||BD();let J=await ID();if($=iD($,J?.config),!X.apikey){if(!Y)H.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!$){if(!Y)H.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}let Q=await jD(X.apikey,X.supaHost,X.supaAnon);await d0(Q,$,Y);let F=await xD(Q,X.apikey,["all"]);if(await u0(Q,X.apikey,$,4,Y,!0),X.deleteBundle&&!Y)H.info(`Deleting bundle ${$}#${D} from Capgo`);if(X.deleteBundle){let z=await ya(Q,$,D);if(z?.name&&!Y)H.info(`Deleting bundle ${z.name} from Capgo`);if(z?.name)await fM(Q,$,z.name)}let{data:w,error:Z}=await ka(Q,$,D);if(Z||!w){if(!Y)H.error(`Channel ${D} not found`);if(X.successIfNotFound){if(!Y)H.success(`Channel ${D} not found and successIfNotFound is true`);return!0}throw Error(`Channel ${D} not found`)}let{error:G}=await fa(Q,$,w.id);if(G){if(!Y)H.error(`Cannot delete channel devices: ${s(G)}`);throw Error(`Cannot delete channel devices: ${s(G)}`)}if(!Y)H.info(`Deleting channel ${$}#${D} from Capgo`);let O=await _a(Q,D,$,F);if(O.error){if(!Y)H.error(`Cannot delete Channel \uD83D\uDE40 ${s(O.error)}`);throw Error(`Cannot delete channel: ${s(O.error)}`)}let U=await o0(Q,$);if(await RD(X.apikey,{channel:"channel",event:"Delete channel",icon:"✅",user_id:U,tags:{"app-id":$,channel:D},notify:!1}).catch(()=>{}),!Y)H.success("Channel deleted"),ND("Done ✅");return!0}vD();fD();async function GDD(D,$,X=!1){if(!X)VD("List channels");$.apikey=$.apikey||BD();let Y=await ID();if(D=iD(D,Y?.config),!$.apikey){if(!X)H.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!D){if(!X)H.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}let J=await jD($.apikey,$.supaHost,$.supaAnon);await d0(J,D,X);let Q=await xD(J,$.apikey,["write","all","read","upload"]);if(await u0(J,$.apikey,D,1,X,!0),!X)H.info("Querying available channels in Capgo");let F=await ga(J,D);if(!X)H.info(`Active channels in Capgo: ${F?.length??0}`),ba(F);if(await RD($.apikey,{channel:"channel",event:"List channel",icon:"✅",user_id:Q,tags:{"app-id":D},notify:!1}).catch(()=>{}),!X)ND("Done ✅");return F}vD();s$();fD();function ODD(D){let $=new R0;$.headers=["Package","Local","Remote","Status","Details"],$.theme=R0.roundTheme,$.rows=[];for(let X of D){let{name:Y,localVersion:J,remoteVersion:Q}=X,F=k8(X),w=F.compatible?"✅":"❌";$.rows.push([Y,J||"-",Q||"-",w,F.message])}H.info($.toString())}var UDD=["major","minor","metadata","patch","none"];async function qDD(D,$,X,Y=!1){if(!Y)VD("Set channel");X.apikey=X.apikey||BD();let J=await ID();if($=iD($,J?.config),!X.apikey){if(!Y)H.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!$){if(!Y)H.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}if(!D){if(!Y)H.error("Missing argument, you need to provide a channel");throw Error("Missing channel id")}let Q=await jD(X.apikey,X.supaHost,X.supaAnon);await d0(Q,$,Y);let F=await xD(Q,X.apikey,["write","all"]);await u0(Q,X.apikey,$,4,Y,!0);let w=await o0(Q,$),{bundle:Z,state:G,downgrade:O,latest:U,latestRemote:z,ios:q,android:B,selfAssign:K,disableAutoUpdate:M,dev:L,emulator:I,device:W,prod:N}=X;if(U&&Z){if(!Y)H.error("Cannot set latest and bundle at the same time");throw Error("Cannot set both latest and bundle simultaneously")}if(z&&Z){if(!Y)H.error("Cannot set latest remote and bundle at the same time");throw Error("Cannot set both latest remote and bundle simultaneously")}if(z&&U){if(!Y)H.error("Cannot set latest remote and latest at the same time");throw Error("Cannot set both latest remote and latest simultaneously")}if(Z==null&&G==null&&U==null&&z==null&&O==null&&q==null&&B==null&&K==null&&L==null&&I==null&&W==null&&N==null&&M==null){if(!Y)H.error("Missing argument, you need to provide a option to set");throw Error("No channel option provided")}await Ma(Q,w,X.apikey,$);let V={created_by:F,app_id:$,name:D,owner_org:w,version:void 0},{error:R}=await Q.from("channels").select().eq("app_id",$).eq("name",D).single();if(R){if(!Y)H.error(`Cannot find channel ${D}`);throw Error(`Cannot find channel ${D}`)}let C=U?J?.config?.plugins?.CapacitorUpdater?.version||N4("",X.packageJson):Z;if(C!=null){let{data:_,error:v}=await Q.from("app_versions").select().eq("app_id",$).eq("name",C).eq("user_id",F).eq("deleted",!1).single();if(v||!_){if(!Y)H.error(`Cannot find version ${C}`);throw Error(`Cannot find version ${C}`)}if(!X.ignoreMetadataCheck){let{finalCompatibility:S,localDependencies:h}=await _M(Q,$,D,_.native_packages??[]),g=S.filter((l)=>!L4(l));if(h.length>0&&g.length>0){if(!Y)H.warn(`Bundle NOT compatible with ${D} channel`),H.warn(""),ODD(S),H.warn(""),H.warn("An app store update may be required for these changes to take effect.");throw Error(`Bundle is not compatible with ${D} channel`)}if(!Y)if(h.length===0&&S.length>0)H.info(`Ignoring check compatibility with ${D} channel because the bundle does not contain any native packages`);else H.info(`Bundle is compatible with ${D} channel`)}if(!Y)H.info(`Set ${$} channel: ${D} to @${C}`);V.version=_.id}if(z){let{data:_,error:v}=await Q.from("app_versions").select().eq("app_id",$).eq("user_id",F).eq("deleted",!1).order("created_at",{ascending:!1}).single();if(v||!_){if(!Y)H.error("Cannot find latest remote version");throw Error("Cannot find latest remote version")}if(!X.ignoreMetadataCheck){let{finalCompatibility:S}=await _M(Q,$,D,_.native_packages??[]);if(S.filter((g)=>!L4(g)).length>0){if(!Y)H.warn(`Bundle NOT compatible with ${D} channel`),H.warn(""),ODD(S),H.warn(""),H.warn("An app store update may be required for these changes to take effect.");throw Error(`Latest remote bundle is not compatible with ${D} channel`)}}if(!Y)H.info(`Set ${$} channel: ${D} to @${_.name}`);V.version=_.id}if(G!=null){if(G!=="normal"&&G!=="default"){if(!Y)H.error(`State ${G} is not known. The possible values are: normal, default.`);throw Error(`Unknown state ${G}. Expected normal or default`)}if(!Y)H.info(`Set ${$} channel: ${D} to ${G}`);V.public=G==="default"}if(O!=null){if(!Y)H.info(`Set ${$} channel: ${D} to ${O?"allow":"disallow"} downgrade`);V.disable_auto_update_under_native=!O}if(q!=null){if(!Y)H.info(`Set ${$} channel: ${D} to ${q?"allow":"disallow"} ios update`);V.ios=!!q}if(B!=null){if(!Y)H.info(`Set ${$} channel: ${D} to ${B?"allow":"disallow"} android update`);V.android=!!B}if(K!=null){if(!Y)H.info(`Set ${$} channel: ${D} to ${K?"allow":"disallow"} self assign to this channel`);V.allow_device_self_set=!!K}if(L!=null){if(!Y)H.info(`Set ${$} channel: ${D} to ${L?"allow":"disallow"} dev devices`);V.allow_dev=!!L}if(I!=null){if(!Y)H.info(`Set ${$} channel: ${D} to ${I?"allow":"disallow"} emulator devices`);V.allow_emulator=!!I}if(W!=null){if(!Y)H.info(`Set ${$} channel: ${D} to ${W?"allow":"disallow"} physical devices`);V.allow_device=!!W}if(N!=null){if(!Y)H.info(`Set ${$} channel: ${D} to ${N?"allow":"disallow"} prod builds`);V.allow_prod=!!N}if(M!=null){let _=M.toLowerCase();if(!UDD.includes(_)){if(!Y)H.error(`Channel strategy ${_} is not known. The possible values are: ${UDD.join(", ")}.`);throw Error(`Unknown channel strategy ${_}`)}if(_==="metadata")_="version_number";if(V.disable_auto_update=_,!Y)H.info(`Set ${$} channel: ${D} to ${_} disable update strategy to this channel`)}let{error:A}=await ZZ(Q,V);if(A){if(!Y)H.error('Cannot set channel the upload key is not allowed to do that, use the "all" for this.');throw Error("Upload key is not allowed to set this channel")}if(await RD(X.apikey,{channel:"channel",event:"Set channel",icon:"✅",user_id:w,tags:{"app-id":$},notify:!1}).catch(()=>{}),!Y)ND("Done ✅");return!0}vD();import{existsSync as O7,readFileSync as dSD,unlinkSync as zDD,writeFileSync as BDD}from"node:fs";q1();GF();fD();function KDD(D){return D.plugins??={},D.plugins.extConfig??={},D.plugins.CapacitorUpdater??={},D.plugins.CapacitorUpdater}async function WDD(D,$=!1){if(!$)VD("Save keys \uD83D\uDD11");let X=await ID(),Y=D.key||R6,J=D.keyData||"";if(!O7(Y)&&!J){if(!$)H.error(`Cannot find a public key at ${Y} or as keyData option or in ${X.path}`);throw Error("Missing public key")}if(O7(Y))J=dSD(Y,"utf8");if(!J.startsWith("-----BEGIN RSA PUBLIC KEY-----")){if(!$)H.error("The public key provided is not a valid RSA Public key");throw Error("Invalid RSA public key")}if(X?.config){let Q=KDD(X.config);if(Q.privateKey){if(delete Q.privateKey,!$)H.info("Old private key deleted from config file");if($?D.setupChannel??!1:D.setupChannel??await c0({message:"Do you want to setup encryption with the new channel in order to support old apps and facilitate the migration?"}))Q.defaultChannel="encryption_v2"}Q.publicKey=J,await U5(X)}if(!$)H.success(`Public key saved into ${X.path} file in local directory`),H.success("Your app will decode the zip archive with this key");return!0}async function HDD(D,$=!1){if(!$)VD("Deleting old private key \uD83D\uDDD1️");let X=await ID(),Y=X?.config?.plugins?.CapacitorUpdater;if(Y?.privateKey){if(delete Y.privateKey,await U5(X),O7(i5))try{if(zDD(i5),!$)H.success(`Old private key file deleted: ${i5}`)}catch(J){if(!$)H.error(`Failed to delete old private key file: ${i5} (${String(J)})`)}if(O7($Z))try{if(zDD($Z),!$)H.success(`Old public key file deleted: ${$Z}`)}catch(J){if(!$)H.error(`Failed to delete old public key file: ${R6} (${String(J)})`)}if(!$)H.success(`Old private key deleted from ${X.path} file`),ND("Done ✅");return!0}if(!$)H.info("No old private key found in config file");return!1}async function VDD(D,$=!1){if(!$)VD("Create keys \uD83D\uDD11");let{publicKey:X,privateKey:Y}=Es();if(O7(R6)&&!D.force){if(!$)H.error("Public Key already exists, use --force to overwrite");throw Error("Public key already exists")}if(BDD(R6,X),O7(i1)&&!D.force){if(!$)H.error("Private Key already exists, use --force to overwrite");throw Error("Private key already exists")}BDD(i1,Y);let J=await ID();if(J){let Q=KDD(J.config);if(Q.privateKey){if(delete Q.privateKey,!$)H.info("Old private key deleted from config file");if($?D.setupChannel??!1:D.setupChannel??await c0({message:"Do you want to setup encryption with the new channel in order to support old apps and facilitate the migration?"}))Q.defaultChannel="encryption_v2"}Q.publicKey=X,await U5(J)}if(!$){H.success("Your RSA key has been generated"),H.success(`Private key saved in ${i1}`),H.success("This key will be used to encrypt your bundle before sending it to Capgo"),H.success("Keep it safe"),H.success("Then make it unreadable by Capgo and unmodifiable by anyone"),H.success(`Public key saved in ${J.path}`),H.success("Your app will be the only one having it"),H.success("Only your users can decrypt your update"),H.success("Only you can send them an update");try{await Sa(void 0,void 0,void 0,{validateIosUpdater:!0}),ND("Done ✅")}catch(Q){if(Q instanceof Error&&Q.message==="Capacitor sync cancelled")return!0;throw Q}}return!0}vD();q1();fD();import{appendFileSync as cSD,existsSync as lSD,writeFileSync as NDD}from"node:fs";import{homedir as nSD}from"node:os";async function MDD(D,$,X=!1){if(!X)VD("Login to Capgo");if(!D&&!X){let F=await qI({message:"Enter your API key:",mask:"*"});if(yD(F))throw H.error("Login cancelled"),Error("Login cancelled");D=F}if(!D){if(!X)H.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}await F0();let{local:Y}=$;if(Y){if(!lSD(".git")){if(!X)H.error("To use local you should be in a git repository");throw Error("Not in a git repository")}NDD(".capgo",`${D}
490
490
  `),cSD(".gitignore",`.capgo
491
491
  `)}else{let F=nSD();NDD(`${F}/.capgo`,`${D}
492
492
  `)}let J=await jD(D,$.supaHost,$.supaAnon),Q=await xD(J,D,["write","all","upload"]);if(await RD(D,{channel:"user-login",event:"User CLI login",icon:"✅",user_id:Q,notify:!1}).catch(),!X)H.success(`login saved into .capgo file in ${Y?"local":"home"} directory`),ND("Done ✅")}vD();q1();fD();async function LDD(D,$=!1){if(!$)VD("Adding organization");await F0();let X={...D,apikey:D.apikey||BD()};if(!X.apikey){if(!$)H.error("Missing API key, you need to provide an API key to add an organization");throw Error("Missing API key")}let Y=await jD(X.apikey,X.supaHost,X.supaAnon),J=await xD(Y,X.apikey,["write","all"]),{name:Q,email:F}=X;if(!$&&!Q){let G=await _6({message:"Organization name:",placeholder:"My Organization"});if(yD(G))throw H.error("Canceled adding organization"),Error("Organization creation cancelled");Q=G}if(!$&&!F){let G=await _6({message:"Management email:",placeholder:"admin@example.com"});if(yD(G))throw H.error("Canceled adding organization"),Error("Organization creation cancelled");F=G}if(!Q||!F){if(!$)H.error("Missing arguments, you need to provide an organization name and management email");throw Error("Missing organization name or management email")}if(!$)H.info(`Adding organization "${Q}" to Capgo`);let{data:w,error:Z}=await Y.from("orgs").insert({name:Q,management_email:F,created_by:J}).select().single();if(Z){if(!$)H.error(`Could not add organization ${s(Z)}`);throw Error(`Could not add organization: ${s(Z)}`)}if(await RD(X.apikey,{channel:"organization",event:"Organization Created",icon:"\uD83C\uDFE2",user_id:w.id,tags:{"org-name":Q},notify:!1}).catch(()=>{}),!$)H.success(`Organization "${Q}" added to Capgo`),ND("Done ✅");return w}vD();q1();fD();async function IDD(D,$,X=!1){if(!X)VD("Deleting organization");await F0();let Y={...$,apikey:$.apikey||BD()};if(!Y.apikey){if(!X)H.error("Missing API key, you need to provide an API key to delete an organization");throw Error("Missing API key")}if(!D){if(!X)H.error("Missing argument, you need to provide an organization ID");throw Error("Missing organization id")}let J=await jD(Y.apikey,Y.supaHost,Y.supaAnon),Q=await xD(J,Y.apikey,["write","all"]);await XZ(J,D,X);let{data:F,error:w}=await J.from("orgs").select("created_by, name").eq("id",D).single();if(w||!F){if(!X)H.error(`Cannot get organization details ${s(w)}`);throw Error(`Cannot get organization details: ${s(w)}`)}if(F.created_by!==Q){if(X)throw Error("Deleting an organization is restricted to the organization owner");H.warn("Deleting an organization is restricted to the organization owner"),H.warn("You are not the owner of this organization"),H.warn("It's strongly recommended that you do not continue!");let G=await t1({message:"Do you want to continue?",options:[{label:"Yes",value:"yes"},{label:"No",value:"no"}]});if(yD(G)||G==="no")throw H.error("Canceled deleting the organization"),Error("Organization deletion cancelled")}if(!X&&!Y.autoConfirm){let G=await c0({message:`Are you sure you want to delete organization "${F.name}"? This action cannot be undone.`});if(yD(G)||!G)throw H.error("Canceled deleting the organization"),Error("Organization deletion cancelled")}if(!X)H.info(`Deleting organization "${F.name}"`);let{error:Z}=await J.from("orgs").delete().eq("id",D);if(Z){if(!X)H.error(`Could not delete organization ${s(Z)}`);throw Error(`Could not delete organization: ${s(Z)}`)}if(await RD(Y.apikey,{channel:"organization",event:"Organization Deleted",icon:"\uD83D\uDDD1️",user_id:D,tags:{"org-name":F.name},notify:!1}).catch(()=>{}),!X)H.success(`Organization "${F.name}" deleted from Capgo`),ND("Done ✅");return!0}vD();s$();q1();fD();function iSD(D,$){if($)return;if(!D.length){H.error("No organizations found");return}let X=new R0;X.headers=["Name","ID","Role","Apps","2FA Required","2FA Access"],X.rows=[];for(let J of D.toReversed()){let Q=J.enforcing_2fa?"✓ Yes":"✗ No",F=J["2fa_has_access"]?"✓ Yes":"✗ No";X.rows.push([J.name??"Unknown",J.gid,J.role,J.app_count?.toString()||"0",Q,F])}H.success("Organizations"),H.success(X.toString());let Y=D.filter((J)=>J.enforcing_2fa&&!J["2fa_has_access"]);if(Y.length>0){H.warn(`
493
493
  ⚠️ You don't have access to ${Y.length} organization(s) due to 2FA enforcement:`);for(let J of Y)H.warn(` - ${J.name} (${J.gid})`);H.warn(`
494
- To regain access, enable 2FA on your account at https://web.capgo.app/settings/account`)}}async function ADD(D,$=!1){if(!$)VD("List organizations");await F0();let X={...D,apikey:D.apikey||BD()};if(!X.apikey){if(!$)H.error("Missing API key, you need to provide an API key to list organizations");throw Error("Missing API key")}let Y=await jD(X.apikey,X.supaHost,X.supaAnon);if(await xD(Y,X.apikey,["read","write","all"]),!$)H.info("Getting organizations from Capgo");let{error:J,data:Q}=await Y.rpc("get_orgs_v7");if(J){if(!$)H.error(`Cannot get organizations ${s(J)}`);throw Error(`Cannot get organizations: ${s(J)}`)}let F=Q||[];if(!$)H.info(`Organizations found: ${F.length}`),iSD(F,$),ND("Done ✅");return F}vD();q1();fD();async function RDD(D,$,X=!1){if(!X)VD("Updating organization");await F0();let Y={...$,apikey:$.apikey||BD()};if(!Y.apikey){if(!X)H.error("Missing API key, you need to provide an API key to update an organization");throw Error("Missing API key")}if(!D){if(!X)H.error("Missing argument, you need to provide an organization ID");throw Error("Missing organization id")}let J=await jD(Y.apikey,Y.supaHost,Y.supaAnon);await xD(J,Y.apikey,["write","all"]),await XZ(J,D,X);let{data:Q,error:F}=await J.from("orgs").select("name, management_email, created_by, enforcing_2fa, password_policy_config, require_apikey_expiration, max_apikey_expiration_days, enforce_hashed_api_keys").eq("id",D).single();if(F||!Q){if(!X)H.error(`Cannot get organization details ${s(F)}`);throw Error(`Cannot get organization details: ${s(F)}`)}let{name:w,email:Z,enforce2fa:G}=Y,{passwordPolicy:O,minLength:U,requireUppercase:z,requireNumber:q,requireSpecial:B}=Y,{requireApikeyExpiration:K,maxApikeyExpirationDays:M,enforceHashedApiKeys:L}=Y;if(G!==void 0){if(!X){if(G&&!Q.enforcing_2fa){H.info("Checking organization members 2FA status...");let{data:R,error:P}=await J.rpc("check_org_members_2fa_enabled",{org_id:D});if(P)throw H.error(`Cannot check members 2FA status: ${s(P)}`),Error("Cannot check members 2FA status");let{data:A,error:_}=await J.rpc("has_2fa_enabled");if(_)throw H.error(`Cannot check your 2FA status: ${s(_)}`),Error("Cannot check your 2FA status");let{data:v,error:S}=await J.rpc("get_identity_apikey_only",{keymode:["read","upload","write","all"]});if(S||!v)throw H.error(`Cannot get current user identity: ${S?s(S):"No user ID returned"}`),Error("Cannot get current user identity");let h=R?.filter((g)=>!g["2fa_enabled"]&&g.user_id!==v)||[];if(h.length>0||!A){if(H.warn("⚠️ Warning: Enabling 2FA enforcement will affect access"),H.message("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"),!A)H.warn("\uD83D\uDD10 YOU do not have 2FA enabled! By enabling 2FA enforcement, you will LOSE ACCESS to this organization until you enable 2FA on your account.");if(h.length>0){let{data:l,error:f}=await J.rpc("get_org_members",{guild_id:D});if(f)throw H.error(`Cannot get organization members: ${s(f)}`),Error("Cannot get organization members");let j=new Map(l?.map((d)=>[d.uid,d])||[]),x=h.map((d)=>{return j.get(d.user_id)?.email||d.user_id}),u=h.length===1?"member does":"members do",y=h.length===1?"This member will":"These members will";H.warn(`${h.length} ${u} not have 2FA enabled: ${x.join(", ")}`),H.warn(`${y} lose access until they enable 2FA.`)}let g=await c0({message:"Are you sure you want to enable 2FA enforcement?"});if(yD(g)||!g)throw H.error("Canceled enabling 2FA enforcement"),Error("2FA enforcement cancelled")}H.info("Enabling 2FA enforcement for organization...")}else if(!G&&Q.enforcing_2fa)H.info("Disabling 2FA enforcement for organization...")}let{error:N}=await J.from("orgs").update({enforcing_2fa:G}).eq("id",D);if(N){if(!X)H.error(`Could not update 2FA enforcement: ${s(N)}`);throw Error(`Could not update 2FA enforcement: ${s(N)}`)}if(!X)if(G)H.success("✓ 2FA enforcement enabled for this organization");else H.success("✓ 2FA enforcement disabled for this organization");if(w===void 0&&Z===void 0&&!(O!==void 0||K!==void 0||M!==void 0||L!==void 0)){if(await RD(Y.apikey,{channel:"organization",event:G?"Organization 2FA Enabled":"Organization 2FA Disabled",icon:"\uD83D\uDD10",user_id:D,tags:{"org-name":Q.name,"enforce-2fa":G.toString()},notify:!1}).catch(()=>{}),!X)ND("Done ✅");return{orgId:D,name:Q.name,email:Q.management_email,enforce2fa:G}}}if(O!==void 0){if(!X)if(O){H.info("Configuring password policy for organization...");let{data:R,error:P}=await J.rpc("check_org_members_password_policy",{org_id:D});if(P){if(!P.message?.includes("NO_RIGHTS"))H.warn(`Cannot check members password policy status: ${s(P)}`)}else if(R){let A=R.filter((_)=>!_.password_policy_compliant);if(A.length>0){H.warn(`⚠️ Warning: ${A.length} member(s) do not meet the password policy requirements`),H.warn("These members will need to update their passwords to regain access.");let _=await c0({message:"Are you sure you want to enable the password policy?"});if(yD(_)||!_)throw H.error("Canceled enabling password policy"),Error("Password policy configuration cancelled")}}}else H.info("Disabling password policy for organization...");let N={enabled:O,min_length:U??10,require_uppercase:z??!0,require_number:q??!0,require_special:B??!0},{error:V}=await J.from("orgs").update({password_policy_config:N}).eq("id",D);if(V){if(!X)H.error(`Could not update password policy: ${s(V)}`);throw Error(`Could not update password policy: ${s(V)}`)}if(!X)if(O)H.success("✓ Password policy enabled for this organization"),H.info(` - Minimum length: ${N.min_length} characters`),H.info(` - Require uppercase: ${N.require_uppercase?"Yes":"No"}`),H.info(` - Require number: ${N.require_number?"Yes":"No"}`),H.info(` - Require special character: ${N.require_special?"Yes":"No"}`);else H.success("✓ Password policy disabled for this organization");if(w===void 0&&Z===void 0&&G===void 0&&K===void 0&&M===void 0&&L===void 0){if(await RD(Y.apikey,{channel:"organization",event:O?"Password Policy Enabled":"Password Policy Disabled",icon:"\uD83D\uDD11",user_id:D,tags:{"org-name":Q.name},notify:!1}).catch(()=>{}),!X)ND("Done ✅");return{orgId:D,name:Q.name,email:Q.management_email,passwordPolicy:O}}}if(K!==void 0||M!==void 0||L!==void 0){if(!X)H.info("Updating API key security settings...");if(M!==void 0&&M!==null){if(M<1||M>365){if(!X)H.error("Maximum API key expiration days must be between 1 and 365");throw Error("Maximum API key expiration days must be between 1 and 365")}}let N={};if(K!==void 0)N.require_apikey_expiration=K;if(M!==void 0)N.max_apikey_expiration_days=M;if(L!==void 0)N.enforce_hashed_api_keys=L;let{error:V}=await J.from("orgs").update(N).eq("id",D);if(V){if(!X)H.error(`Could not update API key settings: ${s(V)}`);throw Error(`Could not update API key settings: ${s(V)}`)}if(!X){if(K!==void 0)H.success(`✓ API key expiration requirement: ${K?"Enabled":"Disabled"}`);if(M!==void 0)if(M===null)H.success("✓ Maximum API key expiration days: No limit");else H.success(`✓ Maximum API key expiration days: ${M}`);if(L!==void 0)H.success(`✓ Hashed API keys enforcement: ${L?"Enabled":"Disabled"}`)}if(w===void 0&&Z===void 0&&G===void 0&&O===void 0){if(await RD(Y.apikey,{channel:"organization",event:"API Key Settings Updated",icon:"\uD83D\uDD10",user_id:D,tags:{"org-name":Q.name},notify:!1}).catch(()=>{}),!X)ND("Done ✅");return{orgId:D,name:Q.name,email:Q.management_email}}}if(!X&&!w){let N=await _6({message:"New organization name:",placeholder:Q.name||"My Organization"});if(yD(N))throw H.error("Canceled updating organization"),Error("Organization update cancelled");w=N}if(!X&&!Z){let N=await _6({message:"Management email:",placeholder:Q.management_email||"admin@example.com"});if(yD(N))throw H.error("Canceled updating organization"),Error("Organization update cancelled");Z=N}if(!w||!Z){if(!X)H.error("Missing arguments, you need to provide an organization name and management email");throw Error("Missing organization name or management email")}if(!X)H.info(`Updating organization "${D}"`);let{error:W}=await J.from("orgs").update({name:w,management_email:Z}).eq("id",D);if(W){if(!X)H.error(`Could not update organization ${s(W)}`);throw Error(`Could not update organization: ${s(W)}`)}if(await RD(Y.apikey,{channel:"organization",event:"Organization Updated",icon:"✏️",user_id:D,tags:{"org-name":w},notify:!1}).catch(()=>{}),!X)H.success("Organization updated"),ND("Done ✅");return{orgId:D,name:w,email:Z,enforce2fa:G??Q.enforcing_2fa}}vD();fD();async function jDD(D,$=!1){if(!$)VD("Getting user id");let X={...D,apikey:D.apikey||BD()};if(!X.apikey){if(!$)H.error("Missing API key, you need to provide an API key to fetch the user id");throw Error("Missing API key")}try{let Y=await jD(X.apikey,X.supaHost,X.supaAnon),J=await xD(Y,X.apikey,["read","all","write"]);if(!$)ND(`Done ✅: ${J}`);return J}catch(Y){if(!$)H.error(`Error getting user id ${s(Y)}`);throw Y instanceof Error?Y:Error(String(Y))}}fD();rw();fD();rw();function gD(D){let $=D instanceof Error?D.message:String(D),X=c5(D);return{success:!1,error:$,isSecurityPolicyError:X.isSecurityPolicyError,securityPolicyMessage:X.isSecurityPolicyError?X.message:void 0}}class H0{apikey;supaHost;supaAnon;constructor(D){this.apikey=D?.apikey,this.supaHost=D?.supaHost,this.supaAnon=D?.supaAnon}async login(D){try{return await MDD(D.apikey,{local:D.local??!1,supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon},!0),{success:!0}}catch($){return gD($)}}async doctor(D){try{return{success:!0,data:await ra({packageJson:D?.packageJson},!0)}}catch($){return gD($)}}async addApp(D){try{let $={apikey:D.apikey||this.apikey||BD(!0),supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon,name:D.name,icon:D.icon};return await na(D.appId,$,void 0,!0),{success:!0}}catch($){return gD($)}}async updateApp(D){try{let $={apikey:D.apikey||this.apikey||BD(!0),supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon,name:D.name,icon:D.icon,retention:D.retention};return await sa(D.appId,$,!0),{success:!0}}catch($){return gD($)}}async deleteApp(D,$=!1){try{let X={apikey:this.apikey||BD(!0),supaHost:this.supaHost,supaAnon:this.supaAnon};return await ia(D,X,!1,$),{success:!0}}catch(X){return gD(X)}}async listApps(){try{let D={apikey:this.apikey||BD(!0),supaHost:this.supaHost,supaAnon:this.supaAnon};return{success:!0,data:(await oa(D,!1)).map((Y)=>({appId:Y.app_id,name:Y.name||"Unknown",iconUrl:Y.icon_url||void 0,createdAt:new Date(Y.created_at||"")}))}}catch(D){return gD(D)}}async getAccountId(D){try{let $={apikey:D?.apikey||this.apikey||BD(!0),supaHost:D?.supaHost||this.supaHost,supaAnon:D?.supaAnon||this.supaAnon};return{success:!0,data:await jDD($,!0)}}catch($){return gD($)}}async checkBundleCompatibility(D){try{let $={apikey:D.apikey||this.apikey||BD(!0),channel:D.channel,text:D.textOutput??!1,packageJson:D.packageJson,nodeModules:D.nodeModules,supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon};return{success:!0,data:(await Ms(D.appId,$,!0)).finalCompatibility}}catch($){return gD($)}}async encryptBundle(D){try{return{success:!0,data:await us(D.zipPath,D.checksum,{key:D.keyPath,keyData:D.keyData,json:D.json,packageJson:D.packageJson},!0)}}catch($){return gD($)}}async decryptBundle(D){try{return{success:!0,data:await Ps(D.zipPath,D.ivSessionKey,{key:D.keyPath,keyData:D.keyData,checksum:D.checksum,packageJson:D.packageJson},!0)}}catch($){return gD($)}}async zipBundle(D){try{return{success:!0,data:await QDD(D.appId,{apikey:this.apikey||BD(!0),path:D.path,bundle:D.bundle,name:D.name,codeCheck:D.codeCheck,json:D.json,keyV2:D.keyV2,packageJson:D.packageJson},!0)}}catch($){return gD($)}}async uploadBundle(D){try{let $={apikey:D.apikey||this.apikey||BD(!0),supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon,path:D.path,bundle:D.bundle,channel:D.channel,external:D.external,key:D.encrypt!==!1,keyV2:D.encryptionKey,timeout:D.timeout,tus:D.useTus,comment:D.comment,minUpdateVersion:D.minUpdateVersion,autoMinUpdateVersion:D.autoMinUpdateVersion,selfAssign:D.selfAssign,packageJson:D.packageJsonPaths,ignoreMetadataCheck:D.ignoreCompatibilityCheck,codeCheck:!D.disableCodeCheck,zip:D.useZip},X=await fL(D.appId,$,!0);return{success:X.success,bundleId:X.bundle,checksum:X.checksum??null,encryptionMethod:X.encryptionMethod,sessionKey:X.sessionKey,ivSessionKey:X.ivSessionKey,storageProvider:X.storageProvider,skipped:X.skipped,reason:X.reason}}catch($){return gD($)}}async listBundles(D){try{let $=this.apikey||BD(!0),X=await jD($,this.supaHost,this.supaAnon);return{success:!0,data:(await qZ(X,D)).map((Q)=>({id:Q.id.toString(),version:Q.name,uploadedAt:new Date(Q.created_at||""),size:0,encrypted:Q.session_key!==null}))}}catch($){return gD($)}}async deleteBundle(D,$){try{let X={apikey:this.apikey||BD(!0),supaHost:this.supaHost,supaAnon:this.supaAnon,bundle:$};return await xs($,D,X,!0),{success:!0}}catch(X){return gD(X)}}async cleanupBundles(D){try{let $={apikey:D.apikey||this.apikey||BD(!0),supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon,bundle:D.bundle||"",version:"",keep:D.keep||4,force:D.force||!1,ignoreChannel:D.ignoreChannel||!1};return{success:!0,data:await Ns(D.appId,$,!0)}}catch($){return gD($)}}async requestBuild(D){try{let $=D.credentials,X={apikey:D.apikey||this.apikey||BD(!0),supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon,path:D.path,platform:D.platform,userId:D.userId,buildCertificateBase64:$?.BUILD_CERTIFICATE_BASE64,buildProvisionProfileBase64:$?.BUILD_PROVISION_PROFILE_BASE64,buildProvisionProfileBase64Prod:$?.BUILD_PROVISION_PROFILE_BASE64_PROD,p12Password:$?.P12_PASSWORD,appleKeyId:$?.APPLE_KEY_ID,appleIssuerId:$?.APPLE_ISSUER_ID,appleKeyContent:$?.APPLE_KEY_CONTENT,appStoreConnectTeamId:$?.APP_STORE_CONNECT_TEAM_ID,androidKeystoreFile:$?.ANDROID_KEYSTORE_FILE,keystoreKeyAlias:$?.KEYSTORE_KEY_ALIAS,keystoreKeyPassword:$?.KEYSTORE_KEY_PASSWORD,keystoreStorePassword:$?.KEYSTORE_STORE_PASSWORD,playConfigJson:$?.PLAY_CONFIG_JSON},Y=await Vs(D.appId,X,!0);if(Y.success&&Y.jobId)return{success:!0,data:{jobId:Y.jobId,uploadUrl:Y.uploadUrl||"",status:Y.status||"unknown"}};return{success:!1,error:Y.error||"Unknown error during build request"}}catch($){return gD($)}}async getCurrentBundle(D,$,X){try{let Y={apikey:X?.apikey||this.apikey||BD(!0),quiet:!0,supaHost:X?.supaHost||this.supaHost,supaAnon:X?.supaAnon||this.supaAnon};return{success:!0,data:await wDD($,D,Y,!0)}}catch(Y){return gD(Y)}}async addChannel(D){try{let $={apikey:D.apikey||this.apikey||BD(!0),supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon,default:D.default,selfAssign:D.selfAssign};return await FDD(D.channelId,D.appId,$,!0),{success:!0}}catch($){return gD($)}}async updateChannel(D){try{let $={apikey:D.apikey||this.apikey||BD(!0),supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon,bundle:D.bundle??void 0,state:D.state,downgrade:D.downgrade,ios:D.ios,android:D.android,selfAssign:D.selfAssign,disableAutoUpdate:D.disableAutoUpdate??void 0,dev:D.dev,emulator:D.emulator,device:D.device,prod:D.prod,latest:!1,latestRemote:!1,packageJson:void 0,ignoreMetadataCheck:!1};return await qDD(D.channelId,D.appId,$,!0),{success:!0}}catch($){return gD($)}}async deleteChannel(D,$,X=!1){try{let Y={apikey:this.apikey||BD(!0),supaHost:this.supaHost,supaAnon:this.supaAnon,deleteBundle:X,successIfNotFound:!1};return await ZDD(D,$,Y,!0),{success:!0}}catch(Y){return gD(Y)}}async listChannels(D){try{let $={apikey:this.apikey||BD(!0),supaHost:this.supaHost,supaAnon:this.supaAnon};return{success:!0,data:await GDD(D,$,!0)}}catch($){return gD($)}}async generateEncryptionKeys(D){try{return await VDD({force:D?.force,setupChannel:D?.setupChannel},!0),{success:!0}}catch($){return gD($)}}async saveEncryptionKey(D){try{return await WDD({key:D?.keyPath,keyData:D?.keyData,setupChannel:D?.setupChannel},!0),{success:!0}}catch($){return gD($)}}async deleteLegacyEncryptionKey(D){try{return{success:!0,data:{deleted:await HDD({force:D?.force,setupChannel:D?.setupChannel},!0)}}}catch($){return gD($)}}async listOrganizations(D){try{let $={apikey:D?.apikey||this.apikey||BD(!0),supaHost:D?.supaHost||this.supaHost,supaAnon:D?.supaAnon||this.supaAnon};return{success:!0,data:(await ADD($,!0)).map((J)=>({id:String(J.id??J.gid??""),name:J.name??"Unknown",role:J.role??void 0,appCount:typeof J.app_count==="number"?J.app_count:void 0,email:J.management_email??void 0,createdAt:J.created_at?new Date(J.created_at):void 0}))}}catch($){return gD($)}}async addOrganization(D){try{let $={apikey:D.apikey||this.apikey||BD(!0),supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon,name:D.name,email:D.email},X=await LDD($,!0);return{success:!0,data:{id:String(X.id??X.gid??""),name:X.name??D.name,role:"owner",appCount:0,email:X.management_email??D.email,createdAt:X.created_at?new Date(X.created_at):void 0}}}catch($){return gD($)}}async updateOrganization(D){try{let $={apikey:D.apikey||this.apikey||BD(!0),supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon,name:D.name,email:D.email},X=await RDD(D.orgId,$,!0);return{success:!0,data:{id:X.orgId,name:X.name,email:X.email}}}catch($){return gD($)}}async deleteOrganization(D,$){try{let X={apikey:$?.apikey||this.apikey||BD(!0),supaHost:$?.supaHost||this.supaHost,supaAnon:$?.supaAnon||this.supaAnon,autoConfirm:$?.autoConfirm??!0};return{success:!0,data:{deleted:await IDD(D,X,!0)}}}catch(X){return gD(X)}}async getStats(D){try{let $=D.apikey||this.apikey||BD(!0),X=await u$(),Y={appId:D.appId,devicesId:D.deviceIds,search:D.search,order:D.order,rangeStart:D.after||D.rangeStart,rangeEnd:D.rangeEnd,limit:D.limit},J=await fetch(`${X.hostApi}/private/stats`,{method:"POST",headers:{"Content-Type":"application/json",capgkey:$},body:JSON.stringify(Y)});if(!J.ok)throw Error(`HTTP error! status: ${J.status}`);return{success:!0,data:(await J.json()).map((w)=>({appId:w.app_id,deviceId:w.device_id,action:w.action,versionId:w.version_id,version:w.version,createdAt:w.created_at}))}}catch($){return gD($)}}async setAppSetting(D,$){try{return await ea(D,{apikey:$.apikey||this.apikey||BD(!0),bool:$.bool,string:$.string},!0),{success:!0}}catch(X){return gD(X)}}async probe(D){try{let{probeInternal:$}=await Promise.resolve().then(() => (yDD(),fDD)),X=await $({platform:D.platform});if(X.error)return{success:!1,error:X.error};return{success:!0,data:X}}catch($){return gD($)}}}async function OeD(D){return new H0({apikey:D.apikey,supaHost:D.supaHost,supaAnon:D.supaAnon}).uploadBundle(D)}async function UeD(D){return new H0({supaHost:D.supaHost,supaAnon:D.supaAnon}).login(D)}async function qeD(D){return new H0().doctor(D)}async function zeD(D){return new H0({apikey:D.apikey,supaHost:D.supaHost,supaAnon:D.supaAnon}).checkBundleCompatibility(D)}async function BeD(D){return new H0().encryptBundle(D)}async function KeD(D){return new H0().decryptBundle(D)}async function WeD(D){return new H0().zipBundle(D)}async function HeD(D){return new H0().generateEncryptionKeys(D)}async function VeD(D){return new H0().saveEncryptionKey(D)}async function NeD(D){return new H0().deleteLegacyEncryptionKey(D)}async function MeD(D,$,X){return new H0({apikey:X?.apikey,supaHost:X?.supaHost,supaAnon:X?.supaAnon}).getCurrentBundle(D,$,X)}async function LeD(D,$){return new H0({apikey:$.apikey}).setAppSetting(D,$)}async function IeD(D){return new H0({apikey:D?.apikey,supaHost:D?.supaHost,supaAnon:D?.supaAnon}).getAccountId(D)}async function AeD(D){return new H0({apikey:D?.apikey,supaHost:D?.supaHost,supaAnon:D?.supaAnon}).listOrganizations(D)}async function ReD(D){return new H0({apikey:D.apikey,supaHost:D.supaHost,supaAnon:D.supaAnon}).addOrganization(D)}async function jeD(D){return new H0({apikey:D.apikey,supaHost:D.supaHost,supaAnon:D.supaAnon}).updateOrganization(D)}async function EeD(D,$){return new H0({apikey:$?.apikey,supaHost:$?.supaHost,supaAnon:$?.supaAnon}).deleteOrganization(D,$)}async function TeD(D){return new H0({apikey:D.apikey,supaHost:D.supaHost,supaAnon:D.supaAnon}).addApp(D)}async function CeD(D,$){return new H0($).listBundles(D)}async function PeD(D){return new H0({apikey:D.apikey,supaHost:D.supaHost,supaAnon:D.supaAnon}).addChannel(D)}async function xeD(D){return new H0({apikey:D.apikey,supaHost:D.supaHost,supaAnon:D.supaAnon}).requestBuild(D)}async function SeD(D){return new H0({apikey:D.apikey,supaHost:D.supaHost,supaAnon:D.supaAnon}).getStats(D)}async function ueD(D){return new H0().probe(D)}async function veD(){try{return await ID()}catch{return null}}export{WeD as zipBundle,OeD as uploadBundle,jeD as updateOrganization,LeD as updateAppSetting,VeD as saveEncryptionKey,xeD as requestBuild,ueD as probeUpdates,c5 as parseSecurityPolicyError,UeD as login,AeD as listOrganizations,CeD as listBundles,uo as isSecurityPolicyError,SeD as getStats,ujD as getSecurityPolicyMessage,MeD as getCurrentBundle,veD as getCapacitorConfig,IeD as getAccountId,HeD as generateEncryptionKeys,FM as formatApiErrorForCli,BeD as encryptBundle,qeD as doctor,EeD as deleteOrganization,NeD as deleteLegacyEncryptionKey,KeD as decryptBundle,jD as createSupabaseClient,zeD as checkBundleCompatibility,ReD as addOrganization,PeD as addChannel,TeD as addApp,pw as SECURITY_POLICY_MESSAGES,tX as SECURITY_POLICY_ERRORS,H0 as CapgoSDK};
494
+ To regain access, enable 2FA on your account at https://web.capgo.app/settings/account`)}}async function ADD(D,$=!1){if(!$)VD("List organizations");await F0();let X={...D,apikey:D.apikey||BD()};if(!X.apikey){if(!$)H.error("Missing API key, you need to provide an API key to list organizations");throw Error("Missing API key")}let Y=await jD(X.apikey,X.supaHost,X.supaAnon);if(await xD(Y,X.apikey,["read","write","all"]),!$)H.info("Getting organizations from Capgo");let{error:J,data:Q}=await Y.rpc("get_orgs_v7");if(J){if(!$)H.error(`Cannot get organizations ${s(J)}`);throw Error(`Cannot get organizations: ${s(J)}`)}let F=Q||[];if(!$)H.info(`Organizations found: ${F.length}`),iSD(F,$),ND("Done ✅");return F}vD();q1();fD();async function RDD(D,$,X=!1){if(!X)VD("Updating organization");await F0();let Y={...$,apikey:$.apikey||BD()};if(!Y.apikey){if(!X)H.error("Missing API key, you need to provide an API key to update an organization");throw Error("Missing API key")}if(!D){if(!X)H.error("Missing argument, you need to provide an organization ID");throw Error("Missing organization id")}let J=await jD(Y.apikey,Y.supaHost,Y.supaAnon);await xD(J,Y.apikey,["write","all"]),await XZ(J,D,X);let{data:Q,error:F}=await J.from("orgs").select("name, management_email, created_by, enforcing_2fa, password_policy_config, require_apikey_expiration, max_apikey_expiration_days, enforce_hashed_api_keys").eq("id",D).single();if(F||!Q){if(!X)H.error(`Cannot get organization details ${s(F)}`);throw Error(`Cannot get organization details: ${s(F)}`)}let{name:w,email:Z,enforce2fa:G}=Y,{passwordPolicy:O,minLength:U,requireUppercase:z,requireNumber:q,requireSpecial:B}=Y,{requireApikeyExpiration:K,maxApikeyExpirationDays:M,enforceHashedApiKeys:L}=Y;if(G!==void 0){if(!X){if(G&&!Q.enforcing_2fa){H.info("Checking organization members 2FA status...");let{data:R,error:C}=await J.rpc("check_org_members_2fa_enabled",{org_id:D});if(C)throw H.error(`Cannot check members 2FA status: ${s(C)}`),Error("Cannot check members 2FA status");let{data:A,error:_}=await J.rpc("has_2fa_enabled");if(_)throw H.error(`Cannot check your 2FA status: ${s(_)}`),Error("Cannot check your 2FA status");let{data:v,error:S}=await J.rpc("get_identity_apikey_only",{keymode:["read","upload","write","all"]});if(S||!v)throw H.error(`Cannot get current user identity: ${S?s(S):"No user ID returned"}`),Error("Cannot get current user identity");let h=R?.filter((g)=>!g["2fa_enabled"]&&g.user_id!==v)||[];if(h.length>0||!A){if(H.warn("⚠️ Warning: Enabling 2FA enforcement will affect access"),H.message("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"),!A)H.warn("\uD83D\uDD10 YOU do not have 2FA enabled! By enabling 2FA enforcement, you will LOSE ACCESS to this organization until you enable 2FA on your account.");if(h.length>0){let{data:l,error:f}=await J.rpc("get_org_members",{guild_id:D});if(f)throw H.error(`Cannot get organization members: ${s(f)}`),Error("Cannot get organization members");let j=new Map(l?.map((d)=>[d.uid,d])||[]),x=h.map((d)=>{return j.get(d.user_id)?.email||d.user_id}),u=h.length===1?"member does":"members do",y=h.length===1?"This member will":"These members will";H.warn(`${h.length} ${u} not have 2FA enabled: ${x.join(", ")}`),H.warn(`${y} lose access until they enable 2FA.`)}let g=await c0({message:"Are you sure you want to enable 2FA enforcement?"});if(yD(g)||!g)throw H.error("Canceled enabling 2FA enforcement"),Error("2FA enforcement cancelled")}H.info("Enabling 2FA enforcement for organization...")}else if(!G&&Q.enforcing_2fa)H.info("Disabling 2FA enforcement for organization...")}let{error:N}=await J.from("orgs").update({enforcing_2fa:G}).eq("id",D);if(N){if(!X)H.error(`Could not update 2FA enforcement: ${s(N)}`);throw Error(`Could not update 2FA enforcement: ${s(N)}`)}if(!X)if(G)H.success("✓ 2FA enforcement enabled for this organization");else H.success("✓ 2FA enforcement disabled for this organization");if(w===void 0&&Z===void 0&&!(O!==void 0||K!==void 0||M!==void 0||L!==void 0)){if(await RD(Y.apikey,{channel:"organization",event:G?"Organization 2FA Enabled":"Organization 2FA Disabled",icon:"\uD83D\uDD10",user_id:D,tags:{"org-name":Q.name,"enforce-2fa":G.toString()},notify:!1}).catch(()=>{}),!X)ND("Done ✅");return{orgId:D,name:Q.name,email:Q.management_email,enforce2fa:G}}}if(O!==void 0){if(!X)if(O){H.info("Configuring password policy for organization...");let{data:R,error:C}=await J.rpc("check_org_members_password_policy",{org_id:D});if(C){if(!C.message?.includes("NO_RIGHTS"))H.warn(`Cannot check members password policy status: ${s(C)}`)}else if(R){let A=R.filter((_)=>!_.password_policy_compliant);if(A.length>0){H.warn(`⚠️ Warning: ${A.length} member(s) do not meet the password policy requirements`),H.warn("These members will need to update their passwords to regain access.");let _=await c0({message:"Are you sure you want to enable the password policy?"});if(yD(_)||!_)throw H.error("Canceled enabling password policy"),Error("Password policy configuration cancelled")}}}else H.info("Disabling password policy for organization...");let N={enabled:O,min_length:U??10,require_uppercase:z??!0,require_number:q??!0,require_special:B??!0},{error:V}=await J.from("orgs").update({password_policy_config:N}).eq("id",D);if(V){if(!X)H.error(`Could not update password policy: ${s(V)}`);throw Error(`Could not update password policy: ${s(V)}`)}if(!X)if(O)H.success("✓ Password policy enabled for this organization"),H.info(` - Minimum length: ${N.min_length} characters`),H.info(` - Require uppercase: ${N.require_uppercase?"Yes":"No"}`),H.info(` - Require number: ${N.require_number?"Yes":"No"}`),H.info(` - Require special character: ${N.require_special?"Yes":"No"}`);else H.success("✓ Password policy disabled for this organization");if(w===void 0&&Z===void 0&&G===void 0&&K===void 0&&M===void 0&&L===void 0){if(await RD(Y.apikey,{channel:"organization",event:O?"Password Policy Enabled":"Password Policy Disabled",icon:"\uD83D\uDD11",user_id:D,tags:{"org-name":Q.name},notify:!1}).catch(()=>{}),!X)ND("Done ✅");return{orgId:D,name:Q.name,email:Q.management_email,passwordPolicy:O}}}if(K!==void 0||M!==void 0||L!==void 0){if(!X)H.info("Updating API key security settings...");if(M!==void 0&&M!==null){if(M<1||M>365){if(!X)H.error("Maximum API key expiration days must be between 1 and 365");throw Error("Maximum API key expiration days must be between 1 and 365")}}let N={};if(K!==void 0)N.require_apikey_expiration=K;if(M!==void 0)N.max_apikey_expiration_days=M;if(L!==void 0)N.enforce_hashed_api_keys=L;let{error:V}=await J.from("orgs").update(N).eq("id",D);if(V){if(!X)H.error(`Could not update API key settings: ${s(V)}`);throw Error(`Could not update API key settings: ${s(V)}`)}if(!X){if(K!==void 0)H.success(`✓ API key expiration requirement: ${K?"Enabled":"Disabled"}`);if(M!==void 0)if(M===null)H.success("✓ Maximum API key expiration days: No limit");else H.success(`✓ Maximum API key expiration days: ${M}`);if(L!==void 0)H.success(`✓ Hashed API keys enforcement: ${L?"Enabled":"Disabled"}`)}if(w===void 0&&Z===void 0&&G===void 0&&O===void 0){if(await RD(Y.apikey,{channel:"organization",event:"API Key Settings Updated",icon:"\uD83D\uDD10",user_id:D,tags:{"org-name":Q.name},notify:!1}).catch(()=>{}),!X)ND("Done ✅");return{orgId:D,name:Q.name,email:Q.management_email}}}if(!X&&!w){let N=await _6({message:"New organization name:",placeholder:Q.name||"My Organization"});if(yD(N))throw H.error("Canceled updating organization"),Error("Organization update cancelled");w=N}if(!X&&!Z){let N=await _6({message:"Management email:",placeholder:Q.management_email||"admin@example.com"});if(yD(N))throw H.error("Canceled updating organization"),Error("Organization update cancelled");Z=N}if(!w||!Z){if(!X)H.error("Missing arguments, you need to provide an organization name and management email");throw Error("Missing organization name or management email")}if(!X)H.info(`Updating organization "${D}"`);let{error:W}=await J.from("orgs").update({name:w,management_email:Z}).eq("id",D);if(W){if(!X)H.error(`Could not update organization ${s(W)}`);throw Error(`Could not update organization: ${s(W)}`)}if(await RD(Y.apikey,{channel:"organization",event:"Organization Updated",icon:"✏️",user_id:D,tags:{"org-name":w},notify:!1}).catch(()=>{}),!X)H.success("Organization updated"),ND("Done ✅");return{orgId:D,name:w,email:Z,enforce2fa:G??Q.enforcing_2fa}}vD();fD();async function jDD(D,$=!1){if(!$)VD("Getting user id");let X={...D,apikey:D.apikey||BD()};if(!X.apikey){if(!$)H.error("Missing API key, you need to provide an API key to fetch the user id");throw Error("Missing API key")}try{let Y=await jD(X.apikey,X.supaHost,X.supaAnon),J=await xD(Y,X.apikey,["read","all","write"]);if(!$)ND(`Done ✅: ${J}`);return J}catch(Y){if(!$)H.error(`Error getting user id ${s(Y)}`);throw Y instanceof Error?Y:Error(String(Y))}}fD();rw();fD();rw();function gD(D){let $=D instanceof Error?D.message:String(D),X=c5(D);return{success:!1,error:$,isSecurityPolicyError:X.isSecurityPolicyError,securityPolicyMessage:X.isSecurityPolicyError?X.message:void 0}}class H0{apikey;supaHost;supaAnon;constructor(D){this.apikey=D?.apikey,this.supaHost=D?.supaHost,this.supaAnon=D?.supaAnon}async login(D){try{return await MDD(D.apikey,{local:D.local??!1,supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon},!0),{success:!0}}catch($){return gD($)}}async doctor(D){try{return{success:!0,data:await ra({packageJson:D?.packageJson},!0)}}catch($){return gD($)}}async addApp(D){try{let $={apikey:D.apikey||this.apikey||BD(!0),supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon,name:D.name,icon:D.icon};return await na(D.appId,$,void 0,!0),{success:!0}}catch($){return gD($)}}async updateApp(D){try{let $={apikey:D.apikey||this.apikey||BD(!0),supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon,name:D.name,icon:D.icon,retention:D.retention};return await sa(D.appId,$,!0),{success:!0}}catch($){return gD($)}}async deleteApp(D,$=!1){try{let X={apikey:this.apikey||BD(!0),supaHost:this.supaHost,supaAnon:this.supaAnon};return await ia(D,X,!1,$),{success:!0}}catch(X){return gD(X)}}async listApps(){try{let D={apikey:this.apikey||BD(!0),supaHost:this.supaHost,supaAnon:this.supaAnon};return{success:!0,data:(await oa(D,!1)).map((Y)=>({appId:Y.app_id,name:Y.name||"Unknown",iconUrl:Y.icon_url||void 0,createdAt:new Date(Y.created_at||"")}))}}catch(D){return gD(D)}}async getAccountId(D){try{let $={apikey:D?.apikey||this.apikey||BD(!0),supaHost:D?.supaHost||this.supaHost,supaAnon:D?.supaAnon||this.supaAnon};return{success:!0,data:await jDD($,!0)}}catch($){return gD($)}}async checkBundleCompatibility(D){try{let $={apikey:D.apikey||this.apikey||BD(!0),channel:D.channel,text:D.textOutput??!1,packageJson:D.packageJson,nodeModules:D.nodeModules,supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon};return{success:!0,data:(await Ms(D.appId,$,!0)).finalCompatibility}}catch($){return gD($)}}async encryptBundle(D){try{return{success:!0,data:await us(D.zipPath,D.checksum,{key:D.keyPath,keyData:D.keyData,json:D.json,packageJson:D.packageJson},!0)}}catch($){return gD($)}}async decryptBundle(D){try{return{success:!0,data:await Ps(D.zipPath,D.ivSessionKey,{key:D.keyPath,keyData:D.keyData,checksum:D.checksum,packageJson:D.packageJson},!0)}}catch($){return gD($)}}async zipBundle(D){try{return{success:!0,data:await QDD(D.appId,{apikey:this.apikey||BD(!0),path:D.path,bundle:D.bundle,name:D.name,codeCheck:D.codeCheck,json:D.json,keyV2:D.keyV2,packageJson:D.packageJson},!0)}}catch($){return gD($)}}async uploadBundle(D){try{let $={apikey:D.apikey||this.apikey||BD(!0),supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon,path:D.path,bundle:D.bundle,channel:D.channel,external:D.external,key:D.encrypt!==!1,keyV2:D.encryptionKey,timeout:D.timeout,tus:D.useTus,comment:D.comment,minUpdateVersion:D.minUpdateVersion,autoMinUpdateVersion:D.autoMinUpdateVersion,selfAssign:D.selfAssign,packageJson:D.packageJsonPaths,ignoreMetadataCheck:D.ignoreCompatibilityCheck,codeCheck:!D.disableCodeCheck,zip:D.useZip},X=await fL(D.appId,$,!0);return{success:X.success,bundleId:X.bundle,checksum:X.checksum??null,encryptionMethod:X.encryptionMethod,sessionKey:X.sessionKey,ivSessionKey:X.ivSessionKey,storageProvider:X.storageProvider,skipped:X.skipped,reason:X.reason}}catch($){return gD($)}}async listBundles(D){try{let $=this.apikey||BD(!0),X=await jD($,this.supaHost,this.supaAnon);return{success:!0,data:(await qZ(X,D)).map((Q)=>({id:Q.id.toString(),version:Q.name,uploadedAt:new Date(Q.created_at||""),size:0,encrypted:Q.session_key!==null}))}}catch($){return gD($)}}async deleteBundle(D,$){try{let X={apikey:this.apikey||BD(!0),supaHost:this.supaHost,supaAnon:this.supaAnon,bundle:$};return await xs($,D,X,!0),{success:!0}}catch(X){return gD(X)}}async cleanupBundles(D){try{let $={apikey:D.apikey||this.apikey||BD(!0),supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon,bundle:D.bundle||"",version:"",keep:D.keep||4,force:D.force||!1,ignoreChannel:D.ignoreChannel||!1};return{success:!0,data:await Ns(D.appId,$,!0)}}catch($){return gD($)}}async requestBuild(D){try{let $=D.credentials,X={apikey:D.apikey||this.apikey||BD(!0),supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon,path:D.path,platform:D.platform,userId:D.userId,buildCertificateBase64:$?.BUILD_CERTIFICATE_BASE64,buildProvisionProfileBase64:$?.BUILD_PROVISION_PROFILE_BASE64,buildProvisionProfileBase64Prod:$?.BUILD_PROVISION_PROFILE_BASE64_PROD,p12Password:$?.P12_PASSWORD,appleKeyId:$?.APPLE_KEY_ID,appleIssuerId:$?.APPLE_ISSUER_ID,appleKeyContent:$?.APPLE_KEY_CONTENT,appStoreConnectTeamId:$?.APP_STORE_CONNECT_TEAM_ID,androidKeystoreFile:$?.ANDROID_KEYSTORE_FILE,keystoreKeyAlias:$?.KEYSTORE_KEY_ALIAS,keystoreKeyPassword:$?.KEYSTORE_KEY_PASSWORD,keystoreStorePassword:$?.KEYSTORE_STORE_PASSWORD,playConfigJson:$?.PLAY_CONFIG_JSON},Y=await Vs(D.appId,X,!0);if(Y.success&&Y.jobId)return{success:!0,data:{jobId:Y.jobId,uploadUrl:Y.uploadUrl||"",status:Y.status||"unknown"}};return{success:!1,error:Y.error||"Unknown error during build request"}}catch($){return gD($)}}async getCurrentBundle(D,$,X){try{let Y={apikey:X?.apikey||this.apikey||BD(!0),quiet:!0,supaHost:X?.supaHost||this.supaHost,supaAnon:X?.supaAnon||this.supaAnon};return{success:!0,data:await wDD($,D,Y,!0)}}catch(Y){return gD(Y)}}async addChannel(D){try{let $={apikey:D.apikey||this.apikey||BD(!0),supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon,default:D.default,selfAssign:D.selfAssign};return await FDD(D.channelId,D.appId,$,!0),{success:!0}}catch($){return gD($)}}async updateChannel(D){try{let $={apikey:D.apikey||this.apikey||BD(!0),supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon,bundle:D.bundle??void 0,state:D.state,downgrade:D.downgrade,ios:D.ios,android:D.android,selfAssign:D.selfAssign,disableAutoUpdate:D.disableAutoUpdate??void 0,dev:D.dev,emulator:D.emulator,device:D.device,prod:D.prod,latest:!1,latestRemote:!1,packageJson:void 0,ignoreMetadataCheck:!1};return await qDD(D.channelId,D.appId,$,!0),{success:!0}}catch($){return gD($)}}async deleteChannel(D,$,X=!1){try{let Y={apikey:this.apikey||BD(!0),supaHost:this.supaHost,supaAnon:this.supaAnon,deleteBundle:X,successIfNotFound:!1};return await ZDD(D,$,Y,!0),{success:!0}}catch(Y){return gD(Y)}}async listChannels(D){try{let $={apikey:this.apikey||BD(!0),supaHost:this.supaHost,supaAnon:this.supaAnon};return{success:!0,data:await GDD(D,$,!0)}}catch($){return gD($)}}async generateEncryptionKeys(D){try{return await VDD({force:D?.force,setupChannel:D?.setupChannel},!0),{success:!0}}catch($){return gD($)}}async saveEncryptionKey(D){try{return await WDD({key:D?.keyPath,keyData:D?.keyData,setupChannel:D?.setupChannel},!0),{success:!0}}catch($){return gD($)}}async deleteLegacyEncryptionKey(D){try{return{success:!0,data:{deleted:await HDD({force:D?.force,setupChannel:D?.setupChannel},!0)}}}catch($){return gD($)}}async listOrganizations(D){try{let $={apikey:D?.apikey||this.apikey||BD(!0),supaHost:D?.supaHost||this.supaHost,supaAnon:D?.supaAnon||this.supaAnon};return{success:!0,data:(await ADD($,!0)).map((J)=>({id:String(J.id??J.gid??""),name:J.name??"Unknown",role:J.role??void 0,appCount:typeof J.app_count==="number"?J.app_count:void 0,email:J.management_email??void 0,createdAt:J.created_at?new Date(J.created_at):void 0}))}}catch($){return gD($)}}async addOrganization(D){try{let $={apikey:D.apikey||this.apikey||BD(!0),supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon,name:D.name,email:D.email},X=await LDD($,!0);return{success:!0,data:{id:String(X.id??X.gid??""),name:X.name??D.name,role:"owner",appCount:0,email:X.management_email??D.email,createdAt:X.created_at?new Date(X.created_at):void 0}}}catch($){return gD($)}}async updateOrganization(D){try{let $={apikey:D.apikey||this.apikey||BD(!0),supaHost:D.supaHost||this.supaHost,supaAnon:D.supaAnon||this.supaAnon,name:D.name,email:D.email},X=await RDD(D.orgId,$,!0);return{success:!0,data:{id:X.orgId,name:X.name,email:X.email}}}catch($){return gD($)}}async deleteOrganization(D,$){try{let X={apikey:$?.apikey||this.apikey||BD(!0),supaHost:$?.supaHost||this.supaHost,supaAnon:$?.supaAnon||this.supaAnon,autoConfirm:$?.autoConfirm??!0};return{success:!0,data:{deleted:await IDD(D,X,!0)}}}catch(X){return gD(X)}}async getStats(D){try{let $=D.apikey||this.apikey||BD(!0),X=await u$(),Y={appId:D.appId,devicesId:D.deviceIds,search:D.search,order:D.order,rangeStart:D.after||D.rangeStart,rangeEnd:D.rangeEnd,limit:D.limit},J=await fetch(`${X.hostApi}/private/stats`,{method:"POST",headers:{"Content-Type":"application/json",capgkey:$},body:JSON.stringify(Y)});if(!J.ok)throw Error(`HTTP error! status: ${J.status}`);return{success:!0,data:(await J.json()).map((w)=>({appId:w.app_id,deviceId:w.device_id,action:w.action,versionId:w.version_id,version:w.version,createdAt:w.created_at}))}}catch($){return gD($)}}async setAppSetting(D,$){try{return await ea(D,{apikey:$.apikey||this.apikey||BD(!0),bool:$.bool,string:$.string},!0),{success:!0}}catch(X){return gD(X)}}async probe(D){try{let{probeInternal:$}=await Promise.resolve().then(() => (yDD(),fDD)),X=await $({platform:D.platform});if(X.error)return{success:!1,error:X.error};return{success:!0,data:X}}catch($){return gD($)}}}async function OeD(D){return new H0({apikey:D.apikey,supaHost:D.supaHost,supaAnon:D.supaAnon}).uploadBundle(D)}async function UeD(D){return new H0({supaHost:D.supaHost,supaAnon:D.supaAnon}).login(D)}async function qeD(D){return new H0().doctor(D)}async function zeD(D){return new H0({apikey:D.apikey,supaHost:D.supaHost,supaAnon:D.supaAnon}).checkBundleCompatibility(D)}async function BeD(D){return new H0().encryptBundle(D)}async function KeD(D){return new H0().decryptBundle(D)}async function WeD(D){return new H0().zipBundle(D)}async function HeD(D){return new H0().generateEncryptionKeys(D)}async function VeD(D){return new H0().saveEncryptionKey(D)}async function NeD(D){return new H0().deleteLegacyEncryptionKey(D)}async function MeD(D,$,X){return new H0({apikey:X?.apikey,supaHost:X?.supaHost,supaAnon:X?.supaAnon}).getCurrentBundle(D,$,X)}async function LeD(D,$){return new H0({apikey:$.apikey}).setAppSetting(D,$)}async function IeD(D){return new H0({apikey:D?.apikey,supaHost:D?.supaHost,supaAnon:D?.supaAnon}).getAccountId(D)}async function AeD(D){return new H0({apikey:D?.apikey,supaHost:D?.supaHost,supaAnon:D?.supaAnon}).listOrganizations(D)}async function ReD(D){return new H0({apikey:D.apikey,supaHost:D.supaHost,supaAnon:D.supaAnon}).addOrganization(D)}async function jeD(D){return new H0({apikey:D.apikey,supaHost:D.supaHost,supaAnon:D.supaAnon}).updateOrganization(D)}async function EeD(D,$){return new H0({apikey:$?.apikey,supaHost:$?.supaHost,supaAnon:$?.supaAnon}).deleteOrganization(D,$)}async function TeD(D){return new H0({apikey:D.apikey,supaHost:D.supaHost,supaAnon:D.supaAnon}).addApp(D)}async function CeD(D,$){return new H0($).listBundles(D)}async function PeD(D){return new H0({apikey:D.apikey,supaHost:D.supaHost,supaAnon:D.supaAnon}).addChannel(D)}async function xeD(D){return new H0({apikey:D.apikey,supaHost:D.supaHost,supaAnon:D.supaAnon}).requestBuild(D)}async function SeD(D){return new H0({apikey:D.apikey,supaHost:D.supaHost,supaAnon:D.supaAnon}).getStats(D)}async function ueD(D){return new H0().probe(D)}async function veD(){try{return await ID()}catch{return null}}export{WeD as zipBundle,OeD as uploadBundle,jeD as updateOrganization,LeD as updateAppSetting,VeD as saveEncryptionKey,xeD as requestBuild,ueD as probeUpdates,c5 as parseSecurityPolicyError,UeD as login,AeD as listOrganizations,CeD as listBundles,uo as isSecurityPolicyError,SeD as getStats,ujD as getSecurityPolicyMessage,MeD as getCurrentBundle,veD as getCapacitorConfig,IeD as getAccountId,HeD as generateEncryptionKeys,FM as formatApiErrorForCli,BeD as encryptBundle,qeD as doctor,EeD as deleteOrganization,NeD as deleteLegacyEncryptionKey,KeD as decryptBundle,jD as createSupabaseClient,zeD as checkBundleCompatibility,ReD as addOrganization,PeD as addChannel,TeD as addApp,pw as SECURITY_POLICY_MESSAGES,tX as SECURITY_POLICY_ERRORS,H0 as CapgoSDK};