@dahawa/hawa-code 2.8.7 → 2.8.8
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/cli.js +2 -2
- package/hands.js +1 -1
- package/package.json +1 -1
- package/server.js +1 -1
- package/webServer/app.js +29 -29
- package/webServer/style.css +37 -3
package/cli.js
CHANGED
|
@@ -652,7 +652,7 @@ globstar while`,e,d,t,f,p),this.matchOne(e.slice(d),t.slice(f),r))return this.de
|
|
|
652
652
|
`)),yzr(e,i,{encoding:r,flush:!0})}var Iot=new $j.default({fetchMethod:e=>Rzr(e),ttl:300*1e3,ttlAutopurge:!1,max:1e3});async function Bot(e){let t=SU(e);return Iot.get(t)||Iot.fetchMethod?.(t)}async function Rzr(e){let t=new AbortController;setTimeout(()=>{t.abort()},1e3);let r=await Vet(e,t.signal,15),n=0;for(let i of r)D1(i)==="CRLF"&&n++;return n>3?"CRLF":"LF"}function Mot(e,t,r){if(e.has(t))return e.get(t);let n=r();return e.set(t,n),n}var Nzr=new $j.default({fetchMethod:e=>kot(e),ttl:300*1e3,ttlAutopurge:!1,max:1e3});function Hd(e){let t=SU(e);return Mot(Nzr,t,()=>kot(t))}function kot(e){let r=Buffer.alloc(4096),n;try{n=vot(e,"r");let i=xot(n,r,0,4096,0);return i===0?"utf8":i>=2&&r[0]===255&&r[1]===254?"utf16le":i>=3&&r[0]===239&&r[1]===187&&r[2]===191||r.slice(0,i).toString("utf8").length>0?"utf8":"ascii"}catch(i){return Ee(`Error detecting encoding for file ${e}: ${i}`),"utf8"}finally{n&&wot(n)}}var Dzr=new $j.default({fetchMethod:e=>Lot(e),ttl:300*1e3,ttlAutopurge:!1,max:1e3});function D1(e){let t=SU(e);return Mot(Dzr,t,()=>Lot(t))}function Lot(e,t="utf8"){try{if(!Rot(e).isFile())return"LF";let n=Buffer.alloc(4096),i=vot(e,"r"),o=xot(i,n,0,4096,0);wot(i);let s=n.toString(t,0,o),a=0,l=0;for(let c=0;c<s.length;c++)s[c]===`
|
|
653
653
|
`&&(c>0&&s[c-1]==="\r"?a++:l++);return a>l?"CRLF":"LF"}catch(r){return Ee(`Error detecting line endings for file ${e}: ${r}`),"LF"}}function pB(e){let t=Not(e)?e:SU(De(),e);return t.endsWith(" AM.png")?t.replace(" AM.png","\u202FAM.png"):t.endsWith(" PM.png")?t.replace(" PM.png","\u202FPM.png"):t}function $_e(e){return e?Not(e)?e:SU(De(),e):void 0}function Pot(e){try{let t=$_e(e),r=t?vzr(De(),t):void 0;return{absolutePath:t,relativePath:r}}catch(t){return X("getAbsoluteAndRelativePaths error ",t),{absolutePath:null,relativePath:null}}}function Yj(e){try{let t=xzr(e),r=yot(e,Cot(e));if(!Czr(t))return;let o=Tzr(t).filter(s=>yot(s,Cot(s))===r&&wzr(t,s)!==e)[0];return o||void 0}catch(t){Ee(`Error finding similar file for ${e}: ${t}`);return}}function q_e(){let e=process.env.HAWA_CODE_COMPACT_LINE_PREFIX;return!(e==="0"||e==="false")}function sC({content:e,startLine:t}){if(!e)return"";let r=e.split(/\r?\n/);return q_e()?r.map((n,i)=>`${i+t} ${n}`).join(`
|
|
654
654
|
`):r.map((n,i)=>{let o=String(i+t);return o.length>=6?`${o}\u2192${n}`:`${o.padStart(6," ")}\u2192${n}`}).join(`
|
|
655
|
-
`)}function Fot(e){try{let t=Izr(e),r=t.readSync();return t.closeSync(),r===null}catch(t){return Ee(`Error checking directory: ${t}`),!1}}Fe();function rC(){let e=Rn();e.hasCompletedProjectOnboarding||Ji({...e,hasCompletedProjectOnboarding:!0})}function Y_e({workspaceDir:e}){let r=!Rn().hasCompletedProjectOnboarding;if(!r)return null;let n=Ozr(Bzr(e,Pi)),i=Fot(e),o=!n&&!i,s=oB.isEnabled&&!zr().shiftEnterKeyBindingInstalled,a=oe();return(0,A.jsxs)(w,{flexDirection:"column",gap:1,padding:1,paddingBottom:0,children:[r&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(I,{color:a.secondaryText,children:"Tips for getting started:"}),(0,A.jsx)(Ec,{children:(()=>{let l=[];return i&&l.push((0,A.jsx)(Ec.Item,{children:(0,A.jsxs)(I,{color:a.secondaryText,children:["Ask ",nt," to create a new app or clone a repository."]})},"workspace")),o&&l.push((0,A.jsx)(Ec.Item,{children:(0,A.jsxs)(I,{color:a.secondaryText,children:["Run ",(0,A.jsx)(I,{color:a.text,children:"/init"})," to create a",Pi," file with instructions for Hawa code."]})},"claudemd")),s&&l.push((0,A.jsx)(Ec.Item,{children:(0,A.jsxs)(I,{color:a.secondaryText,children:["Run ",(0,A.jsx)(I,{color:a.text,children:"/terminal-setup"}),(0,A.jsx)(I,{bold:!1,children:" to set up terminal integration"})]})},"terminal")),l.push((0,A.jsx)(Ec.Item,{children:(0,A.jsxs)(I,{color:a.secondaryText,children:["Ask ",nt," questions about your codebase."]})},"questions")),l.push((0,A.jsx)(Ec.Item,{children:(0,A.jsxs)(I,{color:a.secondaryText,children:["Ask ",nt," to implement changes to your codebase."]})},"changes")),l})()})]}),e===Mzr()&&(0,A.jsxs)(I,{color:oe().warning,children:["Note: You have launched ",(0,A.jsx)(I,{bold:!0,children:nt})," in your home directory. For the best experience, launch it in a project directory instead."]})]})}function z_e({isFocused:e,isSelected:t,smallPointer:r,children:n}){let{styles:i}=Ao("Select");return(0,A.jsxs)(w,{...i.option({isFocused:e}),children:[e&&(0,A.jsx)(I,{...i.focusIndicator(),children:r?nr.triangleDownSmall:nr.pointer}),(0,A.jsx)(I,{...i.label({isFocused:e,isSelected:t}),children:n}),t&&(0,A.jsx)(I,{...i.selectedIndicator(),children:nr.tick})]})}var $d=Ie(Ye(),1);import{isDeepStrictEqual as kzr}from"node:util";var bU=class extends Map{first;constructor(t){let r=[],n,i,o=0;for(let s of t){let a={...s,previous:i,next:void 0,index:o};i&&(i.next=a),n||=a;let l="value"in s?s.value:V_e(s);r.push([l,a]),o++,i=a}super(r),this.first=n}};var Lzr=(e,t)=>{switch(t.type){case"focus-next-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.next;for(;n&&!("value"in n);)n=n.next;if(!n)return e;if(!(n.index>=e.visibleToIndex))return{...e,focusedValue:n.value};let o=Math.min(e.optionMap.size,e.visibleToIndex+1),s=o-e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:s,visibleToIndex:o}}case"focus-previous-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.previous;for(;n&&!("value"in n);)n=n.previous;if(!n)return e;if(!(n.index<=e.visibleFromIndex))return{...e,focusedValue:n.value};let o=Math.max(0,e.visibleFromIndex-1),s=o+e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:o,visibleToIndex:s}}case"select-focused-option":return{...e,previousValue:e.value,value:e.focusedValue};case"reset":return t.state;case"set-focus":return{...e,focusedValue:t.value}}},W_e=e=>e.flatMap(t=>{if("options"in t){let r=W_e(t.options),n=r.flatMap(o=>"value"in o?o.value:[]);return[...t.header!==void 0?[{header:t.header,optionValues:n}]:[],...r]}return t}),Qot=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=W_e(r),i=typeof e=="number"?Math.min(e,n.length):n.length,o=new bU(n),s=o.first,a=s&&"value"in s?s.value:void 0;return{optionMap:o,visibleOptionCount:i,focusedValue:a,visibleFromIndex:0,visibleToIndex:i,previousValue:t,value:t}},j_e=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n,onFocus:i,focusValue:o})=>{let s=W_e(t),[a,l]=(0,$d.useReducer)(Lzr,{visibleOptionCount:e,defaultValue:r,options:t},Qot),[c,u]=(0,$d.useState)(s);s!==c&&!kzr(s,c)&&(l({type:"reset",state:Qot({visibleOptionCount:e,defaultValue:r,options:t})}),u(s));let d=(0,$d.useCallback)(()=>{l({type:"focus-next-option"})},[]),f=(0,$d.useCallback)(()=>{l({type:"focus-previous-option"})},[]),p=(0,$d.useCallback)(()=>{l({type:"select-focused-option"})},[]),h=(0,$d.useMemo)(()=>s.map((_,E)=>({..._,index:E})).slice(a.visibleFromIndex,a.visibleToIndex),[s,a.visibleFromIndex,a.visibleToIndex]);return(0,$d.useEffect)(()=>{a.value&&a.previousValue!==a.value&&n?.(a.value)},[a.previousValue,a.value,t,n]),(0,$d.useEffect)(()=>{a.focusedValue&&i?.(a.focusedValue)},[a.focusedValue,i]),(0,$d.useEffect)(()=>{o&&l({type:"set-focus",value:o})},[o]),{focusedValue:a.focusedValue,visibleFromIndex:a.visibleFromIndex,visibleToIndex:a.visibleToIndex,value:a.value,visibleOptions:h,focusNextOption:d,focusPreviousOption:f,selectFocusedOption:p}};var K_e=({isDisabled:e=!1,state:t})=>{_t((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};var V_e=e=>`HEADER-${e.optionValues.join(",")}`;function OS({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:i,onChange:o,onFocus:s,focusValue:a}){let l=j_e({visibleOptionCount:t,options:n,defaultValue:i,onChange:o,onFocus:s,focusValue:a});K_e({isDisabled:e,state:l});let{styles:c}=Ao("Select");return(0,A.jsx)(w,{...c.container(),children:l.visibleOptions.map(u=>{let d="value"in u?u.value:V_e(u),f=!e&&l.focusedValue!==void 0&&("value"in u?l.focusedValue===u.value:u.optionValues.includes(l.focusedValue)),p=!!l.value&&("value"in u?l.value===u.value:u.optionValues.includes(l.value)),h="header"in u,_="label"in u?u.label:u.header,E=_;if(r&&_.includes(r)){let b=_.indexOf(r);E=(0,A.jsxs)(A.Fragment,{children:[_.slice(0,b),(0,A.jsx)(I,{...c.highlightedText(),children:r}),_.slice(b+r.length)]})}return(0,A.jsx)(z_e,{isFocused:f,isSelected:p,smallPointer:h,children:E},d)})})}function Uot({onDone:e}){return _t((t,r)=>{(r.ctrl&&(t==="c"||t==="d")||r.escape)&&e()}),(0,A.jsxs)(w,{flexDirection:"column",borderStyle:"round",padding:1,borderColor:oe().secondaryBorder,children:[(0,A.jsx)(w,{marginBottom:1,flexDirection:"column",children:(0,A.jsx)(I,{bold:!0,children:"You've spent $5 this session."})}),(0,A.jsx)(w,{children:(0,A.jsx)(OS,{options:[{value:"ok",label:"Got it, thanks!"}],onChange:e})})]})}var vr=Ie(Ye(),1);Fe();mr();jA();var Qzr="2.8.7",BS={VERSION:Qzr,PACKAGE_URL:"@dahawa/hawa-code",README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var X_e=46,$ot=["(\u2740\u2579\u25E1\u2579)","(\u25D5\u072B\u25D5)","\u239D(\u25D5u\u25D5)\u23A0","\u10DA(\u25C9\u25DE\u0C6A\u25DF\u25C9 )\u10DA","(\xB4\u25C9\u203F\u25C9\uFF40)","\u0E01\u0E47\u0295\u2022\u0361\u1D25\u2022\u0294 \u0E01\u0E49","\uFF0F/( \u25D5\u203F\u203F\u25D5 )\uFF3C"];function zj({isDefaultModel:e=!1}){let t=Math.max(X_e,De().length+12),r=oe(),n=$ot[Math.floor(Math.random()*$ot.length)];return(0,A.jsx)(w,{flexDirection:"column",children:(0,A.jsxs)(w,{flexDirection:"column",gap:1,paddingLeft:1,width:"100%",children:[(0,A.jsxs)(I,{children:[(0,A.jsx)(I,{children:n})," Welcome to"," ",(0,A.jsx)(I,{bold:!0,children:nt}),(0,A.jsxs)(I,{color:r.secondaryText,children:[" v",BS.VERSION]})]}),(0,A.jsx)(A.Fragment,{children:(0,A.jsxs)(w,{paddingLeft:2,flexDirection:"column",gap:1,children:[(0,A.jsx)(I,{color:r.secondaryText,italic:!0,children:"/help for help"}),(0,A.jsxs)(I,{color:r.secondaryText,children:["cwd: ",De()]}),(0,A.jsxs)(I,{color:r.secondaryText,children:["model: ",Wn.getConfig().routing.MODEL?.map(i=>`${i.source}__${i.model}`).join(", ")??"N/A"]}),(0,A.jsxs)(I,{color:r.secondaryText,children:["small fast model: ",Wn.getConfig().routing.SMALL_FAST_MODEL?.map(i=>`${i.source}__${i.model}`).join(", ")??"N/A"]})]})})]})})}Te();import{randomUUID as kg}from"crypto";wo();Te();cr();mr();Te();Fe();import{existsSync as LS,readdirSync as fKr,statSync as gKr}from"fs";import{join as dC,relative as hKr}from"path";import{homedir as Llt}from"os";import{platform as AKr}from"process";import{readFile as pC}from"fs/promises";mr();rm();Jt();import{join as Yzr,sep as zzr}from"path";function Wu(){if(!Sc())return!1;try{let e=We();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function qd(){return(Yzr(De(),".hcode","team-memory")+zzr).normalize("NFC")}function Lf(e){let t=e.normalize("NFC"),r=qd();return t.startsWith(r)}rm();var Plt=Ie(NU(),1);li();var AEe=(e,t,r)=>{let n=e instanceof RegExp?ult(e,r):e,i=t instanceof RegExp?ult(t,r):t,o=n!==null&&i!=null&&ijr(n,i,r);return o&&{start:o[0],end:o[1],pre:r.slice(0,o[0]),body:r.slice(o[0]+n.length,o[1]),post:r.slice(o[1]+i.length)}},ult=(e,t)=>{let r=t.match(e);return r?r[0]:null},ijr=(e,t,r)=>{let n,i,o,s,a,l=r.indexOf(e),c=r.indexOf(t,l+1),u=l;if(l>=0&&c>0){if(e===t)return[l,c];for(n=[],o=r.length;u>=0&&!a;){if(u===l)n.push(u),l=r.indexOf(e,u+1);else if(n.length===1){let d=n.pop();d!==void 0&&(a=[d,c])}else i=n.pop(),i!==void 0&&i<o&&(o=i,s=c),c=r.indexOf(t,u+1);u=l<c&&l>=0?l:c}n.length&&s!==void 0&&(a=[o,s])}return a};var dlt="\0SLASH"+Math.random()+"\0",plt="\0OPEN"+Math.random()+"\0",SEe="\0CLOSE"+Math.random()+"\0",mlt="\0COMMA"+Math.random()+"\0",flt="\0PERIOD"+Math.random()+"\0",ojr=new RegExp(dlt,"g"),sjr=new RegExp(plt,"g"),ajr=new RegExp(SEe,"g"),ljr=new RegExp(mlt,"g"),cjr=new RegExp(flt,"g"),ujr=/\\\\/g,djr=/\\{/g,pjr=/\\}/g,mjr=/\\,/g,fjr=/\\\./g,gjr=1e5,hjr=4e6;function _Ee(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Ajr(e){return e.replace(ujr,dlt).replace(djr,plt).replace(pjr,SEe).replace(mjr,mlt).replace(fjr,flt)}function _jr(e){return e.replace(ojr,"\\").replace(sjr,"{").replace(ajr,"}").replace(ljr,",").replace(cjr,".")}function glt(e){if(!e)return[""];let t=[],r=AEe("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=glt(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function hlt(e,t={}){if(!e)return[];let{max:r=gjr,maxLength:n=hjr}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),EEe(Ajr(e),r,n,!0).map(_jr)}function Ejr(e){return"{"+e+"}"}function Sjr(e){return/^-?0\d/.test(e)}function bjr(e,t){return e<=t}function yjr(e,t){return e>=t}function DU(e,t,r,n,i,o){let s=[],a=0;for(let l=0;l<e.length;l++)for(let c=0;c<r.length;c++){if(s.length>=n)return s;let u=e[l]+t+r[c];if(!(o&&!u)){if(a+u.length>i)return s;s.push(u),a+=u.length}}return s}function Cjr(e,t,r,n){let i=e.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let s=_Ee(i[0]),a=_Ee(i[1]),l=Math.max(i[0].length,i[1].length),c=i.length===3&&i[2]!==void 0?Math.max(Math.abs(_Ee(i[2])),1):1,u=bjr;a<s&&(c*=-1,u=yjr);let f=i.some(Sjr),p=0;for(let h=s;u(h,a)&&o.length<r;h+=c){let _;if(t)_=String.fromCharCode(h),_==="\\"&&(_="");else if(_=String(h),f){let E=l-_.length;if(E>0){let b=new Array(E+1).join("0");h<0?_="-"+b+_.slice(1):_=b+_}}if(p+_.length>n)break;o.push(_),p+=_.length}return o}function EEe(e,t,r,n){let i=[""],o=!1,s=!0;for(;;){let a=AEe("{","}",e);if(!a)return DU(i,e,[""],t,r,o);let l=a.pre;if(/\$$/.test(l)){if(i=DU(i,l+"{"+a.body+"}",[""],t,r,o&&!a.post.length),s=!1,!a.post.length)break;e=a.post;continue}let c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),d=c||u,f=a.body.indexOf(",")>=0;if(!d&&!f){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+SEe+a.post,n=!0;continue}return DU(i,l+"{"+a.body+"}"+a.post,[""],t,r,o)}s&&(o=n&&!d,s=!1);let p;if(d)p=Cjr(a.body,u,t,r);else{let h=glt(a.body);if(h.length===1&&h[0]!==void 0&&(h=EEe(h[0],t,r,!1).map(Ejr),h.length===1)){if(i=DU(i,l+h[0],[""],t,r,o&&!a.post.length),!a.post.length)break;e=a.post;continue}let _=o&&!a.post.length&&!l;for(let b=0;_&&b<i.length;b++)i[b]&&(_=!1);p=[];let E=0;e:for(let b=0;b<h.length;b++){let C=EEe(h[b],t,r,!1);for(let v=0;v<C.length;v++){let R=C[v];if(!(_&&!R)){if(p.length>=t||E+R.length>r)break e;p.push(R),E+=R.length}}}}if(i=DU(i,l,p,t,r,o&&!a.post.length),!a.post.length)break;e=a.post}return i}var OU=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Tjr={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},BU=e=>e.replace(/[[\]\\-]/g,"\\$&"),Ijr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Alt=e=>e.join(""),_lt=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],o=r+1,s=!1,a=!1,l=!1,c=!1,u=r,d="";e:for(;o<e.length;){let _=e.charAt(o);if((_==="!"||_==="^")&&o===r+1){c=!0,o++;continue}if(_==="]"&&s&&!l){u=o+1;break}if(s=!0,_==="\\"&&!l){l=!0,o++;continue}if(_==="["&&!l){for(let[E,[b,C,v]]of Object.entries(Tjr))if(e.startsWith(E,o)){if(d)return["$.",!1,e.length-r,!0];o+=E.length,v?i.push(b):n.push(b),a=a||C;continue e}}if(l=!1,d){_>d?n.push(BU(d)+"-"+BU(_)):_===d&&n.push(BU(_)),d="",o++;continue}if(e.startsWith("-]",o+1)){n.push(BU(_+"-")),o+=2;continue}if(e.startsWith("-",o+1)){d=_,o+=2;continue}n.push(BU(_)),o++}if(u<o)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,e.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!c){let _=n[0].length===2?n[0].slice(-1):n[0];return[Ijr(_),!1,u-r,!1]}let f="["+(c?"^":"")+Alt(n)+"]",p="["+(c?"":"^")+Alt(i)+"]";return[n.length&&i.length?"("+f+"|"+p+")":n.length?f:p,a,u-r,!0]};var uC=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!0}={})=>r?t?e.replace(/\[([^/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?e.replace(/\[([^/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var zd,vjr=new Set(["!","?","+","*","@"]),bEe=e=>vjr.has(e),Elt=e=>bEe(e.type),xjr=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),wjr=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Rjr=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),Slt=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Njr="(?!(?:^|/)\\.\\.?(?:$|/))",iK="(?!\\.)",Djr=new Set(["[","."]),Ojr=new Set(["..","."]),Bjr=new Set("().*{}+?[]^$\\!"),Mjr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),yEe="[^/]",blt=yEe+"*?",ylt=yEe+"+?",kjr=0,Q1=class{type;#e;#t;#n=!1;#r=[];#o;#i;#l;#s=!1;#a;#d;#m=!1;id=++kjr;get depth(){return(this.#o?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#o?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(t,r,n={}){this.type=t,t&&(this.#t=!0),this.#o=r,this.#e=this.#o?this.#o.#e:this,this.#a=this.#e===this?n:this.#e.#a,this.#l=this.#e===this?[]:this.#e.#l,t==="!"&&!this.#e.#s&&this.#l.push(this),this.#i=this.#o?this.#o.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let t of this.#r)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#d!==void 0?this.#d:this.type?this.#d=this.type+"("+this.#r.map(t=>String(t)).join("|")+")":this.#d=this.#r.map(t=>String(t)).join("")}#p(){if(this!==this.#e)throw new Error("should only call on root");if(this.#s)return this;this.toString(),this.#s=!0;let t;for(;t=this.#l.pop();){if(t.type!=="!")continue;let r=t,n=r.#o;for(;n;){for(let i=r.#i+1;!n.type&&i<n.#r.length;i++)for(let o of t.#r){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#r[i])}r=n,n=r.#o}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof zd&&r.#o===this))throw new Error("invalid part: "+r);this.#r.push(r)}}toJSON(){let t=this.type===null?this.#r.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#r.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#o?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#o?.isStart())return!1;if(this.#i===0)return!0;let t=this.#o;for(let r=0;r<this.#i;r++){let n=t.#r[r];if(!(n instanceof zd&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let t=this.#o?this.#o.#r.length:0;return this.#i===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new zd(this.type,t);for(let n of this.#r)r.copyIn(n);return r}static#c(t,r,n,i,o){let s=i.maxExtglobRecursion??2,a=!1,l=!1,c=-1,u=!1;if(r.type===null){let _=n,E="";for(;_<t.length;){let b=t.charAt(_++);if(a||b==="\\"){a=!a,E+=b;continue}if(l){_===c+1?(b==="^"||b==="!")&&(u=!0):b==="]"&&!(_===c+2&&u)&&(l=!1),E+=b;continue}else if(b==="["){l=!0,c=_,u=!1,E+=b;continue}if(!i.noext&&bEe(b)&&t.charAt(_)==="("&&o<=s){r.push(E),E="";let v=new zd(b,r);_=zd.#c(t,v,_,i,o+1),r.push(v);continue}E+=b}return r.push(E),_}let d=n+1,f=new zd(null,r),p=[],h="";for(;d<t.length;){let _=t.charAt(d++);if(a||_==="\\"){a=!a,h+=_;continue}if(l){d===c+1?(_==="^"||_==="!")&&(u=!0):_==="]"&&!(d===c+2&&u)&&(l=!1),h+=_;continue}else if(_==="["){l=!0,c=d,u=!1,h+=_;continue}if(!i.noext&&bEe(_)&&t.charAt(d)==="("&&(o<=s||r&&r.#_(_))){let b=r&&r.#_(_)?0:1;f.push(h),h="";let C=new zd(_,f);f.push(C),d=zd.#c(t,C,d,i,o+b);continue}if(_==="|"){f.push(h),h="",p.push(f),f=new zd(null,r);continue}if(_===")")return h===""&&r.#r.length===0&&(r.#m=!0),f.push(h),h="",r.push(...p,f),d;h+=_}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],d}#g(t){return this.#A(t,wjr)}#A(t,r=xjr){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null)return!1;let n=t.#r[0];return!n||typeof n!="object"||n.type===null?!1:this.#_(n.type,r)}#_(t,r=Rjr){return!!r.get(this.type)?.includes(t)}#h(t,r){let n=t.#r[0],i=new zd(null,n,this.options);i.#r.push(""),n.push(i),this.#v(t,r)}#v(t,r){let n=t.#r[0];this.#r.splice(r,1,...n.#r);for(let i of n.#r)typeof i=="object"&&(i.#o=this);this.#d=void 0}#S(t){return!!Slt.get(this.type)?.has(t)}#C(t){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let r=t.#r[0];return!r||typeof r!="object"||r.type===null?!1:this.#S(r.type)}#T(t){let r=Slt.get(this.type),n=t.#r[0],i=r?.get(n.type);if(!i)return!1;this.#r=n.#r;for(let o of this.#r)typeof o=="object"&&(o.#o=this);this.type=i,this.#d=void 0,this.#m=!1}static fromGlob(t,r={}){let n=new zd(null,void 0,r);return zd.#c(t,n,0,r,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[r,n,i,o]=this.toRegExpSource();if(!(i||this.#t||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#a}toRegExpSource(t){let r=t??!!this.#a.dot;if(this.#e===this&&(this.#E(),this.#p()),!Elt(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(p=>typeof p!="string"),c=this.#r.map(p=>{let[h,_,E,b]=typeof p=="string"?zd.#y(p,this.#t,l):p.toRegExpSource(t);return this.#t=this.#t||E,this.#n=this.#n||b,h}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&Ojr.has(this.#r[0]))){let h=Djr,_=r&&h.has(c.charAt(0))||c.startsWith("\\.")&&h.has(c.charAt(2))||c.startsWith("\\.\\.")&&h.has(c.charAt(4)),E=!r&&!t&&h.has(c.charAt(0));u=_?Njr:E?iK:""}let d="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(d="(?:$|\\/)"),[u+c+d,uC(c),this.#t=!!this.#t,this.#n]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#b(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString(),c=this;return c.#r=[l],c.type=null,c.#t=void 0,[l,uC(this.toString()),!1,!1]}let s=!n||t||r||!iK?"":this.#b(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#m)a=(this.isStart()&&!r?iK:"")+ylt;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?iK:"")+blt+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,uC(o),this.#t=!!this.#t,this.#n]}#E(){if(Elt(this)){let t=0,r=!1;do{r=!0;for(let n=0;n<this.#r.length;n++){let i=this.#r[n];typeof i=="object"&&(i.#E(),this.#A(i)?(r=!1,this.#v(i,n)):this.#g(i)?(r=!1,this.#h(i,n)):this.#C(i)&&(r=!1,this.#T(i)))}}while(!r&&++t<10)}else for(let t of this.#r)typeof t=="object"&&t.#E();this.#d=void 0}#b(t){return this.#r.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,o,s]=r.toRegExpSource(t);return this.#n=this.#n||s,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#y(t,r,n=!1){let i=!1,o="",s=!1,a=!1;for(let l=0;l<t.length;l++){let c=t.charAt(l);if(i){i=!1,o+=(Bjr.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?ylt:blt,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,d,f,p]=_lt(t,l);if(f){o+=u,s=s||d,l+=f-1,r=r||p;continue}}if(c==="?"){o+=yEe,r=!0;continue}o+=Mjr(c)}return[o,uC(t),!!r,s]}};zd=Q1;var CEe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var bc=(e,t,r={})=>(OU(t),!r.nocomment&&t.charAt(0)==="#"?!1:new CB(t,r).match(e)),Ljr=/^\*+([^+@!?*[(]*)$/,Pjr=e=>t=>!t.startsWith(".")&&t.endsWith(e),Fjr=e=>t=>t.endsWith(e),Qjr=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Ujr=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Gjr=/^\*+\.\*+$/,Hjr=e=>!e.startsWith(".")&&e.includes("."),$jr=e=>e!=="."&&e!==".."&&e.includes("."),qjr=/^\.\*+$/,Yjr=e=>e!=="."&&e!==".."&&e.startsWith("."),zjr=/^\*+$/,Vjr=e=>e.length!==0&&!e.startsWith("."),Wjr=e=>e.length!==0&&e!=="."&&e!=="..",jjr=/^\?+([^+@!?*[(]*)?$/,Kjr=([e,t=""])=>{let r=Ilt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Jjr=([e,t=""])=>{let r=vlt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Zjr=([e,t=""])=>{let r=vlt([e]);return t?n=>r(n)&&n.endsWith(t):r},Xjr=([e,t=""])=>{let r=Ilt([e]);return t?n=>r(n)&&n.endsWith(t):r},Ilt=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},vlt=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},xlt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Clt={win32:{sep:"\\"},posix:{sep:"/"}},eKr=xlt==="win32"?Clt.win32.sep:Clt.posix.sep;bc.sep=eKr;var fu=Symbol("globstar **");bc.GLOBSTAR=fu;var tKr="[^/]",rKr=tKr+"*?",nKr="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",iKr="(?:(?!(?:\\/|^)\\.).)*?",oKr=(e,t={})=>r=>bc(r,e,t);bc.filter=oKr;var Pf=(e,t={})=>Object.assign({},e,t),sKr=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return bc;let t=bc;return Object.assign((n,i,o={})=>t(n,i,Pf(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,Pf(e,o))}static defaults(i){return t.defaults(Pf(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,Pf(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,Pf(e,o))}},unescape:(n,i={})=>t.unescape(n,Pf(e,i)),escape:(n,i={})=>t.escape(n,Pf(e,i)),filter:(n,i={})=>t.filter(n,Pf(e,i)),defaults:n=>t.defaults(Pf(e,n)),makeRe:(n,i={})=>t.makeRe(n,Pf(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,Pf(e,i)),match:(n,i,o={})=>t.match(n,i,Pf(e,o)),sep:t.sep,GLOBSTAR:fu})};bc.defaults=sKr;var wlt=(e,t={})=>(OU(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:hlt(e,{max:t.braceExpandMax}));bc.braceExpand=wlt;var aKr=(e,t={})=>new CB(e,t).makeRe();bc.makeRe=aKr;var lKr=(e,t,r={})=>{let n=new CB(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};bc.match=lKr;var Tlt=/[?*]|[+@!]\(.*?\)|\[|\]/,cKr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),CB=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){OU(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||xlt,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((o,s,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=o[0]===""&&o[1]===""&&(o[2]==="?"||!Tlt.test(o[2]))&&!Tlt.test(o[3]),c=/^[a-z]:/i.test(o[0]);if(l)return[...o.slice(0,4),...o.slice(4).map(u=>this.parse(u))];if(c)return[o[0],...o.slice(1).map(u=>this.parse(u))]}return o.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let s=this.set[o];s[0]===""&&s[1]===""&&this.globParts[o][2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3])&&(s[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n of t)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,i)=>{let o=n[n.length-1];return i==="**"&&o==="**"?n:i===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let o=t[i];i===1&&o===""&&t[0]===""||(o==="."||o==="")&&(r=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let s=i;for(;n[s+1]==="**";)s++;s>i&&n.splice(i+1,s-i);let a=n[i+1],l=n[i+2],c=n[i+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",t.push(u),i--}if(!this.preserveMultipleSlashes){for(let s=1;s<n.length-1;s++){let a=n[s];s===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(s,1),s--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let s=n[o-1];if(s&&s!=="."&&s!==".."&&s!=="**"){r=!0;let l=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...l),n.length===0&&n.push(""),o-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let i=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(i){t[r]=[],t[n]=i;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let i=0,o=0,s=[],a="";for(;i<t.length&&o<r.length;)if(t[i]===r[o])s.push(a==="b"?r[o]:t[i]),i++,o++;else if(n&&t[i]==="**"&&r[o]===t[i+1])s.push(t[i]),i++;else if(n&&r[o]==="**"&&t[i]===r[o+1])s.push(r[o]),o++;else if(t[i]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",s.push(t[i]),i++,o++}else if(r[o]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(a==="a")return!1;a="b",s.push(r[o]),i++,o++}else return!1;return t.length===r.length&&s}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let i=0,o=0;if(this.isWindows){let a=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),l=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),c=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),u=!c&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),d=l?3:a?0:void 0,f=u?3:c?0:void 0;if(typeof d=="number"&&typeof f=="number"){let[p,h]=[t[d],r[f]];p.toLowerCase()===h.toLowerCase()&&(r[f]=p,o=f,i=d)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(fu)?this.#e(t,r,n,i,o):this.#n(t,r,n,i,o)}#e(t,r,n,i,o){let s=r.indexOf(fu,o),a=r.lastIndexOf(fu),[l,c,u]=n?[r.slice(o,s),r.slice(s+1),[]]:[r.slice(o,s),r.slice(s+1,a),r.slice(a+1)];if(l.length){let C=t.slice(i,i+l.length);if(!this.#n(C,l,n,0,0))return!1;i+=l.length,o+=l.length}let d=0;if(u.length){if(u.length+i>t.length)return!1;let C=t.length-u.length;if(this.#n(t,u,n,C,0))d=u.length;else{if(t[t.length-1]!==""||i+u.length===t.length||(C--,!this.#n(t,u,n,C,0)))return!1;d=u.length+1}}if(!c.length){let C=!!d;for(let v=i;v<t.length-d;v++){let R=String(t[v]);if(C=!0,R==="."||R===".."||!this.options.dot&&R.startsWith("."))return!1}return n||C}let f=[[[],0]],p=f[0],h=0,_=[0];for(let C of c)C===fu?(_.push(h),p=[[],0],f.push(p)):(p[0].push(C),h++);let E=f.length-1,b=t.length-d;for(let C of f)C[1]=b-(_[E--]+C[0].length);return!!this.#t(t,f,i,0,n,0,!!d)}#t(t,r,n,i,o,s,a){let l=r[i];if(!l){for(let d=n;d<t.length;d++){a=!0;let f=t[d];if(f==="."||f===".."||!this.options.dot&&f.startsWith("."))return!1}return a}let[c,u]=l;for(;n<=u;){if(this.#n(t.slice(0,n+c.length),c,o,n,0)&&s<this.maxGlobstarRecursion){let p=this.#t(t,r,n+c.length,i+1,o,s+1,a);if(p!==!1)return p}let f=t[n];if(f==="."||f===".."||!this.options.dot&&f.startsWith("."))return!1;n++}return o||null}#n(t,r,n,i,o){let s,a,l,c;for(s=i,a=o,c=t.length,l=r.length;s<c&&a<l;s++,a++){this.debug("matchOne loop");let u=r[a],d=t[s];if(this.debug(r,u,d),u===!1||u===fu)return!1;let f;if(typeof u=="string"?(f=d===u,this.debug("string match",u,d,f)):(f=u.test(d),this.debug("pattern match",u,d,f)),!f)return!1}if(s===c&&a===l)return!0;if(s===c)return n;if(a===l)return s===c-1&&t[s]==="";throw new Error("wtf?")}braceExpand(){return wlt(this.pattern,this.options)}parse(t){OU(t);let r=this.options;if(t==="**")return fu;if(t==="")return"";let n,i=null;(n=t.match(zjr))?i=r.dot?Wjr:Vjr:(n=t.match(Ljr))?i=(r.nocase?r.dot?Ujr:Qjr:r.dot?Fjr:Pjr)(n[1]):(n=t.match(jjr))?i=(r.nocase?r.dot?Jjr:Kjr:r.dot?Zjr:Xjr)(n):(n=t.match(Gjr))?i=r.dot?$jr:Hjr:(n=t.match(qjr))&&(i=Yjr);let o=Q1.fromGlob(t,this.options).toMMPattern();return i&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:i}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?rKr:r.dot?nKr:iKr,i=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let c=l.map(d=>{if(d instanceof RegExp)for(let f of d.flags.split(""))i.add(f);return typeof d=="string"?cKr(d):d===fu?fu:d._src});c.forEach((d,f)=>{let p=c[f+1],h=c[f-1];d!==fu||h===fu||(h===void 0?p!==void 0&&p!==fu?c[f+1]="(?:\\/|"+n+"\\/)?"+p:c[f]=n:p===void 0?c[f-1]=h+"(?:\\/|\\/"+n+")?":p!==fu&&(c[f-1]=h+"(?:\\/|\\/"+n+"\\/)"+p,c[f+1]=fu))});let u=c.filter(d=>d!==fu);if(this.partial&&u.length>=1){let d=[];for(let f=1;f<=u.length;f++)d.push(u.slice(0,f).join("/"));return"(?:"+d.join("|")+")"}return u.join("/")}).join("|"),[s,a]=t.length>1?["(?:",")"]:["",""];o="^"+s+o+a+"$",this.partial&&(o="^(?:\\/|"+s+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let o=this.set;this.debug(this.pattern,"set",o);let s=i[i.length-1];if(!s)for(let a=i.length-2;!s&&a>=0;a--)s=i[a];for(let a of o){let l=i;if(n.matchBase&&a.length===1&&(l=[s]),this.matchOne(l,a,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return bc.defaults(t).Minimatch}};bc.AST=Q1;bc.Minimatch=CB;bc.escape=CEe;bc.unescape=uC;var Dlt=Ie(NU(),1);mr();Fe();Te();qu();import{readFile as Rlt}from"fs/promises";import{existsSync as TEe,readdirSync as uKr,statSync as dKr}from"fs";import{join as IEe,relative as Olt}from"path";import{homedir as pKr}from"os";function Nlt(e){try{let t=(0,Dlt.default)(e),r=t.data.paths,n=[];return typeof r=="string"?n=r.split(",").map(i=>i.trim()).filter(Boolean):Array.isArray(r)&&(n=r.filter(i=>typeof i=="string")),{paths:n,content:t.content.trim()}}catch(t){return Ee(t),{paths:[],content:e.trim()}}}function mKr(e,t){return t.length===0?!0:t.some(r=>{try{return bc(e,r,{matchBase:!0,dot:!0})}catch(n){return Ee(n),!1}})}function vEe(e){let t=[];try{if(!TEe(e))return t;let r=uKr(e);for(let n of r){let i=IEe(e,n),o=dKr(i);o.isDirectory()?t.push(...vEe(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){Ee(r)}return t}async function oK(){let e=[];try{let t=IEe(pKr(),bn,"rules");if(TEe(t)){let r=vEe(t);for(let n of r)try{let i=await Rlt(n,"utf-8"),{paths:o,content:s}=Nlt(i);o.length>0&&e.push({filePath:n,content:s,paths:o,isProjectRule:!1})}catch(i){Ee(i)}}}catch(t){Ee(t)}try{let t=IEe(De(),bn,"rules");if(TEe(t)){let r=vEe(t);for(let n of r)try{let i=await Rlt(n,"utf-8"),{paths:o,content:s}=Nlt(i);o.length>0&&e.push({filePath:Olt(De(),n),content:s,paths:o,isProjectRule:!0})}catch(i){Ee(i)}}}catch(t){Ee(t)}return e}function Blt(e,t){e=Q7(e);let r=Q7(De()),n=e.startsWith(r)?Olt(r,e):e;return t.filter(i=>mKr(n,i.paths))}function Mlt(e){return e.length===0?"":e.map(r=>{let n=r.isProjectRule?"project instructions, checked into the codebase":"user's private global instructions for all projects";return`Contents of ${r.filePath} (${n}):
|
|
655
|
+
`)}function Fot(e){try{let t=Izr(e),r=t.readSync();return t.closeSync(),r===null}catch(t){return Ee(`Error checking directory: ${t}`),!1}}Fe();function rC(){let e=Rn();e.hasCompletedProjectOnboarding||Ji({...e,hasCompletedProjectOnboarding:!0})}function Y_e({workspaceDir:e}){let r=!Rn().hasCompletedProjectOnboarding;if(!r)return null;let n=Ozr(Bzr(e,Pi)),i=Fot(e),o=!n&&!i,s=oB.isEnabled&&!zr().shiftEnterKeyBindingInstalled,a=oe();return(0,A.jsxs)(w,{flexDirection:"column",gap:1,padding:1,paddingBottom:0,children:[r&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(I,{color:a.secondaryText,children:"Tips for getting started:"}),(0,A.jsx)(Ec,{children:(()=>{let l=[];return i&&l.push((0,A.jsx)(Ec.Item,{children:(0,A.jsxs)(I,{color:a.secondaryText,children:["Ask ",nt," to create a new app or clone a repository."]})},"workspace")),o&&l.push((0,A.jsx)(Ec.Item,{children:(0,A.jsxs)(I,{color:a.secondaryText,children:["Run ",(0,A.jsx)(I,{color:a.text,children:"/init"})," to create a",Pi," file with instructions for Hawa code."]})},"claudemd")),s&&l.push((0,A.jsx)(Ec.Item,{children:(0,A.jsxs)(I,{color:a.secondaryText,children:["Run ",(0,A.jsx)(I,{color:a.text,children:"/terminal-setup"}),(0,A.jsx)(I,{bold:!1,children:" to set up terminal integration"})]})},"terminal")),l.push((0,A.jsx)(Ec.Item,{children:(0,A.jsxs)(I,{color:a.secondaryText,children:["Ask ",nt," questions about your codebase."]})},"questions")),l.push((0,A.jsx)(Ec.Item,{children:(0,A.jsxs)(I,{color:a.secondaryText,children:["Ask ",nt," to implement changes to your codebase."]})},"changes")),l})()})]}),e===Mzr()&&(0,A.jsxs)(I,{color:oe().warning,children:["Note: You have launched ",(0,A.jsx)(I,{bold:!0,children:nt})," in your home directory. For the best experience, launch it in a project directory instead."]})]})}function z_e({isFocused:e,isSelected:t,smallPointer:r,children:n}){let{styles:i}=Ao("Select");return(0,A.jsxs)(w,{...i.option({isFocused:e}),children:[e&&(0,A.jsx)(I,{...i.focusIndicator(),children:r?nr.triangleDownSmall:nr.pointer}),(0,A.jsx)(I,{...i.label({isFocused:e,isSelected:t}),children:n}),t&&(0,A.jsx)(I,{...i.selectedIndicator(),children:nr.tick})]})}var $d=Ie(Ye(),1);import{isDeepStrictEqual as kzr}from"node:util";var bU=class extends Map{first;constructor(t){let r=[],n,i,o=0;for(let s of t){let a={...s,previous:i,next:void 0,index:o};i&&(i.next=a),n||=a;let l="value"in s?s.value:V_e(s);r.push([l,a]),o++,i=a}super(r),this.first=n}};var Lzr=(e,t)=>{switch(t.type){case"focus-next-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.next;for(;n&&!("value"in n);)n=n.next;if(!n)return e;if(!(n.index>=e.visibleToIndex))return{...e,focusedValue:n.value};let o=Math.min(e.optionMap.size,e.visibleToIndex+1),s=o-e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:s,visibleToIndex:o}}case"focus-previous-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.previous;for(;n&&!("value"in n);)n=n.previous;if(!n)return e;if(!(n.index<=e.visibleFromIndex))return{...e,focusedValue:n.value};let o=Math.max(0,e.visibleFromIndex-1),s=o+e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:o,visibleToIndex:s}}case"select-focused-option":return{...e,previousValue:e.value,value:e.focusedValue};case"reset":return t.state;case"set-focus":return{...e,focusedValue:t.value}}},W_e=e=>e.flatMap(t=>{if("options"in t){let r=W_e(t.options),n=r.flatMap(o=>"value"in o?o.value:[]);return[...t.header!==void 0?[{header:t.header,optionValues:n}]:[],...r]}return t}),Qot=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=W_e(r),i=typeof e=="number"?Math.min(e,n.length):n.length,o=new bU(n),s=o.first,a=s&&"value"in s?s.value:void 0;return{optionMap:o,visibleOptionCount:i,focusedValue:a,visibleFromIndex:0,visibleToIndex:i,previousValue:t,value:t}},j_e=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n,onFocus:i,focusValue:o})=>{let s=W_e(t),[a,l]=(0,$d.useReducer)(Lzr,{visibleOptionCount:e,defaultValue:r,options:t},Qot),[c,u]=(0,$d.useState)(s);s!==c&&!kzr(s,c)&&(l({type:"reset",state:Qot({visibleOptionCount:e,defaultValue:r,options:t})}),u(s));let d=(0,$d.useCallback)(()=>{l({type:"focus-next-option"})},[]),f=(0,$d.useCallback)(()=>{l({type:"focus-previous-option"})},[]),p=(0,$d.useCallback)(()=>{l({type:"select-focused-option"})},[]),h=(0,$d.useMemo)(()=>s.map((_,E)=>({..._,index:E})).slice(a.visibleFromIndex,a.visibleToIndex),[s,a.visibleFromIndex,a.visibleToIndex]);return(0,$d.useEffect)(()=>{a.value&&a.previousValue!==a.value&&n?.(a.value)},[a.previousValue,a.value,t,n]),(0,$d.useEffect)(()=>{a.focusedValue&&i?.(a.focusedValue)},[a.focusedValue,i]),(0,$d.useEffect)(()=>{o&&l({type:"set-focus",value:o})},[o]),{focusedValue:a.focusedValue,visibleFromIndex:a.visibleFromIndex,visibleToIndex:a.visibleToIndex,value:a.value,visibleOptions:h,focusNextOption:d,focusPreviousOption:f,selectFocusedOption:p}};var K_e=({isDisabled:e=!1,state:t})=>{_t((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};var V_e=e=>`HEADER-${e.optionValues.join(",")}`;function OS({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:i,onChange:o,onFocus:s,focusValue:a}){let l=j_e({visibleOptionCount:t,options:n,defaultValue:i,onChange:o,onFocus:s,focusValue:a});K_e({isDisabled:e,state:l});let{styles:c}=Ao("Select");return(0,A.jsx)(w,{...c.container(),children:l.visibleOptions.map(u=>{let d="value"in u?u.value:V_e(u),f=!e&&l.focusedValue!==void 0&&("value"in u?l.focusedValue===u.value:u.optionValues.includes(l.focusedValue)),p=!!l.value&&("value"in u?l.value===u.value:u.optionValues.includes(l.value)),h="header"in u,_="label"in u?u.label:u.header,E=_;if(r&&_.includes(r)){let b=_.indexOf(r);E=(0,A.jsxs)(A.Fragment,{children:[_.slice(0,b),(0,A.jsx)(I,{...c.highlightedText(),children:r}),_.slice(b+r.length)]})}return(0,A.jsx)(z_e,{isFocused:f,isSelected:p,smallPointer:h,children:E},d)})})}function Uot({onDone:e}){return _t((t,r)=>{(r.ctrl&&(t==="c"||t==="d")||r.escape)&&e()}),(0,A.jsxs)(w,{flexDirection:"column",borderStyle:"round",padding:1,borderColor:oe().secondaryBorder,children:[(0,A.jsx)(w,{marginBottom:1,flexDirection:"column",children:(0,A.jsx)(I,{bold:!0,children:"You've spent $5 this session."})}),(0,A.jsx)(w,{children:(0,A.jsx)(OS,{options:[{value:"ok",label:"Got it, thanks!"}],onChange:e})})]})}var vr=Ie(Ye(),1);Fe();mr();jA();var Qzr="2.8.8",BS={VERSION:Qzr,PACKAGE_URL:"@dahawa/hawa-code",README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var X_e=46,$ot=["(\u2740\u2579\u25E1\u2579)","(\u25D5\u072B\u25D5)","\u239D(\u25D5u\u25D5)\u23A0","\u10DA(\u25C9\u25DE\u0C6A\u25DF\u25C9 )\u10DA","(\xB4\u25C9\u203F\u25C9\uFF40)","\u0E01\u0E47\u0295\u2022\u0361\u1D25\u2022\u0294 \u0E01\u0E49","\uFF0F/( \u25D5\u203F\u203F\u25D5 )\uFF3C"];function zj({isDefaultModel:e=!1}){let t=Math.max(X_e,De().length+12),r=oe(),n=$ot[Math.floor(Math.random()*$ot.length)];return(0,A.jsx)(w,{flexDirection:"column",children:(0,A.jsxs)(w,{flexDirection:"column",gap:1,paddingLeft:1,width:"100%",children:[(0,A.jsxs)(I,{children:[(0,A.jsx)(I,{children:n})," Welcome to"," ",(0,A.jsx)(I,{bold:!0,children:nt}),(0,A.jsxs)(I,{color:r.secondaryText,children:[" v",BS.VERSION]})]}),(0,A.jsx)(A.Fragment,{children:(0,A.jsxs)(w,{paddingLeft:2,flexDirection:"column",gap:1,children:[(0,A.jsx)(I,{color:r.secondaryText,italic:!0,children:"/help for help"}),(0,A.jsxs)(I,{color:r.secondaryText,children:["cwd: ",De()]}),(0,A.jsxs)(I,{color:r.secondaryText,children:["model: ",Wn.getConfig().routing.MODEL?.map(i=>`${i.source}__${i.model}`).join(", ")??"N/A"]}),(0,A.jsxs)(I,{color:r.secondaryText,children:["small fast model: ",Wn.getConfig().routing.SMALL_FAST_MODEL?.map(i=>`${i.source}__${i.model}`).join(", ")??"N/A"]})]})})]})})}Te();import{randomUUID as kg}from"crypto";wo();Te();cr();mr();Te();Fe();import{existsSync as LS,readdirSync as fKr,statSync as gKr}from"fs";import{join as dC,relative as hKr}from"path";import{homedir as Llt}from"os";import{platform as AKr}from"process";import{readFile as pC}from"fs/promises";mr();rm();Jt();import{join as Yzr,sep as zzr}from"path";function Wu(){if(!Sc())return!1;try{let e=We();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function qd(){return(Yzr(De(),".hcode","team-memory")+zzr).normalize("NFC")}function Lf(e){let t=e.normalize("NFC"),r=qd();return t.startsWith(r)}rm();var Plt=Ie(NU(),1);li();var AEe=(e,t,r)=>{let n=e instanceof RegExp?ult(e,r):e,i=t instanceof RegExp?ult(t,r):t,o=n!==null&&i!=null&&ijr(n,i,r);return o&&{start:o[0],end:o[1],pre:r.slice(0,o[0]),body:r.slice(o[0]+n.length,o[1]),post:r.slice(o[1]+i.length)}},ult=(e,t)=>{let r=t.match(e);return r?r[0]:null},ijr=(e,t,r)=>{let n,i,o,s,a,l=r.indexOf(e),c=r.indexOf(t,l+1),u=l;if(l>=0&&c>0){if(e===t)return[l,c];for(n=[],o=r.length;u>=0&&!a;){if(u===l)n.push(u),l=r.indexOf(e,u+1);else if(n.length===1){let d=n.pop();d!==void 0&&(a=[d,c])}else i=n.pop(),i!==void 0&&i<o&&(o=i,s=c),c=r.indexOf(t,u+1);u=l<c&&l>=0?l:c}n.length&&s!==void 0&&(a=[o,s])}return a};var dlt="\0SLASH"+Math.random()+"\0",plt="\0OPEN"+Math.random()+"\0",SEe="\0CLOSE"+Math.random()+"\0",mlt="\0COMMA"+Math.random()+"\0",flt="\0PERIOD"+Math.random()+"\0",ojr=new RegExp(dlt,"g"),sjr=new RegExp(plt,"g"),ajr=new RegExp(SEe,"g"),ljr=new RegExp(mlt,"g"),cjr=new RegExp(flt,"g"),ujr=/\\\\/g,djr=/\\{/g,pjr=/\\}/g,mjr=/\\,/g,fjr=/\\\./g,gjr=1e5,hjr=4e6;function _Ee(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Ajr(e){return e.replace(ujr,dlt).replace(djr,plt).replace(pjr,SEe).replace(mjr,mlt).replace(fjr,flt)}function _jr(e){return e.replace(ojr,"\\").replace(sjr,"{").replace(ajr,"}").replace(ljr,",").replace(cjr,".")}function glt(e){if(!e)return[""];let t=[],r=AEe("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=glt(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function hlt(e,t={}){if(!e)return[];let{max:r=gjr,maxLength:n=hjr}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),EEe(Ajr(e),r,n,!0).map(_jr)}function Ejr(e){return"{"+e+"}"}function Sjr(e){return/^-?0\d/.test(e)}function bjr(e,t){return e<=t}function yjr(e,t){return e>=t}function DU(e,t,r,n,i,o){let s=[],a=0;for(let l=0;l<e.length;l++)for(let c=0;c<r.length;c++){if(s.length>=n)return s;let u=e[l]+t+r[c];if(!(o&&!u)){if(a+u.length>i)return s;s.push(u),a+=u.length}}return s}function Cjr(e,t,r,n){let i=e.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let s=_Ee(i[0]),a=_Ee(i[1]),l=Math.max(i[0].length,i[1].length),c=i.length===3&&i[2]!==void 0?Math.max(Math.abs(_Ee(i[2])),1):1,u=bjr;a<s&&(c*=-1,u=yjr);let f=i.some(Sjr),p=0;for(let h=s;u(h,a)&&o.length<r;h+=c){let _;if(t)_=String.fromCharCode(h),_==="\\"&&(_="");else if(_=String(h),f){let E=l-_.length;if(E>0){let b=new Array(E+1).join("0");h<0?_="-"+b+_.slice(1):_=b+_}}if(p+_.length>n)break;o.push(_),p+=_.length}return o}function EEe(e,t,r,n){let i=[""],o=!1,s=!0;for(;;){let a=AEe("{","}",e);if(!a)return DU(i,e,[""],t,r,o);let l=a.pre;if(/\$$/.test(l)){if(i=DU(i,l+"{"+a.body+"}",[""],t,r,o&&!a.post.length),s=!1,!a.post.length)break;e=a.post;continue}let c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),d=c||u,f=a.body.indexOf(",")>=0;if(!d&&!f){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+SEe+a.post,n=!0;continue}return DU(i,l+"{"+a.body+"}"+a.post,[""],t,r,o)}s&&(o=n&&!d,s=!1);let p;if(d)p=Cjr(a.body,u,t,r);else{let h=glt(a.body);if(h.length===1&&h[0]!==void 0&&(h=EEe(h[0],t,r,!1).map(Ejr),h.length===1)){if(i=DU(i,l+h[0],[""],t,r,o&&!a.post.length),!a.post.length)break;e=a.post;continue}let _=o&&!a.post.length&&!l;for(let b=0;_&&b<i.length;b++)i[b]&&(_=!1);p=[];let E=0;e:for(let b=0;b<h.length;b++){let C=EEe(h[b],t,r,!1);for(let v=0;v<C.length;v++){let R=C[v];if(!(_&&!R)){if(p.length>=t||E+R.length>r)break e;p.push(R),E+=R.length}}}}if(i=DU(i,l,p,t,r,o&&!a.post.length),!a.post.length)break;e=a.post}return i}var OU=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Tjr={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},BU=e=>e.replace(/[[\]\\-]/g,"\\$&"),Ijr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Alt=e=>e.join(""),_lt=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],o=r+1,s=!1,a=!1,l=!1,c=!1,u=r,d="";e:for(;o<e.length;){let _=e.charAt(o);if((_==="!"||_==="^")&&o===r+1){c=!0,o++;continue}if(_==="]"&&s&&!l){u=o+1;break}if(s=!0,_==="\\"&&!l){l=!0,o++;continue}if(_==="["&&!l){for(let[E,[b,C,v]]of Object.entries(Tjr))if(e.startsWith(E,o)){if(d)return["$.",!1,e.length-r,!0];o+=E.length,v?i.push(b):n.push(b),a=a||C;continue e}}if(l=!1,d){_>d?n.push(BU(d)+"-"+BU(_)):_===d&&n.push(BU(_)),d="",o++;continue}if(e.startsWith("-]",o+1)){n.push(BU(_+"-")),o+=2;continue}if(e.startsWith("-",o+1)){d=_,o+=2;continue}n.push(BU(_)),o++}if(u<o)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,e.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!c){let _=n[0].length===2?n[0].slice(-1):n[0];return[Ijr(_),!1,u-r,!1]}let f="["+(c?"^":"")+Alt(n)+"]",p="["+(c?"":"^")+Alt(i)+"]";return[n.length&&i.length?"("+f+"|"+p+")":n.length?f:p,a,u-r,!0]};var uC=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!0}={})=>r?t?e.replace(/\[([^/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?e.replace(/\[([^/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var zd,vjr=new Set(["!","?","+","*","@"]),bEe=e=>vjr.has(e),Elt=e=>bEe(e.type),xjr=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),wjr=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Rjr=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),Slt=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Njr="(?!(?:^|/)\\.\\.?(?:$|/))",iK="(?!\\.)",Djr=new Set(["[","."]),Ojr=new Set(["..","."]),Bjr=new Set("().*{}+?[]^$\\!"),Mjr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),yEe="[^/]",blt=yEe+"*?",ylt=yEe+"+?",kjr=0,Q1=class{type;#e;#t;#n=!1;#r=[];#o;#i;#l;#s=!1;#a;#d;#m=!1;id=++kjr;get depth(){return(this.#o?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#o?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(t,r,n={}){this.type=t,t&&(this.#t=!0),this.#o=r,this.#e=this.#o?this.#o.#e:this,this.#a=this.#e===this?n:this.#e.#a,this.#l=this.#e===this?[]:this.#e.#l,t==="!"&&!this.#e.#s&&this.#l.push(this),this.#i=this.#o?this.#o.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let t of this.#r)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#d!==void 0?this.#d:this.type?this.#d=this.type+"("+this.#r.map(t=>String(t)).join("|")+")":this.#d=this.#r.map(t=>String(t)).join("")}#p(){if(this!==this.#e)throw new Error("should only call on root");if(this.#s)return this;this.toString(),this.#s=!0;let t;for(;t=this.#l.pop();){if(t.type!=="!")continue;let r=t,n=r.#o;for(;n;){for(let i=r.#i+1;!n.type&&i<n.#r.length;i++)for(let o of t.#r){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#r[i])}r=n,n=r.#o}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof zd&&r.#o===this))throw new Error("invalid part: "+r);this.#r.push(r)}}toJSON(){let t=this.type===null?this.#r.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#r.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#o?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#o?.isStart())return!1;if(this.#i===0)return!0;let t=this.#o;for(let r=0;r<this.#i;r++){let n=t.#r[r];if(!(n instanceof zd&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let t=this.#o?this.#o.#r.length:0;return this.#i===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new zd(this.type,t);for(let n of this.#r)r.copyIn(n);return r}static#c(t,r,n,i,o){let s=i.maxExtglobRecursion??2,a=!1,l=!1,c=-1,u=!1;if(r.type===null){let _=n,E="";for(;_<t.length;){let b=t.charAt(_++);if(a||b==="\\"){a=!a,E+=b;continue}if(l){_===c+1?(b==="^"||b==="!")&&(u=!0):b==="]"&&!(_===c+2&&u)&&(l=!1),E+=b;continue}else if(b==="["){l=!0,c=_,u=!1,E+=b;continue}if(!i.noext&&bEe(b)&&t.charAt(_)==="("&&o<=s){r.push(E),E="";let v=new zd(b,r);_=zd.#c(t,v,_,i,o+1),r.push(v);continue}E+=b}return r.push(E),_}let d=n+1,f=new zd(null,r),p=[],h="";for(;d<t.length;){let _=t.charAt(d++);if(a||_==="\\"){a=!a,h+=_;continue}if(l){d===c+1?(_==="^"||_==="!")&&(u=!0):_==="]"&&!(d===c+2&&u)&&(l=!1),h+=_;continue}else if(_==="["){l=!0,c=d,u=!1,h+=_;continue}if(!i.noext&&bEe(_)&&t.charAt(d)==="("&&(o<=s||r&&r.#_(_))){let b=r&&r.#_(_)?0:1;f.push(h),h="";let C=new zd(_,f);f.push(C),d=zd.#c(t,C,d,i,o+b);continue}if(_==="|"){f.push(h),h="",p.push(f),f=new zd(null,r);continue}if(_===")")return h===""&&r.#r.length===0&&(r.#m=!0),f.push(h),h="",r.push(...p,f),d;h+=_}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],d}#g(t){return this.#A(t,wjr)}#A(t,r=xjr){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null)return!1;let n=t.#r[0];return!n||typeof n!="object"||n.type===null?!1:this.#_(n.type,r)}#_(t,r=Rjr){return!!r.get(this.type)?.includes(t)}#h(t,r){let n=t.#r[0],i=new zd(null,n,this.options);i.#r.push(""),n.push(i),this.#v(t,r)}#v(t,r){let n=t.#r[0];this.#r.splice(r,1,...n.#r);for(let i of n.#r)typeof i=="object"&&(i.#o=this);this.#d=void 0}#S(t){return!!Slt.get(this.type)?.has(t)}#C(t){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let r=t.#r[0];return!r||typeof r!="object"||r.type===null?!1:this.#S(r.type)}#T(t){let r=Slt.get(this.type),n=t.#r[0],i=r?.get(n.type);if(!i)return!1;this.#r=n.#r;for(let o of this.#r)typeof o=="object"&&(o.#o=this);this.type=i,this.#d=void 0,this.#m=!1}static fromGlob(t,r={}){let n=new zd(null,void 0,r);return zd.#c(t,n,0,r,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[r,n,i,o]=this.toRegExpSource();if(!(i||this.#t||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#a}toRegExpSource(t){let r=t??!!this.#a.dot;if(this.#e===this&&(this.#E(),this.#p()),!Elt(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(p=>typeof p!="string"),c=this.#r.map(p=>{let[h,_,E,b]=typeof p=="string"?zd.#y(p,this.#t,l):p.toRegExpSource(t);return this.#t=this.#t||E,this.#n=this.#n||b,h}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&Ojr.has(this.#r[0]))){let h=Djr,_=r&&h.has(c.charAt(0))||c.startsWith("\\.")&&h.has(c.charAt(2))||c.startsWith("\\.\\.")&&h.has(c.charAt(4)),E=!r&&!t&&h.has(c.charAt(0));u=_?Njr:E?iK:""}let d="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(d="(?:$|\\/)"),[u+c+d,uC(c),this.#t=!!this.#t,this.#n]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#b(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString(),c=this;return c.#r=[l],c.type=null,c.#t=void 0,[l,uC(this.toString()),!1,!1]}let s=!n||t||r||!iK?"":this.#b(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#m)a=(this.isStart()&&!r?iK:"")+ylt;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?iK:"")+blt+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,uC(o),this.#t=!!this.#t,this.#n]}#E(){if(Elt(this)){let t=0,r=!1;do{r=!0;for(let n=0;n<this.#r.length;n++){let i=this.#r[n];typeof i=="object"&&(i.#E(),this.#A(i)?(r=!1,this.#v(i,n)):this.#g(i)?(r=!1,this.#h(i,n)):this.#C(i)&&(r=!1,this.#T(i)))}}while(!r&&++t<10)}else for(let t of this.#r)typeof t=="object"&&t.#E();this.#d=void 0}#b(t){return this.#r.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,o,s]=r.toRegExpSource(t);return this.#n=this.#n||s,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#y(t,r,n=!1){let i=!1,o="",s=!1,a=!1;for(let l=0;l<t.length;l++){let c=t.charAt(l);if(i){i=!1,o+=(Bjr.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?ylt:blt,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,d,f,p]=_lt(t,l);if(f){o+=u,s=s||d,l+=f-1,r=r||p;continue}}if(c==="?"){o+=yEe,r=!0;continue}o+=Mjr(c)}return[o,uC(t),!!r,s]}};zd=Q1;var CEe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var bc=(e,t,r={})=>(OU(t),!r.nocomment&&t.charAt(0)==="#"?!1:new CB(t,r).match(e)),Ljr=/^\*+([^+@!?*[(]*)$/,Pjr=e=>t=>!t.startsWith(".")&&t.endsWith(e),Fjr=e=>t=>t.endsWith(e),Qjr=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Ujr=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Gjr=/^\*+\.\*+$/,Hjr=e=>!e.startsWith(".")&&e.includes("."),$jr=e=>e!=="."&&e!==".."&&e.includes("."),qjr=/^\.\*+$/,Yjr=e=>e!=="."&&e!==".."&&e.startsWith("."),zjr=/^\*+$/,Vjr=e=>e.length!==0&&!e.startsWith("."),Wjr=e=>e.length!==0&&e!=="."&&e!=="..",jjr=/^\?+([^+@!?*[(]*)?$/,Kjr=([e,t=""])=>{let r=Ilt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Jjr=([e,t=""])=>{let r=vlt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Zjr=([e,t=""])=>{let r=vlt([e]);return t?n=>r(n)&&n.endsWith(t):r},Xjr=([e,t=""])=>{let r=Ilt([e]);return t?n=>r(n)&&n.endsWith(t):r},Ilt=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},vlt=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},xlt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Clt={win32:{sep:"\\"},posix:{sep:"/"}},eKr=xlt==="win32"?Clt.win32.sep:Clt.posix.sep;bc.sep=eKr;var fu=Symbol("globstar **");bc.GLOBSTAR=fu;var tKr="[^/]",rKr=tKr+"*?",nKr="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",iKr="(?:(?!(?:\\/|^)\\.).)*?",oKr=(e,t={})=>r=>bc(r,e,t);bc.filter=oKr;var Pf=(e,t={})=>Object.assign({},e,t),sKr=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return bc;let t=bc;return Object.assign((n,i,o={})=>t(n,i,Pf(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,Pf(e,o))}static defaults(i){return t.defaults(Pf(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,Pf(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,Pf(e,o))}},unescape:(n,i={})=>t.unescape(n,Pf(e,i)),escape:(n,i={})=>t.escape(n,Pf(e,i)),filter:(n,i={})=>t.filter(n,Pf(e,i)),defaults:n=>t.defaults(Pf(e,n)),makeRe:(n,i={})=>t.makeRe(n,Pf(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,Pf(e,i)),match:(n,i,o={})=>t.match(n,i,Pf(e,o)),sep:t.sep,GLOBSTAR:fu})};bc.defaults=sKr;var wlt=(e,t={})=>(OU(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:hlt(e,{max:t.braceExpandMax}));bc.braceExpand=wlt;var aKr=(e,t={})=>new CB(e,t).makeRe();bc.makeRe=aKr;var lKr=(e,t,r={})=>{let n=new CB(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};bc.match=lKr;var Tlt=/[?*]|[+@!]\(.*?\)|\[|\]/,cKr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),CB=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){OU(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||xlt,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((o,s,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=o[0]===""&&o[1]===""&&(o[2]==="?"||!Tlt.test(o[2]))&&!Tlt.test(o[3]),c=/^[a-z]:/i.test(o[0]);if(l)return[...o.slice(0,4),...o.slice(4).map(u=>this.parse(u))];if(c)return[o[0],...o.slice(1).map(u=>this.parse(u))]}return o.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let s=this.set[o];s[0]===""&&s[1]===""&&this.globParts[o][2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3])&&(s[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n of t)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,i)=>{let o=n[n.length-1];return i==="**"&&o==="**"?n:i===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let o=t[i];i===1&&o===""&&t[0]===""||(o==="."||o==="")&&(r=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let s=i;for(;n[s+1]==="**";)s++;s>i&&n.splice(i+1,s-i);let a=n[i+1],l=n[i+2],c=n[i+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",t.push(u),i--}if(!this.preserveMultipleSlashes){for(let s=1;s<n.length-1;s++){let a=n[s];s===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(s,1),s--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let s=n[o-1];if(s&&s!=="."&&s!==".."&&s!=="**"){r=!0;let l=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...l),n.length===0&&n.push(""),o-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let i=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(i){t[r]=[],t[n]=i;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let i=0,o=0,s=[],a="";for(;i<t.length&&o<r.length;)if(t[i]===r[o])s.push(a==="b"?r[o]:t[i]),i++,o++;else if(n&&t[i]==="**"&&r[o]===t[i+1])s.push(t[i]),i++;else if(n&&r[o]==="**"&&t[i]===r[o+1])s.push(r[o]),o++;else if(t[i]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",s.push(t[i]),i++,o++}else if(r[o]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(a==="a")return!1;a="b",s.push(r[o]),i++,o++}else return!1;return t.length===r.length&&s}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let i=0,o=0;if(this.isWindows){let a=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),l=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),c=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),u=!c&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),d=l?3:a?0:void 0,f=u?3:c?0:void 0;if(typeof d=="number"&&typeof f=="number"){let[p,h]=[t[d],r[f]];p.toLowerCase()===h.toLowerCase()&&(r[f]=p,o=f,i=d)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(fu)?this.#e(t,r,n,i,o):this.#n(t,r,n,i,o)}#e(t,r,n,i,o){let s=r.indexOf(fu,o),a=r.lastIndexOf(fu),[l,c,u]=n?[r.slice(o,s),r.slice(s+1),[]]:[r.slice(o,s),r.slice(s+1,a),r.slice(a+1)];if(l.length){let C=t.slice(i,i+l.length);if(!this.#n(C,l,n,0,0))return!1;i+=l.length,o+=l.length}let d=0;if(u.length){if(u.length+i>t.length)return!1;let C=t.length-u.length;if(this.#n(t,u,n,C,0))d=u.length;else{if(t[t.length-1]!==""||i+u.length===t.length||(C--,!this.#n(t,u,n,C,0)))return!1;d=u.length+1}}if(!c.length){let C=!!d;for(let v=i;v<t.length-d;v++){let R=String(t[v]);if(C=!0,R==="."||R===".."||!this.options.dot&&R.startsWith("."))return!1}return n||C}let f=[[[],0]],p=f[0],h=0,_=[0];for(let C of c)C===fu?(_.push(h),p=[[],0],f.push(p)):(p[0].push(C),h++);let E=f.length-1,b=t.length-d;for(let C of f)C[1]=b-(_[E--]+C[0].length);return!!this.#t(t,f,i,0,n,0,!!d)}#t(t,r,n,i,o,s,a){let l=r[i];if(!l){for(let d=n;d<t.length;d++){a=!0;let f=t[d];if(f==="."||f===".."||!this.options.dot&&f.startsWith("."))return!1}return a}let[c,u]=l;for(;n<=u;){if(this.#n(t.slice(0,n+c.length),c,o,n,0)&&s<this.maxGlobstarRecursion){let p=this.#t(t,r,n+c.length,i+1,o,s+1,a);if(p!==!1)return p}let f=t[n];if(f==="."||f===".."||!this.options.dot&&f.startsWith("."))return!1;n++}return o||null}#n(t,r,n,i,o){let s,a,l,c;for(s=i,a=o,c=t.length,l=r.length;s<c&&a<l;s++,a++){this.debug("matchOne loop");let u=r[a],d=t[s];if(this.debug(r,u,d),u===!1||u===fu)return!1;let f;if(typeof u=="string"?(f=d===u,this.debug("string match",u,d,f)):(f=u.test(d),this.debug("pattern match",u,d,f)),!f)return!1}if(s===c&&a===l)return!0;if(s===c)return n;if(a===l)return s===c-1&&t[s]==="";throw new Error("wtf?")}braceExpand(){return wlt(this.pattern,this.options)}parse(t){OU(t);let r=this.options;if(t==="**")return fu;if(t==="")return"";let n,i=null;(n=t.match(zjr))?i=r.dot?Wjr:Vjr:(n=t.match(Ljr))?i=(r.nocase?r.dot?Ujr:Qjr:r.dot?Fjr:Pjr)(n[1]):(n=t.match(jjr))?i=(r.nocase?r.dot?Jjr:Kjr:r.dot?Zjr:Xjr)(n):(n=t.match(Gjr))?i=r.dot?$jr:Hjr:(n=t.match(qjr))&&(i=Yjr);let o=Q1.fromGlob(t,this.options).toMMPattern();return i&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:i}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?rKr:r.dot?nKr:iKr,i=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let c=l.map(d=>{if(d instanceof RegExp)for(let f of d.flags.split(""))i.add(f);return typeof d=="string"?cKr(d):d===fu?fu:d._src});c.forEach((d,f)=>{let p=c[f+1],h=c[f-1];d!==fu||h===fu||(h===void 0?p!==void 0&&p!==fu?c[f+1]="(?:\\/|"+n+"\\/)?"+p:c[f]=n:p===void 0?c[f-1]=h+"(?:\\/|\\/"+n+")?":p!==fu&&(c[f-1]=h+"(?:\\/|\\/"+n+"\\/)"+p,c[f+1]=fu))});let u=c.filter(d=>d!==fu);if(this.partial&&u.length>=1){let d=[];for(let f=1;f<=u.length;f++)d.push(u.slice(0,f).join("/"));return"(?:"+d.join("|")+")"}return u.join("/")}).join("|"),[s,a]=t.length>1?["(?:",")"]:["",""];o="^"+s+o+a+"$",this.partial&&(o="^(?:\\/|"+s+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let o=this.set;this.debug(this.pattern,"set",o);let s=i[i.length-1];if(!s)for(let a=i.length-2;!s&&a>=0;a--)s=i[a];for(let a of o){let l=i;if(n.matchBase&&a.length===1&&(l=[s]),this.matchOne(l,a,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return bc.defaults(t).Minimatch}};bc.AST=Q1;bc.Minimatch=CB;bc.escape=CEe;bc.unescape=uC;var Dlt=Ie(NU(),1);mr();Fe();Te();qu();import{readFile as Rlt}from"fs/promises";import{existsSync as TEe,readdirSync as uKr,statSync as dKr}from"fs";import{join as IEe,relative as Olt}from"path";import{homedir as pKr}from"os";function Nlt(e){try{let t=(0,Dlt.default)(e),r=t.data.paths,n=[];return typeof r=="string"?n=r.split(",").map(i=>i.trim()).filter(Boolean):Array.isArray(r)&&(n=r.filter(i=>typeof i=="string")),{paths:n,content:t.content.trim()}}catch(t){return Ee(t),{paths:[],content:e.trim()}}}function mKr(e,t){return t.length===0?!0:t.some(r=>{try{return bc(e,r,{matchBase:!0,dot:!0})}catch(n){return Ee(n),!1}})}function vEe(e){let t=[];try{if(!TEe(e))return t;let r=uKr(e);for(let n of r){let i=IEe(e,n),o=dKr(i);o.isDirectory()?t.push(...vEe(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){Ee(r)}return t}async function oK(){let e=[];try{let t=IEe(pKr(),bn,"rules");if(TEe(t)){let r=vEe(t);for(let n of r)try{let i=await Rlt(n,"utf-8"),{paths:o,content:s}=Nlt(i);o.length>0&&e.push({filePath:n,content:s,paths:o,isProjectRule:!1})}catch(i){Ee(i)}}}catch(t){Ee(t)}try{let t=IEe(De(),bn,"rules");if(TEe(t)){let r=vEe(t);for(let n of r)try{let i=await Rlt(n,"utf-8"),{paths:o,content:s}=Nlt(i);o.length>0&&e.push({filePath:Olt(De(),n),content:s,paths:o,isProjectRule:!0})}catch(i){Ee(i)}}}catch(t){Ee(t)}return e}function Blt(e,t){e=Q7(e);let r=Q7(De()),n=e.startsWith(r)?Olt(r,e):e;return t.filter(i=>mKr(n,i.paths))}function Mlt(e){return e.length===0?"":e.map(r=>{let n=r.isProjectRule?"project instructions, checked into the codebase":"user's private global instructions for all projects";return`Contents of ${r.filePath} (${n}):
|
|
656
656
|
|
|
657
657
|
${r.content}`}).join(`
|
|
658
658
|
|
|
@@ -753,7 +753,7 @@ data: ${JSON.stringify(P)}
|
|
|
753
753
|
`);a=O.pop()||"";for(let P of O){let H=P.trim();if(!(!H||H==="data: [DONE]"))if(H.startsWith("data: ")){let Q=H.slice(6);try{let V=JSON.parse(Q);R(V)}catch(V){this.logger&&this.logger.error({err:V,line:H},"Failed to parse Gemini SSE chunk")}}else try{let Q=JSON.parse(H);R(Q)}catch{}}};(async()=>{try{for(;;){let{value:O,done:P}=await s.read();if(P)break;a+=n.decode(O,{stream:!0}),D()}v()}catch(O){o.error(O)}})()}})}convertGeminiResponseToAnthropic(t){this.logger&&this.logger.debug({response:t},"Original Gemini response");try{if(!t.candidates||!t.candidates[0])throw new Error("No candidates found in Gemini response");let r=t.candidates[0],n=[];r.content&&r.content.parts&&r.content.parts.forEach(o=>{if(o.text&&n.push({type:"text",text:o.text}),o.functionCall){let s=`toolu_${zB()}`,a=o.functionCall.thoughtSignature||o.functionCall.thought_signature||null;n.push({type:"tool_use",id:s,name:o.functionCall.name,input:o.functionCall.args||{},thought_signature:a})}}),r.groundingMetadata&&(this.logger&&this.logger.debug({groundingMetadata:r.groundingMetadata},"Processing grounding metadata"),r.groundingMetadata.webSearchQueries&&n.push({type:"text",text:`
|
|
754
754
|
|
|
755
755
|
[Search queries used: ${r.groundingMetadata.webSearchQueries.join(", ")}]`}));let i={id:`msg_${Math.random().toString(36).slice(2)}`,type:"message",role:"assistant",model:t.modelVersion||"gemini",content:n,stop_reason:r.finishReason?r.finishReason==="STOP"&&n.some(o=>o.type==="tool_use")?"tool_use":this.mapGeminiFinishReason(r.finishReason):"end_turn",stop_sequence:null,usage:{input_tokens:t.usageMetadata?.promptTokenCount||0,output_tokens:t.usageMetadata?.candidatesTokenCount||0}};return this.logger&&this.logger.debug({result:i},"Conversion complete, final Anthropic response"),i}catch{throw ktn(`Provider error: ${JSON.stringify(t)}`,500,"provider_error")}}mapGeminiFinishReason(t){switch(t){case"STOP":return"end_turn";case"MAX_TOKENS":return"max_tokens";case"SAFETY":case"RECITATION":return"stop_sequence";default:return"end_turn"}}},Pbe=new Lbe;var JEt=Ie(WEt(),1);Jt();wo();function Th(e){return e?typeof e.entries=="function"?Object.fromEntries(e.entries()):{...e}:{}}function jEt(e){let t=String(e?.["x-thinking-level"]??"medium").toLowerCase();return["off","low","medium","high"].includes(t)?t:"medium"}function jAn(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t}}function KAn(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t,summary:"auto"}}function JAn(e,t="chat"){let r={request:{},response:{},openai:{request:{},response:{}}};return r.request.model=e.request.body.model,r.request.messages=e.request.body.messages,r.request.system=e.request.body.system,r.response.content=e.response.body.content,r.response.usage=e.response.body?.usage,t==="responses"?(r.openai.request.model=e.openai.request.body.model,r.openai.request.input=e.openai.request.body.input,r.openai.response.output=e.openai.response.body?.output,r.openai.response.usage=e.openai.response.body?.usage):(r.openai.request.model=e.openai.request.body.model,r.openai.request.messages=e.openai.request.body.messages,r.openai.response.choices=e.openai.response.body.choices,r.openai.response.usage=e.openai.response.body?.usage),r}function R4(e,t,r){BY(t,e),MY(t,JAn(e,r),r)}function MM(e){let t=[],r=e.getReader(),n,i=new Promise(l=>n=l),o=!1,s=()=>{o||(o=!0,n(Buffer.concat(t).toString("utf8")))};return{stream:new ReadableStream({async pull(l){try{let{done:c,value:u}=await r.read();if(c){l.close(),s();return}t.push(u),l.enqueue(u)}catch(c){l.error(c),s()}},cancel(l){r.cancel(l).catch(()=>{}),s()}}),done:i}}function N4(e){let t=new Headers(e);return t.delete("content-encoding"),t.delete("content-length"),t.delete("transfer-encoding"),t}function dIe(e,t,r,n,i){let o;try{o={type:"error",error:{type:"api_error",message:JSON.parse(i).error?.message??`${e}: ${n}`,code:`${t}_${r}_ERROR`}}}catch{o={type:"error",error:{type:"api_error",message:`${e}: ${n}`,code:`${t}_${r}_ERROR`}}}return new Response(JSON.stringify(o),{status:r,statusText:n,headers:{"Content-Type":"application/json"}})}var KEt=["/v1/messages"];function pIe(e){let t;try{typeof e=="string"?t=new wx(e):e instanceof wx?t=e:t=new wx(e.url)}catch{return""}let r=t.pathname;for(let n of KEt){let i=r.indexOf(n);if(i!==-1)return t.origin+r.slice(0,i)}return t.origin}function UX(e,t){let r=typeof e=="string"?e:e instanceof wx?e.toString():e.url,n;try{n=new wx(r).pathname}catch{return!1}return KEt.some(i=>n.includes(i))&&(t.method==="POST"||t.method==="post")}function ZAn(e){return async(t,r)=>{if(!UX(t,r))return e(t,r);let n=JSON.parse(r.body),i=await GJ.transformRequestOut(n),o=pIe(t)+"/chat/completions",s=Th(r.headers),a=s.authorization??s.Authorization??"";jAn(i,jEt(s));let l=await e(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:a},body:JSON.stringify(i),signal:r.signal});if(!l.ok){let E=await l.text();return X(`OpenAI Chat Completions API error: ${l.status}`,{url:o,errorResponse:E}),dIe("OpenAI Chat Completions API error","OPENROUTER",l.status,l.statusText,E)}let c=n.stream===!0,u=s["x-agent-id"],d={request:{url:o,method:r.method,headers:s,body:n},response:{status:l.status,statusText:l.statusText,headers:Th(l.headers)},openai:{request:{body:i},response:{}}};if(!c){let E=await l.text(),b=new Response(E,{status:l.status,statusText:l.statusText,headers:N4(l.headers)}),C=await GJ.transformResponseIn(b,n),v=await C.text();try{R4({...d,openai:{...d.openai,response:{body:JSON.parse(E)}},response:{...d.response,body:JSON.parse(v)}},u)}catch(R){X("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u975E\u6D41\u5F0F):",R)}return new Response(v,{status:C.status,statusText:C.statusText,headers:C.headers})}let f=MM(l.body),p=new Response(f.stream,{status:l.status,statusText:l.statusText,headers:N4(l.headers)}),h=await GJ.transformResponseIn(p,n),_=MM(h.body);return Promise.all([f.done,_.done]).then(async([E,b])=>{try{R4({...d,openai:{...d.openai,response:{body:await Tut(E)}},response:{...d.response,body:await b9(b)}},u)}catch(C){X("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u6D41\u5F0F):"+C?.stack)}}).catch(E=>X("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Chat):"+E)),new Response(_.stream,{status:h.status,statusText:h.statusText,headers:h.headers})}}function XAn(e){return async(t,r)=>{if(!UX(t,r))return e(t,r);let n=JSON.parse(r.body),i=await HJ.transformRequestOut(n),o=Th(r.headers);KAn(i,jEt(o));let s=JSON.stringify(i),l=pIe(t)+"/responses",c=o.authorization??o.Authorization??"";if(!c)return new Response(JSON.stringify({type:"error",error:{type:"api_error",message:"Missing Authorization header",code:"RESPONSES_AUTH_MISSING"}}),{status:401,headers:{"Content-Type":"application/json"}});let u=await e(l,{method:"POST",headers:{"Content-Type":"application/json",Authorization:c,"x-api-key":c.replace(/^Bearer\s+/i,"").trim()},body:s,signal:r.signal});if(!u.ok){let C=await u.text();return X(`OpenAI Responses API error: ${u.status} ${u.statusText}`,{url:l,status:u.status,errorResponse:C}),dIe("OpenAI Responses API error","RESPONSES",u.status,u.statusText,C)}let d=n.stream===!0,f=o["x-agent-id"],p={request:{url:l,method:r.method,headers:o,body:n},response:{status:u.status,statusText:u.statusText,headers:Th(u.headers)},openai:{request:{body:i},response:{}}};if(!d){let C=await u.text(),v=new Response(C,{status:u.status,statusText:u.statusText,headers:N4(u.headers)}),R=await HJ.transformResponseIn(v,n),D=await R.text();try{R4({...p,openai:{...p.openai,response:{body:JSON.parse(C)}},response:{...p.response,body:JSON.parse(D)}},f,"responses")}catch(O){X("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u975E\u6D41\u5F0F):",O)}return new Response(D,{status:R.status,statusText:R.statusText,headers:R.headers})}let h=MM(u.body),_=new Response(h.stream,{status:u.status,statusText:u.statusText,headers:N4(u.headers)}),E=await HJ.transformResponseIn(_,n),b=MM(E.body);return Promise.all([h.done,b.done]).then(async([C,v])=>{try{R4({...p,openai:{...p.openai,response:{body:await Cut(C)}},response:{...p.response,body:await b9(v)}},f,"responses")}catch(R){X("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u6D41\u5F0F):"+R?.stack)}}).catch(C=>X("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Responses):"+C)),new Response(b.stream,{status:E.status,statusText:E.statusText,headers:E.headers})}}function e_n(e){return async(t,r)=>{if(!UX(t,r))return e(t,r);let n=JSON.parse(r.body),i=Th(r.headers),o=await Pbe.transformRequestOut(n),s=JSON.stringify(o),a=pIe(t)+`/models/${n.model}:streamGenerateContent?alt=sse`,l=i.authorization??i.Authorization??"",c;try{c=await e(a,{method:"POST",headers:{"Content-Type":"application/json","x-goog-api-key":String(l).replace(/^Bearer\s+/i,"").trim()},body:s,signal:r.signal})}catch(b){throw X("gemini request error:",b),b}if(!c.ok){let b=await c.text();return X(`Gemini API error response: ${c.status} ${c.statusText}`,{url:a,status:c.status,errorResponse:b}),dIe("Gemini API error","Gemini",c.status,c.statusText,b)}let u=n.stream===!0,d=i["x-agent-id"],f={request:{url:a,method:r.method,headers:Th(r.headers),body:n},response:{status:c.status,statusText:c.statusText,headers:Th(c.headers)},openai:{request:{body:o},response:{}}},p=MM(c.body),h=new Response(p.stream,{status:c.status,statusText:c.statusText,headers:N4(c.headers)}),_=await Pbe.transformResponseIn(h),E=MM(_.body);return Promise.all([p.done,E.done]).then(async([b,C])=>{try{let v=u?Iut(b):JSON.parse(b),R=u?await b9(C):JSON.parse(C);R4({...f,openai:{...f.openai,response:{body:v}},response:{...f.response,body:R}},d)}catch(v){X("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Gemini):"+v?.stack)}}).catch(b=>X("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Gemini):"+b)),new Response(E.stream,{status:_.status,statusText:_.statusText,headers:_.headers})}}function t_n(e){return async(t,r)=>{if(!UX(t,r))return e(t,r);let n=r.body;if(r.body)try{let d=JSON.parse(r.body);n=JSON.stringify(d)}catch{}let i=Th(r.headers);["1","true"].includes(String(process.env.HAWA_CODE_X_API_KEY_DISABLED??"").toLowerCase())&&(delete i["x-api-key"],delete i["X-API-Key"]),["1","true"].includes(String(process.env.HAWA_CODE_AUTH_DISABLED??"").toLowerCase())&&(delete i.authorization,delete i.Authorization),delete i["content-length"];let a=await e(t,{method:r.method,headers:i,body:n,signal:r.signal});if(!a.ok){let d=await a.text();X(`API error response: ${a.status} ${a.statusText}`,{url:typeof t=="string"?t:t instanceof wx?t.toString():t.url,status:a.status,errorResponse:d});let f;try{let p=JSON.parse(d);f={type:"error",error:{type:"api_error",message:p.error?.message||p.message||`API error: ${a.statusText}`,code:p.error?.code||p.code||`API_${a.status}_ERROR`}},p.error?.details&&(f.error.details=p.error.details)}catch{f={type:"error",error:{type:"api_error",message:`API error: ${a.statusText}`,code:`API_${a.status}_ERROR`}}}return new Response(JSON.stringify(f),{status:a.status,statusText:a.statusText,headers:{"Content-Type":"application/json"}})}let l=a.clone(),c=!(Object.hasOwn(JSON.parse(n),"stream")&&!JSON.parse(n).stream),u={request:{url:typeof t=="string"?t:t instanceof wx?t.toString():t.url,method:r.method,headers:Th(r.headers),body:JSON.parse(n)},response:{status:a.status,statusText:a.statusText,headers:Th(a.headers)}};return(async()=>{if(c){let p=await a.text();u.response.body=await b9(p)}else u.response.body=await a.json();let f=Th(r.headers)["x-agent-id"];BY(f,u),MY(f,{request:u.request.body.messages,response:u.response.body.content,usage:u.response.body?.usage})})().catch(d=>X(`\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF:
|
|
756
|
-
Stack trace: `+d.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var QX=null,uIe=!1;function r_n(){QX=null,uIe=!1}Tt.on("proxy:changed",r_n);function n_n(){if(uIe)return QX;if(uIe=!0,We().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(QX=new JEt.ProxyAgent({uri:e}),St(`[proxy] using proxy: ${e}`)),QX}function i_n(){let e=n_n();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function GX(e){let t=e||process.env.API_TYPE,r=i_n();switch(t){case"openai":return ZAn(r);case"openai-responses":return XAn(r);case"gemini":return e_n(r);default:return t_n(r)}}jA();Te();Fe();Fe();var mIe="2.8.
|
|
756
|
+
Stack trace: `+d.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var QX=null,uIe=!1;function r_n(){QX=null,uIe=!1}Tt.on("proxy:changed",r_n);function n_n(){if(uIe)return QX;if(uIe=!0,We().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(QX=new JEt.ProxyAgent({uri:e}),St(`[proxy] using proxy: ${e}`)),QX}function i_n(){let e=n_n();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function GX(e){let t=e||process.env.API_TYPE,r=i_n();switch(t){case"openai":return ZAn(r);case"openai-responses":return XAn(r);case"gemini":return e_n(r);default:return t_n(r)}}jA();Te();Fe();Fe();var mIe="2.8.8";globalThis.MACRO={VERSION:mIe,PACKAGE_URL:`@dahawa/${Fi}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var HX=process.env.HAWA_CODE_USER_AGENT||`${Fi}/${mIe} (${process.env.USER_TYPE})`;Te();Te();cr();function Au(e,t){let r=[],n=new Set;return e.filter(i=>i.type!=="progress"&&i.type!=="reminder").forEach(i=>{switch(i.type){case"user":{let o=Yp(r);if(o?.type==="user"){r[r.length-1]=ZEt(o,i);return}r.push(i);return}case"assistant":r.push(i);return;case"insert":{let o=Yp(r);o?.type==="user"&&(r[r.length-1]=o_n(o,i));return}case"path_rules":{let o=t?.pathRules;if(!o)return;let s=i.content.paths.filter(u=>!n.has(u));if(s.length===0)return;let a=s.map(u=>o.get(u)).filter(u=>u!==void 0);if(s.forEach(u=>n.add(u)),a.length===0)return;let l=Bt([{type:"text",text:`<system-rules>
|
|
757
757
|
${Mlt(a)}
|
|
758
758
|
</system-rules>`}]),c=Yp(r);c?.type==="user"?r[r.length-1]=ZEt(c,l,{skipTrailingSystemReminders:!0}):r.push(l);return}}}),r}function o_n(e,t){return{...e,message:{...e.message,content:a_n(e.message.content,s_n(t.content.content))}}}function s_n(e){return`
|
|
759
759
|
<system-reminder>
|
package/hands.js
CHANGED
|
@@ -622,7 +622,7 @@ data: ${JSON.stringify(z)}
|
|
|
622
622
|
`);a=M.pop()||"";for(let z of M){let Y=z.trim();if(!(!Y||Y==="data: [DONE]"))if(Y.startsWith("data: ")){let q=Y.slice(6);try{let K=JSON.parse(q);D(K)}catch(K){this.logger&&this.logger.error({err:K,line:Y},"Failed to parse Gemini SSE chunk")}}else try{let q=JSON.parse(Y);D(q)}catch{}}};(async()=>{try{for(;;){let{value:M,done:z}=await s.read();if(z)break;a+=n.decode(M,{stream:!0}),B()}T()}catch(M){o.error(M)}})()}})}convertGeminiResponseToAnthropic(t){this.logger&&this.logger.debug({response:t},"Original Gemini response");try{if(!t.candidates||!t.candidates[0])throw new Error("No candidates found in Gemini response");let r=t.candidates[0],n=[];r.content&&r.content.parts&&r.content.parts.forEach(o=>{if(o.text&&n.push({type:"text",text:o.text}),o.functionCall){let s=`toolu_${NN()}`,a=o.functionCall.thoughtSignature||o.functionCall.thought_signature||null;n.push({type:"tool_use",id:s,name:o.functionCall.name,input:o.functionCall.args||{},thought_signature:a})}}),r.groundingMetadata&&(this.logger&&this.logger.debug({groundingMetadata:r.groundingMetadata},"Processing grounding metadata"),r.groundingMetadata.webSearchQueries&&n.push({type:"text",text:`
|
|
623
623
|
|
|
624
624
|
[Search queries used: ${r.groundingMetadata.webSearchQueries.join(", ")}]`}));let i={id:`msg_${Math.random().toString(36).slice(2)}`,type:"message",role:"assistant",model:t.modelVersion||"gemini",content:n,stop_reason:r.finishReason?r.finishReason==="STOP"&&n.some(o=>o.type==="tool_use")?"tool_use":this.mapGeminiFinishReason(r.finishReason):"end_turn",stop_sequence:null,usage:{input_tokens:t.usageMetadata?.promptTokenCount||0,output_tokens:t.usageMetadata?.candidatesTokenCount||0}};return this.logger&&this.logger.debug({result:i},"Conversion complete, final Anthropic response"),i}catch{throw t3r(`Provider error: ${JSON.stringify(t)}`,500,"provider_error")}}mapGeminiFinishReason(t){switch(t){case"STOP":return"end_turn";case"MAX_TOKENS":return"max_tokens";case"SAFETY":case"RECITATION":return"stop_sequence";default:return"end_turn"}}},q_e=new $_e;var Rpt=we(xpt(),1);Zt();rs();function rg(e){return e?typeof e.entries=="function"?Object.fromEntries(e.entries()):{...e}:{}}function wpt(e){let t=String(e?.["x-thinking-level"]??"medium").toLowerCase();return["off","low","medium","high"].includes(t)?t:"medium"}function gXr(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t}}function AXr(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t,summary:"auto"}}function hXr(e,t="chat"){let r={request:{},response:{},openai:{request:{},response:{}}};return r.request.model=e.request.body.model,r.request.messages=e.request.body.messages,r.request.system=e.request.body.system,r.response.content=e.response.body.content,r.response.usage=e.response.body?.usage,t==="responses"?(r.openai.request.model=e.openai.request.body.model,r.openai.request.input=e.openai.request.body.input,r.openai.response.output=e.openai.response.body?.output,r.openai.response.usage=e.openai.response.body?.usage):(r.openai.request.model=e.openai.request.body.model,r.openai.request.messages=e.openai.request.body.messages,r.openai.response.choices=e.openai.response.body.choices,r.openai.response.usage=e.openai.response.body?.usage),r}function bU(e,t,r){mG(t,e),gG(t,hXr(e,r),r)}function _B(e){let t=[],r=e.getReader(),n,i=new Promise(l=>n=l),o=!1,s=()=>{o||(o=!0,n(Buffer.concat(t).toString("utf8")))};return{stream:new ReadableStream({async pull(l){try{let{done:c,value:u}=await r.read();if(c){l.close(),s();return}t.push(u),l.enqueue(u)}catch(c){l.error(c),s()}},cancel(l){r.cancel(l).catch(()=>{}),s()}}),done:i}}function CU(e){let t=new Headers(e);return t.delete("content-encoding"),t.delete("content-length"),t.delete("transfer-encoding"),t}function h1e(e,t,r,n,i){let o;try{o={type:"error",error:{type:"api_error",message:JSON.parse(i).error?.message??`${e}: ${n}`,code:`${t}_${r}_ERROR`}}}catch{o={type:"error",error:{type:"api_error",message:`${e}: ${n}`,code:`${t}_${r}_ERROR`}}}return new Response(JSON.stringify(o),{status:r,statusText:n,headers:{"Content-Type":"application/json"}})}var Dpt=["/v1/messages"];function E1e(e){let t;try{typeof e=="string"?t=new _T(e):e instanceof _T?t=e:t=new _T(e.url)}catch{return""}let r=t.pathname;for(let n of Dpt){let i=r.indexOf(n);if(i!==-1)return t.origin+r.slice(0,i)}return t.origin}function vJ(e,t){let r=typeof e=="string"?e:e instanceof _T?e.toString():e.url,n;try{n=new _T(r).pathname}catch{return!1}return Dpt.some(i=>n.includes(i))&&(t.method==="POST"||t.method==="post")}function EXr(e){return async(t,r)=>{if(!vJ(t,r))return e(t,r);let n=JSON.parse(r.body),i=await xW.transformRequestOut(n),o=E1e(t)+"/chat/completions",s=rg(r.headers),a=s.authorization??s.Authorization??"";gXr(i,wpt(s));let l=await e(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:a},body:JSON.stringify(i),signal:r.signal});if(!l.ok){let y=await l.text();return V(`OpenAI Chat Completions API error: ${l.status}`,{url:o,errorResponse:y}),h1e("OpenAI Chat Completions API error","OPENROUTER",l.status,l.statusText,y)}let c=n.stream===!0,u=s["x-agent-id"],f={request:{url:o,method:r.method,headers:s,body:n},response:{status:l.status,statusText:l.statusText,headers:rg(l.headers)},openai:{request:{body:i},response:{}}};if(!c){let y=await l.text(),C=new Response(y,{status:l.status,statusText:l.statusText,headers:CU(l.headers)}),I=await xW.transformResponseIn(C,n),T=await I.text();try{bU({...f,openai:{...f.openai,response:{body:JSON.parse(y)}},response:{...f.response,body:JSON.parse(T)}},u)}catch(D){V("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u975E\u6D41\u5F0F):",D)}return new Response(T,{status:I.status,statusText:I.statusText,headers:I.headers})}let g=_B(l.body),m=new Response(g.stream,{status:l.status,statusText:l.statusText,headers:CU(l.headers)}),A=await xW.transformResponseIn(m,n),h=_B(A.body);return Promise.all([g.done,h.done]).then(async([y,C])=>{try{bU({...f,openai:{...f.openai,response:{body:await nit(y)}},response:{...f.response,body:await pF(C)}},u)}catch(I){V("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u6D41\u5F0F):"+I?.stack)}}).catch(y=>V("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Chat):"+y)),new Response(h.stream,{status:A.status,statusText:A.statusText,headers:A.headers})}}function _Xr(e){return async(t,r)=>{if(!vJ(t,r))return e(t,r);let n=JSON.parse(r.body),i=await wW.transformRequestOut(n),o=rg(r.headers);AXr(i,wpt(o));let s=JSON.stringify(i),l=E1e(t)+"/responses",c=o.authorization??o.Authorization??"";if(!c)return new Response(JSON.stringify({type:"error",error:{type:"api_error",message:"Missing Authorization header",code:"RESPONSES_AUTH_MISSING"}}),{status:401,headers:{"Content-Type":"application/json"}});let u=await e(l,{method:"POST",headers:{"Content-Type":"application/json",Authorization:c,"x-api-key":c.replace(/^Bearer\s+/i,"").trim()},body:s,signal:r.signal});if(!u.ok){let I=await u.text();return V(`OpenAI Responses API error: ${u.status} ${u.statusText}`,{url:l,status:u.status,errorResponse:I}),h1e("OpenAI Responses API error","RESPONSES",u.status,u.statusText,I)}let f=n.stream===!0,g=o["x-agent-id"],m={request:{url:l,method:r.method,headers:o,body:n},response:{status:u.status,statusText:u.statusText,headers:rg(u.headers)},openai:{request:{body:i},response:{}}};if(!f){let I=await u.text(),T=new Response(I,{status:u.status,statusText:u.statusText,headers:CU(u.headers)}),D=await wW.transformResponseIn(T,n),B=await D.text();try{bU({...m,openai:{...m.openai,response:{body:JSON.parse(I)}},response:{...m.response,body:JSON.parse(B)}},g,"responses")}catch(M){V("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u975E\u6D41\u5F0F):",M)}return new Response(B,{status:D.status,statusText:D.statusText,headers:D.headers})}let A=_B(u.body),h=new Response(A.stream,{status:u.status,statusText:u.statusText,headers:CU(u.headers)}),y=await wW.transformResponseIn(h,n),C=_B(y.body);return Promise.all([A.done,C.done]).then(async([I,T])=>{try{bU({...m,openai:{...m.openai,response:{body:await rit(I)}},response:{...m.response,body:await pF(T)}},g,"responses")}catch(D){V("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u6D41\u5F0F):"+D?.stack)}}).catch(I=>V("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Responses):"+I)),new Response(C.stream,{status:y.status,statusText:y.statusText,headers:y.headers})}}function yXr(e){return async(t,r)=>{if(!vJ(t,r))return e(t,r);let n=JSON.parse(r.body),i=rg(r.headers),o=await q_e.transformRequestOut(n),s=JSON.stringify(o),a=E1e(t)+`/models/${n.model}:streamGenerateContent?alt=sse`,l=i.authorization??i.Authorization??"",c;try{c=await e(a,{method:"POST",headers:{"Content-Type":"application/json","x-goog-api-key":String(l).replace(/^Bearer\s+/i,"").trim()},body:s,signal:r.signal})}catch(C){throw V("gemini request error:",C),C}if(!c.ok){let C=await c.text();return V(`Gemini API error response: ${c.status} ${c.statusText}`,{url:a,status:c.status,errorResponse:C}),h1e("Gemini API error","Gemini",c.status,c.statusText,C)}let u=n.stream===!0,f=i["x-agent-id"],g={request:{url:a,method:r.method,headers:rg(r.headers),body:n},response:{status:c.status,statusText:c.statusText,headers:rg(c.headers)},openai:{request:{body:o},response:{}}},m=_B(c.body),A=new Response(m.stream,{status:c.status,statusText:c.statusText,headers:CU(c.headers)}),h=await q_e.transformResponseIn(A),y=_B(h.body);return Promise.all([m.done,y.done]).then(async([C,I])=>{try{let T=u?iit(C):JSON.parse(C),D=u?await pF(I):JSON.parse(I);bU({...g,openai:{...g.openai,response:{body:T}},response:{...g.response,body:D}},f)}catch(T){V("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Gemini):"+T?.stack)}}).catch(C=>V("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Gemini):"+C)),new Response(y.stream,{status:h.status,statusText:h.statusText,headers:h.headers})}}function bXr(e){return async(t,r)=>{if(!vJ(t,r))return e(t,r);let n=r.body;if(r.body)try{let f=JSON.parse(r.body);n=JSON.stringify(f)}catch{}let i=rg(r.headers);["1","true"].includes(String(process.env.HAWA_CODE_X_API_KEY_DISABLED??"").toLowerCase())&&(delete i["x-api-key"],delete i["X-API-Key"]),["1","true"].includes(String(process.env.HAWA_CODE_AUTH_DISABLED??"").toLowerCase())&&(delete i.authorization,delete i.Authorization),delete i["content-length"];let a=await e(t,{method:r.method,headers:i,body:n,signal:r.signal});if(!a.ok){let f=await a.text();V(`API error response: ${a.status} ${a.statusText}`,{url:typeof t=="string"?t:t instanceof _T?t.toString():t.url,status:a.status,errorResponse:f});let g;try{let m=JSON.parse(f);g={type:"error",error:{type:"api_error",message:m.error?.message||m.message||`API error: ${a.statusText}`,code:m.error?.code||m.code||`API_${a.status}_ERROR`}},m.error?.details&&(g.error.details=m.error.details)}catch{g={type:"error",error:{type:"api_error",message:`API error: ${a.statusText}`,code:`API_${a.status}_ERROR`}}}return new Response(JSON.stringify(g),{status:a.status,statusText:a.statusText,headers:{"Content-Type":"application/json"}})}let l=a.clone(),c=!(Object.hasOwn(JSON.parse(n),"stream")&&!JSON.parse(n).stream),u={request:{url:typeof t=="string"?t:t instanceof _T?t.toString():t.url,method:r.method,headers:rg(r.headers),body:JSON.parse(n)},response:{status:a.status,statusText:a.statusText,headers:rg(a.headers)}};return(async()=>{if(c){let m=await a.text();u.response.body=await pF(m)}else u.response.body=await a.json();let g=rg(r.headers)["x-agent-id"];mG(g,u),gG(g,{request:u.request.body.messages,response:u.response.body.content,usage:u.response.body?.usage})})().catch(f=>V(`\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF:
|
|
625
|
-
Stack trace: `+f.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var TJ=null,A1e=!1;function CXr(){TJ=null,A1e=!1}Yt.on("proxy:changed",CXr);function SXr(){if(A1e)return TJ;if(A1e=!0,Ze().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(TJ=new Rpt.ProxyAgent({uri:e}),yt(`[proxy] using proxy: ${e}`)),TJ}function IXr(){let e=SXr();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function xJ(e){let t=e||process.env.API_TYPE,r=IXr();switch(t){case"openai":return EXr(r);case"openai-responses":return _Xr(r);case"gemini":return yXr(r);default:return bXr(r)}}IA();var wXr=we(et(),1);function Npt(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=TXr(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function TXr(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||vXr(t)?0:xXr(t)?2:1}function vXr(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function xXr(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=128591||e>=129280&&e<=129535||e>=131072&&e<=262141)}function SU(e){if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/36e5),r=Math.floor(e%36e5/6e4),n=(e%6e4/1e3).toFixed(1);return t>0?`${t}h ${r}m ${n}s`:r>0?`${r}m ${n}s`:`${n}s`}function wJ(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}De();rs();var zl={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function DJ(e,t){zl.totalCost+=e,zl.totalAPIDuration+=t}function RJ(e,t){zl.inputTokens+=e,zl.outputTokens+=t,Yt.emit("token:change",{inputTokens:zl.inputTokens,outputTokens:zl.outputTokens})}function NJ(e,t){zl.cacheCreationTokens+=e,zl.cacheReadTokens+=t}function _1e(){return{inputTokens:zl.inputTokens,outputTokens:zl.outputTokens,cacheCreationTokens:zl.cacheCreationTokens,cacheReadTokens:zl.cacheReadTokens}}function Bpt(){return zl.totalCost}function Opt(){return Date.now()-zl.startTime}function kpt(){return zl.totalAPIDuration}function Mpt(e){zl.currentContextTokens=e}function Qpt(){return zl.currentContextTokens}De();$e();$e();var y1e="2.8.7";globalThis.MACRO={VERSION:y1e,PACKAGE_URL:`@dahawa/${qi}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var BJ=process.env.HAWA_CODE_USER_AGENT||`${qi}/${y1e} (${process.env.USER_TYPE})`;import{randomUUID as kh}from"crypto";rs();De();sr();Sr();De();$e();import{existsSync as w0,readdirSync as rin,statSync as nin}from"fs";import{join as iC,relative as iin}from"path";import{homedir as xAt}from"os";import{platform as oin}from"process";import{readFile as oC}from"fs/promises";Sr();Up();Zt();import{join as OXr,sep as kXr}from"path";function Hp(){if(!au())return!1;try{let e=Ze();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function bf(){return(OXr(Ne(),".hcode","team-memory")+kXr).normalize("NFC")}function T0(e){let t=e.normalize("NFC"),r=bf();return t.startsWith(r)}Up();var wAt=we(BU(),1);vi();var P1e=(e,t,r)=>{let n=e instanceof RegExp?tAt(e,r):e,i=t instanceof RegExp?tAt(t,r):t,o=n!==null&&i!=null&&jrn(n,i,r);return o&&{start:o[0],end:o[1],pre:r.slice(0,o[0]),body:r.slice(o[0]+n.length,o[1]),post:r.slice(o[1]+i.length)}},tAt=(e,t)=>{let r=t.match(e);return r?r[0]:null},jrn=(e,t,r)=>{let n,i,o,s,a,l=r.indexOf(e),c=r.indexOf(t,l+1),u=l;if(l>=0&&c>0){if(e===t)return[l,c];for(n=[],o=r.length;u>=0&&!a;){if(u===l)n.push(u),l=r.indexOf(e,u+1);else if(n.length===1){let f=n.pop();f!==void 0&&(a=[f,c])}else i=n.pop(),i!==void 0&&i<o&&(o=i,s=c),c=r.indexOf(t,u+1);u=l<c&&l>=0?l:c}n.length&&s!==void 0&&(a=[o,s])}return a};var rAt="\0SLASH"+Math.random()+"\0",nAt="\0OPEN"+Math.random()+"\0",U1e="\0CLOSE"+Math.random()+"\0",iAt="\0COMMA"+Math.random()+"\0",oAt="\0PERIOD"+Math.random()+"\0",Yrn=new RegExp(rAt,"g"),Vrn=new RegExp(nAt,"g"),Wrn=new RegExp(U1e,"g"),Krn=new RegExp(iAt,"g"),Jrn=new RegExp(oAt,"g"),Zrn=/\\\\/g,Xrn=/\\{/g,enn=/\\}/g,tnn=/\\,/g,rnn=/\\\./g,nnn=1e5,inn=4e6;function L1e(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function onn(e){return e.replace(Zrn,rAt).replace(Xrn,nAt).replace(enn,U1e).replace(tnn,iAt).replace(rnn,oAt)}function snn(e){return e.replace(Yrn,"\\").replace(Vrn,"{").replace(Wrn,"}").replace(Krn,",").replace(Jrn,".")}function sAt(e){if(!e)return[""];let t=[],r=P1e("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=sAt(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function aAt(e,t={}){if(!e)return[];let{max:r=nnn,maxLength:n=inn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),F1e(onn(e),r,n,!0).map(snn)}function ann(e){return"{"+e+"}"}function lnn(e){return/^-?0\d/.test(e)}function cnn(e,t){return e<=t}function unn(e,t){return e>=t}function OU(e,t,r,n,i,o){let s=[],a=0;for(let l=0;l<e.length;l++)for(let c=0;c<r.length;c++){if(s.length>=n)return s;let u=e[l]+t+r[c];if(!(o&&!u)){if(a+u.length>i)return s;s.push(u),a+=u.length}}return s}function dnn(e,t,r,n){let i=e.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let s=L1e(i[0]),a=L1e(i[1]),l=Math.max(i[0].length,i[1].length),c=i.length===3&&i[2]!==void 0?Math.max(Math.abs(L1e(i[2])),1):1,u=cnn;a<s&&(c*=-1,u=unn);let g=i.some(lnn),m=0;for(let A=s;u(A,a)&&o.length<r;A+=c){let h;if(t)h=String.fromCharCode(A),h==="\\"&&(h="");else if(h=String(A),g){let y=l-h.length;if(y>0){let C=new Array(y+1).join("0");A<0?h="-"+C+h.slice(1):h=C+h}}if(m+h.length>n)break;o.push(h),m+=h.length}return o}function F1e(e,t,r,n){let i=[""],o=!1,s=!0;for(;;){let a=P1e("{","}",e);if(!a)return OU(i,e,[""],t,r,o);let l=a.pre;if(/\$$/.test(l)){if(i=OU(i,l+"{"+a.body+"}",[""],t,r,o&&!a.post.length),s=!1,!a.post.length)break;e=a.post;continue}let c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),f=c||u,g=a.body.indexOf(",")>=0;if(!f&&!g){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+U1e+a.post,n=!0;continue}return OU(i,l+"{"+a.body+"}"+a.post,[""],t,r,o)}s&&(o=n&&!f,s=!1);let m;if(f)m=dnn(a.body,u,t,r);else{let A=sAt(a.body);if(A.length===1&&A[0]!==void 0&&(A=F1e(A[0],t,r,!1).map(ann),A.length===1)){if(i=OU(i,l+A[0],[""],t,r,o&&!a.post.length),!a.post.length)break;e=a.post;continue}let h=o&&!a.post.length&&!l;for(let C=0;h&&C<i.length;C++)i[C]&&(h=!1);m=[];let y=0;e:for(let C=0;C<A.length;C++){let I=F1e(A[C],t,r,!1);for(let T=0;T<I.length;T++){let D=I[T];if(!(h&&!D)){if(m.length>=t||y+D.length>r)break e;m.push(D),y+=D.length}}}}if(i=OU(i,l,m,t,r,o&&!a.post.length),!a.post.length)break;e=a.post}return i}var kU=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var fnn={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},MU=e=>e.replace(/[[\]\\-]/g,"\\$&"),pnn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),lAt=e=>e.join(""),cAt=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],o=r+1,s=!1,a=!1,l=!1,c=!1,u=r,f="";e:for(;o<e.length;){let h=e.charAt(o);if((h==="!"||h==="^")&&o===r+1){c=!0,o++;continue}if(h==="]"&&s&&!l){u=o+1;break}if(s=!0,h==="\\"&&!l){l=!0,o++;continue}if(h==="["&&!l){for(let[y,[C,I,T]]of Object.entries(fnn))if(e.startsWith(y,o)){if(f)return["$.",!1,e.length-r,!0];o+=y.length,T?i.push(C):n.push(C),a=a||I;continue e}}if(l=!1,f){h>f?n.push(MU(f)+"-"+MU(h)):h===f&&n.push(MU(h)),f="",o++;continue}if(e.startsWith("-]",o+1)){n.push(MU(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){f=h,o+=2;continue}n.push(MU(h)),o++}if(u<o)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,e.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!c){let h=n[0].length===2?n[0].slice(-1):n[0];return[pnn(h),!1,u-r,!1]}let g="["+(c?"^":"")+lAt(n)+"]",m="["+(c?"":"^")+lAt(i)+"]";return[n.length&&i.length?"("+g+"|"+m+")":n.length?g:m,a,u-r,!0]};var nC=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!0}={})=>r?t?e.replace(/\[([^/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?e.replace(/\[([^/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var dd,mnn=new Set(["!","?","+","*","@"]),H1e=e=>mnn.has(e),uAt=e=>H1e(e.type),gnn=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),Ann=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),hnn=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),dAt=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Enn="(?!(?:^|/)\\.\\.?(?:$|/))",zJ="(?!\\.)",_nn=new Set(["[","."]),ynn=new Set(["..","."]),bnn=new Set("().*{}+?[]^$\\!"),Cnn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),$1e="[^/]",fAt=$1e+"*?",pAt=$1e+"+?",Snn=0,xT=class{type;#e;#t;#n=!1;#r=[];#o;#i;#l;#s=!1;#a;#d;#p=!1;id=++Snn;get depth(){return(this.#o?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#o?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(t,r,n={}){this.type=t,t&&(this.#t=!0),this.#o=r,this.#e=this.#o?this.#o.#e:this,this.#a=this.#e===this?n:this.#e.#a,this.#l=this.#e===this?[]:this.#e.#l,t==="!"&&!this.#e.#s&&this.#l.push(this),this.#i=this.#o?this.#o.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let t of this.#r)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#d!==void 0?this.#d:this.type?this.#d=this.type+"("+this.#r.map(t=>String(t)).join("|")+")":this.#d=this.#r.map(t=>String(t)).join("")}#f(){if(this!==this.#e)throw new Error("should only call on root");if(this.#s)return this;this.toString(),this.#s=!0;let t;for(;t=this.#l.pop();){if(t.type!=="!")continue;let r=t,n=r.#o;for(;n;){for(let i=r.#i+1;!n.type&&i<n.#r.length;i++)for(let o of t.#r){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#r[i])}r=n,n=r.#o}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof dd&&r.#o===this))throw new Error("invalid part: "+r);this.#r.push(r)}}toJSON(){let t=this.type===null?this.#r.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#r.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#o?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#o?.isStart())return!1;if(this.#i===0)return!0;let t=this.#o;for(let r=0;r<this.#i;r++){let n=t.#r[r];if(!(n instanceof dd&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let t=this.#o?this.#o.#r.length:0;return this.#i===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new dd(this.type,t);for(let n of this.#r)r.copyIn(n);return r}static#c(t,r,n,i,o){let s=i.maxExtglobRecursion??2,a=!1,l=!1,c=-1,u=!1;if(r.type===null){let h=n,y="";for(;h<t.length;){let C=t.charAt(h++);if(a||C==="\\"){a=!a,y+=C;continue}if(l){h===c+1?(C==="^"||C==="!")&&(u=!0):C==="]"&&!(h===c+2&&u)&&(l=!1),y+=C;continue}else if(C==="["){l=!0,c=h,u=!1,y+=C;continue}if(!i.noext&&H1e(C)&&t.charAt(h)==="("&&o<=s){r.push(y),y="";let T=new dd(C,r);h=dd.#c(t,T,h,i,o+1),r.push(T);continue}y+=C}return r.push(y),h}let f=n+1,g=new dd(null,r),m=[],A="";for(;f<t.length;){let h=t.charAt(f++);if(a||h==="\\"){a=!a,A+=h;continue}if(l){f===c+1?(h==="^"||h==="!")&&(u=!0):h==="]"&&!(f===c+2&&u)&&(l=!1),A+=h;continue}else if(h==="["){l=!0,c=f,u=!1,A+=h;continue}if(!i.noext&&H1e(h)&&t.charAt(f)==="("&&(o<=s||r&&r.#E(h))){let C=r&&r.#E(h)?0:1;g.push(A),A="";let I=new dd(h,g);g.push(I),f=dd.#c(t,I,f,i,o+C);continue}if(h==="|"){g.push(A),A="",m.push(g),g=new dd(null,r);continue}if(h===")")return A===""&&r.#r.length===0&&(r.#p=!0),g.push(A),A="",r.push(...m,g),f;A+=h}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],f}#g(t){return this.#h(t,Ann)}#h(t,r=gnn){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null)return!1;let n=t.#r[0];return!n||typeof n!="object"||n.type===null?!1:this.#E(n.type,r)}#E(t,r=hnn){return!!r.get(this.type)?.includes(t)}#A(t,r){let n=t.#r[0],i=new dd(null,n,this.options);i.#r.push(""),n.push(i),this.#v(t,r)}#v(t,r){let n=t.#r[0];this.#r.splice(r,1,...n.#r);for(let i of n.#r)typeof i=="object"&&(i.#o=this);this.#d=void 0}#y(t){return!!dAt.get(this.type)?.has(t)}#S(t){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let r=t.#r[0];return!r||typeof r!="object"||r.type===null?!1:this.#y(r.type)}#I(t){let r=dAt.get(this.type),n=t.#r[0],i=r?.get(n.type);if(!i)return!1;this.#r=n.#r;for(let o of this.#r)typeof o=="object"&&(o.#o=this);this.type=i,this.#d=void 0,this.#p=!1}static fromGlob(t,r={}){let n=new dd(null,void 0,r);return dd.#c(t,n,0,r,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[r,n,i,o]=this.toRegExpSource();if(!(i||this.#t||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#a}toRegExpSource(t){let r=t??!!this.#a.dot;if(this.#e===this&&(this.#_(),this.#f()),!uAt(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(m=>typeof m!="string"),c=this.#r.map(m=>{let[A,h,y,C]=typeof m=="string"?dd.#C(m,this.#t,l):m.toRegExpSource(t);return this.#t=this.#t||y,this.#n=this.#n||C,A}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&ynn.has(this.#r[0]))){let A=_nn,h=r&&A.has(c.charAt(0))||c.startsWith("\\.")&&A.has(c.charAt(2))||c.startsWith("\\.\\.")&&A.has(c.charAt(4)),y=!r&&!t&&A.has(c.charAt(0));u=h?Enn:y?zJ:""}let f="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(f="(?:$|\\/)"),[u+c+f,nC(c),this.#t=!!this.#t,this.#n]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#b(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString(),c=this;return c.#r=[l],c.type=null,c.#t=void 0,[l,nC(this.toString()),!1,!1]}let s=!n||t||r||!zJ?"":this.#b(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?zJ:"")+pAt;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?zJ:"")+fAt+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,nC(o),this.#t=!!this.#t,this.#n]}#_(){if(uAt(this)){let t=0,r=!1;do{r=!0;for(let n=0;n<this.#r.length;n++){let i=this.#r[n];typeof i=="object"&&(i.#_(),this.#h(i)?(r=!1,this.#v(i,n)):this.#g(i)?(r=!1,this.#A(i,n)):this.#S(i)&&(r=!1,this.#I(i)))}}while(!r&&++t<10)}else for(let t of this.#r)typeof t=="object"&&t.#_();this.#d=void 0}#b(t){return this.#r.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,o,s]=r.toRegExpSource(t);return this.#n=this.#n||s,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#C(t,r,n=!1){let i=!1,o="",s=!1,a=!1;for(let l=0;l<t.length;l++){let c=t.charAt(l);if(i){i=!1,o+=(bnn.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?pAt:fAt,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,f,g,m]=cAt(t,l);if(g){o+=u,s=s||f,l+=g-1,r=r||m;continue}}if(c==="?"){o+=$1e,r=!0;continue}o+=Cnn(c)}return[o,nC(t),!!r,s]}};dd=xT;var q1e=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var Yl=(e,t,r={})=>(kU(t),!r.nocomment&&t.charAt(0)==="#"?!1:new DB(t,r).match(e)),Inn=/^\*+([^+@!?*[(]*)$/,Tnn=e=>t=>!t.startsWith(".")&&t.endsWith(e),vnn=e=>t=>t.endsWith(e),xnn=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),wnn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Dnn=/^\*+\.\*+$/,Rnn=e=>!e.startsWith(".")&&e.includes("."),Nnn=e=>e!=="."&&e!==".."&&e.includes("."),Bnn=/^\.\*+$/,Onn=e=>e!=="."&&e!==".."&&e.startsWith("."),knn=/^\*+$/,Mnn=e=>e.length!==0&&!e.startsWith("."),Qnn=e=>e.length!==0&&e!=="."&&e!=="..",Pnn=/^\?+([^+@!?*[(]*)?$/,Lnn=([e,t=""])=>{let r=AAt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Fnn=([e,t=""])=>{let r=hAt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Unn=([e,t=""])=>{let r=hAt([e]);return t?n=>r(n)&&n.endsWith(t):r},Hnn=([e,t=""])=>{let r=AAt([e]);return t?n=>r(n)&&n.endsWith(t):r},AAt=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},hAt=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},EAt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",mAt={win32:{sep:"\\"},posix:{sep:"/"}},$nn=EAt==="win32"?mAt.win32.sep:mAt.posix.sep;Yl.sep=$nn;var xc=Symbol("globstar **");Yl.GLOBSTAR=xc;var qnn="[^/]",Gnn=qnn+"*?",znn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",jnn="(?:(?!(?:\\/|^)\\.).)*?",Ynn=(e,t={})=>r=>Yl(r,e,t);Yl.filter=Ynn;var $p=(e,t={})=>Object.assign({},e,t),Vnn=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return Yl;let t=Yl;return Object.assign((n,i,o={})=>t(n,i,$p(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,$p(e,o))}static defaults(i){return t.defaults($p(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,$p(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,$p(e,o))}},unescape:(n,i={})=>t.unescape(n,$p(e,i)),escape:(n,i={})=>t.escape(n,$p(e,i)),filter:(n,i={})=>t.filter(n,$p(e,i)),defaults:n=>t.defaults($p(e,n)),makeRe:(n,i={})=>t.makeRe(n,$p(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,$p(e,i)),match:(n,i,o={})=>t.match(n,i,$p(e,o)),sep:t.sep,GLOBSTAR:xc})};Yl.defaults=Vnn;var _At=(e,t={})=>(kU(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:aAt(e,{max:t.braceExpandMax}));Yl.braceExpand=_At;var Wnn=(e,t={})=>new DB(e,t).makeRe();Yl.makeRe=Wnn;var Knn=(e,t,r={})=>{let n=new DB(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};Yl.match=Knn;var gAt=/[?*]|[+@!]\(.*?\)|\[|\]/,Jnn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),DB=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){kU(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||EAt,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((o,s,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=o[0]===""&&o[1]===""&&(o[2]==="?"||!gAt.test(o[2]))&&!gAt.test(o[3]),c=/^[a-z]:/i.test(o[0]);if(l)return[...o.slice(0,4),...o.slice(4).map(u=>this.parse(u))];if(c)return[o[0],...o.slice(1).map(u=>this.parse(u))]}return o.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let s=this.set[o];s[0]===""&&s[1]===""&&this.globParts[o][2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3])&&(s[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n of t)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,i)=>{let o=n[n.length-1];return i==="**"&&o==="**"?n:i===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let o=t[i];i===1&&o===""&&t[0]===""||(o==="."||o==="")&&(r=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let s=i;for(;n[s+1]==="**";)s++;s>i&&n.splice(i+1,s-i);let a=n[i+1],l=n[i+2],c=n[i+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",t.push(u),i--}if(!this.preserveMultipleSlashes){for(let s=1;s<n.length-1;s++){let a=n[s];s===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(s,1),s--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let s=n[o-1];if(s&&s!=="."&&s!==".."&&s!=="**"){r=!0;let l=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...l),n.length===0&&n.push(""),o-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let i=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(i){t[r]=[],t[n]=i;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let i=0,o=0,s=[],a="";for(;i<t.length&&o<r.length;)if(t[i]===r[o])s.push(a==="b"?r[o]:t[i]),i++,o++;else if(n&&t[i]==="**"&&r[o]===t[i+1])s.push(t[i]),i++;else if(n&&r[o]==="**"&&t[i]===r[o+1])s.push(r[o]),o++;else if(t[i]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",s.push(t[i]),i++,o++}else if(r[o]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(a==="a")return!1;a="b",s.push(r[o]),i++,o++}else return!1;return t.length===r.length&&s}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let i=0,o=0;if(this.isWindows){let a=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),l=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),c=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),u=!c&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),f=l?3:a?0:void 0,g=u?3:c?0:void 0;if(typeof f=="number"&&typeof g=="number"){let[m,A]=[t[f],r[g]];m.toLowerCase()===A.toLowerCase()&&(r[g]=m,o=g,i=f)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(xc)?this.#e(t,r,n,i,o):this.#n(t,r,n,i,o)}#e(t,r,n,i,o){let s=r.indexOf(xc,o),a=r.lastIndexOf(xc),[l,c,u]=n?[r.slice(o,s),r.slice(s+1),[]]:[r.slice(o,s),r.slice(s+1,a),r.slice(a+1)];if(l.length){let I=t.slice(i,i+l.length);if(!this.#n(I,l,n,0,0))return!1;i+=l.length,o+=l.length}let f=0;if(u.length){if(u.length+i>t.length)return!1;let I=t.length-u.length;if(this.#n(t,u,n,I,0))f=u.length;else{if(t[t.length-1]!==""||i+u.length===t.length||(I--,!this.#n(t,u,n,I,0)))return!1;f=u.length+1}}if(!c.length){let I=!!f;for(let T=i;T<t.length-f;T++){let D=String(t[T]);if(I=!0,D==="."||D===".."||!this.options.dot&&D.startsWith("."))return!1}return n||I}let g=[[[],0]],m=g[0],A=0,h=[0];for(let I of c)I===xc?(h.push(A),m=[[],0],g.push(m)):(m[0].push(I),A++);let y=g.length-1,C=t.length-f;for(let I of g)I[1]=C-(h[y--]+I[0].length);return!!this.#t(t,g,i,0,n,0,!!f)}#t(t,r,n,i,o,s,a){let l=r[i];if(!l){for(let f=n;f<t.length;f++){a=!0;let g=t[f];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1}return a}let[c,u]=l;for(;n<=u;){if(this.#n(t.slice(0,n+c.length),c,o,n,0)&&s<this.maxGlobstarRecursion){let m=this.#t(t,r,n+c.length,i+1,o,s+1,a);if(m!==!1)return m}let g=t[n];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1;n++}return o||null}#n(t,r,n,i,o){let s,a,l,c;for(s=i,a=o,c=t.length,l=r.length;s<c&&a<l;s++,a++){this.debug("matchOne loop");let u=r[a],f=t[s];if(this.debug(r,u,f),u===!1||u===xc)return!1;let g;if(typeof u=="string"?(g=f===u,this.debug("string match",u,f,g)):(g=u.test(f),this.debug("pattern match",u,f,g)),!g)return!1}if(s===c&&a===l)return!0;if(s===c)return n;if(a===l)return s===c-1&&t[s]==="";throw new Error("wtf?")}braceExpand(){return _At(this.pattern,this.options)}parse(t){kU(t);let r=this.options;if(t==="**")return xc;if(t==="")return"";let n,i=null;(n=t.match(knn))?i=r.dot?Qnn:Mnn:(n=t.match(Inn))?i=(r.nocase?r.dot?wnn:xnn:r.dot?vnn:Tnn)(n[1]):(n=t.match(Pnn))?i=(r.nocase?r.dot?Fnn:Lnn:r.dot?Unn:Hnn)(n):(n=t.match(Dnn))?i=r.dot?Nnn:Rnn:(n=t.match(Bnn))&&(i=Onn);let o=xT.fromGlob(t,this.options).toMMPattern();return i&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:i}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?Gnn:r.dot?znn:jnn,i=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let c=l.map(f=>{if(f instanceof RegExp)for(let g of f.flags.split(""))i.add(g);return typeof f=="string"?Jnn(f):f===xc?xc:f._src});c.forEach((f,g)=>{let m=c[g+1],A=c[g-1];f!==xc||A===xc||(A===void 0?m!==void 0&&m!==xc?c[g+1]="(?:\\/|"+n+"\\/)?"+m:c[g]=n:m===void 0?c[g-1]=A+"(?:\\/|\\/"+n+")?":m!==xc&&(c[g-1]=A+"(?:\\/|\\/"+n+"\\/)"+m,c[g+1]=xc))});let u=c.filter(f=>f!==xc);if(this.partial&&u.length>=1){let f=[];for(let g=1;g<=u.length;g++)f.push(u.slice(0,g).join("/"));return"(?:"+f.join("|")+")"}return u.join("/")}).join("|"),[s,a]=t.length>1?["(?:",")"]:["",""];o="^"+s+o+a+"$",this.partial&&(o="^(?:\\/|"+s+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let o=this.set;this.debug(this.pattern,"set",o);let s=i[i.length-1];if(!s)for(let a=i.length-2;!s&&a>=0;a--)s=i[a];for(let a of o){let l=i;if(n.matchBase&&a.length===1&&(l=[s]),this.matchOne(l,a,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return Yl.defaults(t).Minimatch}};Yl.AST=xT;Yl.Minimatch=DB;Yl.escape=q1e;Yl.unescape=nC;var CAt=we(BU(),1);Sr();$e();De();Xc();import{readFile as yAt}from"fs/promises";import{existsSync as G1e,readdirSync as Znn,statSync as Xnn}from"fs";import{join as z1e,relative as SAt}from"path";import{homedir as ein}from"os";function bAt(e){try{let t=(0,CAt.default)(e),r=t.data.paths,n=[];return typeof r=="string"?n=r.split(",").map(i=>i.trim()).filter(Boolean):Array.isArray(r)&&(n=r.filter(i=>typeof i=="string")),{paths:n,content:t.content.trim()}}catch(t){return ve(t),{paths:[],content:e.trim()}}}function tin(e,t){return t.length===0?!0:t.some(r=>{try{return Yl(e,r,{matchBase:!0,dot:!0})}catch(n){return ve(n),!1}})}function j1e(e){let t=[];try{if(!G1e(e))return t;let r=Znn(e);for(let n of r){let i=z1e(e,n),o=Xnn(i);o.isDirectory()?t.push(...j1e(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){ve(r)}return t}async function jJ(){let e=[];try{let t=z1e(ein(),Kr,"rules");if(G1e(t)){let r=j1e(t);for(let n of r)try{let i=await yAt(n,"utf-8"),{paths:o,content:s}=bAt(i);o.length>0&&e.push({filePath:n,content:s,paths:o,isProjectRule:!1})}catch(i){ve(i)}}}catch(t){ve(t)}try{let t=z1e(Ne(),Kr,"rules");if(G1e(t)){let r=j1e(t);for(let n of r)try{let i=await yAt(n,"utf-8"),{paths:o,content:s}=bAt(i);o.length>0&&e.push({filePath:SAt(Ne(),n),content:s,paths:o,isProjectRule:!0})}catch(i){ve(i)}}}catch(t){ve(t)}return e}function IAt(e,t){e=dY(e);let r=dY(Ne()),n=e.startsWith(r)?SAt(r,e):e;return t.filter(i=>tin(n,i.paths))}function TAt(e){return e.length===0?"":e.map(r=>{let n=r.isProjectRule?"project instructions, checked into the codebase":"user's private global instructions for all projects";return`Contents of ${r.filePath} (${n}):
|
|
625
|
+
Stack trace: `+f.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var TJ=null,A1e=!1;function CXr(){TJ=null,A1e=!1}Yt.on("proxy:changed",CXr);function SXr(){if(A1e)return TJ;if(A1e=!0,Ze().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(TJ=new Rpt.ProxyAgent({uri:e}),yt(`[proxy] using proxy: ${e}`)),TJ}function IXr(){let e=SXr();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function xJ(e){let t=e||process.env.API_TYPE,r=IXr();switch(t){case"openai":return EXr(r);case"openai-responses":return _Xr(r);case"gemini":return yXr(r);default:return bXr(r)}}IA();var wXr=we(et(),1);function Npt(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=TXr(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function TXr(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||vXr(t)?0:xXr(t)?2:1}function vXr(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function xXr(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=128591||e>=129280&&e<=129535||e>=131072&&e<=262141)}function SU(e){if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/36e5),r=Math.floor(e%36e5/6e4),n=(e%6e4/1e3).toFixed(1);return t>0?`${t}h ${r}m ${n}s`:r>0?`${r}m ${n}s`:`${n}s`}function wJ(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}De();rs();var zl={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function DJ(e,t){zl.totalCost+=e,zl.totalAPIDuration+=t}function RJ(e,t){zl.inputTokens+=e,zl.outputTokens+=t,Yt.emit("token:change",{inputTokens:zl.inputTokens,outputTokens:zl.outputTokens})}function NJ(e,t){zl.cacheCreationTokens+=e,zl.cacheReadTokens+=t}function _1e(){return{inputTokens:zl.inputTokens,outputTokens:zl.outputTokens,cacheCreationTokens:zl.cacheCreationTokens,cacheReadTokens:zl.cacheReadTokens}}function Bpt(){return zl.totalCost}function Opt(){return Date.now()-zl.startTime}function kpt(){return zl.totalAPIDuration}function Mpt(e){zl.currentContextTokens=e}function Qpt(){return zl.currentContextTokens}De();$e();$e();var y1e="2.8.8";globalThis.MACRO={VERSION:y1e,PACKAGE_URL:`@dahawa/${qi}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var BJ=process.env.HAWA_CODE_USER_AGENT||`${qi}/${y1e} (${process.env.USER_TYPE})`;import{randomUUID as kh}from"crypto";rs();De();sr();Sr();De();$e();import{existsSync as w0,readdirSync as rin,statSync as nin}from"fs";import{join as iC,relative as iin}from"path";import{homedir as xAt}from"os";import{platform as oin}from"process";import{readFile as oC}from"fs/promises";Sr();Up();Zt();import{join as OXr,sep as kXr}from"path";function Hp(){if(!au())return!1;try{let e=Ze();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function bf(){return(OXr(Ne(),".hcode","team-memory")+kXr).normalize("NFC")}function T0(e){let t=e.normalize("NFC"),r=bf();return t.startsWith(r)}Up();var wAt=we(BU(),1);vi();var P1e=(e,t,r)=>{let n=e instanceof RegExp?tAt(e,r):e,i=t instanceof RegExp?tAt(t,r):t,o=n!==null&&i!=null&&jrn(n,i,r);return o&&{start:o[0],end:o[1],pre:r.slice(0,o[0]),body:r.slice(o[0]+n.length,o[1]),post:r.slice(o[1]+i.length)}},tAt=(e,t)=>{let r=t.match(e);return r?r[0]:null},jrn=(e,t,r)=>{let n,i,o,s,a,l=r.indexOf(e),c=r.indexOf(t,l+1),u=l;if(l>=0&&c>0){if(e===t)return[l,c];for(n=[],o=r.length;u>=0&&!a;){if(u===l)n.push(u),l=r.indexOf(e,u+1);else if(n.length===1){let f=n.pop();f!==void 0&&(a=[f,c])}else i=n.pop(),i!==void 0&&i<o&&(o=i,s=c),c=r.indexOf(t,u+1);u=l<c&&l>=0?l:c}n.length&&s!==void 0&&(a=[o,s])}return a};var rAt="\0SLASH"+Math.random()+"\0",nAt="\0OPEN"+Math.random()+"\0",U1e="\0CLOSE"+Math.random()+"\0",iAt="\0COMMA"+Math.random()+"\0",oAt="\0PERIOD"+Math.random()+"\0",Yrn=new RegExp(rAt,"g"),Vrn=new RegExp(nAt,"g"),Wrn=new RegExp(U1e,"g"),Krn=new RegExp(iAt,"g"),Jrn=new RegExp(oAt,"g"),Zrn=/\\\\/g,Xrn=/\\{/g,enn=/\\}/g,tnn=/\\,/g,rnn=/\\\./g,nnn=1e5,inn=4e6;function L1e(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function onn(e){return e.replace(Zrn,rAt).replace(Xrn,nAt).replace(enn,U1e).replace(tnn,iAt).replace(rnn,oAt)}function snn(e){return e.replace(Yrn,"\\").replace(Vrn,"{").replace(Wrn,"}").replace(Krn,",").replace(Jrn,".")}function sAt(e){if(!e)return[""];let t=[],r=P1e("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=sAt(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function aAt(e,t={}){if(!e)return[];let{max:r=nnn,maxLength:n=inn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),F1e(onn(e),r,n,!0).map(snn)}function ann(e){return"{"+e+"}"}function lnn(e){return/^-?0\d/.test(e)}function cnn(e,t){return e<=t}function unn(e,t){return e>=t}function OU(e,t,r,n,i,o){let s=[],a=0;for(let l=0;l<e.length;l++)for(let c=0;c<r.length;c++){if(s.length>=n)return s;let u=e[l]+t+r[c];if(!(o&&!u)){if(a+u.length>i)return s;s.push(u),a+=u.length}}return s}function dnn(e,t,r,n){let i=e.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let s=L1e(i[0]),a=L1e(i[1]),l=Math.max(i[0].length,i[1].length),c=i.length===3&&i[2]!==void 0?Math.max(Math.abs(L1e(i[2])),1):1,u=cnn;a<s&&(c*=-1,u=unn);let g=i.some(lnn),m=0;for(let A=s;u(A,a)&&o.length<r;A+=c){let h;if(t)h=String.fromCharCode(A),h==="\\"&&(h="");else if(h=String(A),g){let y=l-h.length;if(y>0){let C=new Array(y+1).join("0");A<0?h="-"+C+h.slice(1):h=C+h}}if(m+h.length>n)break;o.push(h),m+=h.length}return o}function F1e(e,t,r,n){let i=[""],o=!1,s=!0;for(;;){let a=P1e("{","}",e);if(!a)return OU(i,e,[""],t,r,o);let l=a.pre;if(/\$$/.test(l)){if(i=OU(i,l+"{"+a.body+"}",[""],t,r,o&&!a.post.length),s=!1,!a.post.length)break;e=a.post;continue}let c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),f=c||u,g=a.body.indexOf(",")>=0;if(!f&&!g){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+U1e+a.post,n=!0;continue}return OU(i,l+"{"+a.body+"}"+a.post,[""],t,r,o)}s&&(o=n&&!f,s=!1);let m;if(f)m=dnn(a.body,u,t,r);else{let A=sAt(a.body);if(A.length===1&&A[0]!==void 0&&(A=F1e(A[0],t,r,!1).map(ann),A.length===1)){if(i=OU(i,l+A[0],[""],t,r,o&&!a.post.length),!a.post.length)break;e=a.post;continue}let h=o&&!a.post.length&&!l;for(let C=0;h&&C<i.length;C++)i[C]&&(h=!1);m=[];let y=0;e:for(let C=0;C<A.length;C++){let I=F1e(A[C],t,r,!1);for(let T=0;T<I.length;T++){let D=I[T];if(!(h&&!D)){if(m.length>=t||y+D.length>r)break e;m.push(D),y+=D.length}}}}if(i=OU(i,l,m,t,r,o&&!a.post.length),!a.post.length)break;e=a.post}return i}var kU=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var fnn={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},MU=e=>e.replace(/[[\]\\-]/g,"\\$&"),pnn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),lAt=e=>e.join(""),cAt=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],o=r+1,s=!1,a=!1,l=!1,c=!1,u=r,f="";e:for(;o<e.length;){let h=e.charAt(o);if((h==="!"||h==="^")&&o===r+1){c=!0,o++;continue}if(h==="]"&&s&&!l){u=o+1;break}if(s=!0,h==="\\"&&!l){l=!0,o++;continue}if(h==="["&&!l){for(let[y,[C,I,T]]of Object.entries(fnn))if(e.startsWith(y,o)){if(f)return["$.",!1,e.length-r,!0];o+=y.length,T?i.push(C):n.push(C),a=a||I;continue e}}if(l=!1,f){h>f?n.push(MU(f)+"-"+MU(h)):h===f&&n.push(MU(h)),f="",o++;continue}if(e.startsWith("-]",o+1)){n.push(MU(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){f=h,o+=2;continue}n.push(MU(h)),o++}if(u<o)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,e.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!c){let h=n[0].length===2?n[0].slice(-1):n[0];return[pnn(h),!1,u-r,!1]}let g="["+(c?"^":"")+lAt(n)+"]",m="["+(c?"":"^")+lAt(i)+"]";return[n.length&&i.length?"("+g+"|"+m+")":n.length?g:m,a,u-r,!0]};var nC=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!0}={})=>r?t?e.replace(/\[([^/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?e.replace(/\[([^/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var dd,mnn=new Set(["!","?","+","*","@"]),H1e=e=>mnn.has(e),uAt=e=>H1e(e.type),gnn=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),Ann=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),hnn=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),dAt=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Enn="(?!(?:^|/)\\.\\.?(?:$|/))",zJ="(?!\\.)",_nn=new Set(["[","."]),ynn=new Set(["..","."]),bnn=new Set("().*{}+?[]^$\\!"),Cnn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),$1e="[^/]",fAt=$1e+"*?",pAt=$1e+"+?",Snn=0,xT=class{type;#e;#t;#n=!1;#r=[];#o;#i;#l;#s=!1;#a;#d;#p=!1;id=++Snn;get depth(){return(this.#o?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#o?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(t,r,n={}){this.type=t,t&&(this.#t=!0),this.#o=r,this.#e=this.#o?this.#o.#e:this,this.#a=this.#e===this?n:this.#e.#a,this.#l=this.#e===this?[]:this.#e.#l,t==="!"&&!this.#e.#s&&this.#l.push(this),this.#i=this.#o?this.#o.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let t of this.#r)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#d!==void 0?this.#d:this.type?this.#d=this.type+"("+this.#r.map(t=>String(t)).join("|")+")":this.#d=this.#r.map(t=>String(t)).join("")}#f(){if(this!==this.#e)throw new Error("should only call on root");if(this.#s)return this;this.toString(),this.#s=!0;let t;for(;t=this.#l.pop();){if(t.type!=="!")continue;let r=t,n=r.#o;for(;n;){for(let i=r.#i+1;!n.type&&i<n.#r.length;i++)for(let o of t.#r){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#r[i])}r=n,n=r.#o}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof dd&&r.#o===this))throw new Error("invalid part: "+r);this.#r.push(r)}}toJSON(){let t=this.type===null?this.#r.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#r.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#o?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#o?.isStart())return!1;if(this.#i===0)return!0;let t=this.#o;for(let r=0;r<this.#i;r++){let n=t.#r[r];if(!(n instanceof dd&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let t=this.#o?this.#o.#r.length:0;return this.#i===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new dd(this.type,t);for(let n of this.#r)r.copyIn(n);return r}static#c(t,r,n,i,o){let s=i.maxExtglobRecursion??2,a=!1,l=!1,c=-1,u=!1;if(r.type===null){let h=n,y="";for(;h<t.length;){let C=t.charAt(h++);if(a||C==="\\"){a=!a,y+=C;continue}if(l){h===c+1?(C==="^"||C==="!")&&(u=!0):C==="]"&&!(h===c+2&&u)&&(l=!1),y+=C;continue}else if(C==="["){l=!0,c=h,u=!1,y+=C;continue}if(!i.noext&&H1e(C)&&t.charAt(h)==="("&&o<=s){r.push(y),y="";let T=new dd(C,r);h=dd.#c(t,T,h,i,o+1),r.push(T);continue}y+=C}return r.push(y),h}let f=n+1,g=new dd(null,r),m=[],A="";for(;f<t.length;){let h=t.charAt(f++);if(a||h==="\\"){a=!a,A+=h;continue}if(l){f===c+1?(h==="^"||h==="!")&&(u=!0):h==="]"&&!(f===c+2&&u)&&(l=!1),A+=h;continue}else if(h==="["){l=!0,c=f,u=!1,A+=h;continue}if(!i.noext&&H1e(h)&&t.charAt(f)==="("&&(o<=s||r&&r.#E(h))){let C=r&&r.#E(h)?0:1;g.push(A),A="";let I=new dd(h,g);g.push(I),f=dd.#c(t,I,f,i,o+C);continue}if(h==="|"){g.push(A),A="",m.push(g),g=new dd(null,r);continue}if(h===")")return A===""&&r.#r.length===0&&(r.#p=!0),g.push(A),A="",r.push(...m,g),f;A+=h}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],f}#g(t){return this.#h(t,Ann)}#h(t,r=gnn){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null)return!1;let n=t.#r[0];return!n||typeof n!="object"||n.type===null?!1:this.#E(n.type,r)}#E(t,r=hnn){return!!r.get(this.type)?.includes(t)}#A(t,r){let n=t.#r[0],i=new dd(null,n,this.options);i.#r.push(""),n.push(i),this.#v(t,r)}#v(t,r){let n=t.#r[0];this.#r.splice(r,1,...n.#r);for(let i of n.#r)typeof i=="object"&&(i.#o=this);this.#d=void 0}#y(t){return!!dAt.get(this.type)?.has(t)}#S(t){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let r=t.#r[0];return!r||typeof r!="object"||r.type===null?!1:this.#y(r.type)}#I(t){let r=dAt.get(this.type),n=t.#r[0],i=r?.get(n.type);if(!i)return!1;this.#r=n.#r;for(let o of this.#r)typeof o=="object"&&(o.#o=this);this.type=i,this.#d=void 0,this.#p=!1}static fromGlob(t,r={}){let n=new dd(null,void 0,r);return dd.#c(t,n,0,r,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[r,n,i,o]=this.toRegExpSource();if(!(i||this.#t||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#a}toRegExpSource(t){let r=t??!!this.#a.dot;if(this.#e===this&&(this.#_(),this.#f()),!uAt(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(m=>typeof m!="string"),c=this.#r.map(m=>{let[A,h,y,C]=typeof m=="string"?dd.#C(m,this.#t,l):m.toRegExpSource(t);return this.#t=this.#t||y,this.#n=this.#n||C,A}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&ynn.has(this.#r[0]))){let A=_nn,h=r&&A.has(c.charAt(0))||c.startsWith("\\.")&&A.has(c.charAt(2))||c.startsWith("\\.\\.")&&A.has(c.charAt(4)),y=!r&&!t&&A.has(c.charAt(0));u=h?Enn:y?zJ:""}let f="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(f="(?:$|\\/)"),[u+c+f,nC(c),this.#t=!!this.#t,this.#n]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#b(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString(),c=this;return c.#r=[l],c.type=null,c.#t=void 0,[l,nC(this.toString()),!1,!1]}let s=!n||t||r||!zJ?"":this.#b(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?zJ:"")+pAt;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?zJ:"")+fAt+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,nC(o),this.#t=!!this.#t,this.#n]}#_(){if(uAt(this)){let t=0,r=!1;do{r=!0;for(let n=0;n<this.#r.length;n++){let i=this.#r[n];typeof i=="object"&&(i.#_(),this.#h(i)?(r=!1,this.#v(i,n)):this.#g(i)?(r=!1,this.#A(i,n)):this.#S(i)&&(r=!1,this.#I(i)))}}while(!r&&++t<10)}else for(let t of this.#r)typeof t=="object"&&t.#_();this.#d=void 0}#b(t){return this.#r.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,o,s]=r.toRegExpSource(t);return this.#n=this.#n||s,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#C(t,r,n=!1){let i=!1,o="",s=!1,a=!1;for(let l=0;l<t.length;l++){let c=t.charAt(l);if(i){i=!1,o+=(bnn.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?pAt:fAt,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,f,g,m]=cAt(t,l);if(g){o+=u,s=s||f,l+=g-1,r=r||m;continue}}if(c==="?"){o+=$1e,r=!0;continue}o+=Cnn(c)}return[o,nC(t),!!r,s]}};dd=xT;var q1e=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var Yl=(e,t,r={})=>(kU(t),!r.nocomment&&t.charAt(0)==="#"?!1:new DB(t,r).match(e)),Inn=/^\*+([^+@!?*[(]*)$/,Tnn=e=>t=>!t.startsWith(".")&&t.endsWith(e),vnn=e=>t=>t.endsWith(e),xnn=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),wnn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Dnn=/^\*+\.\*+$/,Rnn=e=>!e.startsWith(".")&&e.includes("."),Nnn=e=>e!=="."&&e!==".."&&e.includes("."),Bnn=/^\.\*+$/,Onn=e=>e!=="."&&e!==".."&&e.startsWith("."),knn=/^\*+$/,Mnn=e=>e.length!==0&&!e.startsWith("."),Qnn=e=>e.length!==0&&e!=="."&&e!=="..",Pnn=/^\?+([^+@!?*[(]*)?$/,Lnn=([e,t=""])=>{let r=AAt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Fnn=([e,t=""])=>{let r=hAt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Unn=([e,t=""])=>{let r=hAt([e]);return t?n=>r(n)&&n.endsWith(t):r},Hnn=([e,t=""])=>{let r=AAt([e]);return t?n=>r(n)&&n.endsWith(t):r},AAt=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},hAt=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},EAt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",mAt={win32:{sep:"\\"},posix:{sep:"/"}},$nn=EAt==="win32"?mAt.win32.sep:mAt.posix.sep;Yl.sep=$nn;var xc=Symbol("globstar **");Yl.GLOBSTAR=xc;var qnn="[^/]",Gnn=qnn+"*?",znn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",jnn="(?:(?!(?:\\/|^)\\.).)*?",Ynn=(e,t={})=>r=>Yl(r,e,t);Yl.filter=Ynn;var $p=(e,t={})=>Object.assign({},e,t),Vnn=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return Yl;let t=Yl;return Object.assign((n,i,o={})=>t(n,i,$p(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,$p(e,o))}static defaults(i){return t.defaults($p(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,$p(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,$p(e,o))}},unescape:(n,i={})=>t.unescape(n,$p(e,i)),escape:(n,i={})=>t.escape(n,$p(e,i)),filter:(n,i={})=>t.filter(n,$p(e,i)),defaults:n=>t.defaults($p(e,n)),makeRe:(n,i={})=>t.makeRe(n,$p(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,$p(e,i)),match:(n,i,o={})=>t.match(n,i,$p(e,o)),sep:t.sep,GLOBSTAR:xc})};Yl.defaults=Vnn;var _At=(e,t={})=>(kU(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:aAt(e,{max:t.braceExpandMax}));Yl.braceExpand=_At;var Wnn=(e,t={})=>new DB(e,t).makeRe();Yl.makeRe=Wnn;var Knn=(e,t,r={})=>{let n=new DB(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};Yl.match=Knn;var gAt=/[?*]|[+@!]\(.*?\)|\[|\]/,Jnn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),DB=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){kU(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||EAt,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((o,s,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=o[0]===""&&o[1]===""&&(o[2]==="?"||!gAt.test(o[2]))&&!gAt.test(o[3]),c=/^[a-z]:/i.test(o[0]);if(l)return[...o.slice(0,4),...o.slice(4).map(u=>this.parse(u))];if(c)return[o[0],...o.slice(1).map(u=>this.parse(u))]}return o.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let s=this.set[o];s[0]===""&&s[1]===""&&this.globParts[o][2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3])&&(s[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n of t)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,i)=>{let o=n[n.length-1];return i==="**"&&o==="**"?n:i===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let o=t[i];i===1&&o===""&&t[0]===""||(o==="."||o==="")&&(r=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let s=i;for(;n[s+1]==="**";)s++;s>i&&n.splice(i+1,s-i);let a=n[i+1],l=n[i+2],c=n[i+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",t.push(u),i--}if(!this.preserveMultipleSlashes){for(let s=1;s<n.length-1;s++){let a=n[s];s===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(s,1),s--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let s=n[o-1];if(s&&s!=="."&&s!==".."&&s!=="**"){r=!0;let l=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...l),n.length===0&&n.push(""),o-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let i=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(i){t[r]=[],t[n]=i;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let i=0,o=0,s=[],a="";for(;i<t.length&&o<r.length;)if(t[i]===r[o])s.push(a==="b"?r[o]:t[i]),i++,o++;else if(n&&t[i]==="**"&&r[o]===t[i+1])s.push(t[i]),i++;else if(n&&r[o]==="**"&&t[i]===r[o+1])s.push(r[o]),o++;else if(t[i]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",s.push(t[i]),i++,o++}else if(r[o]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(a==="a")return!1;a="b",s.push(r[o]),i++,o++}else return!1;return t.length===r.length&&s}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let i=0,o=0;if(this.isWindows){let a=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),l=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),c=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),u=!c&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),f=l?3:a?0:void 0,g=u?3:c?0:void 0;if(typeof f=="number"&&typeof g=="number"){let[m,A]=[t[f],r[g]];m.toLowerCase()===A.toLowerCase()&&(r[g]=m,o=g,i=f)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(xc)?this.#e(t,r,n,i,o):this.#n(t,r,n,i,o)}#e(t,r,n,i,o){let s=r.indexOf(xc,o),a=r.lastIndexOf(xc),[l,c,u]=n?[r.slice(o,s),r.slice(s+1),[]]:[r.slice(o,s),r.slice(s+1,a),r.slice(a+1)];if(l.length){let I=t.slice(i,i+l.length);if(!this.#n(I,l,n,0,0))return!1;i+=l.length,o+=l.length}let f=0;if(u.length){if(u.length+i>t.length)return!1;let I=t.length-u.length;if(this.#n(t,u,n,I,0))f=u.length;else{if(t[t.length-1]!==""||i+u.length===t.length||(I--,!this.#n(t,u,n,I,0)))return!1;f=u.length+1}}if(!c.length){let I=!!f;for(let T=i;T<t.length-f;T++){let D=String(t[T]);if(I=!0,D==="."||D===".."||!this.options.dot&&D.startsWith("."))return!1}return n||I}let g=[[[],0]],m=g[0],A=0,h=[0];for(let I of c)I===xc?(h.push(A),m=[[],0],g.push(m)):(m[0].push(I),A++);let y=g.length-1,C=t.length-f;for(let I of g)I[1]=C-(h[y--]+I[0].length);return!!this.#t(t,g,i,0,n,0,!!f)}#t(t,r,n,i,o,s,a){let l=r[i];if(!l){for(let f=n;f<t.length;f++){a=!0;let g=t[f];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1}return a}let[c,u]=l;for(;n<=u;){if(this.#n(t.slice(0,n+c.length),c,o,n,0)&&s<this.maxGlobstarRecursion){let m=this.#t(t,r,n+c.length,i+1,o,s+1,a);if(m!==!1)return m}let g=t[n];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1;n++}return o||null}#n(t,r,n,i,o){let s,a,l,c;for(s=i,a=o,c=t.length,l=r.length;s<c&&a<l;s++,a++){this.debug("matchOne loop");let u=r[a],f=t[s];if(this.debug(r,u,f),u===!1||u===xc)return!1;let g;if(typeof u=="string"?(g=f===u,this.debug("string match",u,f,g)):(g=u.test(f),this.debug("pattern match",u,f,g)),!g)return!1}if(s===c&&a===l)return!0;if(s===c)return n;if(a===l)return s===c-1&&t[s]==="";throw new Error("wtf?")}braceExpand(){return _At(this.pattern,this.options)}parse(t){kU(t);let r=this.options;if(t==="**")return xc;if(t==="")return"";let n,i=null;(n=t.match(knn))?i=r.dot?Qnn:Mnn:(n=t.match(Inn))?i=(r.nocase?r.dot?wnn:xnn:r.dot?vnn:Tnn)(n[1]):(n=t.match(Pnn))?i=(r.nocase?r.dot?Fnn:Lnn:r.dot?Unn:Hnn)(n):(n=t.match(Dnn))?i=r.dot?Nnn:Rnn:(n=t.match(Bnn))&&(i=Onn);let o=xT.fromGlob(t,this.options).toMMPattern();return i&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:i}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?Gnn:r.dot?znn:jnn,i=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let c=l.map(f=>{if(f instanceof RegExp)for(let g of f.flags.split(""))i.add(g);return typeof f=="string"?Jnn(f):f===xc?xc:f._src});c.forEach((f,g)=>{let m=c[g+1],A=c[g-1];f!==xc||A===xc||(A===void 0?m!==void 0&&m!==xc?c[g+1]="(?:\\/|"+n+"\\/)?"+m:c[g]=n:m===void 0?c[g-1]=A+"(?:\\/|\\/"+n+")?":m!==xc&&(c[g-1]=A+"(?:\\/|\\/"+n+"\\/)"+m,c[g+1]=xc))});let u=c.filter(f=>f!==xc);if(this.partial&&u.length>=1){let f=[];for(let g=1;g<=u.length;g++)f.push(u.slice(0,g).join("/"));return"(?:"+f.join("|")+")"}return u.join("/")}).join("|"),[s,a]=t.length>1?["(?:",")"]:["",""];o="^"+s+o+a+"$",this.partial&&(o="^(?:\\/|"+s+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let o=this.set;this.debug(this.pattern,"set",o);let s=i[i.length-1];if(!s)for(let a=i.length-2;!s&&a>=0;a--)s=i[a];for(let a of o){let l=i;if(n.matchBase&&a.length===1&&(l=[s]),this.matchOne(l,a,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return Yl.defaults(t).Minimatch}};Yl.AST=xT;Yl.Minimatch=DB;Yl.escape=q1e;Yl.unescape=nC;var CAt=we(BU(),1);Sr();$e();De();Xc();import{readFile as yAt}from"fs/promises";import{existsSync as G1e,readdirSync as Znn,statSync as Xnn}from"fs";import{join as z1e,relative as SAt}from"path";import{homedir as ein}from"os";function bAt(e){try{let t=(0,CAt.default)(e),r=t.data.paths,n=[];return typeof r=="string"?n=r.split(",").map(i=>i.trim()).filter(Boolean):Array.isArray(r)&&(n=r.filter(i=>typeof i=="string")),{paths:n,content:t.content.trim()}}catch(t){return ve(t),{paths:[],content:e.trim()}}}function tin(e,t){return t.length===0?!0:t.some(r=>{try{return Yl(e,r,{matchBase:!0,dot:!0})}catch(n){return ve(n),!1}})}function j1e(e){let t=[];try{if(!G1e(e))return t;let r=Znn(e);for(let n of r){let i=z1e(e,n),o=Xnn(i);o.isDirectory()?t.push(...j1e(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){ve(r)}return t}async function jJ(){let e=[];try{let t=z1e(ein(),Kr,"rules");if(G1e(t)){let r=j1e(t);for(let n of r)try{let i=await yAt(n,"utf-8"),{paths:o,content:s}=bAt(i);o.length>0&&e.push({filePath:n,content:s,paths:o,isProjectRule:!1})}catch(i){ve(i)}}}catch(t){ve(t)}try{let t=z1e(Ne(),Kr,"rules");if(G1e(t)){let r=j1e(t);for(let n of r)try{let i=await yAt(n,"utf-8"),{paths:o,content:s}=bAt(i);o.length>0&&e.push({filePath:SAt(Ne(),n),content:s,paths:o,isProjectRule:!0})}catch(i){ve(i)}}}catch(t){ve(t)}return e}function IAt(e,t){e=dY(e);let r=dY(Ne()),n=e.startsWith(r)?SAt(r,e):e;return t.filter(i=>tin(n,i.paths))}function TAt(e){return e.length===0?"":e.map(r=>{let n=r.isProjectRule?"project instructions, checked into the codebase":"user's private global instructions for all projects";return`Contents of ${r.filePath} (${n}):
|
|
626
626
|
|
|
627
627
|
${r.content}`}).join(`
|
|
628
628
|
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -599,7 +599,7 @@ data: ${JSON.stringify(z)}
|
|
|
599
599
|
`);a=M.pop()||"";for(let z of M){let Y=z.trim();if(!(!Y||Y==="data: [DONE]"))if(Y.startsWith("data: ")){let q=Y.slice(6);try{let K=JSON.parse(q);D(K)}catch(K){this.logger&&this.logger.error({err:K,line:Y},"Failed to parse Gemini SSE chunk")}}else try{let q=JSON.parse(Y);D(q)}catch{}}};(async()=>{try{for(;;){let{value:M,done:z}=await s.read();if(z)break;a+=n.decode(M,{stream:!0}),B()}T()}catch(M){o.error(M)}})()}})}convertGeminiResponseToAnthropic(t){this.logger&&this.logger.debug({response:t},"Original Gemini response");try{if(!t.candidates||!t.candidates[0])throw new Error("No candidates found in Gemini response");let r=t.candidates[0],n=[];r.content&&r.content.parts&&r.content.parts.forEach(o=>{if(o.text&&n.push({type:"text",text:o.text}),o.functionCall){let s=`toolu_${nN()}`,a=o.functionCall.thoughtSignature||o.functionCall.thought_signature||null;n.push({type:"tool_use",id:s,name:o.functionCall.name,input:o.functionCall.args||{},thought_signature:a})}}),r.groundingMetadata&&(this.logger&&this.logger.debug({groundingMetadata:r.groundingMetadata},"Processing grounding metadata"),r.groundingMetadata.webSearchQueries&&n.push({type:"text",text:`
|
|
600
600
|
|
|
601
601
|
[Search queries used: ${r.groundingMetadata.webSearchQueries.join(", ")}]`}));let i={id:`msg_${Math.random().toString(36).slice(2)}`,type:"message",role:"assistant",model:t.modelVersion||"gemini",content:n,stop_reason:r.finishReason?r.finishReason==="STOP"&&n.some(o=>o.type==="tool_use")?"tool_use":this.mapGeminiFinishReason(r.finishReason):"end_turn",stop_sequence:null,usage:{input_tokens:t.usageMetadata?.promptTokenCount||0,output_tokens:t.usageMetadata?.candidatesTokenCount||0}};return this.logger&&this.logger.debug({result:i},"Conversion complete, final Anthropic response"),i}catch{throw rQr(`Provider error: ${JSON.stringify(t)}`,500,"provider_error")}}mapGeminiFinishReason(t){switch(t){case"STOP":return"end_turn";case"MAX_TOKENS":return"max_tokens";case"SAFETY":case"RECITATION":return"stop_sequence";default:return"end_turn"}}},Ome=new Bme;var xst=De(Ist(),1);jt();Mo();function Vm(e){return e?typeof e.entries=="function"?Object.fromEntries(e.entries()):{...e}:{}}function Tst(e){let t=String(e?.["x-thinking-level"]??"medium").toLowerCase();return["off","low","medium","high"].includes(t)?t:"medium"}function A7r(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t}}function h7r(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t,summary:"auto"}}function E7r(e,t="chat"){let r={request:{},response:{},openai:{request:{},response:{}}};return r.request.model=e.request.body.model,r.request.messages=e.request.body.messages,r.request.system=e.request.body.system,r.response.content=e.response.body.content,r.response.usage=e.response.body?.usage,t==="responses"?(r.openai.request.model=e.openai.request.body.model,r.openai.request.input=e.openai.request.body.input,r.openai.response.output=e.openai.response.body?.output,r.openai.response.usage=e.openai.response.body?.usage):(r.openai.request.model=e.openai.request.body.model,r.openai.request.messages=e.openai.request.body.messages,r.openai.response.choices=e.openai.response.body.choices,r.openai.response.usage=e.openai.response.body?.usage),r}function eF(e,t,r){T8(t,e),v8(t,E7r(e,r),r)}function zN(e){let t=[],r=e.getReader(),n,i=new Promise(l=>n=l),o=!1,s=()=>{o||(o=!0,n(Buffer.concat(t).toString("utf8")))};return{stream:new ReadableStream({async pull(l){try{let{done:c,value:u}=await r.read();if(c){l.close(),s();return}t.push(u),l.enqueue(u)}catch(c){l.error(c),s()}},cancel(l){r.cancel(l).catch(()=>{}),s()}}),done:i}}function tF(e){let t=new Headers(e);return t.delete("content-encoding"),t.delete("content-length"),t.delete("transfer-encoding"),t}function a0e(e,t,r,n,i){let o;try{o={type:"error",error:{type:"api_error",message:JSON.parse(i).error?.message??`${e}: ${n}`,code:`${t}_${r}_ERROR`}}}catch{o={type:"error",error:{type:"api_error",message:`${e}: ${n}`,code:`${t}_${r}_ERROR`}}}return new Response(JSON.stringify(o),{status:r,statusText:n,headers:{"Content-Type":"application/json"}})}var vst=["/v1/messages"];function l0e(e){let t;try{typeof e=="string"?t=new uT(e):e instanceof uT?t=e:t=new uT(e.url)}catch{return""}let r=t.pathname;for(let n of vst){let i=r.indexOf(n);if(i!==-1)return t.origin+r.slice(0,i)}return t.origin}function YV(e,t){let r=typeof e=="string"?e:e instanceof uT?e.toString():e.url,n;try{n=new uT(r).pathname}catch{return!1}return vst.some(i=>n.includes(i))&&(t.method==="POST"||t.method==="post")}function _7r(e){return async(t,r)=>{if(!YV(t,r))return e(t,r);let n=JSON.parse(r.body),i=await Vj.transformRequestOut(n),o=l0e(t)+"/chat/completions",s=Vm(r.headers),a=s.authorization??s.Authorization??"";A7r(i,Tst(s));let l=await e(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:a},body:JSON.stringify(i),signal:r.signal});if(!l.ok){let y=await l.text();return V(`OpenAI Chat Completions API error: ${l.status}`,{url:o,errorResponse:y}),a0e("OpenAI Chat Completions API error","OPENROUTER",l.status,l.statusText,y)}let c=n.stream===!0,u=s["x-agent-id"],f={request:{url:o,method:r.method,headers:s,body:n},response:{status:l.status,statusText:l.statusText,headers:Vm(l.headers)},openai:{request:{body:i},response:{}}};if(!c){let y=await l.text(),C=new Response(y,{status:l.status,statusText:l.statusText,headers:tF(l.headers)}),I=await Vj.transformResponseIn(C,n),T=await I.text();try{eF({...f,openai:{...f.openai,response:{body:JSON.parse(y)}},response:{...f.response,body:JSON.parse(T)}},u)}catch(D){V("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u975E\u6D41\u5F0F):",D)}return new Response(T,{status:I.status,statusText:I.statusText,headers:I.headers})}let g=zN(l.body),m=new Response(g.stream,{status:l.status,statusText:l.statusText,headers:tF(l.headers)}),A=await Vj.transformResponseIn(m,n),E=zN(A.body);return Promise.all([g.done,E.done]).then(async([y,C])=>{try{eF({...f,openai:{...f.openai,response:{body:await ZKe(y)}},response:{...f.response,body:await jP(C)}},u)}catch(I){V("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u6D41\u5F0F):"+I?.stack)}}).catch(y=>V("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Chat):"+y)),new Response(E.stream,{status:A.status,statusText:A.statusText,headers:A.headers})}}function y7r(e){return async(t,r)=>{if(!YV(t,r))return e(t,r);let n=JSON.parse(r.body),i=await Wj.transformRequestOut(n),o=Vm(r.headers);h7r(i,Tst(o));let s=JSON.stringify(i),l=l0e(t)+"/responses",c=o.authorization??o.Authorization??"";if(!c)return new Response(JSON.stringify({type:"error",error:{type:"api_error",message:"Missing Authorization header",code:"RESPONSES_AUTH_MISSING"}}),{status:401,headers:{"Content-Type":"application/json"}});let u=await e(l,{method:"POST",headers:{"Content-Type":"application/json",Authorization:c,"x-api-key":c.replace(/^Bearer\s+/i,"").trim()},body:s,signal:r.signal});if(!u.ok){let I=await u.text();return V(`OpenAI Responses API error: ${u.status} ${u.statusText}`,{url:l,status:u.status,errorResponse:I}),a0e("OpenAI Responses API error","RESPONSES",u.status,u.statusText,I)}let f=n.stream===!0,g=o["x-agent-id"],m={request:{url:l,method:r.method,headers:o,body:n},response:{status:u.status,statusText:u.statusText,headers:Vm(u.headers)},openai:{request:{body:i},response:{}}};if(!f){let I=await u.text(),T=new Response(I,{status:u.status,statusText:u.statusText,headers:tF(u.headers)}),D=await Wj.transformResponseIn(T,n),B=await D.text();try{eF({...m,openai:{...m.openai,response:{body:JSON.parse(I)}},response:{...m.response,body:JSON.parse(B)}},g,"responses")}catch(M){V("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u975E\u6D41\u5F0F):",M)}return new Response(B,{status:D.status,statusText:D.statusText,headers:D.headers})}let A=zN(u.body),E=new Response(A.stream,{status:u.status,statusText:u.statusText,headers:tF(u.headers)}),y=await Wj.transformResponseIn(E,n),C=zN(y.body);return Promise.all([A.done,C.done]).then(async([I,T])=>{try{eF({...m,openai:{...m.openai,response:{body:await JKe(I)}},response:{...m.response,body:await jP(T)}},g,"responses")}catch(D){V("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u6D41\u5F0F):"+D?.stack)}}).catch(I=>V("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Responses):"+I)),new Response(C.stream,{status:y.status,statusText:y.statusText,headers:y.headers})}}function b7r(e){return async(t,r)=>{if(!YV(t,r))return e(t,r);let n=JSON.parse(r.body),i=Vm(r.headers),o=await Ome.transformRequestOut(n),s=JSON.stringify(o),a=l0e(t)+`/models/${n.model}:streamGenerateContent?alt=sse`,l=i.authorization??i.Authorization??"",c;try{c=await e(a,{method:"POST",headers:{"Content-Type":"application/json","x-goog-api-key":String(l).replace(/^Bearer\s+/i,"").trim()},body:s,signal:r.signal})}catch(C){throw V("gemini request error:",C),C}if(!c.ok){let C=await c.text();return V(`Gemini API error response: ${c.status} ${c.statusText}`,{url:a,status:c.status,errorResponse:C}),a0e("Gemini API error","Gemini",c.status,c.statusText,C)}let u=n.stream===!0,f=i["x-agent-id"],g={request:{url:a,method:r.method,headers:Vm(r.headers),body:n},response:{status:c.status,statusText:c.statusText,headers:Vm(c.headers)},openai:{request:{body:o},response:{}}},m=zN(c.body),A=new Response(m.stream,{status:c.status,statusText:c.statusText,headers:tF(c.headers)}),E=await Ome.transformResponseIn(A),y=zN(E.body);return Promise.all([m.done,y.done]).then(async([C,I])=>{try{let T=u?XKe(C):JSON.parse(C),D=u?await jP(I):JSON.parse(I);eF({...g,openai:{...g.openai,response:{body:T}},response:{...g.response,body:D}},f)}catch(T){V("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Gemini):"+T?.stack)}}).catch(C=>V("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Gemini):"+C)),new Response(y.stream,{status:E.status,statusText:E.statusText,headers:E.headers})}}function C7r(e){return async(t,r)=>{if(!YV(t,r))return e(t,r);let n=r.body;if(r.body)try{let f=JSON.parse(r.body);n=JSON.stringify(f)}catch{}let i=Vm(r.headers);["1","true"].includes(String(process.env.HAWA_CODE_X_API_KEY_DISABLED??"").toLowerCase())&&(delete i["x-api-key"],delete i["X-API-Key"]),["1","true"].includes(String(process.env.HAWA_CODE_AUTH_DISABLED??"").toLowerCase())&&(delete i.authorization,delete i.Authorization),delete i["content-length"];let a=await e(t,{method:r.method,headers:i,body:n,signal:r.signal});if(!a.ok){let f=await a.text();V(`API error response: ${a.status} ${a.statusText}`,{url:typeof t=="string"?t:t instanceof uT?t.toString():t.url,status:a.status,errorResponse:f});let g;try{let m=JSON.parse(f);g={type:"error",error:{type:"api_error",message:m.error?.message||m.message||`API error: ${a.statusText}`,code:m.error?.code||m.code||`API_${a.status}_ERROR`}},m.error?.details&&(g.error.details=m.error.details)}catch{g={type:"error",error:{type:"api_error",message:`API error: ${a.statusText}`,code:`API_${a.status}_ERROR`}}}return new Response(JSON.stringify(g),{status:a.status,statusText:a.statusText,headers:{"Content-Type":"application/json"}})}let l=a.clone(),c=!(Object.hasOwn(JSON.parse(n),"stream")&&!JSON.parse(n).stream),u={request:{url:typeof t=="string"?t:t instanceof uT?t.toString():t.url,method:r.method,headers:Vm(r.headers),body:JSON.parse(n)},response:{status:a.status,statusText:a.statusText,headers:Vm(a.headers)}};return(async()=>{if(c){let m=await a.text();u.response.body=await jP(m)}else u.response.body=await a.json();let g=Vm(r.headers)["x-agent-id"];T8(g,u),v8(g,{request:u.request.body.messages,response:u.response.body.content,usage:u.response.body?.usage})})().catch(f=>V(`\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF:
|
|
602
|
-
Stack trace: `+f.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var jV=null,s0e=!1;function S7r(){jV=null,s0e=!1}It.on("proxy:changed",S7r);function I7r(){if(s0e)return jV;if(s0e=!0,Ve().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(jV=new xst.ProxyAgent({uri:e}),Et(`[proxy] using proxy: ${e}`)),jV}function T7r(){let e=I7r();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function VV(e){let t=e||process.env.API_TYPE,r=T7r();switch(t){case"openai":return _7r(r);case"openai-responses":return y7r(r);case"gemini":return b7r(r);default:return C7r(r)}}LA();var N7r=De(tt(),1);function Rst(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=w7r(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function w7r(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||D7r(t)?0:R7r(t)?2:1}function D7r(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function R7r(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=128591||e>=129280&&e<=129535||e>=131072&&e<=262141)}function rF(e){if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/36e5),r=Math.floor(e%36e5/6e4),n=(e%6e4/1e3).toFixed(1);return t>0?`${t}h ${r}m ${n}s`:r>0?`${r}m ${n}s`:`${n}s`}function WV(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}we();Mo();var ql={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function KV(e,t){ql.totalCost+=e,ql.totalAPIDuration+=t}function JV(e,t){ql.inputTokens+=e,ql.outputTokens+=t,It.emit("token:change",{inputTokens:ql.inputTokens,outputTokens:ql.outputTokens})}function ZV(e,t){ql.cacheCreationTokens+=e,ql.cacheReadTokens+=t}function nF(){return{inputTokens:ql.inputTokens,outputTokens:ql.outputTokens,cacheCreationTokens:ql.cacheCreationTokens,cacheReadTokens:ql.cacheReadTokens}}function Nst(){return ql.totalCost}function Bst(){return Date.now()-ql.startTime}function Ost(){return ql.totalAPIDuration}function kst(e){ql.currentContextTokens=e}function Mst(){return ql.currentContextTokens}we();He();He();var d0e="2.8.
|
|
602
|
+
Stack trace: `+f.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var jV=null,s0e=!1;function S7r(){jV=null,s0e=!1}It.on("proxy:changed",S7r);function I7r(){if(s0e)return jV;if(s0e=!0,Ve().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(jV=new xst.ProxyAgent({uri:e}),Et(`[proxy] using proxy: ${e}`)),jV}function T7r(){let e=I7r();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function VV(e){let t=e||process.env.API_TYPE,r=T7r();switch(t){case"openai":return _7r(r);case"openai-responses":return y7r(r);case"gemini":return b7r(r);default:return C7r(r)}}LA();var N7r=De(tt(),1);function Rst(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=w7r(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function w7r(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||D7r(t)?0:R7r(t)?2:1}function D7r(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function R7r(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=128591||e>=129280&&e<=129535||e>=131072&&e<=262141)}function rF(e){if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/36e5),r=Math.floor(e%36e5/6e4),n=(e%6e4/1e3).toFixed(1);return t>0?`${t}h ${r}m ${n}s`:r>0?`${r}m ${n}s`:`${n}s`}function WV(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}we();Mo();var ql={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function KV(e,t){ql.totalCost+=e,ql.totalAPIDuration+=t}function JV(e,t){ql.inputTokens+=e,ql.outputTokens+=t,It.emit("token:change",{inputTokens:ql.inputTokens,outputTokens:ql.outputTokens})}function ZV(e,t){ql.cacheCreationTokens+=e,ql.cacheReadTokens+=t}function nF(){return{inputTokens:ql.inputTokens,outputTokens:ql.outputTokens,cacheCreationTokens:ql.cacheCreationTokens,cacheReadTokens:ql.cacheReadTokens}}function Nst(){return ql.totalCost}function Bst(){return Date.now()-ql.startTime}function Ost(){return ql.totalAPIDuration}function kst(e){ql.currentContextTokens=e}function Mst(){return ql.currentContextTokens}we();He();He();var d0e="2.8.8";globalThis.MACRO={VERSION:d0e,PACKAGE_URL:`@dahawa/${Hi}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var XV=process.env.HAWA_CODE_USER_AGENT||`${Hi}/${d0e} (${process.env.USER_TYPE})`;we();we();ir();function od(e,t){let r=[],n=new Set;return e.filter(i=>i.type!=="progress"&&i.type!=="reminder").forEach(i=>{switch(i.type){case"user":{let o=uE(r);if(o?.type==="user"){r[r.length-1]=Qst(o,i);return}r.push(i);return}case"assistant":r.push(i);return;case"insert":{let o=uE(r);o?.type==="user"&&(r[r.length-1]=B7r(o,i));return}case"path_rules":{let o=t?.pathRules;if(!o)return;let s=i.content.paths.filter(u=>!n.has(u));if(s.length===0)return;let a=s.map(u=>o.get(u)).filter(u=>u!==void 0);if(s.forEach(u=>n.add(u)),a.length===0)return;let l=Ct([{type:"text",text:`<system-rules>
|
|
603
603
|
${xze(a)}
|
|
604
604
|
</system-rules>`}]),c=uE(r);c?.type==="user"?r[r.length-1]=Qst(c,l,{skipTrailingSystemReminders:!0}):r.push(l);return}}}),r}function B7r(e,t){return{...e,message:{...e.message,content:k7r(e.message.content,O7r(t.content.content))}}}function O7r(e){return`
|
|
605
605
|
<system-reminder>
|