@builder.io/dev-tools 1.36.0-beta.202603260907.bbf4118 → 1.36.0-beta.202603260926.def4b32

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/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- var lFe=Object.create;var mQ=Object.defineProperty;var gFe=Object.getOwnPropertyDescriptor;var pFe=Object.getOwnPropertyNames;var dFe=Object.getPrototypeOf,fFe=Object.prototype.hasOwnProperty;var N=(t,e)=>()=>(t&&(e=t(t=0)),e);var k=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),eA=(t,e)=>{for(var r in e)mQ(t,r,{get:e[r],enumerable:!0})},y6=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of pFe(e))!fFe.call(t,i)&&i!==r&&mQ(t,i,{get:()=>e[i],enumerable:!(n=gFe(e,i))||n.enumerable});return t};var Z=(t,e,r)=>(r=t!=null?lFe(dFe(t)):{},y6(e||!t||!t.__esModule?mQ(r,"default",{value:t,enumerable:!0}):r,t)),mn=t=>y6(mQ({},"__esModule",{value:!0}),t);var h=N(()=>{(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"bbf4118c1e3d81e1a96f5a1d00db7370d054498d"}}catch{}})()});var D6=k((LCt,Q6)=>{h();function wk(t){return t==null?[]:Array.isArray(t)?t:[t]}function mFe(t,e,r,n){var i,o=t[e],s=~n.string.indexOf(e)?r==null||r===!0?"":String(r):typeof r=="boolean"?r:~n.boolean.indexOf(e)?r==="false"?!1:r==="true"||(t._.push((i=+r,i*0===0?i:r)),!!r):(i=+r,i*0===0?i:r);t[e]=o==null?s:Array.isArray(o)?o.concat(s):[o,s]}Q6.exports=function(t,e){t=t||[],e=e||{};var r,n,i,o,s,a={_:[]},A=0,c=0,u=0,l=t.length;let d=e.alias!==void 0,g=e.unknown!==void 0,p=e.default!==void 0;if(e.alias=e.alias||{},e.string=wk(e.string),e.boolean=wk(e.boolean),d)for(r in e.alias)for(n=e.alias[r]=wk(e.alias[r]),A=0;A<n.length;A++)(e.alias[n[A]]=n.concat(r)).splice(A,1);for(A=e.boolean.length;A-- >0;)for(n=e.alias[e.boolean[A]]||[],c=n.length;c-- >0;)e.boolean.push(n[c]);for(A=e.string.length;A-- >0;)for(n=e.alias[e.string[A]]||[],c=n.length;c-- >0;)e.string.push(n[c]);if(p){for(r in e.default)if(o=typeof e.default[r],n=e.alias[r]=e.alias[r]||[],e[o]!==void 0)for(e[o].push(r),A=0;A<n.length;A++)e[o].push(n[A])}let f=g?Object.keys(e.alias):[];for(A=0;A<l;A++){if(i=t[A],i==="--"){a._=a._.concat(t.slice(++A));break}for(c=0;c<i.length&&i.charCodeAt(c)===45;c++);if(c===0)a._.push(i);else if(i.substring(c,c+3)==="no-"){if(o=i.substring(c+3),g&&!~f.indexOf(o))return e.unknown(i);a[o]=!1}else{for(u=c+1;u<i.length&&i.charCodeAt(u)!==61;u++);for(o=i.substring(c,u),s=i.substring(++u)||A+1===l||(""+t[A+1]).charCodeAt(0)===45||t[++A],n=c===2?[o]:o,u=0;u<n.length;u++){if(o=n[u],g&&!~f.indexOf(o))return e.unknown("-".repeat(c)+o);mFe(a,o,u+1<n.length||s,e)}}}if(p)for(r in e.default)a[r]===void 0&&(a[r]=e.default[r]);if(d)for(r in a)for(n=e.alias[r]||[];n.length>0;)a[n.shift()]=a[r];return a}});function hFe(){if(Kh!==void 0)return Kh;try{return Kh=require("prettier"),Kh}catch{return Kh=null,null}}function CFe(t){let e=[],r=Wl.default.dirname(t);for(;r!==Wl.default.dirname(r);){let n=Wl.default.join(r,".prettierignore");vk.default.existsSync(n)&&e.push(n);let i=Wl.default.join(r,".git");if(vk.default.existsSync(i))break;r=Wl.default.dirname(r)}return e}function IFe(t){if(t)try{let r=(0,w6.createRequire)(t)("prettier");if(r)return r}catch{}return hFe()}async function pa(t,e,r,n){try{let i=Wl.default.resolve(t,n??"file.tsx"),o=IFe(i);if(!o)return e;if(n){let A=CFe(i);if((await o.getFileInfo(i,{ignorePath:A.length>0?A:void 0})).ignored)return e}let s=await o.resolveConfig(i);return await o.format(e,{...s,filepath:n,parser:r})}catch{return e}}var w6,Wl,vk,Kh,hQ=N(()=>{"use strict";h();w6=require("node:module"),Wl=Z(require("node:path"),1),vk=Z(require("node:fs"),1)});var bk,ed,CQ,IQ,v6,Zl,Sk,xk,Xl,b6,td=N(()=>{"use strict";h();bk="preview-url",ed="framework",CQ="platform",IQ="node",v6="/~builder-connect",Zl="/~builder-connected",Sk="/~builder-dev-tools",xk="/~builder-dev-tools.js",Xl="/~builder-dev-tools-close",b6="/mappings"});var EQ=k((JCt,S6)=>{"use strict";h();var Fk={to(t,e){return e?`\x1B[${e+1};${t+1}H`:`\x1B[${t+1}G`},move(t,e){let r="";return t<0?r+=`\x1B[${-t}D`:t>0&&(r+=`\x1B[${t}C`),e<0?r+=`\x1B[${-e}A`:e>0&&(r+=`\x1B[${e}B`),r},up:(t=1)=>`\x1B[${t}A`,down:(t=1)=>`\x1B[${t}B`,forward:(t=1)=>`\x1B[${t}C`,backward:(t=1)=>`\x1B[${t}D`,nextLine:(t=1)=>"\x1B[E".repeat(t),prevLine:(t=1)=>"\x1B[F".repeat(t),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},EFe={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},BFe={screen:"\x1B[2J",up:(t=1)=>"\x1B[1J".repeat(t),down:(t=1)=>"\x1B[J".repeat(t),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(t){let e="";for(let r=0;r<t;r++)e+=this.line+(r<t-1?Fk.up():"");return t&&(e+=Fk.left),e}};S6.exports={cursor:Fk,scroll:EFe,erase:BFe,beep:"\x07"}});var Zr=k((jCt,kk)=>{h();var yQ=process||{},x6=yQ.argv||[],BQ=yQ.env||{},yFe=!(BQ.NO_COLOR||x6.includes("--no-color"))&&(!!BQ.FORCE_COLOR||x6.includes("--color")||yQ.platform==="win32"||(yQ.stdout||{}).isTTY&&BQ.TERM!=="dumb"||!!BQ.CI),QFe=(t,e,r=t)=>n=>{let i=""+n,o=i.indexOf(e,t.length);return~o?t+DFe(i,e,r,o)+e:t+i+e},DFe=(t,e,r,n)=>{let i="",o=0;do i+=t.substring(o,n)+r,o=n+e.length,n=t.indexOf(e,o);while(~n);return i+t.substring(o)},F6=(t=yFe)=>{let e=t?QFe:()=>String;return{isColorSupported:t,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};kk.exports=F6();kk.exports.createColors=F6});function wFe({onlyFirst:t=!1}={}){let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(e,t?void 0:"g")}function O6(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(vFe,"")}function K6(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Hh(t,e={}){if(typeof t!="string"||t.length===0||(e={ambiguousIsNarrow:!0,...e},t=O6(t),t.length===0))return 0;t=t.replace(FFe()," ");let r=e.ambiguousIsNarrow?1:2,n=0;for(let i of t){let o=i.codePointAt(0);if(!(o<=31||o>=127&&o<=159||o>=768&&o<=879))switch(SFe.eastAsianWidth(i)){case"F":case"W":n+=2;break;case"A":n+=r;break;default:n+=1}}return n}function NFe(){let t=new Map;for(let[e,r]of Object.entries(Xr)){for(let[n,i]of Object.entries(r))Xr[n]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},r[n]=Xr[n],t.set(i[0],i[1]);Object.defineProperty(Xr,e,{value:r,enumerable:!1})}return Object.defineProperty(Xr,"codes",{value:t,enumerable:!1}),Xr.color.close="\x1B[39m",Xr.bgColor.close="\x1B[49m",Xr.color.ansi=k6(),Xr.color.ansi256=R6(),Xr.color.ansi16m=N6(),Xr.bgColor.ansi=k6(Rk),Xr.bgColor.ansi256=R6(Rk),Xr.bgColor.ansi16m=N6(Rk),Object.defineProperties(Xr,{rgbToAnsi256:{value:(e,r,n)=>e===r&&r===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!r)return[0,0,0];let[n]=r;n.length===3&&(n=[...n].map(o=>o+o).join(""));let i=Number.parseInt(n,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:e=>Xr.rgbToAnsi256(...Xr.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let r,n,i;if(e>=232)r=((e-232)*10+8)/255,n=r,i=r;else{e-=16;let a=e%36;r=Math.floor(e/36)/5,n=Math.floor(a/6)/5,i=a%6/5}let o=Math.max(r,n,i)*2;if(o===0)return 30;let s=30+(Math.round(i)<<2|Math.round(n)<<1|Math.round(r));return o===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(e,r,n)=>Xr.ansi256ToAnsi(Xr.rgbToAnsi256(e,r,n)),enumerable:!1},hexToAnsi:{value:e=>Xr.ansi256ToAnsi(Xr.hexToAnsi256(e)),enumerable:!1}}),Xr}function P6(t,e,r){return String(t).normalize().replace(/\r\n/g,`
1
+ var lFe=Object.create;var mQ=Object.defineProperty;var gFe=Object.getOwnPropertyDescriptor;var pFe=Object.getOwnPropertyNames;var dFe=Object.getPrototypeOf,fFe=Object.prototype.hasOwnProperty;var N=(t,e)=>()=>(t&&(e=t(t=0)),e);var k=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),eA=(t,e)=>{for(var r in e)mQ(t,r,{get:e[r],enumerable:!0})},y6=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of pFe(e))!fFe.call(t,i)&&i!==r&&mQ(t,i,{get:()=>e[i],enumerable:!(n=gFe(e,i))||n.enumerable});return t};var Z=(t,e,r)=>(r=t!=null?lFe(dFe(t)):{},y6(e||!t||!t.__esModule?mQ(r,"default",{value:t,enumerable:!0}):r,t)),mn=t=>y6(mQ({},"__esModule",{value:!0}),t);var h=N(()=>{(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"def4b3276bcd3cef22d8b222594ca4be0fb82abd"}}catch{}})()});var D6=k((LCt,Q6)=>{h();function wk(t){return t==null?[]:Array.isArray(t)?t:[t]}function mFe(t,e,r,n){var i,o=t[e],s=~n.string.indexOf(e)?r==null||r===!0?"":String(r):typeof r=="boolean"?r:~n.boolean.indexOf(e)?r==="false"?!1:r==="true"||(t._.push((i=+r,i*0===0?i:r)),!!r):(i=+r,i*0===0?i:r);t[e]=o==null?s:Array.isArray(o)?o.concat(s):[o,s]}Q6.exports=function(t,e){t=t||[],e=e||{};var r,n,i,o,s,a={_:[]},A=0,c=0,u=0,l=t.length;let d=e.alias!==void 0,g=e.unknown!==void 0,p=e.default!==void 0;if(e.alias=e.alias||{},e.string=wk(e.string),e.boolean=wk(e.boolean),d)for(r in e.alias)for(n=e.alias[r]=wk(e.alias[r]),A=0;A<n.length;A++)(e.alias[n[A]]=n.concat(r)).splice(A,1);for(A=e.boolean.length;A-- >0;)for(n=e.alias[e.boolean[A]]||[],c=n.length;c-- >0;)e.boolean.push(n[c]);for(A=e.string.length;A-- >0;)for(n=e.alias[e.string[A]]||[],c=n.length;c-- >0;)e.string.push(n[c]);if(p){for(r in e.default)if(o=typeof e.default[r],n=e.alias[r]=e.alias[r]||[],e[o]!==void 0)for(e[o].push(r),A=0;A<n.length;A++)e[o].push(n[A])}let f=g?Object.keys(e.alias):[];for(A=0;A<l;A++){if(i=t[A],i==="--"){a._=a._.concat(t.slice(++A));break}for(c=0;c<i.length&&i.charCodeAt(c)===45;c++);if(c===0)a._.push(i);else if(i.substring(c,c+3)==="no-"){if(o=i.substring(c+3),g&&!~f.indexOf(o))return e.unknown(i);a[o]=!1}else{for(u=c+1;u<i.length&&i.charCodeAt(u)!==61;u++);for(o=i.substring(c,u),s=i.substring(++u)||A+1===l||(""+t[A+1]).charCodeAt(0)===45||t[++A],n=c===2?[o]:o,u=0;u<n.length;u++){if(o=n[u],g&&!~f.indexOf(o))return e.unknown("-".repeat(c)+o);mFe(a,o,u+1<n.length||s,e)}}}if(p)for(r in e.default)a[r]===void 0&&(a[r]=e.default[r]);if(d)for(r in a)for(n=e.alias[r]||[];n.length>0;)a[n.shift()]=a[r];return a}});function hFe(){if(Kh!==void 0)return Kh;try{return Kh=require("prettier"),Kh}catch{return Kh=null,null}}function CFe(t){let e=[],r=Wl.default.dirname(t);for(;r!==Wl.default.dirname(r);){let n=Wl.default.join(r,".prettierignore");vk.default.existsSync(n)&&e.push(n);let i=Wl.default.join(r,".git");if(vk.default.existsSync(i))break;r=Wl.default.dirname(r)}return e}function IFe(t){if(t)try{let r=(0,w6.createRequire)(t)("prettier");if(r)return r}catch{}return hFe()}async function pa(t,e,r,n){try{let i=Wl.default.resolve(t,n??"file.tsx"),o=IFe(i);if(!o)return e;if(n){let A=CFe(i);if((await o.getFileInfo(i,{ignorePath:A.length>0?A:void 0})).ignored)return e}let s=await o.resolveConfig(i);return await o.format(e,{...s,filepath:n,parser:r})}catch{return e}}var w6,Wl,vk,Kh,hQ=N(()=>{"use strict";h();w6=require("node:module"),Wl=Z(require("node:path"),1),vk=Z(require("node:fs"),1)});var bk,ed,CQ,IQ,v6,Zl,Sk,xk,Xl,b6,td=N(()=>{"use strict";h();bk="preview-url",ed="framework",CQ="platform",IQ="node",v6="/~builder-connect",Zl="/~builder-connected",Sk="/~builder-dev-tools",xk="/~builder-dev-tools.js",Xl="/~builder-dev-tools-close",b6="/mappings"});var EQ=k((JCt,S6)=>{"use strict";h();var Fk={to(t,e){return e?`\x1B[${e+1};${t+1}H`:`\x1B[${t+1}G`},move(t,e){let r="";return t<0?r+=`\x1B[${-t}D`:t>0&&(r+=`\x1B[${t}C`),e<0?r+=`\x1B[${-e}A`:e>0&&(r+=`\x1B[${e}B`),r},up:(t=1)=>`\x1B[${t}A`,down:(t=1)=>`\x1B[${t}B`,forward:(t=1)=>`\x1B[${t}C`,backward:(t=1)=>`\x1B[${t}D`,nextLine:(t=1)=>"\x1B[E".repeat(t),prevLine:(t=1)=>"\x1B[F".repeat(t),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},EFe={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},BFe={screen:"\x1B[2J",up:(t=1)=>"\x1B[1J".repeat(t),down:(t=1)=>"\x1B[J".repeat(t),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(t){let e="";for(let r=0;r<t;r++)e+=this.line+(r<t-1?Fk.up():"");return t&&(e+=Fk.left),e}};S6.exports={cursor:Fk,scroll:EFe,erase:BFe,beep:"\x07"}});var Zr=k((jCt,kk)=>{h();var yQ=process||{},x6=yQ.argv||[],BQ=yQ.env||{},yFe=!(BQ.NO_COLOR||x6.includes("--no-color"))&&(!!BQ.FORCE_COLOR||x6.includes("--color")||yQ.platform==="win32"||(yQ.stdout||{}).isTTY&&BQ.TERM!=="dumb"||!!BQ.CI),QFe=(t,e,r=t)=>n=>{let i=""+n,o=i.indexOf(e,t.length);return~o?t+DFe(i,e,r,o)+e:t+i+e},DFe=(t,e,r,n)=>{let i="",o=0;do i+=t.substring(o,n)+r,o=n+e.length,n=t.indexOf(e,o);while(~n);return i+t.substring(o)},F6=(t=yFe)=>{let e=t?QFe:()=>String;return{isColorSupported:t,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};kk.exports=F6();kk.exports.createColors=F6});function wFe({onlyFirst:t=!1}={}){let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(e,t?void 0:"g")}function O6(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(vFe,"")}function K6(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Hh(t,e={}){if(typeof t!="string"||t.length===0||(e={ambiguousIsNarrow:!0,...e},t=O6(t),t.length===0))return 0;t=t.replace(FFe()," ");let r=e.ambiguousIsNarrow?1:2,n=0;for(let i of t){let o=i.codePointAt(0);if(!(o<=31||o>=127&&o<=159||o>=768&&o<=879))switch(SFe.eastAsianWidth(i)){case"F":case"W":n+=2;break;case"A":n+=r;break;default:n+=1}}return n}function NFe(){let t=new Map;for(let[e,r]of Object.entries(Xr)){for(let[n,i]of Object.entries(r))Xr[n]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},r[n]=Xr[n],t.set(i[0],i[1]);Object.defineProperty(Xr,e,{value:r,enumerable:!1})}return Object.defineProperty(Xr,"codes",{value:t,enumerable:!1}),Xr.color.close="\x1B[39m",Xr.bgColor.close="\x1B[49m",Xr.color.ansi=k6(),Xr.color.ansi256=R6(),Xr.color.ansi16m=N6(),Xr.bgColor.ansi=k6(Rk),Xr.bgColor.ansi256=R6(Rk),Xr.bgColor.ansi16m=N6(Rk),Object.defineProperties(Xr,{rgbToAnsi256:{value:(e,r,n)=>e===r&&r===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!r)return[0,0,0];let[n]=r;n.length===3&&(n=[...n].map(o=>o+o).join(""));let i=Number.parseInt(n,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:e=>Xr.rgbToAnsi256(...Xr.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let r,n,i;if(e>=232)r=((e-232)*10+8)/255,n=r,i=r;else{e-=16;let a=e%36;r=Math.floor(e/36)/5,n=Math.floor(a/6)/5,i=a%6/5}let o=Math.max(r,n,i)*2;if(o===0)return 30;let s=30+(Math.round(i)<<2|Math.round(n)<<1|Math.round(r));return o===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(e,r,n)=>Xr.ansi256ToAnsi(Xr.rgbToAnsi256(e,r,n)),enumerable:!1},hexToAnsi:{value:e=>Xr.ansi256ToAnsi(Xr.hexToAnsi256(e)),enumerable:!1}}),Xr}function P6(t,e,r){return String(t).normalize().replace(/\r\n/g,`
2
2
  `).split(`
3
3
  `).map(n=>UFe(n,e,r)).join(`
4
4
  `)}function Lk(t,e){if(typeof t=="string")return DQ.aliases.get(t)===e;for(let r of t)if(r!==void 0&&Lk(r,e))return!0;return!1}function OFe(t,e){if(t===e)return;let r=t.split(`
@@ -73,7 +73,7 @@ ${V6}${n.trimStart()}`),r=3+(0,eg.stripVTControlCharacters)(n.trimStart()).lengt
73
73
  `),p(),i()};return{start:I,stop:B,message:(E="")=>{a=m(E??a)}}}});function sr(t,e=""){return t.ts.createSourceFile("module.tsx",typeof e=="string"?e:"",t.ts.ScriptTarget.Latest,void 0)}function kQ(t,e=""){let r=sr(t,e?.trim());if(r.statements.length===0)throw new Error(`No statements found in code: ${e}`);return r.statements[0]}function ti(t,e,r){if(e){let n=t.ts.createPrinter({newLine:t.ts.NewLineKind.LineFeed,removeComments:r});return t.ts.isSourceFile(e)?n.printFile(e).trim()+`
74
74
  `:n.printNode(t.ts.EmitHint.Unspecified,e,t.ts.createSourceFile("module.tsx","",t.ts.ScriptTarget.Latest)).trim()+`
75
75
  `}return""}var gn=N(()=>{"use strict";h()});var i9=k((AIt,n9)=>{"use strict";h();n9.exports=function(){if(process.env.npm_config_user_agent)return ike(process.env.npm_config_user_agent)};function ike(t){let e=t.split(" ")[0],r=e.lastIndexOf("/"),n=e.substring(0,r);return{name:n==="npminstall"?"cnpm":n,version:e.substring(r+1)}}});function no(t){return t.endsWith(".mapper.tsx")||t.endsWith(".mapper.jsx")||t.endsWith(".mapper.ts")||t.endsWith(".mapper.js")||t.endsWith(".mapper.mjs")}function ar(t,e,r){e=da(e),r=da(r),e=t.dirname(e);let n=t.basename(r,t.extname(r));r=t.dirname(r);let i;return n==="index"?i=t.relative(e,r):i=t.relative(e,t.join(r,n)),i=da(t.normalize(i)),i.startsWith(".")||(i="./"+i),i}function da(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}function rg(t,e){let r=t.extname(e),n=t.basename(e,r).split(/[\/\\]/),i=n[n.length-1];return o9(i==="index"?t.basename(t.dirname(e)):i)}function o9(t){return _r(t).replace(/ /g,"")}function Ds(t,e){let r=t.extname(e),n=da(t.basename(e,r)).split("/").pop();return _r(n==="index"?t.basename(t.dirname(e)):n)}function Lr(t,e){let r=da(t.relative(t.getAppRootDir(),e));r=r.split("/").filter(i=>i!=="."&&i!==".."&&i!=="").join("/"),r.endsWith(".tsx")||r.endsWith(".jsx")?r=r.slice(0,-4):(r.endsWith(".ts")||r.endsWith(".js"))&&(r=r.slice(0,-3));let n=t.getFrameworks();return r.startsWith("src/")&&(r=r.slice(4)),n.some(i=>i.name.includes("next"))?"@/"+r:"~/"+r}function hr(t,e){let r=e,n=[];for(let i=0;i<2;i++){let o=t.basename(r);if(!o||o==="components")break;n.unshift(o),r=t.dirname(r)}return n.join("/")}function _r(t){for(t=t.replace(/([A-Z])/g," $1").replace(/\./g," ").replace(/_/g," ").replace(/-/g," ").replace(/\s/g," ").trim();t.includes(" ");)t=t.replace(/ /g," ");return t.split(" ").map(e=>e.length>2?e[0].toUpperCase()+e.slice(1):e).join("").trim()}function xo(t){return t.sort((e,r)=>e.name.toLocaleLowerCase().localeCompare(r.name.toLocaleLowerCase()))}async function kr(t,e,r,n){if(typeof r!="string"||r==="")throw new Error(`getComponentId(), exportName must be a non-empty string, received: ${r}, ${e}`);return n&&(e=n),e=t.normalize(e),(await t.hash(e+"#"+r)).substring(0,8)}async function a9(t){return(await t.hash(t.getAppRootDir())).substring(0,8)}function $h(t){return typeof t=="number"}function id(t){return typeof t=="boolean"}function io(t){return typeof t=="string"}function od(t){return typeof t=="string"?/^[A-Z][A-Za-z0-9]*$/.test(t):!1}function es(t){return JSON.parse(JSON.stringify(t))}function RQ(t,e,r){for(let n of e)if(t.dirname(r).includes(n))return!0;return!1}function A9(){try{let t=(0,s9.default)();if(t?.name)return t.name}catch{}return"npm"}function oke(){return process.platform.startsWith("win")}function Dr(){return process.pkg?"@builder.io/agent":oke()?'"@builder.io/dev-tools"':"builder.io"}function Jk(t){return t.replace(/[^a-zA-Z0-9-_]/g,"_")}var s9,Wt=N(()=>{"use strict";h();s9=Z(i9(),1)});function oo(t){let e=t.join(t.getAppRootDir(),"tsconfig.json");return t.exists(e)}async function Fo(t,e){async function r(i,o){if(o>10)return;let s=await t.readdir(i);for(let a of s){if(ske.includes(a))continue;let A=t.join(i,a),c=await t.stat(A);if(c){if(c.isFile()&&a.startsWith("builder-registry."))return A;if(c.isDirectory()){let u=await r(A,o+1);if(u)return u}}}}let n=await r(t.getAppRootDir(),0);if(!n){let o=`builder-registry.${await oo(t)?"ts":"js"}`;return t.join(e,o)}return n}async function fa(t,e){let r=t.resolve("/");for(let n=0;n<20;n++){let i=t.join(e,"package.json"),o=await t.readFile(i);if(o)return JSON.parse(o);if(e===r)break;e=t.dirname(e)}return null}async function c9(t,e){for(let r=0;r<20;r++){let n=t.dirname(e),i=t.join(n,"node_modules");if(await t.exists(i))return i;if(e===t.getAppRootDir())break;e=t.dirname(e)}return t.join(t.getAppRootDir(),"node_modules")}async function jh(t,e,r){let n=await t.readdir(e);return n.includes(r)?t.join(e,r):(await Promise.all(n.map(async o=>{if(o.startsWith(".")||o==="node_modules")return;let s=t.join(e,o);if((await t.stat(s)).isDirectory()){let A=await jh(t,s,r);if(A)return A}}))).find(o=>typeof o=="string")}var ske,Gi=N(()=>{"use strict";h();ske=["node_modules","dist","build","public"]});async function Kn(t,e,r){if(!Array.isArray(e)||e.length===0)throw new Error(`createTsProgram() Invalid filePaths: ${e}`);let n=await c9(t,e[0]),i=t.join(n,"typescript","lib"),o=new Map,s={fileExists:a=>{if(a=t.normalize(a),a.includes("node_modules")){let A=Yh.get(a);if(!A){try{t.statSync(a).isFile()?A={exists:!0,content:t.readFileSync(a)}:A={exists:!1}}catch{A={exists:!1}}Yh.set(a,A)}return A.exists}if(!o.has(a))if(t.existsSync(a)){let c=t.statSync(a);o.set(a,c.isFile())}else o.set(a,!1);return o.get(a)},getCanonicalFileName:a=>t.normalize(a),getCurrentDirectory:()=>t.cwd(),getDefaultLibFileName:()=>t.join(i,"lib.d.ts"),getDefaultLibLocation:()=>i,getNewLine:()=>`
76
- `,getSourceFile:a=>{if(a=t.normalize(a),a.includes("node_modules")){let c=Yh.get(a);if(c)return sr(t,c.content)}let A;try{A=t.readFileSync(a)}catch{console.error(`Could not read: ${a}`),A==null}if(A==null){let c=t.basename(a),u=t.extname(c).toLowerCase();if(a.startsWith(i)&&u===".ts"&&(A=l9.get(c),A==null&&typeof self<"u"&&typeof fetch=="function"))throw new TQ(c)}return a.includes("node_modules")&&(A?Yh.set(a,{exists:!0,content:A}):Yh.set(a,{exists:!1})),sr(t,A)},readFile:a=>{let A=t.readFileSync(a);return typeof A=="string"?A:void 0},useCaseSensitiveFileNames:()=>!1,writeFile:()=>{}};for(;;)try{return ake(t,s,e,r)}catch(a){if(a instanceof TQ){await Ake(t,a.libName);continue}throw t.Sentry?.captureException(a),new Error(`createTsProgram() Could not create program for: ${e[0]}`,{cause:a})}}function ake(t,e,r,n){let i={rootNames:[...r],host:e,options:{}},o=t.ts.findConfigFile(t.dirname(r[0]),s=>t.existsSync(s));if(o){let s=u9.get(o);if(!s){let a=t.ts.readConfigFile(o,A=>{let c=t.readFileSync(A);return typeof c=="string"?c:void 0});a.error?t.Sentry?.captureException(new Error("Error reading tsconfig for createTsProgram"),{extra:{error:a.error,tsConfigPath:o}}):(s=t.ts.parseJsonConfigFileContent(a.config,t.ts.sys||{useCaseSensitiveFileNames:!1,readDirectory:(c,u)=>t.readdirSync(c),fileExists:c=>t.existsSync(c),readFile:c=>t.readFileSync(c)||void 0},t.dirname(o),void 0,o).options,u9.set(o,s))}s&&(i.options=es(s))}return i.options.noEmit=!0,i.options.isolatedModules=!1,i.options.strict=!1,i.options.jsx=t.ts.JsxEmit.Preserve,i.options.allowJs=!0,Object.assign(i.options,n),t.ts.createProgram(i)}async function sd(t,e,r){r||(r=await Kn(t,[e]));let n=r.getSourceFile(e);if(!n)throw new Error(`getTypeChecker() Could not find source file: ${e}`);return{typeChecker:r.getTypeChecker(),sourceFile:n}}async function Ake(t,e){let r=`https://cdn.jsdelivr.net/npm/typescript@${t.ts.version}/lib/${e}`;NQ.has(e)||NQ.set(e,fetch(r).then(n=>n.text()).then(n=>{l9.set(e,n)})),await NQ.get(e),NQ.delete(e)}async function g9(t,e){let r=await t.readFile(e.filePath);return r==null?{diagnostics:[{messageText:`Error reading: ${e.filePath}`}],code:null,output:null}:$k(t,{code:r,filePath:e.filePath,compilerOptions:e.compilerOptions})}function $k(t,e){let r={diagnostics:[],code:e.code,output:null};try{let n=t.ts.transpileModule(e.code,{compilerOptions:e.compilerOptions,fileName:e.filePath??"module.tsx",reportDiagnostics:!0});n.diagnostics?.forEach(i=>{r.diagnostics.push({messageText:String(i.messageText)})}),r.output=n.outputText}catch(n){console.error("transpileModule",n),r.diagnostics.push({messageText:String(n)})}return r}var TQ,l9,NQ,Yh,u9,ws=N(()=>{"use strict";h();gn();Wt();Gi();TQ=class{libName;constructor(e){this.libName=e}};l9=new Map,NQ=new Map,Yh=new Map,u9=new Map});var cke,wt,Qn=N(()=>{"use strict";h();cke="1.36.0-beta.202603260907.bbf4118",wt=process.env.OVERRIDE_VERSION??cke});async function ng(t){let e=[],r=await fa(t,t.getRepoRootDir());if(r){let n=await d9(r,t);e.push(...n)}return e}async function d9(t,e){let r=[];if(t&&typeof t=="object"){let n=new Set(Object.keys({...t.dependencies,...t.devDependencies}));for(let i of uke)if(n.has(i)&&!r.some(o=>o.name===i)){let o={name:i};p9.has(i)&&(o.version=await p9.get(i)(e)),r.push(o)}}return r}function jk(t){let e=parseInt(t);return Number.isNaN(e)?void 0:e}var p9,uke,ig=N(()=>{"use strict";h();Gi();Wt();p9=new Map([["next",async t=>{if(!t.spawnSync)return;let e=A9(),r=e==="npm"?"npx":e,{stdout:n}=t.spawnSync(r,["next","-v"],{encoding:"utf8"});if(!n)return;let i=n.match(/(Next.js v)([\d.]+)/g);if(!i)return;let o=i[0].split("Next.js v")[1],[s,a,A]=o.split(".");return{major:jk(s),minor:jk(a),patch:jk(A)}}]]),uke=["@shopify/remix-oxygen","@shopify/hydrogen","@builder.io/qwik-city","@remix-run/react","@sveltejs/kit","astro","gatsby","next","nuxt","@builder.io/qwik","@angular/core","react","solid-js","svelte","vue"]});async function vs(t){let e=f9(t),r=await t.readFile(e);return typeof r=="string"?JSON.parse(r):{}}async function bs(t,e){e=typeof e=="object"&&e!=null?e:{};let r=f9(t);await t.writeFile(r,JSON.stringify(e??{},null,2))}function f9(t){let e=t.getAppRootDir();return t.join(e,"node_modules",".builder","builder-cache.json")}var og=N(()=>{"use strict";h()});async function tA(t,e,r){let n={envKey:r,envValue:null,file:""};for(let i of e){let o=t.join(t.getAppRootDir(),i),s=await lke(t,o);if(s){let a=s[r];if(typeof a=="string"&&a.length>0&&a!=="YOUR_API_KEY")return n.envValue=a,n.file=o,n}}return n.file=t.join(t.getAppRootDir(),e[e.length-1]),n}async function lke(t,e){let r=await t.readFile(e);return typeof r=="string"?m9(r):null}function m9(t){let e={},r=t.replace(/\r\n?/gm,`
76
+ `,getSourceFile:a=>{if(a=t.normalize(a),a.includes("node_modules")){let c=Yh.get(a);if(c)return sr(t,c.content)}let A;try{A=t.readFileSync(a)}catch{console.error(`Could not read: ${a}`),A==null}if(A==null){let c=t.basename(a),u=t.extname(c).toLowerCase();if(a.startsWith(i)&&u===".ts"&&(A=l9.get(c),A==null&&typeof self<"u"&&typeof fetch=="function"))throw new TQ(c)}return a.includes("node_modules")&&(A?Yh.set(a,{exists:!0,content:A}):Yh.set(a,{exists:!1})),sr(t,A)},readFile:a=>{let A=t.readFileSync(a);return typeof A=="string"?A:void 0},useCaseSensitiveFileNames:()=>!1,writeFile:()=>{}};for(;;)try{return ake(t,s,e,r)}catch(a){if(a instanceof TQ){await Ake(t,a.libName);continue}throw t.Sentry?.captureException(a),new Error(`createTsProgram() Could not create program for: ${e[0]}`,{cause:a})}}function ake(t,e,r,n){let i={rootNames:[...r],host:e,options:{}},o=t.ts.findConfigFile(t.dirname(r[0]),s=>t.existsSync(s));if(o){let s=u9.get(o);if(!s){let a=t.ts.readConfigFile(o,A=>{let c=t.readFileSync(A);return typeof c=="string"?c:void 0});a.error?t.Sentry?.captureException(new Error("Error reading tsconfig for createTsProgram"),{extra:{error:a.error,tsConfigPath:o}}):(s=t.ts.parseJsonConfigFileContent(a.config,t.ts.sys||{useCaseSensitiveFileNames:!1,readDirectory:(c,u)=>t.readdirSync(c),fileExists:c=>t.existsSync(c),readFile:c=>t.readFileSync(c)||void 0},t.dirname(o),void 0,o).options,u9.set(o,s))}s&&(i.options=es(s))}return i.options.noEmit=!0,i.options.isolatedModules=!1,i.options.strict=!1,i.options.jsx=t.ts.JsxEmit.Preserve,i.options.allowJs=!0,Object.assign(i.options,n),t.ts.createProgram(i)}async function sd(t,e,r){r||(r=await Kn(t,[e]));let n=r.getSourceFile(e);if(!n)throw new Error(`getTypeChecker() Could not find source file: ${e}`);return{typeChecker:r.getTypeChecker(),sourceFile:n}}async function Ake(t,e){let r=`https://cdn.jsdelivr.net/npm/typescript@${t.ts.version}/lib/${e}`;NQ.has(e)||NQ.set(e,fetch(r).then(n=>n.text()).then(n=>{l9.set(e,n)})),await NQ.get(e),NQ.delete(e)}async function g9(t,e){let r=await t.readFile(e.filePath);return r==null?{diagnostics:[{messageText:`Error reading: ${e.filePath}`}],code:null,output:null}:$k(t,{code:r,filePath:e.filePath,compilerOptions:e.compilerOptions})}function $k(t,e){let r={diagnostics:[],code:e.code,output:null};try{let n=t.ts.transpileModule(e.code,{compilerOptions:e.compilerOptions,fileName:e.filePath??"module.tsx",reportDiagnostics:!0});n.diagnostics?.forEach(i=>{r.diagnostics.push({messageText:String(i.messageText)})}),r.output=n.outputText}catch(n){console.error("transpileModule",n),r.diagnostics.push({messageText:String(n)})}return r}var TQ,l9,NQ,Yh,u9,ws=N(()=>{"use strict";h();gn();Wt();Gi();TQ=class{libName;constructor(e){this.libName=e}};l9=new Map,NQ=new Map,Yh=new Map,u9=new Map});var cke,wt,Qn=N(()=>{"use strict";h();cke="1.36.0-beta.202603260926.def4b32",wt=process.env.OVERRIDE_VERSION??cke});async function ng(t){let e=[],r=await fa(t,t.getRepoRootDir());if(r){let n=await d9(r,t);e.push(...n)}return e}async function d9(t,e){let r=[];if(t&&typeof t=="object"){let n=new Set(Object.keys({...t.dependencies,...t.devDependencies}));for(let i of uke)if(n.has(i)&&!r.some(o=>o.name===i)){let o={name:i};p9.has(i)&&(o.version=await p9.get(i)(e)),r.push(o)}}return r}function jk(t){let e=parseInt(t);return Number.isNaN(e)?void 0:e}var p9,uke,ig=N(()=>{"use strict";h();Gi();Wt();p9=new Map([["next",async t=>{if(!t.spawnSync)return;let e=A9(),r=e==="npm"?"npx":e,{stdout:n}=t.spawnSync(r,["next","-v"],{encoding:"utf8"});if(!n)return;let i=n.match(/(Next.js v)([\d.]+)/g);if(!i)return;let o=i[0].split("Next.js v")[1],[s,a,A]=o.split(".");return{major:jk(s),minor:jk(a),patch:jk(A)}}]]),uke=["@shopify/remix-oxygen","@shopify/hydrogen","@builder.io/qwik-city","@remix-run/react","@sveltejs/kit","astro","gatsby","next","nuxt","@builder.io/qwik","@angular/core","react","solid-js","svelte","vue"]});async function vs(t){let e=f9(t),r=await t.readFile(e);return typeof r=="string"?JSON.parse(r):{}}async function bs(t,e){e=typeof e=="object"&&e!=null?e:{};let r=f9(t);await t.writeFile(r,JSON.stringify(e??{},null,2))}function f9(t){let e=t.getAppRootDir();return t.join(e,"node_modules",".builder","builder-cache.json")}var og=N(()=>{"use strict";h()});async function tA(t,e,r){let n={envKey:r,envValue:null,file:""};for(let i of e){let o=t.join(t.getAppRootDir(),i),s=await lke(t,o);if(s){let a=s[r];if(typeof a=="string"&&a.length>0&&a!=="YOUR_API_KEY")return n.envValue=a,n.file=o,n}}return n.file=t.join(t.getAppRootDir(),e[e.length-1]),n}async function lke(t,e){let r=await t.readFile(e);return typeof r=="string"?m9(r):null}function m9(t){let e={},r=t.replace(/\r\n?/gm,`
77
77
  `),n;for(;(n=gke.exec(r))!=null;){let i=n[1],o=n[2]||"";o=o.trim();let s=o[0];o=o.replace(/^(['"`])([\s\S]*)\1$/gm,"$2"),s==='"'&&(o=o.replace(/\\n/g,`
78
78
  `),o=o.replace(/\\r/g,"\r")),e[i]=o}return e}async function rA(t,e,r,n){let i="# https://www.builder.io/c/docs/using-your-api-key",o=await t.readFile(e);try{if(o)if(o.includes(r))if(o.includes(n))t.debug(`"${r}" with "${n}" already set in ${e}`);else return t.debug(`Replace "${r}" in ${e}`),o=o.replace(new RegExp(`${r}=.*`),`${r}=${n}`),await t.writeFile(e,o),"update";else return t.debug(`Append "${r}" to ${e}`),o+=`
79
79
 
@@ -1276,7 +1276,7 @@ Restarting server after Builder Devtools update...
1276
1276
  <h3>How's Devtools working for you?</h3>
1277
1277
  <p>We'd love your feedback!</p>
1278
1278
  </div>
1279
- \`,t.appendChild(e),setTimeout(()=>{e.classList.add("menu-toggle-tooltip-show"),e.addEventListener("click",()=>{e.classList.remove("menu-toggle-tooltip-show")})},1e3)};function ui(t){t.getElementById("go-to-builder").addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),Ee(t,!1),window.open(Ur(),"builder")}),t.getElementById("components-link").addEventListener("click",a=>{a.preventDefault(),a.stopPropagation();let c=t.querySelector(".nav-cmp-list .section-content");c.scrollTop=0,oe(t,"nav-cmp-list"),ai(t)}),t.getElementById("settings-link").addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),oe(t,"nav-settings")}),t.getElementById("add-page-link").addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),Ee(t,!1),window.open(je(),"builder")}),t.getElementById("import-from-figma").addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),Ee(t,!1),window.open("https://www.figma.com/community/plugin/747985167520967365/builder-io-ai-powered-figma-to-code-react-vue-tailwind-more")})}function ci(t){let e=t.getElementById("enable-edit");e.addEventListener("change",r=>{r.stopPropagation(),Ht(e.checked)}),e.checked=it(),Ht(e.checked)}var Dt=class extends HTMLElement{constructor(){super()}connectedCallback(){let e=this.attachShadow({mode:"open"});e.innerHTML=\`<style>*,*:before,*:after{box-sizing:border-box}:host{--background-color: rgba(40, 40, 40, 1);--primary-color: rgba(72, 161, 255, 1);--primary-color-subdued: rgb(72, 161, 255, .6);--primary-color-highlight: rgb(126, 188, 255);--primary-contrast-color: white;--edit-color: #1d74e2;--edit-color-highlight: #1c6bd1;--edit-color-alpha: rgb(72, 161, 255, .15);--error-color: #ff2b55;--text-color: white;--text-color-highlight: white;--border-color: #454545;--button-background-color-hover: rgba(255, 255, 255, .1);--menu-width: 320px;--transition-time: .15s;--font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";font-family:var(--font-family);line-height:1.6}button{cursor:pointer;color:var(--text-color);-webkit-tap-highlight-color:transparent}input,select,button{font-family:var(--font-family)}.menu-toggle{position:absolute;right:0;bottom:0;pointer-events:auto;padding:8px;background:transparent;border:none;appearance:none}.menu-toggle div{position:relative;width:64px;height:64px;pointer-events:none;border-radius:50%;background:#000;border:1px solid white;box-shadow:#00000054 0 0 8px}.menu-toggle:hover div{background-color:var(--background-color);border:1px solid rgb(220,220,220)}.menu-toggle svg{position:absolute;top:15px;left:15px;width:33px;height:32px}div.highlight-bg{position:absolute;top:-1px;left:-1px;background-color:#1a1a1a;pointer-events:none;transition:all .4s ease-out;opacity:0}.menu-toggle-highlight-no-transition div.highlight-bg{transition:none}.menu-toggle-highlight div.highlight-bg{opacity:1}.menu-toggle-tooltip{position:absolute;bottom:0;right:0;width:382px;height:72px;padding:0;text-align:left;appearance:none;background-color:transparent;border:none;pointer-events:none;transform:translate3d(320px,0,0);opacity:0;transition:all .15s ease-in-out;color:#fff}.menu-toggle-tooltip.menu-toggle-tooltip-show{pointer-events:auto;opacity:1;transform:translateZ(0)}.menu-toggle-tooltip-content{position:absolute;inset:0 95px 10px 0;padding:8px 12px;background-color:var(--primary-color);box-shadow:#00000054 0 0 20px;border-radius:2px}.menu-toggle-tooltip-content:before{content:"";position:absolute;bottom:15px;right:-6px;width:30px;height:30px;background-color:var(--primary-color);transform:rotate(45deg)}.menu-toggle-tooltip:hover .menu-toggle-tooltip-content,.menu-toggle-tooltip:hover .menu-toggle-tooltip-content:before{background-color:var(--primary-color-highlight)}.menu-toggle-tooltip-content h3{margin:0;font-size:16px}.menu-toggle-tooltip-content p{margin:0;font-size:12px}section{position:absolute;display:grid;grid-template-rows:64px auto 64px;top:0;left:0;width:100%;height:100%;padding:0;pointer-events:none}.section-content{margin:0;padding:0 0 10px;font-weight:300;transform:translate3d(105%,0,0);transition:transform var(--transition-time) ease-in-out;overflow-y:auto}.section-content .error{color:var(--error-color);font-weight:700}section a{text-decoration:none;color:var(--text-color)}section h3,section p{margin-left:16px;margin-right:16px}.info{font-size:12px}ul.list{list-style:none;padding:0;margin:0}ul.list li{display:block;padding:0;margin:0}ul.list a,ul.list button{display:grid;grid-template-columns:24px auto;grid-gap:16px;padding:12px;margin:8px 0;border:none;background:transparent;appearance:none;width:100%;font-weight:300;text-align:left;text-decoration:none;color:var(--text-color)}ul.list a:hover,ul.list button:hover{text-decoration:none;color:var(--text-color);background-color:var(--button-background-color-hover)}ul.list a span,ul.list button span{display:block;font-size:16px;font-weight:500;line-height:1.5;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}header{position:relative;display:grid;grid-template-columns:44px 1fr;gap:8px;padding-left:8px;border-bottom:1px solid var(--border-color);transition:opacity var(--transition-time) ease-in-out;opacity:0;pointer-events:none}header>div{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nav-home header>div{margin-right:56px}header h2{margin:7px 0 0;font-size:18px;font-weight:500;line-height:1.5;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}header p{margin:2px 0 0;font-size:12px;font-weight:300;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}header p button{display:block;margin:0;padding:0;width:100%;font-size:12px;font-weight:300;text-decoration:none;appearance:none;text-align:left;background-color:transparent;border:none;color:var(--primary-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}header p button:hover{text-decoration:underline;color:var(--primary-color)}.builder-logo{margin:12px 0 0 8px}#close{display:block;position:absolute;appearance:none;background:transparent;border:none;border-radius:50%;margin:0;padding:0;right:4px;top:8px;width:48px;height:48px;z-index:1;opacity:.7}#close:hover{opacity:1;background-color:var(--button-background-color-hover)}#close svg{position:absolute;top:12px;left:12px;width:24px;height:24px;fill:currentColor;pointer-events:none}.back-button{position:relative;display:block;margin:7px 0 0 -2px;width:48px;height:48px;background:transparent;border:none;appearance:none;border-radius:50%}.back-button:hover{background-color:var(--button-background-color-hover)}.back-button svg{position:absolute;top:12px;left:12px;width:24px;height:24px;fill:currentColor;pointer-events:none}footer{border-top:1px solid var(--border-color);transition:opacity var(--transition-time) ease-in-out;opacity:0;pointer-events:none}section.nav-cmp-list{grid-template-rows:64px auto 120px}footer a{text-decoration:underline;color:var(--primary-color)}footer a:hover{color:var(--primary-color);text-decoration:none}.nav-list{padding:2px 0}.nav-loading{pointer-events:none}.nav-loading-icon{position:absolute;display:inline-block;top:170px;left:0;width:100%;transform:translateZ(0);pointer-events:auto;opacity:0;transition:all 50ms ease-in-out;transition-delay:50ms;pointer-events:none}.nav-loading .nav-loading-icon{opacity:.5}.nav-list h4{margin:8px 8px 8px 10px;font-size:14px;font-weight:600}.nav-list .nav-list-item+h4{margin-top:30px}.nav-list-item{display:grid;grid-template-columns:1fr 1fr;gap:8px;position:relative;margin:2px 0;padding:8px 28px 8px 46px;width:100%;font-size:14px;font-weight:300;text-align:left;border:none;background:transparent;appearance:none}.nav-list-item:hover{background-color:var(--button-background-color-hover)}.nav-list-item-icon{position:absolute;top:4px;left:10px;width:24px;height:24px;object-fit:contain;filter:invert(100%);background-size:24px 24px;background-repeat:no-repeat;background-position:center center}.nav-list-item span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;pointer-events:none}.nav-list-item:after{display:block;position:absolute;content:"";background-image:url('data:image/svg+xml,<svg width="8" height="14" viewBox="0 0 8 14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L7 7L1 13" stroke="%23F2F2F2" stroke-opacity="0.5" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/></svg>');background-repeat:no-repeat;background-position:12px 9px;top:0;right:0;width:32px;height:32px;pointer-events:none}.nav-list-item-note{opacity:0;font-size:12px;padding-top:1px;text-align:right}.nav-list-item:hover .nav-list-item-note{opacity:.5}.ui-select{display:block;margin:8px 0 16px;padding:8px 16px;cursor:pointer}.ui-select h3{margin:0;font-size:14px;font-weight:500}.ui-select p{margin:8px 0;font-size:12px;font-weight:300}.ui-select .select{position:relative;margin:8px 0;border-radius:4px;padding:0;line-height:1.1;overflow:hidden;border:1px solid var(--border-color)}.ui-select select{appearance:none;background-color:transparent;border:none;outline:none;padding:8px 32px 8px 8px;margin:0;width:100%;font-size:14px;cursor:pointer;text-overflow:ellipsis;opacity:.6;color:var(--text-color)}.ui-select .select:after{content:"";top:6px;right:5px;width:24px;height:24px;position:absolute;background-image:url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="%23F2F2F2" d="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"/></svg>');background-repeat:no-repeat;background-position:center;pointer-events:none;opacity:.6}.ui-select .select:hover{border-color:var(--primary-color-subdued)}.ui-text-input .select:focus-within{border-color:var(--primary-color)}.ui-text-input .select:focus-within select{opacity:1}.spinner:after{content:" ";display:block;width:32px;height:32px;margin:0 auto;pointer-events:auto;border-radius:50%;border:3px solid var(--text-color);border-color:var(--text-color) transparent var(--text-color) transparent;animation:spinner .75s linear infinite}@keyframes spinner{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.ui-switch{display:grid;grid-template-columns:auto 48px;grid-gap:20px;margin:8px 0 16px;padding:8px 0 8px 16px;cursor:pointer}.ui-switch>*{pointer-events:none}.ui-switch input{display:none;visibility:hidden}.ui-switch .switcher{display:inline-block;border-radius:100px;width:35px;height:14px;background-color:#ccc;position:relative;top:6px;vertical-align:middle;cursor:pointer}.ui-switch input[type=checkbox]:checked+.switcher{background-color:var(--primary-color-subdued)}.ui-switch .switcher:before{content:"";display:block;width:20px;height:20px;background-color:var(--text-color);box-shadow:0 1px 3px #0009;border-radius:50%;position:absolute;top:-3px;left:0;margin-right:0;transition:all .15s}.ui-switch input[type=checkbox]:checked+.switcher:before{left:100%;margin-left:-20px;background-color:var(--primary-color)}.ui-switch h3{margin:0;font-size:14px;font-weight:500}.ui-switch p{margin:4px 0 0;font-size:12px;font-weight:300}.ui-text-input{display:block;margin:8px 0 16px;padding:8px 16px;cursor:pointer}.ui-text-input h3{margin:0;font-size:14px;font-weight:500}.ui-text-input p{margin:8px 0;font-size:12px;font-weight:300}.ui-text-input .input{position:relative;margin:8px 0;border:1px solid var(--border-color);border-radius:4px;background:transparent;padding:2px;overflow:hidden}.ui-text-input input{display:block;width:235px;font-size:14px;border:none;background:transparent;padding:6px;appearance:none;color:var(--text-color);opacity:.6;outline:none}.ui-text-input .input:hover{border-color:var(--primary-color-subdued)}.ui-text-input .input:focus-within{border-color:var(--primary-color)}.ui-text-input .input:focus-within input{opacity:1}.ui-text-input .input:after{content:"";position:absolute;top:5px;right:14px;width:8px;height:17px;border:2px solid rgba(51,181,51,1);border-top:none;border-left:none;transform:rotate(45deg);opacity:0;transition:opacity 80ms ease-in-out;pointer-events:none}.ui-text-input.saved .input:after{opacity:1}.ui-toast{position:fixed;bottom:8px;left:8px;right:8px;padding:6px 12px;font-size:14px;border-radius:4px;transform:translate3d(0,150%,0);opacity:0;transition:all var(--transition-time) ease-in-out;background-color:var(--primary-color-subdued);color:var(--text-color);pointer-events:none}.ui-toast.ui-toast-show{transform:translateZ(0);opacity:1;pointer-events:auto}[data-view=nav-home] .nav-home .section-content,[data-view=nav-cmp-list] .nav-cmp-list .section-content,[data-view=nav-cmp-detail] .nav-cmp-detail .section-content,[data-view=nav-cmp-input] .nav-cmp-input .section-content,[data-view=nav-settings] .nav-settings .section-content{transform:translateZ(0);pointer-events:auto}[data-view=nav-home] .nav-home header,[data-view=nav-home] .nav-home footer,[data-view=nav-cmp-list] .nav-cmp-list header,[data-view=nav-cmp-list] .nav-cmp-list footer,[data-view=nav-cmp-detail] .nav-cmp-detail header,[data-view=nav-cmp-detail] .nav-cmp-detail footer,[data-view=nav-cmp-input] .nav-cmp-input header,[data-view=nav-cmp-input] .nav-cmp-input footer,[data-view=nav-settings] .nav-settings header,[data-view=nav-settings] .nav-settings footer{opacity:1;pointer-events:auto}[data-view=nav-cmp-list] .nav-home .section-content,[data-view=nav-cmp-detail] .nav-home .section-content,[data-view=nav-cmp-detail] .nav-cmp-list .section-content,[data-view=nav-cmp-input] .nav-home .section-content,[data-view=nav-cmp-input] .nav-cmp-list .section-content,[data-view=nav-cmp-input] .nav-cmp-detail .section-content,[data-view=nav-settings] .nav-home .section-content{transform:translate3d(-105%,0,0)}.cmp-item .nav-list-item-icon{background-image:url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M20.83 16.809C20.94 16.561 21 16.289 21 16.008V7.99001C20.9994 7.64108 20.9066 7.29851 20.731 6.99699C20.5554 6.69547 20.3032 6.44571 20 6.27301L13 2.26501C12.6954 2.09103 12.3508 1.99951 12 1.99951C11.6492 1.99951 11.3046 2.09103 11 2.26501L7.988 3.99001M5.441 5.44801L4 6.27301C3.381 6.62801 3 7.28301 3 7.99101V16.009C3 16.718 3.381 17.372 4 17.726L11 21.734C11.3046 21.908 11.6492 21.9995 12 21.9995C12.3508 21.9995 12.6954 21.908 13 21.734L18.544 18.56" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 22V12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.532 10.538L20.73 6.95996" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/><path d="M3.27002 6.95996L12 12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/><path d="M3 3L21 21" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/></svg>');opacity:.3}.cmp-item.registered .nav-list-item-icon{background-image:url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M21 16.008V7.99001C20.9994 7.64108 20.9066 7.29851 20.731 6.99699C20.5554 6.69547 20.3032 6.44571 20 6.27301L13 2.26501C12.6954 2.09103 12.3508 1.99951 12 1.99951C11.6492 1.99951 11.3046 2.09103 11 2.26501L4 6.27301C3.381 6.62801 3 7.28301 3 7.99101V16.009C3 16.718 3.381 17.372 4 17.726L11 21.734C11.3046 21.908 11.6492 21.9995 12 21.9995C12.3508 21.9995 12.6954 21.908 13 21.734L20 17.726C20.619 17.371 21 16.716 21 16.008Z" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M12 22V12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M12 12L20.73 6.95996" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M3.26999 6.95996L12 12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /></svg>');opacity:.8}.search-highlight{background-color:var(--primary-color-alpha);padding:0 2px;border-radius:2px;font-weight:500}.search-container{position:sticky;top:0;z-index:10;padding:12px 16px;background:var(--background-color);border-bottom:1px solid var(--border-color)}.search-input-wrapper{position:relative;display:flex;align-items:center}.search-icon{position:absolute;left:12px;color:var(--text-color-secondary);pointer-events:none}.component-search-input{width:100%;height:36px;padding:8px 36px;border:1px solid var(--border-color);border-radius:6px;background:var(--input-background);color:var(--text-color);font-size:14px;transition:border-color .2s,box-shadow .2s}.component-search-input:focus{outline:none;border-color:var(--primary-color);box-shadow:0 0 0 2px var(--primary-color-alpha)}.component-search-input::placeholder{color:var(--text-color-tertiary)}.clear-search-button{position:absolute;right:8px;padding:4px;color:var(--text-color-secondary);border:none;background:transparent;border-radius:4px;cursor:pointer;opacity:0;transition:opacity .2s,background-color .2s;display:flex;align-items:center;justify-content:center}.clear-search-button:hover{background-color:var(--hover-color)}.component-search-input:not(:placeholder-shown)+.clear-search-button{opacity:1}.no-results{padding:32px 16px;text-align:center;color:var(--text-color-secondary);font-size:14px}#cmp-detail{position:relative}.cmp-loading{pointer-events:none!important}.cmp-loading-icon{position:absolute;display:inline-block;top:170px;left:0;width:100%;transform:translateZ(0);pointer-events:auto;opacity:0;transition:all 50ms ease-in-out;transition-delay:50ms;pointer-events:none}.cmp-loading .cmp-loading-icon{opacity:.5}.cmp-cover{position:absolute;top:160px;left:0;width:100%;height:100vh;background:var(--background-color);transform:translateZ(0);pointer-events:none;display:none}[data-view=nav-cmp-detail] .cmp-cover{display:block;pointer-events:auto}.cmp-enabled .cmp-cover{transform:translate3d(0,105%,0);pointer-events:none}.section-ready .cmp-cover{transition:all var(--transition-time) ease-in-out}.cmp-detail-inputs-container{margin:8px 0 16px;padding:0}.cmp-detail-inputs-container h3{margin:0 0 6px;padding-left:16px;padding-right:8px;font-size:14px;font-weight:500;display:flex;justify-content:space-between;align-items:center}.cmp-detail-inputs-reload{font-weight:300;font-size:.9em;text-decoration:none;appearance:none;text-align:left;background-color:transparent;border:none;color:var(--primary-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.cmp-detail-inputs-reload:hover{text-decoration:underline;color:var(--primary-color)}.cmp-detail-inputs-container .cmp-inputs-empty{padding:0;margin-top:12px;font-size:12px;font-weight:300;opacity:.5;font-style:italic}.cmp-detail-inputs-container .nav-list-item-icon{opacity:.8;background-size:20px 20px;background-position:4px center}.input-icon{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path></svg>')}.input-icon-array{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path> <path d="M10 16v-6a2 2 0 1 1 4 0v6"></path> <path d="M10 13h4"></path></svg>')}.input-icon-boolean{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path> <path d="M10 16h2a2 2 0 1 0 0 -4h-2h2a2 2 0 1 0 0 -4h-2v8z"></path></svg>')}.input-icon-number{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path> <path d="M10 16v-8l4 8v-8"></path></svg>')}.input-icon-object{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path> <path d="M12 8a2 2 0 0 1 2 2v4a2 2 0 1 1 -4 0v-4a2 2 0 0 1 2 -2z"></path></svg>')}.input-icon-string{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path> <path d="M10 15a1 1 0 0 0 1 1h2a1 1 0 0 0 1 -1v-2a1 1 0 0 0 -1 -1h-2a1 1 0 0 1 -1 -1v-2a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1"></path></svg>')}.cmp-input-item-unregistered{opacity:.4}.cmp-input-item-unregistered .input-icon:after{content:"";position:absolute;top:11px;left:4px;width:20px;height:2px;background-color:#000;transform:rotate(-45deg)}.cmp-prop-info{border-bottom:1px solid var(--border-color)}.cmp-input-readonly{margin:16px 0;padding:0 16px;display:grid;grid-template-columns:50% 50%;gap:12px}.cmp-input-readonly h3{margin:0;font-size:14px;font-weight:500}.cmp-input-readonly span{margin-top:2px;font-size:12px;font-weight:300;opacity:.8}.cmp-input-detail{margin:16px 0}.cmp-input-detail a{color:var(--primary-color);text-decoration:none}.cmp-input-detail a:hover{text-decoration:underline}.input-cover{position:absolute;top:175px;left:0;width:100%;height:100%;background:var(--background-color);transform:translateZ(0);transition:all var(--transition-time) ease-in-out;pointer-events:auto}.input-enabled .input-cover{transform:translate3d(0,105%,0);pointer-events:none}.input-loading-icon{position:absolute;display:inline-block;top:190px;left:0;width:100%;transform:translateZ(0);pointer-events:auto;opacity:0;transition:all 50ms ease-in-out;transition-delay:50ms;pointer-events:none}.input-loading .input-loading-icon{opacity:.5}:host{position:fixed;inset:0;z-index:2147483646;user-select:none;pointer-events:none;color:var(--text-color)}aside{position:absolute;top:0;right:0;width:var(--menu-width);height:100%;transform:translate3d(105%,0,0);transition:transform var(--transition-time) ease-in-out;background:var(--background-color);box-shadow:#000000c9 5px 0 20px;overflow:hidden;z-index:1}:host(.show-builder-menu) aside{pointer-events:auto;transform:translateZ(0)}#hit{position:absolute;inset:0;display:none}:host(.show-builder-menu) #hit{display:block;pointer-events:auto}#version{position:absolute;bottom:6px;right:6px;font-size:8px;color:#9b9b9b}</style><div id="hit"></div> <aside data-view="nav-home"> <section class="nav-home"> <header> <svg class="builder-logo" viewBox="0 0 31 36" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M31 9.96854C31.0016 11.4553 30.6701 12.9236 30.03 14.2654C29.3898 15.6072 28.4572 16.7884 27.3007 17.7221L0.702841 2.61812C0.601104 2.56012 0.506714 2.49008 0.421705 2.40951C0.288323 2.27871 0.182333 2.12263 0.109928 1.95039C0.0375215 1.77814 0.000151253 1.59319 0 1.40633C0 1.03335 0.148098 0.675643 0.411715 0.411905C0.675332 0.148167 1.03287 0 1.40568 0L21.036 0C23.6786 0 26.213 1.05025 28.0816 2.91972C29.9502 4.78918 31 7.32472 31 9.96854Z" fill="#18B4F4" /> <path d="M31 25.4757C31.0004 26.7849 30.7429 28.0815 30.2423 29.2912C29.7417 30.5009 29.0078 31.6001 28.0825 32.526C27.1572 33.4519 26.0587 34.1864 24.8497 34.6875C23.6406 35.1886 22.3448 35.4465 21.0361 35.4465H1.40573C1.12766 35.4436 0.856725 35.3581 0.627199 35.201C0.397672 35.044 0.219871 34.8223 0.116289 34.5641C0.0127078 34.3059 -0.011999 34.0228 0.0452946 33.7505C0.102588 33.4783 0.239308 33.2292 0.438156 33.0347C0.517415 32.9551 0.606358 32.8858 0.702893 32.8284L11.1705 26.8843L27.2984 17.7244C28.4548 18.6579 29.3874 19.8387 30.028 21.18C30.6685 22.5213 31.0007 23.9891 31 25.4757Z" fill="#FD6B3C" /> <path d="M27.3011 17.7221L11.1709 26.8843L0.703209 32.8284C0.602697 32.8843 0.509784 32.9528 0.426758 33.0323C4.41799 28.9369 6.6496 23.442 6.64456 17.7221C6.65208 12.0015 4.42111 6.50517 0.429101 2.40948C0.51411 2.49005 0.6085 2.56009 0.710237 2.61809L27.3011 17.7221Z" fill="#A97FF2" /> </svg> <div> <h2 class="builder-home-title">Builder Devtools</h2> <p><button id="go-to-builder">Go to Builder</button></p> </div> <button id="close" aria-label="Close Menu"> <svg viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" > <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M18 6l-12 12" /> <path d="M6 6l12 12" /> </svg> </button> </header> <div class="section-content"> <ul class="list"> <li> <button id="components-link"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M21 16.008V7.99001C20.9994 7.64108 20.9066 7.29851 20.731 6.99699C20.5554 6.69547 20.3032 6.44571 20 6.27301L13 2.26501C12.6954 2.09103 12.3508 1.99951 12 1.99951C11.6492 1.99951 11.3046 2.09103 11 2.26501L4 6.27301C3.381 6.62801 3 7.28301 3 7.99101V16.009C3 16.718 3.381 17.372 4 17.726L11 21.734C11.3046 21.908 11.6492 21.9995 12 21.9995C12.3508 21.9995 12.6954 21.908 13 21.734L20 17.726C20.619 17.371 21 16.716 21 16.008Z" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M12 22V12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M12 12L20.73 6.95996" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M3.26999 6.95996L12 12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> </svg> <span>Components</span> </button> </li> <li> <button id="settings-link"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M10.325 4.317C10.751 2.561 13.249 2.561 13.675 4.317C13.7389 4.5808 13.8642 4.82578 14.0407 5.032C14.2172 5.23822 14.4399 5.39985 14.6907 5.50375C14.9414 5.60764 15.2132 5.65085 15.4838 5.62987C15.7544 5.60889 16.0162 5.5243 16.248 5.383C17.791 4.443 19.558 6.209 18.618 7.753C18.4769 7.98466 18.3924 8.24634 18.3715 8.51677C18.3506 8.78721 18.3938 9.05877 18.4975 9.30938C18.6013 9.55999 18.7627 9.78258 18.9687 9.95905C19.1747 10.1355 19.4194 10.2609 19.683 10.325C21.439 10.751 21.439 13.249 19.683 13.675C19.4192 13.7389 19.1742 13.8642 18.968 14.0407C18.7618 14.2172 18.6001 14.4399 18.4963 14.6907C18.3924 14.9414 18.3491 15.2132 18.3701 15.4838C18.3911 15.7544 18.4757 16.0162 18.617 16.248C19.557 17.791 17.791 19.558 16.247 18.618C16.0153 18.4769 15.7537 18.3924 15.4832 18.3715C15.2128 18.3506 14.9412 18.3938 14.6906 18.4975C14.44 18.6013 14.2174 18.7627 14.0409 18.9687C13.8645 19.1747 13.7391 19.4194 13.675 19.683C13.249 21.439 10.751 21.439 10.325 19.683C10.2611 19.4192 10.1358 19.1742 9.95929 18.968C9.7828 18.7618 9.56011 18.6001 9.30935 18.4963C9.05859 18.3924 8.78683 18.3491 8.51621 18.3701C8.24559 18.3911 7.98375 18.4757 7.752 18.617C6.209 19.557 4.442 17.791 5.382 16.247C5.5231 16.0153 5.60755 15.7537 5.62848 15.4832C5.64942 15.2128 5.60624 14.9412 5.50247 14.6906C5.3987 14.44 5.23726 14.2174 5.03127 14.0409C4.82529 13.8645 4.58056 13.7391 4.317 13.675C2.561 13.249 2.561 10.751 4.317 10.325C4.5808 10.2611 4.82578 10.1358 5.032 9.95929C5.23822 9.7828 5.39985 9.56011 5.50375 9.30935C5.60764 9.05859 5.65085 8.78683 5.62987 8.51621C5.60889 8.24559 5.5243 7.98375 5.383 7.752C4.443 6.209 6.209 4.442 7.753 5.382C8.753 5.99 10.049 5.452 10.325 4.317Z" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M9 12C9 12.7956 9.31607 13.5587 9.87868 14.1213C10.4413 14.6839 11.2044 15 12 15C12.7956 15 13.5587 14.6839 14.1213 14.1213C14.6839 13.5587 15 12.7956 15 12C15 11.2044 14.6839 10.4413 14.1213 9.87868C13.5587 9.31607 12.7956 9 12 9C11.2044 9 10.4413 9.31607 9.87868 9.87868C9.31607 10.4413 9 11.2044 9 12Z" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> </svg> <span>Settings</span> </button> </li> <li> <button id="add-page-link"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" > <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M14 3v4a1 1 0 0 0 1 1h4" /> <path d="M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z" /> <path d="M12 11l0 6" /> <path d="M9 14l6 0" /> </svg> <span>Add Builder Page</span> </button> </li> <li> <button id="import-from-figma"> <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-brand-figma" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" > <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M15 12m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0" /> <path d="M6 3m0 3a3 3 0 0 1 3 -3h6a3 3 0 0 1 3 3v0a3 3 0 0 1 -3 3h-6a3 3 0 0 1 -3 -3z" /> <path d="M9 9a3 3 0 0 0 0 6h3m-3 0a3 3 0 1 0 3 3v-15" /> </svg> <span>Import From Figma</span> </button> </li> </ul> </div> <footer> <ul class="list"> <li> <a href="https://docs.google.com/forms/d/e/1FAIpQLSdqZcJpRtm_Ia5DTHP6SDY9Xa6LID3KiTjRWkjMzWyJRUtSHw/viewform" target="_blank" > <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M11.013 17.0114L10.013 18.0114L2.513 10.5834C2.0183 10.102 1.62864 9.52342 1.36854 8.88404C1.10845 8.24466 0.983558 7.55836 1.00173 6.86834C1.01991 6.17832 1.18076 5.49954 1.47415 4.87474C1.76755 4.24994 2.18713 3.69266 2.70648 3.23799C3.22583 2.78331 3.8337 2.4411 4.49181 2.23289C5.14991 2.02468 5.844 1.95499 6.53036 2.02821C7.21673 2.10143 7.8805 2.31596 8.47987 2.65831C9.07925 3.00066 9.60124 3.46341 10.013 4.01741C10.8086 2.95654 11.9931 2.2552 13.3059 2.06766C14.6186 1.88012 15.9521 2.22176 17.013 3.01741C18.0739 3.81306 18.7752 4.99755 18.9627 6.3103C19.1503 7.62305 18.8086 8.95654 18.013 10.0174" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" /> <path d="M18.2006 19.8175L16.0286 20.9555C15.9642 20.989 15.8917 21.004 15.8192 20.9987C15.7467 20.9934 15.6771 20.9681 15.6182 20.9256C15.5593 20.8831 15.5134 20.825 15.4855 20.7579C15.4577 20.6907 15.4491 20.6172 15.4606 20.5455L15.8756 18.1345L14.1186 16.4275C14.0662 16.3768 14.0291 16.3123 14.0115 16.2416C13.9939 16.1708 13.9966 16.0965 14.0192 16.0271C14.0418 15.9578 14.0835 15.8962 14.1394 15.8494C14.1954 15.8026 14.2634 15.7725 14.3356 15.7625L16.7636 15.4105L17.8496 13.2175C17.8821 13.1521 17.9322 13.0972 17.9942 13.0588C18.0562 13.0204 18.1277 13 18.2006 13C18.2736 13 18.3451 13.0204 18.4071 13.0588C18.4691 13.0972 18.5191 13.1521 18.5516 13.2175L19.6376 15.4105L22.0656 15.7625C22.1377 15.7728 22.2054 15.8031 22.2611 15.85C22.3168 15.8968 22.3583 15.9583 22.3809 16.0275C22.4034 16.0967 22.4062 16.1708 22.3888 16.2415C22.3715 16.3122 22.3347 16.3766 22.2826 16.4275L20.5256 18.1345L20.9396 20.5445C20.9521 20.6163 20.9441 20.6902 20.9166 20.7578C20.8891 20.8254 20.8433 20.8839 20.7842 20.9267C20.7252 20.9695 20.6553 20.9949 20.5825 21C20.5098 21.005 20.4371 20.9896 20.3726 20.9555L18.2006 19.8175Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" /> </svg> <span>Give Feedback</span> </a> </li> </ul> <div id="version"></div> </footer> </section> <section class="nav-cmp-list"> <header> <button class="back-button"> <svg viewBox="0 0 24 24"> <path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" /> </svg> </button> <div class="search-container"> <div class="search-input-wrapper"> <svg class="search-icon" viewBox="0 0 24 24" width="16" height="16"> <path fill="none" stroke="currentColor" stroke-width="2" d="M15.5 15.5L20 20M10 17C6.13401 17 3 13.866 3 10C3 6.13401 6.13401 3 10 3C13.866 3 17 6.13401 17 10C17 13.866 13.866 17 10 17Z" /> </svg> <input type="text" id="component-search" class="component-search-input" placeholder="Search components..." autocomplete="off" spellcheck="false" /> <button id="clear-search" class="clear-search-button" type="button" aria-label="Clear search" > <svg viewBox="0 0 24 24" width="16" height="16"> <path fill="none" stroke="currentColor" stroke-width="2" d="M6 6l12 12M6 18L18 6" /> </svg> </button> </div> </div> <div> <h2>Custom Components</h2> <p> <button id="open-builder-registry"></button> </p> </div> </header> <div class="section-content"> <div id="cmp-list" class="cmp-list nav-list"></div> </div> <div class="nav-loading-icon spinner"></div> <footer> <p class="info"> Expand on Builder's selection of built-in blocks by <a target="_blank" href="https://www.builder.io/c/docs/custom-components-intro" >registering components</a > from your codebase. This way, teammates can drag and drop your components within Builder's Visual Editor just like any other block. </p> </footer> </section> <section class="nav-cmp-detail"> <header> <button class="back-button" data-back="nav-cmp-list"> <svg viewBox="0 0 24 24"> <path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" /> </svg> </button> <div> <h2 id="cmp-detail-title"></h2> <p> <button id="cmp-open-source"></button> </p> </div> </header> <div class="section-content"> <div id="cmp-error"></div> <label class="ui-switch"> <div> <h3>Register Component</h3> <p> Registers this component so it can be used within Builder Visual CMS </p> </div> <input type="checkbox" role="switch" id="cmp-register" /> <span class="switcher"></span> </label> <div id="cmp-detail"> <label class="ui-text-input"> <h3>Component Name</h3> <div class="input"> <input type="text" id="cmp-name" autocapitalize="off" autocorrect="off" spellcheck="false" autocomplete="off" minlength="2" maxlength="30" required placeholder="e.g. My Counter" /> </div> <p> Unique name to identify this custom component within Builder. Press ESC to cancel </p> </label> <div class="cmp-detail-inputs-container"> <h3> <span>Builder Inputs (Props)</span> <button class="cmp-detail-inputs-reload" id="btn-inputs-reload"> Reload </button> </h3> <div id="cmp-detail-inputs"></div> </div> </div> </div> <div class="cmp-cover"></div> <div class="cmp-loading-icon spinner"></div> </section> <section class="nav-cmp-input"> <header> <button class="back-button" data-back="nav-cmp-detail"> <svg viewBox="0 0 24 24"> <path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" /> </svg> </button> <div> <h2 id="cmp-input-title"></h2> <p> <button id="input-open-source"></button> </p> </div> </header> <div class="section-content"> <label class="ui-switch"> <div> <h3>Enable Input</h3> <p>Add this component prop as a Builder input</p> </div> <input type="checkbox" role="switch" id="input-register" /> <span class="switcher"></span> </label> <div class="cmp-prop-info"> <div class="cmp-input-readonly"> <h3>Prop Name</h3> <span id="cmp-prop-name"></span> </div> <div class="cmp-input-readonly"> <h3>Prop Type</h3> <span id="cmp-prop-type"></span> </div> </div> <div class="cmp-input-detail"> <label class="ui-text-input"> <h3>Builder Input Name</h3> <div class="input"> <input type="text" id="input-name" autocapitalize="off" autocorrect="off" spellcheck="false" autocomplete="off" minlength="1" maxlength="30" required placeholder="e.g. Text" /> </div> <p> Friendly name to identify this component prop as a Builder input. Press ESC to cancel </p> </label> <label class="ui-select"> <h3>Builder Input Type</h3> <div class="select"> <select id="input-type"></select> </div> <p> Correlate to what editing UI is appropriate for this Builder input. <a href="https://www.builder.io/c/docs/custom-components-input-types" target="_blank" >Read more about input types.</a > </p> </label> </div> <div class="input-cover"></div> <div class="input-loading-icon spinner"></div> </div> </section> <section class="nav-settings"> <header> <button class="back-button"> <svg viewBox="0 0 24 24"> <path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" /> </svg> </button> <div> <h2>Settings</h2> <p>Configure Builder's Devtools</p> </div> </header> <div class="section-content"> <label class="ui-switch"> <div> <h3>Enable edit button in UI</h3> <p>Enables the edit button so you can edit content in Builder</p> </div> <input type="checkbox" role="switch" id="enable-edit" /> <span class="switcher"></span> </label> </div> </section> <div class="ui-toast" id="toast"></div> </aside> <button class="menu-toggle" aria-label="Toggle Builder Devtools"> <div> <div class="highlight-bg"></div> <svg viewBox="0 0 31 36" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M31 9.96854C31.0016 11.4553 30.6701 12.9236 30.03 14.2654C29.3898 15.6072 28.4572 16.7884 27.3007 17.7221L0.702841 2.61812C0.601104 2.56012 0.506714 2.49008 0.421705 2.40951C0.288323 2.27871 0.182333 2.12263 0.109928 1.95039C0.0375215 1.77814 0.000151253 1.59319 0 1.40633C0 1.03335 0.148098 0.675643 0.411715 0.411905C0.675332 0.148167 1.03287 0 1.40568 0L21.036 0C23.6786 0 26.213 1.05025 28.0816 2.91972C29.9502 4.78918 31 7.32472 31 9.96854Z" fill="#18B4F4" /> <path d="M31 25.4757C31.0004 26.7849 30.7429 28.0815 30.2423 29.2912C29.7417 30.5009 29.0078 31.6001 28.0825 32.526C27.1572 33.4519 26.0587 34.1864 24.8497 34.6875C23.6406 35.1886 22.3448 35.4465 21.0361 35.4465H1.40573C1.12766 35.4436 0.856725 35.3581 0.627199 35.201C0.397672 35.044 0.219871 34.8223 0.116289 34.5641C0.0127078 34.3059 -0.011999 34.0228 0.0452946 33.7505C0.102588 33.4783 0.239308 33.2292 0.438156 33.0347C0.517415 32.9551 0.606358 32.8858 0.702893 32.8284L11.1705 26.8843L27.2984 17.7244C28.4548 18.6579 29.3874 19.8387 30.028 21.18C30.6685 22.5213 31.0007 23.9891 31 25.4757Z" fill="#FD6B3C" /> <path d="M27.3011 17.7221L11.1709 26.8843L0.703209 32.8284C0.602697 32.8843 0.509784 32.9528 0.426758 33.0323C4.41799 28.9369 6.6496 23.442 6.64456 17.7221C6.65208 12.0015 4.42111 6.50517 0.429101 2.40948C0.51411 2.49005 0.6085 2.56009 0.710237 2.61809L27.3011 17.7221Z" fill="#A97FF2" /> </svg> </div> </button>\`,si(e),ui(e),oi(e),ri(e),ti(e),ci(e),this.setAttribute("aria-hidden","true"),e.getElementById("version").textContent="v1.36.0-beta.202603260907.bbf4118"}highlightOpener(){let e=this.shadowRoot.querySelector(".menu-toggle");e.classList.add("menu-toggle-highlight"),e.classList.add("menu-toggle-highlight-no-transition"),setTimeout(()=>{e.classList.remove("menu-toggle-highlight-no-transition"),setTimeout(()=>{e.classList.remove("menu-toggle-highlight")},20)},20)}};var lo=\`<style>*,*:before,*:after{box-sizing:border-box}html,body,:host{position:fixed;top:0;left:0;width:100%;height:100vh;z-index:2147483646;margin:0;padding:0;line-height:1.8;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";background-color:#252525;color:#fff;transition:opacity .25s ease-in-out}:host([aria-hidden="true"]){opacity:0;pointer-events:none}main{position:absolute;top:0;left:0;width:100%;height:100vh}h1{margin-top:0;font-size:24px;font-weight:300;line-height:1.4}p{margin:20px 0;font-weight:300}button{cursor:pointer}aside{position:absolute;top:0;left:0;width:350px;height:100vh;padding:60px 0 0 50px;background-color:#121212}aside ul{margin:30px 0 0;padding:0;list-style:none}aside li{position:relative;margin:0;padding:20px 10px;font-weight:300}aside li.highlight{color:#48a1ff}aside li.active{font-weight:700}aside li .circle{position:absolute;top:20px;left:10px;width:24px;height:24px;border:3px solid white;border-radius:50%;font-size:14px}aside li.highlight .circle{border-color:#48a1ff}aside li.active .circle:after{content:"";position:absolute;top:3px;left:3px;width:12px;height:12px;border-radius:50%;background-color:#48a1ff}aside li.completed .circle{background-color:#48a1ff}aside li.completed .circle:after{content:"";position:absolute;top:2px;left:6px;width:6px;height:13px;border:3px solid black;border-top:none;border-left:none;transform:rotate(45deg)}aside li .line{position:absolute;top:44px;left:21px;width:3px;height:45px;background-color:#fff}aside li.completed .line{background-color:#48a1ff}aside li span{display:block;margin-left:44px}nav{margin-top:30px}section{position:absolute;top:135px;left:350px;padding:0 80px 0 140px;transition:opacity .15s ease-in-out}section[aria-hidden=true]{pointer-events:none;opacity:0}section h1,section p{min-width:300px;max-width:600px}.button{position:relative;display:inline-block;color:#fff;background-color:#48a1ff;border-radius:4px;text-decoration:none;padding:10px 40px 10px 20px;white-space:nowrap}.button:hover{background-color:#48a1ffd9}#button-icon{position:absolute;top:1px;right:5px;bottom:0;width:30px;background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="none" stroke="white" stroke-linecap="square" stroke-miterlimit="10" stroke-width="48" d="M184 112l144 144-144 144"/></svg>');background-repeat:no-repeat;background-position:center;background-size:24px 24px}.button[aria-disabled=true]{opacity:.9;background-color:#ffffff4d;pointer-events:none;padding-right:60px}.button[aria-disabled=true] #button-icon{top:21px;right:29px;width:8px;height:8px;border-radius:4px;background:#fff;color:#fff;animation:dot-flashing .5s infinite linear alternate;animation-delay:.25s}.button[aria-disabled=true] #button-icon:before,.button[aria-disabled=true] #button-icon:after{content:"";display:inline-block;position:absolute;top:0}.button[aria-disabled=true] #button-icon:before{left:-12px;width:8px;height:8px;border-radius:4px;background-color:#fff;color:#fff;animation:dot-flashing .5s infinite alternate;animation-delay:0s}.button[aria-disabled=true] #button-icon:after{left:12px;width:8px;height:8px;border-radius:4px;background-color:#fff;color:#fff;animation:dot-flashing .5s infinite alternate;animation-delay:.5s}@keyframes dot-flashing{0%{background-color:#fff}50%,to{background-color:#ffffff4d}}.logo{margin-left:9px;background:url('data:image/svg+xml,<svg viewBox="0 0 150 32" fill="none" xmlns="http://www.w3.org/2000/svg" > <g clip-path="url(%23clip0_4_304)"> <path d="M27.9858 8.99927C27.9872 10.3415 27.688 11.667 27.1101 12.8783C26.5321 14.0896 25.6902 15.156 24.6462 15.9989V15.9989L0.634502 2.36355C0.542657 2.31119 0.457444 2.24796 0.380701 2.17523C0.260289 2.05715 0.164605 1.91624 0.0992389 1.76075C0.0338732 1.60525 0.000136546 1.43828 0 1.26959C0 0.932873 0.133698 0.609948 0.371683 0.371854C0.609667 0.13376 0.932443 0 1.269 0L18.9906 0C21.3763 0 23.6642 0.948135 25.3512 2.63583C27.0381 4.32352 27.9858 6.61252 27.9858 8.99927V8.99927Z" fill="%2318B4F4" /> <path d="M27.9858 22.9986C27.9861 24.1806 27.7536 25.351 27.3017 26.4431C26.8498 27.5352 26.1873 28.5275 25.352 29.3634C24.5167 30.1993 23.5249 30.8624 22.4335 31.3147C21.342 31.7671 20.1721 32 18.9907 32H1.26906C1.01802 31.9973 0.77343 31.9202 0.566221 31.7784C0.359012 31.6366 0.198499 31.4364 0.104989 31.2034C0.0114791 30.9703 -0.0108254 30.7147 0.0408974 30.4689C0.0926201 30.2231 0.216046 29.9982 0.395559 29.8226V29.8226C0.467112 29.7508 0.547407 29.6882 0.634555 29.6364L10.0844 24.2703L24.6441 16.001C25.688 16.8438 26.53 17.9097 27.1083 19.1206C27.6866 20.3315 27.9864 21.6566 27.9858 22.9986V22.9986Z" fill="%23FD6B3C" /> <path d="M24.6461 15.9989L10.0843 24.2703L0.634458 29.6365C0.54372 29.6868 0.459841 29.7487 0.384888 29.8205C3.98804 26.1233 6.00266 21.1627 5.99812 15.9989C6.0049 10.8346 3.99085 5.87268 0.387003 2.17523C0.463746 2.24796 0.548959 2.31119 0.640803 2.36355L24.6461 15.9989Z" fill="%23A97FF2" /> <path d="M47.6659 11.7352C51.8177 11.7352 54.1632 15.0531 54.1632 19.0714C54.1632 23.0896 51.8177 26.3821 47.6659 26.3821C45.5086 26.3821 43.8589 25.5188 42.9473 24.0545L42.5709 26.052H39.9736V6.77115H43.1884V13.8914C43.971 12.6959 45.5086 11.7352 47.6659 11.7352ZM47.0187 23.5488C49.4446 23.5488 50.9547 21.5809 50.9547 19.0714C50.9547 16.5089 49.4446 14.5664 47.0187 14.5664C44.5928 14.5664 43.0806 16.5047 43.0806 19.0714C43.0806 21.583 44.5653 23.5488 47.0187 23.5488V23.5488Z" fill="white" /> <path d="M65.4595 20.2859V12.0611H68.668V20.123C68.668 23.7202 67.0246 26.3821 62.4943 26.3821C57.9639 26.3821 56.3206 23.7117 56.3206 20.123V12.0611H59.529V20.2859C59.529 22.4696 60.5527 23.5488 62.49 23.5488C64.4274 23.5488 65.4595 22.4696 65.4595 20.2859Z" fill="white" /> <path d="M71.2355 7.74451C71.2247 7.46284 71.2724 7.18199 71.3755 6.91968C71.4787 6.65737 71.6351 6.41929 71.8348 6.22047C72.0345 6.02165 72.2732 5.8664 72.5359 5.76452C72.7986 5.66264 73.0796 5.61633 73.3611 5.62853C74.5793 5.62853 75.4571 6.50666 75.4571 7.75509C75.4571 9.00352 74.5793 9.8224 73.3611 9.8224C72.1428 9.8224 71.2355 8.9612 71.2355 7.74451Z" fill="white" /> <path d="M128.476 7.74451C128.465 7.46376 128.513 7.18383 128.615 6.92227C128.718 6.66071 128.873 6.42315 129.072 6.22449C129.27 6.02583 129.508 5.87035 129.769 5.7678C130.031 5.66524 130.31 5.61783 130.591 5.62852C131.809 5.62852 132.687 6.50666 132.687 7.75509C132.687 9.00352 131.809 9.8224 130.591 9.8224C129.373 9.8224 128.476 8.9612 128.476 7.74451Z" fill="white" /> <path d="M122.302 24.1031C122.291 23.8223 122.339 23.5422 122.441 23.2805C122.543 23.0188 122.699 22.7811 122.897 22.5824C123.096 22.3837 123.334 22.2282 123.595 22.1258C123.857 22.0233 124.137 21.9761 124.417 21.9872C125.636 21.9872 126.513 22.8653 126.513 24.1031C126.513 25.341 125.636 26.1726 124.417 26.1726C123.199 26.1726 122.302 25.3219 122.302 24.1031Z" fill="white" /> <path d="M74.9516 12.059H71.7432V26.0583H74.9516V12.059Z" fill="white" /> <path d="M78.16 26.0583V6.77115H81.3685V26.0626L78.16 26.0583Z" fill="white" /> <path d="M94.6063 6.77115H97.8148V26.0626H95.2239L94.8474 24.0651C93.9591 25.523 92.3094 26.3927 90.131 26.3927C86.0046 26.3927 83.6591 23.0748 83.6591 19.0819C83.6591 15.0891 86.0046 11.7458 90.131 11.7458C92.3137 11.7458 93.8238 12.7149 94.6063 13.902V6.77115ZM90.7993 14.5707C88.3734 14.5707 86.8633 16.5131 86.8633 19.0756C86.8633 21.5851 88.3734 23.553 90.7993 23.553C93.2252 23.553 94.7354 21.5851 94.7354 19.0756C94.7396 16.5047 93.257 14.5664 90.8036 14.5664L90.7993 14.5707Z" fill="white" /> <path d="M113.479 22.2284C112.482 24.7359 110.162 26.3821 107.117 26.3821C102.887 26.3821 100.137 23.225 100.137 19.0439C100.137 14.9706 102.942 11.7353 107.093 11.7353C111.245 11.7353 113.969 14.8902 113.969 18.991C113.982 19.3255 113.953 19.6604 113.883 19.9876H103.288C103.53 22.2009 104.959 23.6292 107.197 23.6292C108.735 23.6292 110.001 22.8738 110.594 21.473L113.479 22.2284ZM103.341 17.6156H110.784C110.513 15.6731 109.166 14.3506 107.089 14.3506C105.012 14.3506 103.665 15.7006 103.341 17.6156V17.6156Z" fill="white" /> <path d="M123.779 14.9452C123.538 14.9117 123.295 14.8933 123.051 14.8902C120.786 14.8902 119.439 16.0772 119.439 18.7751V26.0583H116.23V12.0611H118.821L119.195 14.0014C119.707 13.1127 120.887 11.9257 123.322 11.9257C123.455 11.9257 123.779 11.9532 123.779 11.9532V14.9452Z" fill="white" /> <path d="M132.192 12.059H128.984V26.0583H132.192V12.059Z" fill="white" /> <path d="M134.483 19.0714C134.483 15.1335 137.287 11.7353 141.735 11.7353C146.183 11.7353 149.015 15.1335 149.015 19.0714C149.015 23.0092 146.213 26.3821 141.735 26.3821C137.258 26.3821 134.483 23.0092 134.483 19.0714ZM141.735 23.5488C144.083 23.5488 145.806 21.7692 145.806 19.0714C145.806 16.3735 144.083 14.5664 141.735 14.5664C139.387 14.5664 137.687 16.346 137.687 19.0714C137.687 21.7968 139.417 23.5488 141.735 23.5488V23.5488Z" fill="white" /> </g> <defs> <clipPath id="clip0_4_304"> <rect width="149.015" height="32" fill="white" /> </clipPath> </defs> </svg>');background-repeat:no-repeat;width:150px;height:32px}@media(max-width:840px){aside{width:250px;padding:60px 0 0 20px}section{left:250px;padding:0 80px}}@media(max-width:590px){aside{width:230px;padding:60px 0 0 10px}section{left:230px;padding:0 40px}}#modified-files-message a{color:#cbcbcb;font-weight:300;text-decoration:underline}#modified-files-message a:hover{color:#fff;text-decoration:none}#restart-warning{border-radius:4px;padding:8px 16px;border:1px solid #fd6b3c;background:#fd6b3c1a}#react-router-steps{margin:0 0 5px;padding:0 20px}#need-help{color:#48a1ff;text-decoration:none}#router-message{border-radius:4px;padding:16px;border:1px solid #48a1ff}#router-finish-button{margin-top:12px}#router-checkbox-div{display:flex;align-items:center}#router-checkbox{margin-right:10px;width:15px;height:15px}#success-title{display:flex;align-items:center;gap:10px}#success-title .check-icon{display:inline-block;width:24px;height:24px;border:2px solid #28a745;border-radius:50%;position:relative}#success-title .check-icon:before{content:"";position:absolute;top:50%;left:50%;width:6px;height:12px;border:solid #28a745;border-width:0 2px 2px 0;transform:translate(-50%,-60%) rotate(45deg)}
1279
+ \`,t.appendChild(e),setTimeout(()=>{e.classList.add("menu-toggle-tooltip-show"),e.addEventListener("click",()=>{e.classList.remove("menu-toggle-tooltip-show")})},1e3)};function ui(t){t.getElementById("go-to-builder").addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),Ee(t,!1),window.open(Ur(),"builder")}),t.getElementById("components-link").addEventListener("click",a=>{a.preventDefault(),a.stopPropagation();let c=t.querySelector(".nav-cmp-list .section-content");c.scrollTop=0,oe(t,"nav-cmp-list"),ai(t)}),t.getElementById("settings-link").addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),oe(t,"nav-settings")}),t.getElementById("add-page-link").addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),Ee(t,!1),window.open(je(),"builder")}),t.getElementById("import-from-figma").addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),Ee(t,!1),window.open("https://www.figma.com/community/plugin/747985167520967365/builder-io-ai-powered-figma-to-code-react-vue-tailwind-more")})}function ci(t){let e=t.getElementById("enable-edit");e.addEventListener("change",r=>{r.stopPropagation(),Ht(e.checked)}),e.checked=it(),Ht(e.checked)}var Dt=class extends HTMLElement{constructor(){super()}connectedCallback(){let e=this.attachShadow({mode:"open"});e.innerHTML=\`<style>*,*:before,*:after{box-sizing:border-box}:host{--background-color: rgba(40, 40, 40, 1);--primary-color: rgba(72, 161, 255, 1);--primary-color-subdued: rgb(72, 161, 255, .6);--primary-color-highlight: rgb(126, 188, 255);--primary-contrast-color: white;--edit-color: #1d74e2;--edit-color-highlight: #1c6bd1;--edit-color-alpha: rgb(72, 161, 255, .15);--error-color: #ff2b55;--text-color: white;--text-color-highlight: white;--border-color: #454545;--button-background-color-hover: rgba(255, 255, 255, .1);--menu-width: 320px;--transition-time: .15s;--font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";font-family:var(--font-family);line-height:1.6}button{cursor:pointer;color:var(--text-color);-webkit-tap-highlight-color:transparent}input,select,button{font-family:var(--font-family)}.menu-toggle{position:absolute;right:0;bottom:0;pointer-events:auto;padding:8px;background:transparent;border:none;appearance:none}.menu-toggle div{position:relative;width:64px;height:64px;pointer-events:none;border-radius:50%;background:#000;border:1px solid white;box-shadow:#00000054 0 0 8px}.menu-toggle:hover div{background-color:var(--background-color);border:1px solid rgb(220,220,220)}.menu-toggle svg{position:absolute;top:15px;left:15px;width:33px;height:32px}div.highlight-bg{position:absolute;top:-1px;left:-1px;background-color:#1a1a1a;pointer-events:none;transition:all .4s ease-out;opacity:0}.menu-toggle-highlight-no-transition div.highlight-bg{transition:none}.menu-toggle-highlight div.highlight-bg{opacity:1}.menu-toggle-tooltip{position:absolute;bottom:0;right:0;width:382px;height:72px;padding:0;text-align:left;appearance:none;background-color:transparent;border:none;pointer-events:none;transform:translate3d(320px,0,0);opacity:0;transition:all .15s ease-in-out;color:#fff}.menu-toggle-tooltip.menu-toggle-tooltip-show{pointer-events:auto;opacity:1;transform:translateZ(0)}.menu-toggle-tooltip-content{position:absolute;inset:0 95px 10px 0;padding:8px 12px;background-color:var(--primary-color);box-shadow:#00000054 0 0 20px;border-radius:2px}.menu-toggle-tooltip-content:before{content:"";position:absolute;bottom:15px;right:-6px;width:30px;height:30px;background-color:var(--primary-color);transform:rotate(45deg)}.menu-toggle-tooltip:hover .menu-toggle-tooltip-content,.menu-toggle-tooltip:hover .menu-toggle-tooltip-content:before{background-color:var(--primary-color-highlight)}.menu-toggle-tooltip-content h3{margin:0;font-size:16px}.menu-toggle-tooltip-content p{margin:0;font-size:12px}section{position:absolute;display:grid;grid-template-rows:64px auto 64px;top:0;left:0;width:100%;height:100%;padding:0;pointer-events:none}.section-content{margin:0;padding:0 0 10px;font-weight:300;transform:translate3d(105%,0,0);transition:transform var(--transition-time) ease-in-out;overflow-y:auto}.section-content .error{color:var(--error-color);font-weight:700}section a{text-decoration:none;color:var(--text-color)}section h3,section p{margin-left:16px;margin-right:16px}.info{font-size:12px}ul.list{list-style:none;padding:0;margin:0}ul.list li{display:block;padding:0;margin:0}ul.list a,ul.list button{display:grid;grid-template-columns:24px auto;grid-gap:16px;padding:12px;margin:8px 0;border:none;background:transparent;appearance:none;width:100%;font-weight:300;text-align:left;text-decoration:none;color:var(--text-color)}ul.list a:hover,ul.list button:hover{text-decoration:none;color:var(--text-color);background-color:var(--button-background-color-hover)}ul.list a span,ul.list button span{display:block;font-size:16px;font-weight:500;line-height:1.5;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}header{position:relative;display:grid;grid-template-columns:44px 1fr;gap:8px;padding-left:8px;border-bottom:1px solid var(--border-color);transition:opacity var(--transition-time) ease-in-out;opacity:0;pointer-events:none}header>div{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nav-home header>div{margin-right:56px}header h2{margin:7px 0 0;font-size:18px;font-weight:500;line-height:1.5;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}header p{margin:2px 0 0;font-size:12px;font-weight:300;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}header p button{display:block;margin:0;padding:0;width:100%;font-size:12px;font-weight:300;text-decoration:none;appearance:none;text-align:left;background-color:transparent;border:none;color:var(--primary-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}header p button:hover{text-decoration:underline;color:var(--primary-color)}.builder-logo{margin:12px 0 0 8px}#close{display:block;position:absolute;appearance:none;background:transparent;border:none;border-radius:50%;margin:0;padding:0;right:4px;top:8px;width:48px;height:48px;z-index:1;opacity:.7}#close:hover{opacity:1;background-color:var(--button-background-color-hover)}#close svg{position:absolute;top:12px;left:12px;width:24px;height:24px;fill:currentColor;pointer-events:none}.back-button{position:relative;display:block;margin:7px 0 0 -2px;width:48px;height:48px;background:transparent;border:none;appearance:none;border-radius:50%}.back-button:hover{background-color:var(--button-background-color-hover)}.back-button svg{position:absolute;top:12px;left:12px;width:24px;height:24px;fill:currentColor;pointer-events:none}footer{border-top:1px solid var(--border-color);transition:opacity var(--transition-time) ease-in-out;opacity:0;pointer-events:none}section.nav-cmp-list{grid-template-rows:64px auto 120px}footer a{text-decoration:underline;color:var(--primary-color)}footer a:hover{color:var(--primary-color);text-decoration:none}.nav-list{padding:2px 0}.nav-loading{pointer-events:none}.nav-loading-icon{position:absolute;display:inline-block;top:170px;left:0;width:100%;transform:translateZ(0);pointer-events:auto;opacity:0;transition:all 50ms ease-in-out;transition-delay:50ms;pointer-events:none}.nav-loading .nav-loading-icon{opacity:.5}.nav-list h4{margin:8px 8px 8px 10px;font-size:14px;font-weight:600}.nav-list .nav-list-item+h4{margin-top:30px}.nav-list-item{display:grid;grid-template-columns:1fr 1fr;gap:8px;position:relative;margin:2px 0;padding:8px 28px 8px 46px;width:100%;font-size:14px;font-weight:300;text-align:left;border:none;background:transparent;appearance:none}.nav-list-item:hover{background-color:var(--button-background-color-hover)}.nav-list-item-icon{position:absolute;top:4px;left:10px;width:24px;height:24px;object-fit:contain;filter:invert(100%);background-size:24px 24px;background-repeat:no-repeat;background-position:center center}.nav-list-item span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;pointer-events:none}.nav-list-item:after{display:block;position:absolute;content:"";background-image:url('data:image/svg+xml,<svg width="8" height="14" viewBox="0 0 8 14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L7 7L1 13" stroke="%23F2F2F2" stroke-opacity="0.5" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/></svg>');background-repeat:no-repeat;background-position:12px 9px;top:0;right:0;width:32px;height:32px;pointer-events:none}.nav-list-item-note{opacity:0;font-size:12px;padding-top:1px;text-align:right}.nav-list-item:hover .nav-list-item-note{opacity:.5}.ui-select{display:block;margin:8px 0 16px;padding:8px 16px;cursor:pointer}.ui-select h3{margin:0;font-size:14px;font-weight:500}.ui-select p{margin:8px 0;font-size:12px;font-weight:300}.ui-select .select{position:relative;margin:8px 0;border-radius:4px;padding:0;line-height:1.1;overflow:hidden;border:1px solid var(--border-color)}.ui-select select{appearance:none;background-color:transparent;border:none;outline:none;padding:8px 32px 8px 8px;margin:0;width:100%;font-size:14px;cursor:pointer;text-overflow:ellipsis;opacity:.6;color:var(--text-color)}.ui-select .select:after{content:"";top:6px;right:5px;width:24px;height:24px;position:absolute;background-image:url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="%23F2F2F2" d="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"/></svg>');background-repeat:no-repeat;background-position:center;pointer-events:none;opacity:.6}.ui-select .select:hover{border-color:var(--primary-color-subdued)}.ui-text-input .select:focus-within{border-color:var(--primary-color)}.ui-text-input .select:focus-within select{opacity:1}.spinner:after{content:" ";display:block;width:32px;height:32px;margin:0 auto;pointer-events:auto;border-radius:50%;border:3px solid var(--text-color);border-color:var(--text-color) transparent var(--text-color) transparent;animation:spinner .75s linear infinite}@keyframes spinner{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.ui-switch{display:grid;grid-template-columns:auto 48px;grid-gap:20px;margin:8px 0 16px;padding:8px 0 8px 16px;cursor:pointer}.ui-switch>*{pointer-events:none}.ui-switch input{display:none;visibility:hidden}.ui-switch .switcher{display:inline-block;border-radius:100px;width:35px;height:14px;background-color:#ccc;position:relative;top:6px;vertical-align:middle;cursor:pointer}.ui-switch input[type=checkbox]:checked+.switcher{background-color:var(--primary-color-subdued)}.ui-switch .switcher:before{content:"";display:block;width:20px;height:20px;background-color:var(--text-color);box-shadow:0 1px 3px #0009;border-radius:50%;position:absolute;top:-3px;left:0;margin-right:0;transition:all .15s}.ui-switch input[type=checkbox]:checked+.switcher:before{left:100%;margin-left:-20px;background-color:var(--primary-color)}.ui-switch h3{margin:0;font-size:14px;font-weight:500}.ui-switch p{margin:4px 0 0;font-size:12px;font-weight:300}.ui-text-input{display:block;margin:8px 0 16px;padding:8px 16px;cursor:pointer}.ui-text-input h3{margin:0;font-size:14px;font-weight:500}.ui-text-input p{margin:8px 0;font-size:12px;font-weight:300}.ui-text-input .input{position:relative;margin:8px 0;border:1px solid var(--border-color);border-radius:4px;background:transparent;padding:2px;overflow:hidden}.ui-text-input input{display:block;width:235px;font-size:14px;border:none;background:transparent;padding:6px;appearance:none;color:var(--text-color);opacity:.6;outline:none}.ui-text-input .input:hover{border-color:var(--primary-color-subdued)}.ui-text-input .input:focus-within{border-color:var(--primary-color)}.ui-text-input .input:focus-within input{opacity:1}.ui-text-input .input:after{content:"";position:absolute;top:5px;right:14px;width:8px;height:17px;border:2px solid rgba(51,181,51,1);border-top:none;border-left:none;transform:rotate(45deg);opacity:0;transition:opacity 80ms ease-in-out;pointer-events:none}.ui-text-input.saved .input:after{opacity:1}.ui-toast{position:fixed;bottom:8px;left:8px;right:8px;padding:6px 12px;font-size:14px;border-radius:4px;transform:translate3d(0,150%,0);opacity:0;transition:all var(--transition-time) ease-in-out;background-color:var(--primary-color-subdued);color:var(--text-color);pointer-events:none}.ui-toast.ui-toast-show{transform:translateZ(0);opacity:1;pointer-events:auto}[data-view=nav-home] .nav-home .section-content,[data-view=nav-cmp-list] .nav-cmp-list .section-content,[data-view=nav-cmp-detail] .nav-cmp-detail .section-content,[data-view=nav-cmp-input] .nav-cmp-input .section-content,[data-view=nav-settings] .nav-settings .section-content{transform:translateZ(0);pointer-events:auto}[data-view=nav-home] .nav-home header,[data-view=nav-home] .nav-home footer,[data-view=nav-cmp-list] .nav-cmp-list header,[data-view=nav-cmp-list] .nav-cmp-list footer,[data-view=nav-cmp-detail] .nav-cmp-detail header,[data-view=nav-cmp-detail] .nav-cmp-detail footer,[data-view=nav-cmp-input] .nav-cmp-input header,[data-view=nav-cmp-input] .nav-cmp-input footer,[data-view=nav-settings] .nav-settings header,[data-view=nav-settings] .nav-settings footer{opacity:1;pointer-events:auto}[data-view=nav-cmp-list] .nav-home .section-content,[data-view=nav-cmp-detail] .nav-home .section-content,[data-view=nav-cmp-detail] .nav-cmp-list .section-content,[data-view=nav-cmp-input] .nav-home .section-content,[data-view=nav-cmp-input] .nav-cmp-list .section-content,[data-view=nav-cmp-input] .nav-cmp-detail .section-content,[data-view=nav-settings] .nav-home .section-content{transform:translate3d(-105%,0,0)}.cmp-item .nav-list-item-icon{background-image:url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M20.83 16.809C20.94 16.561 21 16.289 21 16.008V7.99001C20.9994 7.64108 20.9066 7.29851 20.731 6.99699C20.5554 6.69547 20.3032 6.44571 20 6.27301L13 2.26501C12.6954 2.09103 12.3508 1.99951 12 1.99951C11.6492 1.99951 11.3046 2.09103 11 2.26501L7.988 3.99001M5.441 5.44801L4 6.27301C3.381 6.62801 3 7.28301 3 7.99101V16.009C3 16.718 3.381 17.372 4 17.726L11 21.734C11.3046 21.908 11.6492 21.9995 12 21.9995C12.3508 21.9995 12.6954 21.908 13 21.734L18.544 18.56" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 22V12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.532 10.538L20.73 6.95996" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/><path d="M3.27002 6.95996L12 12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/><path d="M3 3L21 21" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/></svg>');opacity:.3}.cmp-item.registered .nav-list-item-icon{background-image:url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M21 16.008V7.99001C20.9994 7.64108 20.9066 7.29851 20.731 6.99699C20.5554 6.69547 20.3032 6.44571 20 6.27301L13 2.26501C12.6954 2.09103 12.3508 1.99951 12 1.99951C11.6492 1.99951 11.3046 2.09103 11 2.26501L4 6.27301C3.381 6.62801 3 7.28301 3 7.99101V16.009C3 16.718 3.381 17.372 4 17.726L11 21.734C11.3046 21.908 11.6492 21.9995 12 21.9995C12.3508 21.9995 12.6954 21.908 13 21.734L20 17.726C20.619 17.371 21 16.716 21 16.008Z" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M12 22V12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M12 12L20.73 6.95996" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M3.26999 6.95996L12 12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /></svg>');opacity:.8}.search-highlight{background-color:var(--primary-color-alpha);padding:0 2px;border-radius:2px;font-weight:500}.search-container{position:sticky;top:0;z-index:10;padding:12px 16px;background:var(--background-color);border-bottom:1px solid var(--border-color)}.search-input-wrapper{position:relative;display:flex;align-items:center}.search-icon{position:absolute;left:12px;color:var(--text-color-secondary);pointer-events:none}.component-search-input{width:100%;height:36px;padding:8px 36px;border:1px solid var(--border-color);border-radius:6px;background:var(--input-background);color:var(--text-color);font-size:14px;transition:border-color .2s,box-shadow .2s}.component-search-input:focus{outline:none;border-color:var(--primary-color);box-shadow:0 0 0 2px var(--primary-color-alpha)}.component-search-input::placeholder{color:var(--text-color-tertiary)}.clear-search-button{position:absolute;right:8px;padding:4px;color:var(--text-color-secondary);border:none;background:transparent;border-radius:4px;cursor:pointer;opacity:0;transition:opacity .2s,background-color .2s;display:flex;align-items:center;justify-content:center}.clear-search-button:hover{background-color:var(--hover-color)}.component-search-input:not(:placeholder-shown)+.clear-search-button{opacity:1}.no-results{padding:32px 16px;text-align:center;color:var(--text-color-secondary);font-size:14px}#cmp-detail{position:relative}.cmp-loading{pointer-events:none!important}.cmp-loading-icon{position:absolute;display:inline-block;top:170px;left:0;width:100%;transform:translateZ(0);pointer-events:auto;opacity:0;transition:all 50ms ease-in-out;transition-delay:50ms;pointer-events:none}.cmp-loading .cmp-loading-icon{opacity:.5}.cmp-cover{position:absolute;top:160px;left:0;width:100%;height:100vh;background:var(--background-color);transform:translateZ(0);pointer-events:none;display:none}[data-view=nav-cmp-detail] .cmp-cover{display:block;pointer-events:auto}.cmp-enabled .cmp-cover{transform:translate3d(0,105%,0);pointer-events:none}.section-ready .cmp-cover{transition:all var(--transition-time) ease-in-out}.cmp-detail-inputs-container{margin:8px 0 16px;padding:0}.cmp-detail-inputs-container h3{margin:0 0 6px;padding-left:16px;padding-right:8px;font-size:14px;font-weight:500;display:flex;justify-content:space-between;align-items:center}.cmp-detail-inputs-reload{font-weight:300;font-size:.9em;text-decoration:none;appearance:none;text-align:left;background-color:transparent;border:none;color:var(--primary-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.cmp-detail-inputs-reload:hover{text-decoration:underline;color:var(--primary-color)}.cmp-detail-inputs-container .cmp-inputs-empty{padding:0;margin-top:12px;font-size:12px;font-weight:300;opacity:.5;font-style:italic}.cmp-detail-inputs-container .nav-list-item-icon{opacity:.8;background-size:20px 20px;background-position:4px center}.input-icon{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path></svg>')}.input-icon-array{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path> <path d="M10 16v-6a2 2 0 1 1 4 0v6"></path> <path d="M10 13h4"></path></svg>')}.input-icon-boolean{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path> <path d="M10 16h2a2 2 0 1 0 0 -4h-2h2a2 2 0 1 0 0 -4h-2v8z"></path></svg>')}.input-icon-number{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path> <path d="M10 16v-8l4 8v-8"></path></svg>')}.input-icon-object{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path> <path d="M12 8a2 2 0 0 1 2 2v4a2 2 0 1 1 -4 0v-4a2 2 0 0 1 2 -2z"></path></svg>')}.input-icon-string{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path> <path d="M10 15a1 1 0 0 0 1 1h2a1 1 0 0 0 1 -1v-2a1 1 0 0 0 -1 -1h-2a1 1 0 0 1 -1 -1v-2a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1"></path></svg>')}.cmp-input-item-unregistered{opacity:.4}.cmp-input-item-unregistered .input-icon:after{content:"";position:absolute;top:11px;left:4px;width:20px;height:2px;background-color:#000;transform:rotate(-45deg)}.cmp-prop-info{border-bottom:1px solid var(--border-color)}.cmp-input-readonly{margin:16px 0;padding:0 16px;display:grid;grid-template-columns:50% 50%;gap:12px}.cmp-input-readonly h3{margin:0;font-size:14px;font-weight:500}.cmp-input-readonly span{margin-top:2px;font-size:12px;font-weight:300;opacity:.8}.cmp-input-detail{margin:16px 0}.cmp-input-detail a{color:var(--primary-color);text-decoration:none}.cmp-input-detail a:hover{text-decoration:underline}.input-cover{position:absolute;top:175px;left:0;width:100%;height:100%;background:var(--background-color);transform:translateZ(0);transition:all var(--transition-time) ease-in-out;pointer-events:auto}.input-enabled .input-cover{transform:translate3d(0,105%,0);pointer-events:none}.input-loading-icon{position:absolute;display:inline-block;top:190px;left:0;width:100%;transform:translateZ(0);pointer-events:auto;opacity:0;transition:all 50ms ease-in-out;transition-delay:50ms;pointer-events:none}.input-loading .input-loading-icon{opacity:.5}:host{position:fixed;inset:0;z-index:2147483646;user-select:none;pointer-events:none;color:var(--text-color)}aside{position:absolute;top:0;right:0;width:var(--menu-width);height:100%;transform:translate3d(105%,0,0);transition:transform var(--transition-time) ease-in-out;background:var(--background-color);box-shadow:#000000c9 5px 0 20px;overflow:hidden;z-index:1}:host(.show-builder-menu) aside{pointer-events:auto;transform:translateZ(0)}#hit{position:absolute;inset:0;display:none}:host(.show-builder-menu) #hit{display:block;pointer-events:auto}#version{position:absolute;bottom:6px;right:6px;font-size:8px;color:#9b9b9b}</style><div id="hit"></div> <aside data-view="nav-home"> <section class="nav-home"> <header> <svg class="builder-logo" viewBox="0 0 31 36" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M31 9.96854C31.0016 11.4553 30.6701 12.9236 30.03 14.2654C29.3898 15.6072 28.4572 16.7884 27.3007 17.7221L0.702841 2.61812C0.601104 2.56012 0.506714 2.49008 0.421705 2.40951C0.288323 2.27871 0.182333 2.12263 0.109928 1.95039C0.0375215 1.77814 0.000151253 1.59319 0 1.40633C0 1.03335 0.148098 0.675643 0.411715 0.411905C0.675332 0.148167 1.03287 0 1.40568 0L21.036 0C23.6786 0 26.213 1.05025 28.0816 2.91972C29.9502 4.78918 31 7.32472 31 9.96854Z" fill="#18B4F4" /> <path d="M31 25.4757C31.0004 26.7849 30.7429 28.0815 30.2423 29.2912C29.7417 30.5009 29.0078 31.6001 28.0825 32.526C27.1572 33.4519 26.0587 34.1864 24.8497 34.6875C23.6406 35.1886 22.3448 35.4465 21.0361 35.4465H1.40573C1.12766 35.4436 0.856725 35.3581 0.627199 35.201C0.397672 35.044 0.219871 34.8223 0.116289 34.5641C0.0127078 34.3059 -0.011999 34.0228 0.0452946 33.7505C0.102588 33.4783 0.239308 33.2292 0.438156 33.0347C0.517415 32.9551 0.606358 32.8858 0.702893 32.8284L11.1705 26.8843L27.2984 17.7244C28.4548 18.6579 29.3874 19.8387 30.028 21.18C30.6685 22.5213 31.0007 23.9891 31 25.4757Z" fill="#FD6B3C" /> <path d="M27.3011 17.7221L11.1709 26.8843L0.703209 32.8284C0.602697 32.8843 0.509784 32.9528 0.426758 33.0323C4.41799 28.9369 6.6496 23.442 6.64456 17.7221C6.65208 12.0015 4.42111 6.50517 0.429101 2.40948C0.51411 2.49005 0.6085 2.56009 0.710237 2.61809L27.3011 17.7221Z" fill="#A97FF2" /> </svg> <div> <h2 class="builder-home-title">Builder Devtools</h2> <p><button id="go-to-builder">Go to Builder</button></p> </div> <button id="close" aria-label="Close Menu"> <svg viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" > <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M18 6l-12 12" /> <path d="M6 6l12 12" /> </svg> </button> </header> <div class="section-content"> <ul class="list"> <li> <button id="components-link"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M21 16.008V7.99001C20.9994 7.64108 20.9066 7.29851 20.731 6.99699C20.5554 6.69547 20.3032 6.44571 20 6.27301L13 2.26501C12.6954 2.09103 12.3508 1.99951 12 1.99951C11.6492 1.99951 11.3046 2.09103 11 2.26501L4 6.27301C3.381 6.62801 3 7.28301 3 7.99101V16.009C3 16.718 3.381 17.372 4 17.726L11 21.734C11.3046 21.908 11.6492 21.9995 12 21.9995C12.3508 21.9995 12.6954 21.908 13 21.734L20 17.726C20.619 17.371 21 16.716 21 16.008Z" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M12 22V12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M12 12L20.73 6.95996" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M3.26999 6.95996L12 12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> </svg> <span>Components</span> </button> </li> <li> <button id="settings-link"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M10.325 4.317C10.751 2.561 13.249 2.561 13.675 4.317C13.7389 4.5808 13.8642 4.82578 14.0407 5.032C14.2172 5.23822 14.4399 5.39985 14.6907 5.50375C14.9414 5.60764 15.2132 5.65085 15.4838 5.62987C15.7544 5.60889 16.0162 5.5243 16.248 5.383C17.791 4.443 19.558 6.209 18.618 7.753C18.4769 7.98466 18.3924 8.24634 18.3715 8.51677C18.3506 8.78721 18.3938 9.05877 18.4975 9.30938C18.6013 9.55999 18.7627 9.78258 18.9687 9.95905C19.1747 10.1355 19.4194 10.2609 19.683 10.325C21.439 10.751 21.439 13.249 19.683 13.675C19.4192 13.7389 19.1742 13.8642 18.968 14.0407C18.7618 14.2172 18.6001 14.4399 18.4963 14.6907C18.3924 14.9414 18.3491 15.2132 18.3701 15.4838C18.3911 15.7544 18.4757 16.0162 18.617 16.248C19.557 17.791 17.791 19.558 16.247 18.618C16.0153 18.4769 15.7537 18.3924 15.4832 18.3715C15.2128 18.3506 14.9412 18.3938 14.6906 18.4975C14.44 18.6013 14.2174 18.7627 14.0409 18.9687C13.8645 19.1747 13.7391 19.4194 13.675 19.683C13.249 21.439 10.751 21.439 10.325 19.683C10.2611 19.4192 10.1358 19.1742 9.95929 18.968C9.7828 18.7618 9.56011 18.6001 9.30935 18.4963C9.05859 18.3924 8.78683 18.3491 8.51621 18.3701C8.24559 18.3911 7.98375 18.4757 7.752 18.617C6.209 19.557 4.442 17.791 5.382 16.247C5.5231 16.0153 5.60755 15.7537 5.62848 15.4832C5.64942 15.2128 5.60624 14.9412 5.50247 14.6906C5.3987 14.44 5.23726 14.2174 5.03127 14.0409C4.82529 13.8645 4.58056 13.7391 4.317 13.675C2.561 13.249 2.561 10.751 4.317 10.325C4.5808 10.2611 4.82578 10.1358 5.032 9.95929C5.23822 9.7828 5.39985 9.56011 5.50375 9.30935C5.60764 9.05859 5.65085 8.78683 5.62987 8.51621C5.60889 8.24559 5.5243 7.98375 5.383 7.752C4.443 6.209 6.209 4.442 7.753 5.382C8.753 5.99 10.049 5.452 10.325 4.317Z" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M9 12C9 12.7956 9.31607 13.5587 9.87868 14.1213C10.4413 14.6839 11.2044 15 12 15C12.7956 15 13.5587 14.6839 14.1213 14.1213C14.6839 13.5587 15 12.7956 15 12C15 11.2044 14.6839 10.4413 14.1213 9.87868C13.5587 9.31607 12.7956 9 12 9C11.2044 9 10.4413 9.31607 9.87868 9.87868C9.31607 10.4413 9 11.2044 9 12Z" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> </svg> <span>Settings</span> </button> </li> <li> <button id="add-page-link"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" > <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M14 3v4a1 1 0 0 0 1 1h4" /> <path d="M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z" /> <path d="M12 11l0 6" /> <path d="M9 14l6 0" /> </svg> <span>Add Builder Page</span> </button> </li> <li> <button id="import-from-figma"> <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-brand-figma" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" > <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M15 12m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0" /> <path d="M6 3m0 3a3 3 0 0 1 3 -3h6a3 3 0 0 1 3 3v0a3 3 0 0 1 -3 3h-6a3 3 0 0 1 -3 -3z" /> <path d="M9 9a3 3 0 0 0 0 6h3m-3 0a3 3 0 1 0 3 3v-15" /> </svg> <span>Import From Figma</span> </button> </li> </ul> </div> <footer> <ul class="list"> <li> <a href="https://docs.google.com/forms/d/e/1FAIpQLSdqZcJpRtm_Ia5DTHP6SDY9Xa6LID3KiTjRWkjMzWyJRUtSHw/viewform" target="_blank" > <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M11.013 17.0114L10.013 18.0114L2.513 10.5834C2.0183 10.102 1.62864 9.52342 1.36854 8.88404C1.10845 8.24466 0.983558 7.55836 1.00173 6.86834C1.01991 6.17832 1.18076 5.49954 1.47415 4.87474C1.76755 4.24994 2.18713 3.69266 2.70648 3.23799C3.22583 2.78331 3.8337 2.4411 4.49181 2.23289C5.14991 2.02468 5.844 1.95499 6.53036 2.02821C7.21673 2.10143 7.8805 2.31596 8.47987 2.65831C9.07925 3.00066 9.60124 3.46341 10.013 4.01741C10.8086 2.95654 11.9931 2.2552 13.3059 2.06766C14.6186 1.88012 15.9521 2.22176 17.013 3.01741C18.0739 3.81306 18.7752 4.99755 18.9627 6.3103C19.1503 7.62305 18.8086 8.95654 18.013 10.0174" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" /> <path d="M18.2006 19.8175L16.0286 20.9555C15.9642 20.989 15.8917 21.004 15.8192 20.9987C15.7467 20.9934 15.6771 20.9681 15.6182 20.9256C15.5593 20.8831 15.5134 20.825 15.4855 20.7579C15.4577 20.6907 15.4491 20.6172 15.4606 20.5455L15.8756 18.1345L14.1186 16.4275C14.0662 16.3768 14.0291 16.3123 14.0115 16.2416C13.9939 16.1708 13.9966 16.0965 14.0192 16.0271C14.0418 15.9578 14.0835 15.8962 14.1394 15.8494C14.1954 15.8026 14.2634 15.7725 14.3356 15.7625L16.7636 15.4105L17.8496 13.2175C17.8821 13.1521 17.9322 13.0972 17.9942 13.0588C18.0562 13.0204 18.1277 13 18.2006 13C18.2736 13 18.3451 13.0204 18.4071 13.0588C18.4691 13.0972 18.5191 13.1521 18.5516 13.2175L19.6376 15.4105L22.0656 15.7625C22.1377 15.7728 22.2054 15.8031 22.2611 15.85C22.3168 15.8968 22.3583 15.9583 22.3809 16.0275C22.4034 16.0967 22.4062 16.1708 22.3888 16.2415C22.3715 16.3122 22.3347 16.3766 22.2826 16.4275L20.5256 18.1345L20.9396 20.5445C20.9521 20.6163 20.9441 20.6902 20.9166 20.7578C20.8891 20.8254 20.8433 20.8839 20.7842 20.9267C20.7252 20.9695 20.6553 20.9949 20.5825 21C20.5098 21.005 20.4371 20.9896 20.3726 20.9555L18.2006 19.8175Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" /> </svg> <span>Give Feedback</span> </a> </li> </ul> <div id="version"></div> </footer> </section> <section class="nav-cmp-list"> <header> <button class="back-button"> <svg viewBox="0 0 24 24"> <path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" /> </svg> </button> <div class="search-container"> <div class="search-input-wrapper"> <svg class="search-icon" viewBox="0 0 24 24" width="16" height="16"> <path fill="none" stroke="currentColor" stroke-width="2" d="M15.5 15.5L20 20M10 17C6.13401 17 3 13.866 3 10C3 6.13401 6.13401 3 10 3C13.866 3 17 6.13401 17 10C17 13.866 13.866 17 10 17Z" /> </svg> <input type="text" id="component-search" class="component-search-input" placeholder="Search components..." autocomplete="off" spellcheck="false" /> <button id="clear-search" class="clear-search-button" type="button" aria-label="Clear search" > <svg viewBox="0 0 24 24" width="16" height="16"> <path fill="none" stroke="currentColor" stroke-width="2" d="M6 6l12 12M6 18L18 6" /> </svg> </button> </div> </div> <div> <h2>Custom Components</h2> <p> <button id="open-builder-registry"></button> </p> </div> </header> <div class="section-content"> <div id="cmp-list" class="cmp-list nav-list"></div> </div> <div class="nav-loading-icon spinner"></div> <footer> <p class="info"> Expand on Builder's selection of built-in blocks by <a target="_blank" href="https://www.builder.io/c/docs/custom-components-intro" >registering components</a > from your codebase. This way, teammates can drag and drop your components within Builder's Visual Editor just like any other block. </p> </footer> </section> <section class="nav-cmp-detail"> <header> <button class="back-button" data-back="nav-cmp-list"> <svg viewBox="0 0 24 24"> <path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" /> </svg> </button> <div> <h2 id="cmp-detail-title"></h2> <p> <button id="cmp-open-source"></button> </p> </div> </header> <div class="section-content"> <div id="cmp-error"></div> <label class="ui-switch"> <div> <h3>Register Component</h3> <p> Registers this component so it can be used within Builder Visual CMS </p> </div> <input type="checkbox" role="switch" id="cmp-register" /> <span class="switcher"></span> </label> <div id="cmp-detail"> <label class="ui-text-input"> <h3>Component Name</h3> <div class="input"> <input type="text" id="cmp-name" autocapitalize="off" autocorrect="off" spellcheck="false" autocomplete="off" minlength="2" maxlength="30" required placeholder="e.g. My Counter" /> </div> <p> Unique name to identify this custom component within Builder. Press ESC to cancel </p> </label> <div class="cmp-detail-inputs-container"> <h3> <span>Builder Inputs (Props)</span> <button class="cmp-detail-inputs-reload" id="btn-inputs-reload"> Reload </button> </h3> <div id="cmp-detail-inputs"></div> </div> </div> </div> <div class="cmp-cover"></div> <div class="cmp-loading-icon spinner"></div> </section> <section class="nav-cmp-input"> <header> <button class="back-button" data-back="nav-cmp-detail"> <svg viewBox="0 0 24 24"> <path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" /> </svg> </button> <div> <h2 id="cmp-input-title"></h2> <p> <button id="input-open-source"></button> </p> </div> </header> <div class="section-content"> <label class="ui-switch"> <div> <h3>Enable Input</h3> <p>Add this component prop as a Builder input</p> </div> <input type="checkbox" role="switch" id="input-register" /> <span class="switcher"></span> </label> <div class="cmp-prop-info"> <div class="cmp-input-readonly"> <h3>Prop Name</h3> <span id="cmp-prop-name"></span> </div> <div class="cmp-input-readonly"> <h3>Prop Type</h3> <span id="cmp-prop-type"></span> </div> </div> <div class="cmp-input-detail"> <label class="ui-text-input"> <h3>Builder Input Name</h3> <div class="input"> <input type="text" id="input-name" autocapitalize="off" autocorrect="off" spellcheck="false" autocomplete="off" minlength="1" maxlength="30" required placeholder="e.g. Text" /> </div> <p> Friendly name to identify this component prop as a Builder input. Press ESC to cancel </p> </label> <label class="ui-select"> <h3>Builder Input Type</h3> <div class="select"> <select id="input-type"></select> </div> <p> Correlate to what editing UI is appropriate for this Builder input. <a href="https://www.builder.io/c/docs/custom-components-input-types" target="_blank" >Read more about input types.</a > </p> </label> </div> <div class="input-cover"></div> <div class="input-loading-icon spinner"></div> </div> </section> <section class="nav-settings"> <header> <button class="back-button"> <svg viewBox="0 0 24 24"> <path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" /> </svg> </button> <div> <h2>Settings</h2> <p>Configure Builder's Devtools</p> </div> </header> <div class="section-content"> <label class="ui-switch"> <div> <h3>Enable edit button in UI</h3> <p>Enables the edit button so you can edit content in Builder</p> </div> <input type="checkbox" role="switch" id="enable-edit" /> <span class="switcher"></span> </label> </div> </section> <div class="ui-toast" id="toast"></div> </aside> <button class="menu-toggle" aria-label="Toggle Builder Devtools"> <div> <div class="highlight-bg"></div> <svg viewBox="0 0 31 36" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M31 9.96854C31.0016 11.4553 30.6701 12.9236 30.03 14.2654C29.3898 15.6072 28.4572 16.7884 27.3007 17.7221L0.702841 2.61812C0.601104 2.56012 0.506714 2.49008 0.421705 2.40951C0.288323 2.27871 0.182333 2.12263 0.109928 1.95039C0.0375215 1.77814 0.000151253 1.59319 0 1.40633C0 1.03335 0.148098 0.675643 0.411715 0.411905C0.675332 0.148167 1.03287 0 1.40568 0L21.036 0C23.6786 0 26.213 1.05025 28.0816 2.91972C29.9502 4.78918 31 7.32472 31 9.96854Z" fill="#18B4F4" /> <path d="M31 25.4757C31.0004 26.7849 30.7429 28.0815 30.2423 29.2912C29.7417 30.5009 29.0078 31.6001 28.0825 32.526C27.1572 33.4519 26.0587 34.1864 24.8497 34.6875C23.6406 35.1886 22.3448 35.4465 21.0361 35.4465H1.40573C1.12766 35.4436 0.856725 35.3581 0.627199 35.201C0.397672 35.044 0.219871 34.8223 0.116289 34.5641C0.0127078 34.3059 -0.011999 34.0228 0.0452946 33.7505C0.102588 33.4783 0.239308 33.2292 0.438156 33.0347C0.517415 32.9551 0.606358 32.8858 0.702893 32.8284L11.1705 26.8843L27.2984 17.7244C28.4548 18.6579 29.3874 19.8387 30.028 21.18C30.6685 22.5213 31.0007 23.9891 31 25.4757Z" fill="#FD6B3C" /> <path d="M27.3011 17.7221L11.1709 26.8843L0.703209 32.8284C0.602697 32.8843 0.509784 32.9528 0.426758 33.0323C4.41799 28.9369 6.6496 23.442 6.64456 17.7221C6.65208 12.0015 4.42111 6.50517 0.429101 2.40948C0.51411 2.49005 0.6085 2.56009 0.710237 2.61809L27.3011 17.7221Z" fill="#A97FF2" /> </svg> </div> </button>\`,si(e),ui(e),oi(e),ri(e),ti(e),ci(e),this.setAttribute("aria-hidden","true"),e.getElementById("version").textContent="v1.36.0-beta.202603260926.def4b32"}highlightOpener(){let e=this.shadowRoot.querySelector(".menu-toggle");e.classList.add("menu-toggle-highlight"),e.classList.add("menu-toggle-highlight-no-transition"),setTimeout(()=>{e.classList.remove("menu-toggle-highlight-no-transition"),setTimeout(()=>{e.classList.remove("menu-toggle-highlight")},20)},20)}};var lo=\`<style>*,*:before,*:after{box-sizing:border-box}html,body,:host{position:fixed;top:0;left:0;width:100%;height:100vh;z-index:2147483646;margin:0;padding:0;line-height:1.8;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";background-color:#252525;color:#fff;transition:opacity .25s ease-in-out}:host([aria-hidden="true"]){opacity:0;pointer-events:none}main{position:absolute;top:0;left:0;width:100%;height:100vh}h1{margin-top:0;font-size:24px;font-weight:300;line-height:1.4}p{margin:20px 0;font-weight:300}button{cursor:pointer}aside{position:absolute;top:0;left:0;width:350px;height:100vh;padding:60px 0 0 50px;background-color:#121212}aside ul{margin:30px 0 0;padding:0;list-style:none}aside li{position:relative;margin:0;padding:20px 10px;font-weight:300}aside li.highlight{color:#48a1ff}aside li.active{font-weight:700}aside li .circle{position:absolute;top:20px;left:10px;width:24px;height:24px;border:3px solid white;border-radius:50%;font-size:14px}aside li.highlight .circle{border-color:#48a1ff}aside li.active .circle:after{content:"";position:absolute;top:3px;left:3px;width:12px;height:12px;border-radius:50%;background-color:#48a1ff}aside li.completed .circle{background-color:#48a1ff}aside li.completed .circle:after{content:"";position:absolute;top:2px;left:6px;width:6px;height:13px;border:3px solid black;border-top:none;border-left:none;transform:rotate(45deg)}aside li .line{position:absolute;top:44px;left:21px;width:3px;height:45px;background-color:#fff}aside li.completed .line{background-color:#48a1ff}aside li span{display:block;margin-left:44px}nav{margin-top:30px}section{position:absolute;top:135px;left:350px;padding:0 80px 0 140px;transition:opacity .15s ease-in-out}section[aria-hidden=true]{pointer-events:none;opacity:0}section h1,section p{min-width:300px;max-width:600px}.button{position:relative;display:inline-block;color:#fff;background-color:#48a1ff;border-radius:4px;text-decoration:none;padding:10px 40px 10px 20px;white-space:nowrap}.button:hover{background-color:#48a1ffd9}#button-icon{position:absolute;top:1px;right:5px;bottom:0;width:30px;background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="none" stroke="white" stroke-linecap="square" stroke-miterlimit="10" stroke-width="48" d="M184 112l144 144-144 144"/></svg>');background-repeat:no-repeat;background-position:center;background-size:24px 24px}.button[aria-disabled=true]{opacity:.9;background-color:#ffffff4d;pointer-events:none;padding-right:60px}.button[aria-disabled=true] #button-icon{top:21px;right:29px;width:8px;height:8px;border-radius:4px;background:#fff;color:#fff;animation:dot-flashing .5s infinite linear alternate;animation-delay:.25s}.button[aria-disabled=true] #button-icon:before,.button[aria-disabled=true] #button-icon:after{content:"";display:inline-block;position:absolute;top:0}.button[aria-disabled=true] #button-icon:before{left:-12px;width:8px;height:8px;border-radius:4px;background-color:#fff;color:#fff;animation:dot-flashing .5s infinite alternate;animation-delay:0s}.button[aria-disabled=true] #button-icon:after{left:12px;width:8px;height:8px;border-radius:4px;background-color:#fff;color:#fff;animation:dot-flashing .5s infinite alternate;animation-delay:.5s}@keyframes dot-flashing{0%{background-color:#fff}50%,to{background-color:#ffffff4d}}.logo{margin-left:9px;background:url('data:image/svg+xml,<svg viewBox="0 0 150 32" fill="none" xmlns="http://www.w3.org/2000/svg" > <g clip-path="url(%23clip0_4_304)"> <path d="M27.9858 8.99927C27.9872 10.3415 27.688 11.667 27.1101 12.8783C26.5321 14.0896 25.6902 15.156 24.6462 15.9989V15.9989L0.634502 2.36355C0.542657 2.31119 0.457444 2.24796 0.380701 2.17523C0.260289 2.05715 0.164605 1.91624 0.0992389 1.76075C0.0338732 1.60525 0.000136546 1.43828 0 1.26959C0 0.932873 0.133698 0.609948 0.371683 0.371854C0.609667 0.13376 0.932443 0 1.269 0L18.9906 0C21.3763 0 23.6642 0.948135 25.3512 2.63583C27.0381 4.32352 27.9858 6.61252 27.9858 8.99927V8.99927Z" fill="%2318B4F4" /> <path d="M27.9858 22.9986C27.9861 24.1806 27.7536 25.351 27.3017 26.4431C26.8498 27.5352 26.1873 28.5275 25.352 29.3634C24.5167 30.1993 23.5249 30.8624 22.4335 31.3147C21.342 31.7671 20.1721 32 18.9907 32H1.26906C1.01802 31.9973 0.77343 31.9202 0.566221 31.7784C0.359012 31.6366 0.198499 31.4364 0.104989 31.2034C0.0114791 30.9703 -0.0108254 30.7147 0.0408974 30.4689C0.0926201 30.2231 0.216046 29.9982 0.395559 29.8226V29.8226C0.467112 29.7508 0.547407 29.6882 0.634555 29.6364L10.0844 24.2703L24.6441 16.001C25.688 16.8438 26.53 17.9097 27.1083 19.1206C27.6866 20.3315 27.9864 21.6566 27.9858 22.9986V22.9986Z" fill="%23FD6B3C" /> <path d="M24.6461 15.9989L10.0843 24.2703L0.634458 29.6365C0.54372 29.6868 0.459841 29.7487 0.384888 29.8205C3.98804 26.1233 6.00266 21.1627 5.99812 15.9989C6.0049 10.8346 3.99085 5.87268 0.387003 2.17523C0.463746 2.24796 0.548959 2.31119 0.640803 2.36355L24.6461 15.9989Z" fill="%23A97FF2" /> <path d="M47.6659 11.7352C51.8177 11.7352 54.1632 15.0531 54.1632 19.0714C54.1632 23.0896 51.8177 26.3821 47.6659 26.3821C45.5086 26.3821 43.8589 25.5188 42.9473 24.0545L42.5709 26.052H39.9736V6.77115H43.1884V13.8914C43.971 12.6959 45.5086 11.7352 47.6659 11.7352ZM47.0187 23.5488C49.4446 23.5488 50.9547 21.5809 50.9547 19.0714C50.9547 16.5089 49.4446 14.5664 47.0187 14.5664C44.5928 14.5664 43.0806 16.5047 43.0806 19.0714C43.0806 21.583 44.5653 23.5488 47.0187 23.5488V23.5488Z" fill="white" /> <path d="M65.4595 20.2859V12.0611H68.668V20.123C68.668 23.7202 67.0246 26.3821 62.4943 26.3821C57.9639 26.3821 56.3206 23.7117 56.3206 20.123V12.0611H59.529V20.2859C59.529 22.4696 60.5527 23.5488 62.49 23.5488C64.4274 23.5488 65.4595 22.4696 65.4595 20.2859Z" fill="white" /> <path d="M71.2355 7.74451C71.2247 7.46284 71.2724 7.18199 71.3755 6.91968C71.4787 6.65737 71.6351 6.41929 71.8348 6.22047C72.0345 6.02165 72.2732 5.8664 72.5359 5.76452C72.7986 5.66264 73.0796 5.61633 73.3611 5.62853C74.5793 5.62853 75.4571 6.50666 75.4571 7.75509C75.4571 9.00352 74.5793 9.8224 73.3611 9.8224C72.1428 9.8224 71.2355 8.9612 71.2355 7.74451Z" fill="white" /> <path d="M128.476 7.74451C128.465 7.46376 128.513 7.18383 128.615 6.92227C128.718 6.66071 128.873 6.42315 129.072 6.22449C129.27 6.02583 129.508 5.87035 129.769 5.7678C130.031 5.66524 130.31 5.61783 130.591 5.62852C131.809 5.62852 132.687 6.50666 132.687 7.75509C132.687 9.00352 131.809 9.8224 130.591 9.8224C129.373 9.8224 128.476 8.9612 128.476 7.74451Z" fill="white" /> <path d="M122.302 24.1031C122.291 23.8223 122.339 23.5422 122.441 23.2805C122.543 23.0188 122.699 22.7811 122.897 22.5824C123.096 22.3837 123.334 22.2282 123.595 22.1258C123.857 22.0233 124.137 21.9761 124.417 21.9872C125.636 21.9872 126.513 22.8653 126.513 24.1031C126.513 25.341 125.636 26.1726 124.417 26.1726C123.199 26.1726 122.302 25.3219 122.302 24.1031Z" fill="white" /> <path d="M74.9516 12.059H71.7432V26.0583H74.9516V12.059Z" fill="white" /> <path d="M78.16 26.0583V6.77115H81.3685V26.0626L78.16 26.0583Z" fill="white" /> <path d="M94.6063 6.77115H97.8148V26.0626H95.2239L94.8474 24.0651C93.9591 25.523 92.3094 26.3927 90.131 26.3927C86.0046 26.3927 83.6591 23.0748 83.6591 19.0819C83.6591 15.0891 86.0046 11.7458 90.131 11.7458C92.3137 11.7458 93.8238 12.7149 94.6063 13.902V6.77115ZM90.7993 14.5707C88.3734 14.5707 86.8633 16.5131 86.8633 19.0756C86.8633 21.5851 88.3734 23.553 90.7993 23.553C93.2252 23.553 94.7354 21.5851 94.7354 19.0756C94.7396 16.5047 93.257 14.5664 90.8036 14.5664L90.7993 14.5707Z" fill="white" /> <path d="M113.479 22.2284C112.482 24.7359 110.162 26.3821 107.117 26.3821C102.887 26.3821 100.137 23.225 100.137 19.0439C100.137 14.9706 102.942 11.7353 107.093 11.7353C111.245 11.7353 113.969 14.8902 113.969 18.991C113.982 19.3255 113.953 19.6604 113.883 19.9876H103.288C103.53 22.2009 104.959 23.6292 107.197 23.6292C108.735 23.6292 110.001 22.8738 110.594 21.473L113.479 22.2284ZM103.341 17.6156H110.784C110.513 15.6731 109.166 14.3506 107.089 14.3506C105.012 14.3506 103.665 15.7006 103.341 17.6156V17.6156Z" fill="white" /> <path d="M123.779 14.9452C123.538 14.9117 123.295 14.8933 123.051 14.8902C120.786 14.8902 119.439 16.0772 119.439 18.7751V26.0583H116.23V12.0611H118.821L119.195 14.0014C119.707 13.1127 120.887 11.9257 123.322 11.9257C123.455 11.9257 123.779 11.9532 123.779 11.9532V14.9452Z" fill="white" /> <path d="M132.192 12.059H128.984V26.0583H132.192V12.059Z" fill="white" /> <path d="M134.483 19.0714C134.483 15.1335 137.287 11.7353 141.735 11.7353C146.183 11.7353 149.015 15.1335 149.015 19.0714C149.015 23.0092 146.213 26.3821 141.735 26.3821C137.258 26.3821 134.483 23.0092 134.483 19.0714ZM141.735 23.5488C144.083 23.5488 145.806 21.7692 145.806 19.0714C145.806 16.3735 144.083 14.5664 141.735 14.5664C139.387 14.5664 137.687 16.346 137.687 19.0714C137.687 21.7968 139.417 23.5488 141.735 23.5488V23.5488Z" fill="white" /> </g> <defs> <clipPath id="clip0_4_304"> <rect width="149.015" height="32" fill="white" /> </clipPath> </defs> </svg>');background-repeat:no-repeat;width:150px;height:32px}@media(max-width:840px){aside{width:250px;padding:60px 0 0 20px}section{left:250px;padding:0 80px}}@media(max-width:590px){aside{width:230px;padding:60px 0 0 10px}section{left:230px;padding:0 40px}}#modified-files-message a{color:#cbcbcb;font-weight:300;text-decoration:underline}#modified-files-message a:hover{color:#fff;text-decoration:none}#restart-warning{border-radius:4px;padding:8px 16px;border:1px solid #fd6b3c;background:#fd6b3c1a}#react-router-steps{margin:0 0 5px;padding:0 20px}#need-help{color:#48a1ff;text-decoration:none}#router-message{border-radius:4px;padding:16px;border:1px solid #48a1ff}#router-finish-button{margin-top:12px}#router-checkbox-div{display:flex;align-items:center}#router-checkbox{margin-right:10px;width:15px;height:15px}#success-title{display:flex;align-items:center;gap:10px}#success-title .check-icon{display:inline-block;width:24px;height:24px;border:2px solid #28a745;border-radius:50%;position:relative}#success-title .check-icon:before{content:"";position:absolute;top:50%;left:50%;width:6px;height:12px;border:solid #28a745;border-width:0 2px 2px 0;transform:translate(-50%,-60%) rotate(45deg)}
1280
1280
  </style>\`,Nt=class extends HTMLElement{constructor(){super()}connectedCallback(){let e=this.attachShadow({mode:"open"});e.innerHTML=lo+\`<main>
1281
1281
  <aside>
1282
1282
  <div class="logo"></div>
@@ -1315,7 +1315,7 @@ Restarting server after Builder Devtools update...
1315
1315
  </nav>
1316
1316
  </section>
1317
1317
  </main>
1318
- \`,po();let r=new URL(Fr,ot);r.searchParams.set(Br,location.href);let n=e.querySelectorAll(".next-step");for(let i of n)i.setAttribute("href",r.href);ye("overview step viewed")}},po=()=>{let t=document.head.querySelector("link[rel='icon'], link[rel='icon shortcut']");t?(t.href="https://cdn.builder.io/favicon.ico",t.removeAttribute("type")):(t=document.createElement("link"),t.rel="icon",t.href="https://cdn.builder.io/favicon.ico",document.head.appendChild(t))};var li=async()=>{(await jr()).isValid||fo()},fo=()=>{customElements.get("builder-dev-tools-overview")||customElements.define("builder-dev-tools-overview",Nt);let t=document.querySelector("builder-dev-tools-overview");t||(t=document.createElement("builder-dev-tools-overview"),t.setAttribute("aria-hidden","true"),document.body.appendChild(t)),setTimeout(()=>{t.removeAttribute("aria-hidden")},32)};var mo=()=>{try{customElements.get("builder-dev-tools-edit")||customElements.define("builder-dev-tools-edit",at),customElements.get("builder-dev-tools-menu")||customElements.define("builder-dev-tools-menu",Dt);let t=document.querySelector("builder-dev-tools-menu");t||(t=document.createElement("builder-dev-tools-menu"),t.setAttribute("data-version","1.36.0-beta.202603260907.bbf4118"),document.body.appendChild(t));let e=document.querySelector("builder-dev-tools-edit");e||(e=document.createElement("builder-dev-tools-edit"),document.body.appendChild(e));let r=document.getElementById("builder-dev-tools-style");r||(r=document.createElement("style"),r.id="builder-dev-tools-style",r.innerHTML=".builder-no-scroll{overflow:hidden !important}",document.head.appendChild(r)),li(),Jn()}catch(t){console.error("Builder Devtools:",t)}};window.location===window.parent.location&&(console.debug("Builder.io Devtools v1.36.0-beta.202603260907.bbf4118"),mo());})();`)}async function Hie(t){return Jie(t,`<!doctype html>
1318
+ \`,po();let r=new URL(Fr,ot);r.searchParams.set(Br,location.href);let n=e.querySelectorAll(".next-step");for(let i of n)i.setAttribute("href",r.href);ye("overview step viewed")}},po=()=>{let t=document.head.querySelector("link[rel='icon'], link[rel='icon shortcut']");t?(t.href="https://cdn.builder.io/favicon.ico",t.removeAttribute("type")):(t=document.createElement("link"),t.rel="icon",t.href="https://cdn.builder.io/favicon.ico",document.head.appendChild(t))};var li=async()=>{(await jr()).isValid||fo()},fo=()=>{customElements.get("builder-dev-tools-overview")||customElements.define("builder-dev-tools-overview",Nt);let t=document.querySelector("builder-dev-tools-overview");t||(t=document.createElement("builder-dev-tools-overview"),t.setAttribute("aria-hidden","true"),document.body.appendChild(t)),setTimeout(()=>{t.removeAttribute("aria-hidden")},32)};var mo=()=>{try{customElements.get("builder-dev-tools-edit")||customElements.define("builder-dev-tools-edit",at),customElements.get("builder-dev-tools-menu")||customElements.define("builder-dev-tools-menu",Dt);let t=document.querySelector("builder-dev-tools-menu");t||(t=document.createElement("builder-dev-tools-menu"),t.setAttribute("data-version","1.36.0-beta.202603260926.def4b32"),document.body.appendChild(t));let e=document.querySelector("builder-dev-tools-edit");e||(e=document.createElement("builder-dev-tools-edit"),document.body.appendChild(e));let r=document.getElementById("builder-dev-tools-style");r||(r=document.createElement("style"),r.id="builder-dev-tools-style",r.innerHTML=".builder-no-scroll{overflow:hidden !important}",document.head.appendChild(r)),li(),Jn()}catch(t){console.error("Builder Devtools:",t)}};window.location===window.parent.location&&(console.debug("Builder.io Devtools v1.36.0-beta.202603260926.def4b32"),mo());})();`)}async function Hie(t){return Jie(t,`<!doctype html>
1319
1319
  <html lang="en" dir="ltr">
1320
1320
  <head>
1321
1321
  <meta charset="utf-8" />
@@ -1844,12 +1844,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
1844
1844
  `):void 0,oldContent:u.length>0?u.join(`
1845
1845
  `):void 0})}let f=p.substring(4).split(" ")[0],m=_et(f);p.startsWith("--- ")?(o=m,i=m,a=0,A=0,c=[],u=[],s=null,l=f==="/dev/null",d=!1):p.startsWith("+++ ")&&(d=f==="/dev/null",f==="/dev/null"?i=o:i=m);continue}else{if(p.startsWith("@@"))continue;p.startsWith("+")?(a++,c.push(p.substring(1)),s===null&&(s="update")):p.startsWith("-")?(A++,u.push(p.substring(1)),s===null&&(s="update")):(p.startsWith(" ")||p==="")&&(c.push(p.substring(1)),u.push(p.substring(1)))}}if(i&&s){let g;l?g="create":d?g="delete":g="update";let p=g==="delete"&&o?o:i;r.push({filePath:p,addedLines:a,removedLines:A,action:g,content:c.length>0?c.join(`
1846
1846
  `):void 0,oldContent:u.length>0?u.join(`
1847
- `):void 0})}return r}var dhe=N(()=>{"use strict";h()});var xl,fhe=N(()=>{"use strict";h();xl=(...t)=>{typeof process<"u"&&process.env.DEBUG==="true"&&console.debug("[DEBUG] ",...t)}});var Uet,$m,mhe,Get,Oet,Ket,tx,BK=N(()=>{"use strict";h();fhe();Uet=()=>{if(typeof globalThis<"u"&&globalThis.crypto)return globalThis.crypto;if(typeof require<"u")try{let t=require("crypto");if(t.webcrypto)return t.webcrypto}catch{}throw new Error("Web Crypto API is not available. Requires Node.js 15+ or a browser environment.")},$m=Uet(),mhe=async()=>{let t=await $m.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]),e=await $m.subtle.exportKey("jwk",t);return JSON.stringify(e)},Get=async()=>$m.getRandomValues(new Uint8Array(16)),Oet=async(t,e,r)=>{let n=await $m.subtle.encrypt({name:"AES-GCM",iv:e,tagLength:128},t,typeof r=="string"?new TextEncoder().encode(r):r);return Buffer.from(n)},Ket=async(t,e,r)=>{let n=await $m.subtle.decrypt({name:"AES-GCM",iv:e,tagLength:128},t,r);return new TextDecoder().decode(n)},tx=async t=>{try{xl("validateEncryptionKey: Validating encryption key");let e=JSON.parse(t);xl("validateEncryptionKey: Parsed JWK");let r=await $m.subtle.importKey("jwk",e,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]);xl("validateEncryptionKey: Imported crypto key");let n="test",i=await Get();xl("validateEncryptionKey: Generated test IV",i);let o=await Oet(r,i,n);xl("validateEncryptionKey: Encrypted test data",o);let s=new Uint8Array(o);xl("validateEncryptionKey: Encrypted test data array",s);let a=await Ket(r,i,s);return xl("validateEncryptionKey: Decrypted test data",a),a===n}catch(e){return console.error("Could not validate encryption key:",e),!1}}});var yK,hhe,Het,Che=N(()=>{h();yK=(t,e,r)=>{let n=t instanceof RegExp?hhe(t,r):t,i=e instanceof RegExp?hhe(e,r):e,o=n!==null&&i!=null&&Het(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)}},hhe=(t,e)=>{let r=e.match(t);return r?r[0]:null},Het=(t,e,r)=>{let n,i,o,s,a,A=r.indexOf(t),c=r.indexOf(e,A+1),u=A;if(A>=0&&c>0){if(t===e)return[A,c];for(n=[],o=r.length;u>=0&&!a;){if(u===A)n.push(u),A=r.indexOf(t,u+1);else if(n.length===1){let l=n.pop();l!==void 0&&(a=[l,c])}else i=n.pop(),i!==void 0&&i<o&&(o=i,s=c),c=r.indexOf(e,u+1);u=A<c&&A>=0?A:c}n.length&&s!==void 0&&(a=[o,s])}return a}});function QK(t){return isNaN(t)?t.charCodeAt(0):parseInt(t,10)}function ttt(t){return t.replace(zet,Ihe).replace(Vet,Ehe).replace(Wet,DK).replace(Zet,Bhe).replace(Xet,yhe)}function rtt(t){return t.replace(Jet,"\\").replace($et,"{").replace(jet,"}").replace(Yet,",").replace(qet,".")}function Qhe(t){if(!t)return[""];let e=[],r=yK("{","}",t);if(!r)return t.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=Qhe(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),e.push.apply(e,s),e}function Dhe(t,e={}){if(!t)return[];let{max:r=ett}=e;return t.slice(0,2)==="{}"&&(t="\\{\\}"+t.slice(2)),ly(ttt(t),r,!0).map(rtt)}function ntt(t){return"{"+t+"}"}function itt(t){return/^-?0\d/.test(t)}function ott(t,e){return t<=e}function stt(t,e){return t>=e}function ly(t,e,r){let n=[],i=yK("{","}",t);if(!i)return[t];let o=i.pre,s=i.post.length?ly(i.post,e,!1):[""];if(/\$$/.test(i.pre))for(let a=0;a<s.length&&a<e;a++){let A=o+"{"+i.body+"}"+s[a];n.push(A)}else{let a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),A=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),c=a||A,u=i.body.indexOf(",")>=0;if(!c&&!u)return i.post.match(/,(?!,).*\}/)?(t=i.pre+"{"+i.body+DK+i.post,ly(t,e,!0)):[t];let l;if(c)l=i.body.split(/\.\./);else if(l=Qhe(i.body),l.length===1&&l[0]!==void 0&&(l=ly(l[0],e,!1).map(ntt),l.length===1))return s.map(g=>i.pre+l[0]+g);let d;if(c&&l[0]!==void 0&&l[1]!==void 0){let g=QK(l[0]),p=QK(l[1]),f=Math.max(l[0].length,l[1].length),m=l.length===3&&l[2]!==void 0?Math.abs(QK(l[2])):1,C=ott;p<g&&(m*=-1,C=stt);let B=l.some(itt);d=[];for(let E=g;C(E,p);E+=m){let y;if(A)y=String.fromCharCode(E),y==="\\"&&(y="");else if(y=String(E),B){let Q=f-y.length;if(Q>0){let b=new Array(Q+1).join("0");E<0?y="-"+b+y.slice(1):y=b+y}}d.push(y)}}else{d=[];for(let g=0;g<l.length;g++)d.push.apply(d,ly(l[g],e,!1))}for(let g=0;g<d.length;g++)for(let p=0;p<s.length&&n.length<e;p++){let f=o+d[g]+s[p];(!r||c||f)&&n.push(f)}}return n}var Ihe,Ehe,DK,Bhe,yhe,Jet,$et,jet,Yet,qet,zet,Vet,Wet,Zet,Xet,ett,whe=N(()=>{h();Che();Ihe="\0SLASH"+Math.random()+"\0",Ehe="\0OPEN"+Math.random()+"\0",DK="\0CLOSE"+Math.random()+"\0",Bhe="\0COMMA"+Math.random()+"\0",yhe="\0PERIOD"+Math.random()+"\0",Jet=new RegExp(Ihe,"g"),$et=new RegExp(Ehe,"g"),jet=new RegExp(DK,"g"),Yet=new RegExp(Bhe,"g"),qet=new RegExp(yhe,"g"),zet=/\\\\/g,Vet=/\\{/g,Wet=/\\}/g,Zet=/\\,/g,Xet=/\\\./g,ett=1e5});var gy,vhe=N(()=>{h();gy=t=>{if(typeof t!="string")throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")}});var att,py,Att,bhe,She,xhe=N(()=>{h();att={"[: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]},py=t=>t.replace(/[[\]\\-]/g,"\\$&"),Att=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),bhe=t=>t.join(""),She=(t,e)=>{let r=e;if(t.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],o=r+1,s=!1,a=!1,A=!1,c=!1,u=r,l="";e:for(;o<t.length;){let f=t.charAt(o);if((f==="!"||f==="^")&&o===r+1){c=!0,o++;continue}if(f==="]"&&s&&!A){u=o+1;break}if(s=!0,f==="\\"&&!A){A=!0,o++;continue}if(f==="["&&!A){for(let[m,[C,I,B]]of Object.entries(att))if(t.startsWith(m,o)){if(l)return["$.",!1,t.length-r,!0];o+=m.length,B?i.push(C):n.push(C),a=a||I;continue e}}if(A=!1,l){f>l?n.push(py(l)+"-"+py(f)):f===l&&n.push(py(f)),l="",o++;continue}if(t.startsWith("-]",o+1)){n.push(py(f+"-")),o+=2;continue}if(t.startsWith("-",o+1)){l=f,o+=2;continue}n.push(py(f)),o++}if(u<o)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,t.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!c){let f=n[0].length===2?n[0].slice(-1):n[0];return[Att(f),!1,u-r,!1]}let d="["+(c?"^":"")+bhe(n)+"]",g="["+(c?"":"^")+bhe(i)+"]";return[n.length&&i.length?"("+d+"|"+g+")":n.length?d:g,a,u-r,!0]}});var Fl,rx=N(()=>{h();Fl=(t,{windowsPathsNoEscape:e=!1,magicalBraces:r=!0}={})=>r?e?t.replace(/\[([^\/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):e?t.replace(/\[([^\/\\{}])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1")});var zo,ctt,wK,Fhe,utt,ltt,gtt,khe,ptt,nx,dtt,ftt,mtt,htt,vK,Rhe,Nhe,Ctt,bp,bK=N(()=>{h();xhe();rx();ctt=new Set(["!","?","+","*","@"]),wK=t=>ctt.has(t),Fhe=t=>wK(t.type),utt=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),ltt=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),gtt=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),khe=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),ptt="(?!(?:^|/)\\.\\.?(?:$|/))",nx="(?!\\.)",dtt=new Set(["[","."]),ftt=new Set(["..","."]),mtt=new Set("().*{}+?[]^$\\!"),htt=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),vK="[^/]",Rhe=vK+"*?",Nhe=vK+"+?",Ctt=0,bp=class{type;#n;#g;#l=!1;#t=[];#c;#o;#e;#s=!1;#B;#h;#N=!1;id=++Ctt;get depth(){return(this.#c?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#n.id,parent:this.#c?.id,depth:this.depth,partsLength:this.#t.length,parts:this.#t}}constructor(e,r,n={}){this.type=e,e&&(this.#g=!0),this.#c=r,this.#n=this.#c?this.#c.#n:this,this.#B=this.#n===this?n:this.#n.#B,this.#e=this.#n===this?[]:this.#n.#e,e==="!"&&!this.#n.#s&&this.#e.push(this),this.#o=this.#c?this.#c.#t.length:0}get hasMagic(){if(this.#g!==void 0)return this.#g;for(let e of this.#t)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#g=!0;return this.#g}toString(){return this.#h!==void 0?this.#h:this.type?this.#h=this.type+"("+this.#t.map(e=>String(e)).join("|")+")":this.#h=this.#t.map(e=>String(e)).join("")}#b(){if(this!==this.#n)throw new Error("should only call on root");if(this.#s)return this;this.toString(),this.#s=!0;let e;for(;e=this.#e.pop();){if(e.type!=="!")continue;let r=e,n=r.#c;for(;n;){for(let i=r.#o+1;!n.type&&i<n.#t.length;i++)for(let o of e.#t){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#t[i])}r=n,n=r.#c}}return this}push(...e){for(let r of e)if(r!==""){if(typeof r!="string"&&!(r instanceof zo&&r.#c===this))throw new Error("invalid part: "+r);this.#t.push(r)}}toJSON(){let e=this.type===null?this.#t.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#t.map(r=>r.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#n||this.#n.#s&&this.#c?.type==="!")&&e.push({}),e}isStart(){if(this.#n===this)return!0;if(!this.#c?.isStart())return!1;if(this.#o===0)return!0;let e=this.#c;for(let r=0;r<this.#o;r++){let n=e.#t[r];if(!(n instanceof zo&&n.type==="!"))return!1}return!0}isEnd(){if(this.#n===this||this.#c?.type==="!")return!0;if(!this.#c?.isEnd())return!1;if(!this.type)return this.#c?.isEnd();let e=this.#c?this.#c.#t.length:0;return this.#o===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let r=new zo(this.type,e);for(let n of this.#t)r.copyIn(n);return r}static#S(e,r,n,i,o){let s=i.maxExtglobRecursion??2,a=!1,A=!1,c=-1,u=!1;if(r.type===null){let f=n,m="";for(;f<e.length;){let C=e.charAt(f++);if(a||C==="\\"){a=!a,m+=C;continue}if(A){f===c+1?(C==="^"||C==="!")&&(u=!0):C==="]"&&!(f===c+2&&u)&&(A=!1),m+=C;continue}else if(C==="["){A=!0,c=f,u=!1,m+=C;continue}if(!i.noext&&wK(C)&&e.charAt(f)==="("&&o<=s){r.push(m),m="";let B=new zo(C,r);f=zo.#S(e,B,f,i,o+1),r.push(B);continue}m+=C}return r.push(m),f}let l=n+1,d=new zo(null,r),g=[],p="";for(;l<e.length;){let f=e.charAt(l++);if(a||f==="\\"){a=!a,p+=f;continue}if(A){l===c+1?(f==="^"||f==="!")&&(u=!0):f==="]"&&!(l===c+2&&u)&&(A=!1),p+=f;continue}else if(f==="["){A=!0,c=l,u=!1,p+=f;continue}if(!i.noext&&wK(f)&&e.charAt(l)==="("&&(o<=s||r&&r.#f(f))){let C=r&&r.#f(f)?0:1;d.push(p),p="";let I=new zo(f,d);d.push(I),l=zo.#S(e,I,l,i,o+C);continue}if(f==="|"){d.push(p),p="",g.push(d),d=new zo(null,r);continue}if(f===")")return p===""&&r.#t.length===0&&(r.#N=!0),d.push(p),p="",r.push(...g,d),l;p+=f}return r.type=null,r.#g=void 0,r.#t=[e.substring(n-1)],l}#x(e){return this.#i(e,ltt)}#i(e,r=utt){if(!e||typeof e!="object"||e.type!==null||e.#t.length!==1||this.type===null)return!1;let n=e.#t[0];return!n||typeof n!="object"||n.type===null?!1:this.#f(n.type,r)}#f(e,r=gtt){return!!r.get(this.type)?.includes(e)}#r(e,r){let n=e.#t[0],i=new zo(null,n,this.options);i.#t.push(""),n.push(i),this.#u(e,r)}#u(e,r){let n=e.#t[0];this.#t.splice(r,1,...n.#t);for(let i of n.#t)typeof i=="object"&&(i.#c=this);this.#h=void 0}#W(e){return!!khe.get(this.type)?.has(e)}#T(e){if(!e||typeof e!="object"||e.type!==null||e.#t.length!==1||this.type===null||this.#t.length!==1)return!1;let r=e.#t[0];return!r||typeof r!="object"||r.type===null?!1:this.#W(r.type)}#fe(e){let r=khe.get(this.type),n=e.#t[0],i=r?.get(n.type);if(!i)return!1;this.#t=n.#t;for(let o of this.#t)typeof o=="object"&&(o.#c=this);this.type=i,this.#h=void 0,this.#N=!1}static fromGlob(e,r={}){let n=new zo(null,void 0,r);return zo.#S(e,n,0,r,0),n}toMMPattern(){if(this!==this.#n)return this.#n.toMMPattern();let e=this.toString(),[r,n,i,o]=this.toRegExpSource();if(!(i||this.#g||this.#B.nocase&&!this.#B.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#B.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:e})}get options(){return this.#B}toRegExpSource(e){let r=e??!!this.#B.dot;if(this.#n===this&&(this.#_(),this.#b()),!Fhe(this)){let A=this.isStart()&&this.isEnd()&&!this.#t.some(g=>typeof g!="string"),c=this.#t.map(g=>{let[p,f,m,C]=typeof g=="string"?zo.#ne(g,this.#g,A):g.toRegExpSource(e);return this.#g=this.#g||m,this.#l=this.#l||C,p}).join(""),u="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&ftt.has(this.#t[0]))){let p=dtt,f=r&&p.has(c.charAt(0))||c.startsWith("\\.")&&p.has(c.charAt(2))||c.startsWith("\\.\\.")&&p.has(c.charAt(4)),m=!r&&!e&&p.has(c.charAt(0));u=f?ptt:m?nx:""}let l="";return this.isEnd()&&this.#n.#s&&this.#c?.type==="!"&&(l="(?:$|\\/)"),[u+c+l,Fl(c),this.#g=!!this.#g,this.#l]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#j(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let A=this.toString(),c=this;return c.#t=[A],c.type=null,c.#g=void 0,[A,Fl(this.toString()),!1,!1]}let s=!n||e||r||!nx?"":this.#j(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#N)a=(this.isStart()&&!r?nx:"")+Nhe;else{let A=this.type==="!"?"))"+(this.isStart()&&!r&&!e?nx:"")+Rhe+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+A}return[a,Fl(o),this.#g=!!this.#g,this.#l]}#_(){if(Fhe(this)){let e=0,r=!1;do{r=!0;for(let n=0;n<this.#t.length;n++){let i=this.#t[n];typeof i=="object"&&(i.#_(),this.#i(i)?(r=!1,this.#u(i,n)):this.#x(i)?(r=!1,this.#r(i,n)):this.#T(i)&&(r=!1,this.#fe(i)))}}while(!r&&++e<10)}else for(let e of this.#t)typeof e=="object"&&e.#_();this.#h=void 0}#j(e){return this.#t.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,o,s]=r.toRegExpSource(e);return this.#l=this.#l||s,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#ne(e,r,n=!1){let i=!1,o="",s=!1,a=!1;for(let A=0;A<e.length;A++){let c=e.charAt(A);if(i){i=!1,o+=(mtt.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(e)?Nhe:Rhe,r=!0;continue}else a=!1;if(c==="\\"){A===e.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,l,d,g]=She(e,A);if(d){o+=u,s=s||l,A+=d-1,r=r||g;continue}}if(c==="?"){o+=vK,r=!0;continue}o+=htt(c)}return[o,Fl(e),!!r,s]}};zo=bp});var SK,xK=N(()=>{h();SK=(t,{windowsPathsNoEscape:e=!1,magicalBraces:r=!1}={})=>r?e?t.replace(/[?*()[\]{}]/g,"[$&]"):t.replace(/[?*()[\]\\{}]/g,"\\$&"):e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&")});var ki,Itt,Ett,Btt,ytt,Qtt,Dtt,wtt,vtt,btt,Stt,xtt,Ftt,ktt,Rtt,Ntt,Ttt,Mtt,Ptt,Phe,_he,Lhe,The,_tt,eo,Ltt,Utt,Gtt,Ott,Ktt,ea,Htt,Uhe,Jtt,$tt,Mhe,jtt,jm,Ghe=N(()=>{h();whe();vhe();bK();xK();rx();bK();xK();rx();ki=(t,e,r={})=>(gy(e),!r.nocomment&&e.charAt(0)==="#"?!1:new jm(e,r).match(t)),Itt=/^\*+([^+@!?\*\[\(]*)$/,Ett=t=>e=>!e.startsWith(".")&&e.endsWith(t),Btt=t=>e=>e.endsWith(t),ytt=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),Qtt=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),Dtt=/^\*+\.\*+$/,wtt=t=>!t.startsWith(".")&&t.includes("."),vtt=t=>t!=="."&&t!==".."&&t.includes("."),btt=/^\.\*+$/,Stt=t=>t!=="."&&t!==".."&&t.startsWith("."),xtt=/^\*+$/,Ftt=t=>t.length!==0&&!t.startsWith("."),ktt=t=>t.length!==0&&t!=="."&&t!=="..",Rtt=/^\?+([^+@!?\*\[\(]*)?$/,Ntt=([t,e=""])=>{let r=Phe([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},Ttt=([t,e=""])=>{let r=_he([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},Mtt=([t,e=""])=>{let r=_he([t]);return e?n=>r(n)&&n.endsWith(e):r},Ptt=([t,e=""])=>{let r=Phe([t]);return e?n=>r(n)&&n.endsWith(e):r},Phe=([t])=>{let e=t.length;return r=>r.length===e&&!r.startsWith(".")},_he=([t])=>{let e=t.length;return r=>r.length===e&&r!=="."&&r!==".."},Lhe=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",The={win32:{sep:"\\"},posix:{sep:"/"}},_tt=Lhe==="win32"?The.win32.sep:The.posix.sep;ki.sep=_tt;eo=Symbol("globstar **");ki.GLOBSTAR=eo;Ltt="[^/]",Utt=Ltt+"*?",Gtt="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Ott="(?:(?!(?:\\/|^)\\.).)*?",Ktt=(t,e={})=>r=>ki(r,t,e);ki.filter=Ktt;ea=(t,e={})=>Object.assign({},t,e),Htt=t=>{if(!t||typeof t!="object"||!Object.keys(t).length)return ki;let e=ki;return Object.assign((n,i,o={})=>e(n,i,ea(t,o)),{Minimatch:class extends e.Minimatch{constructor(i,o={}){super(i,ea(t,o))}static defaults(i){return e.defaults(ea(t,i)).Minimatch}},AST:class extends e.AST{constructor(i,o,s={}){super(i,o,ea(t,s))}static fromGlob(i,o={}){return e.AST.fromGlob(i,ea(t,o))}},unescape:(n,i={})=>e.unescape(n,ea(t,i)),escape:(n,i={})=>e.escape(n,ea(t,i)),filter:(n,i={})=>e.filter(n,ea(t,i)),defaults:n=>e.defaults(ea(t,n)),makeRe:(n,i={})=>e.makeRe(n,ea(t,i)),braceExpand:(n,i={})=>e.braceExpand(n,ea(t,i)),match:(n,i,o={})=>e.match(n,i,ea(t,o)),sep:e.sep,GLOBSTAR:eo})};ki.defaults=Htt;Uhe=(t,e={})=>(gy(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:Dhe(t,{max:e.braceExpandMax}));ki.braceExpand=Uhe;Jtt=(t,e={})=>new jm(t,e).makeRe();ki.makeRe=Jtt;$tt=(t,e,r={})=>{let n=new jm(e,r);return t=t.filter(i=>n.match(i)),n.options.nonull&&!t.length&&t.push(e),t};ki.match=$tt;Mhe=/[?*]|[+@!]\(.*?\)|\[|\]/,jtt=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),jm=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,r={}){gy(e),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=e,this.platform=r.platform||Lhe,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 e of this.set)for(let r of e)if(typeof r!="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,r=this.options;if(!r.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){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 A=o[0]===""&&o[1]===""&&(o[2]==="?"||!Mhe.test(o[2]))&&!Mhe.test(o[3]),c=/^[a-z]:/i.test(o[0]);if(A)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(A=>this.parse(A))});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(e){if(this.options.noglobstar)for(let n=0;n<e.length;n++)for(let i=0;i<e[n].length;i++)e[n][i]==="**"&&(e[n][i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):r>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.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(e){return e.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(e){Array.isArray(e)||(e=this.slashSplit(e));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let o=e[i];i===1&&o===""&&e[0]===""||(o==="."||o==="")&&(r=!0,e.splice(i,1),i--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(r=!0,e.pop())}let n=0;for(;(n=e.indexOf("..",n+1))!==-1;){let i=e[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&(r=!0,e.splice(n-1,2),n-=2)}}while(r);return e.length===0?[""]:e}firstPhasePreProcess(e){let r=!1;do{r=!1;for(let n of e){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],A=n[i+2],c=n[i+3];if(a!==".."||!A||A==="."||A===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",e.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 A=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...A),n.length===0&&n.push(""),o-=2}}}}while(r);return e}secondPhasePreProcess(e){for(let r=0;r<e.length-1;r++)for(let n=r+1;n<e.length;n++){let i=this.partsMatch(e[r],e[n],!this.preserveMultipleSlashes);if(i){e[r]=[],e[n]=i;break}}return e.filter(r=>r.length)}partsMatch(e,r,n=!1){let i=0,o=0,s=[],a="";for(;i<e.length&&o<r.length;)if(e[i]===r[o])s.push(a==="b"?r[o]:e[i]),i++,o++;else if(n&&e[i]==="**"&&r[o]===e[i+1])s.push(e[i]),i++;else if(n&&r[o]==="**"&&e[i]===r[o+1])s.push(r[o]),o++;else if(e[i]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",s.push(e[i]),i++,o++}else if(r[o]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(a==="a")return!1;a="b",s.push(r[o]),i++,o++}else return!1;return e.length===r.length&&s}parseNegate(){if(this.nonegate)return;let e=this.pattern,r=!1,n=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=e.slice(n)),this.negate=r}matchOne(e,r,n=!1){let i=0,o=0;if(this.isWindows){let a=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),A=!a&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[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]),l=A?3:a?0:void 0,d=u?3:c?0:void 0;if(typeof l=="number"&&typeof d=="number"){let[g,p]=[e[l],r[d]];g.toLowerCase()===p.toLowerCase()&&(r[d]=g,o=d,i=l)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(e=this.levelTwoFileOptimize(e)),r.includes(eo)?this.#n(e,r,n,i,o):this.#l(e,r,n,i,o)}#n(e,r,n,i,o){let s=r.indexOf(eo,o),a=r.lastIndexOf(eo),[A,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(A.length){let I=e.slice(i,i+A.length);if(!this.#l(I,A,n,0,0))return!1;i+=A.length,o+=A.length}let l=0;if(u.length){if(u.length+i>e.length)return!1;let I=e.length-u.length;if(this.#l(e,u,n,I,0))l=u.length;else{if(e[e.length-1]!==""||i+u.length===e.length||(I--,!this.#l(e,u,n,I,0)))return!1;l=u.length+1}}if(!c.length){let I=!!l;for(let B=i;B<e.length-l;B++){let E=String(e[B]);if(I=!0,E==="."||E===".."||!this.options.dot&&E.startsWith("."))return!1}return n||I}let d=[[[],0]],g=d[0],p=0,f=[0];for(let I of c)I===eo?(f.push(p),g=[[],0],d.push(g)):(g[0].push(I),p++);let m=d.length-1,C=e.length-l;for(let I of d)I[1]=C-(f[m--]+I[0].length);return!!this.#g(e,d,i,0,n,0,!!l)}#g(e,r,n,i,o,s,a){let A=r[i];if(!A){for(let l=n;l<e.length;l++){a=!0;let d=e[l];if(d==="."||d===".."||!this.options.dot&&d.startsWith("."))return!1}return a}let[c,u]=A;for(;n<=u;){if(this.#l(e.slice(0,n+c.length),c,o,n,0)&&s<this.maxGlobstarRecursion){let g=this.#g(e,r,n+c.length,i+1,o,s+1,a);if(g!==!1)return g}let d=e[n];if(d==="."||d===".."||!this.options.dot&&d.startsWith("."))return!1;n++}return o||null}#l(e,r,n,i,o){let s,a,A,c;for(s=i,a=o,c=e.length,A=r.length;s<c&&a<A;s++,a++){this.debug("matchOne loop");let u=r[a],l=e[s];if(this.debug(r,u,l),u===!1||u===eo)return!1;let d;if(typeof u=="string"?(d=l===u,this.debug("string match",u,l,d)):(d=u.test(l),this.debug("pattern match",u,l,d)),!d)return!1}if(s===c&&a===A)return!0;if(s===c)return n;if(a===A)return s===c-1&&e[s]==="";throw new Error("wtf?")}braceExpand(){return Uhe(this.pattern,this.options)}parse(e){gy(e);let r=this.options;if(e==="**")return eo;if(e==="")return"";let n,i=null;(n=e.match(xtt))?i=r.dot?ktt:Ftt:(n=e.match(Itt))?i=(r.nocase?r.dot?Qtt:ytt:r.dot?Btt:Ett)(n[1]):(n=e.match(Rtt))?i=(r.nocase?r.dot?Ttt:Ntt:r.dot?Mtt:Ptt)(n):(n=e.match(Dtt))?i=r.dot?vtt:wtt:(n=e.match(btt))&&(i=Stt);let o=bp.fromGlob(e,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 e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?Utt:r.dot?Gtt:Ott,i=new Set(r.nocase?["i"]:[]),o=e.map(A=>{let c=A.map(l=>{if(l instanceof RegExp)for(let d of l.flags.split(""))i.add(d);return typeof l=="string"?jtt(l):l===eo?eo:l._src});c.forEach((l,d)=>{let g=c[d+1],p=c[d-1];l!==eo||p===eo||(p===void 0?g!==void 0&&g!==eo?c[d+1]="(?:\\/|"+n+"\\/)?"+g:c[d]=n:g===void 0?c[d-1]=p+"(?:\\/|\\/"+n+")?":g!==eo&&(c[d-1]=p+"(?:\\/|\\/"+n+"\\/)"+g,c[d+1]=eo))});let u=c.filter(l=>l!==eo);if(this.partial&&u.length>=1){let l=[];for(let d=1;d<=u.length;d++)l.push(u.slice(0,d).join("/"));return"(?:"+l.join("|")+")"}return u.join("/")}).join("|"),[s,a]=e.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(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,r=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&r)return!0;let n=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);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=0;a<o.length;a++){let A=o[a],c=i;if(n.matchBase&&A.length===1&&(c=[s]),this.matchOne(c,A,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return ki.defaults(e).Minimatch}};ki.AST=bp;ki.Minimatch=jm;ki.escape=SK;ki.unescape=Fl});async function Ytt(t,e,r){let n=t.builderPublicKey;if(!n)return[];let i=new URL(`${Je}/projects/memories`);i.searchParams.set("apiKey",n),i.searchParams.set("projectId",e),t.userId&&i.searchParams.set("userId",t.userId);let o={"Content-Type":"application/json"};t.builderPrivateKey&&(o.Authorization=`Bearer ${t.builderPrivateKey}`);let a=await(await Ge(i,{method:"GET",headers:o,keepalive:!0,signal:r})).json();return Array.isArray(a?.memories)?a.memories:[]}function qtt(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Ohe(t){return t.replace(/[*?{}[\]!]/g,"").replace(/\/+/g,"/").toLowerCase()}async function ztt(t,e){let r=new Map;for(let i of t){let o=i.category||"general";r.has(o)||r.set(o,[]),r.get(o).push(i)}if(r.size===0)return;await ix.default.mkdir(e,{recursive:!0});let n=[];for(let[i,o]of r){let s=`${qtt(i)}.md`,a=Khe.default.join(e,s),A=o.filter(g=>g.glob),c=o.filter(g=>!g.glob),u=new Map;for(let g of A){let p=g.glob;u.has(p)||u.set(p,[]),u.get(p).push(g)}let l=[...u.keys()].sort((g,p)=>Ohe(g).localeCompare(Ohe(p))),d=[];if(d.push(`# ${i}`),d.push(""),l.length>0){d.push("## File-specific"),d.push("");for(let g of l){let p=u.get(g);d.push(`### \`${g}\``),d.push("");for(let f of p)d.push(`- **When**: ${f.when}`),d.push(` ${f.memory}`),d.push("")}}if(c.length>0){d.push("## General"),d.push("");for(let g of c)d.push(`- **When**: ${g.when}`),d.push(` ${g.memory}`),d.push("")}n.push(ix.default.writeFile(a,d.join(`
1848
- `),"utf-8"))}await Promise.all(n)}function Vtt(t){let e=[],r=0,n=0;for(let i=0;i<t.length;i++){let o=t[i];o==="{"?r++:o==="}"&&r>0?r--:o===","&&r===0&&(e.push(t.slice(n,i)),n=i+1)}return e.push(t.slice(n)),e.map(i=>i.trim()).filter(Boolean)}function Hhe(t,e){if(!e)return[];let r=e.replace(/\\/g,"/");return t.filter(n=>n.glob?Vtt(n.glob).some(o=>{try{return ki(r,o.replace(/\\/g,"/"),{matchBase:!0})}catch{return!1}}):!1)}async function Jhe(t,e,r,n){try{return await Ytt(e,r,n)}catch(i){return t.Sentry?.captureException(new Error("Failed to load memories",{cause:i})),[]}}async function ox(t,e,r){try{await ix.default.rm(r,{recursive:!0,force:!0}),e.length>0&&await ztt(e,r)}catch(n){t.Sentry?.captureException(new Error("Failed to sync memories to disk",{cause:n}))}}var ix,Khe,FK=N(()=>{"use strict";h();ix=Z(require("node:fs/promises"),1),Khe=Z(require("node:path"),1);Ghe();pn();nn()});function Wtt(){if(dy!==void 0)return dy;try{return dy=require("prettier"),dy}catch{return dy=null,null}}function ta(t){try{return JSON.stringify(t)}catch{return String(t)}}var kl,kK,ax,jhe,ux,Ax,Yhe,dy,$he,Ztt,ja,sx,qm=N(()=>{"use strict";h();Zg();Tae();bn();Mo();pn();nn();kl=Z(require("node:fs"),1),kK=require("node:crypto");EL();Lae();Kae();vL();D1();QI();jae();ax=Z(require("node:os"),1);Ii();_t();qae();hv();sAe();cAe();cs();FL();jhe=Z(require("chokidar"),1);RL();LK();dAe();OK();Er();ux=Z(require("node:events"),1);xI();Ax=require("node:crypto");zI();yAe();S1();bI();Rg();phe();Vg();dhe();Yhe=require("node:fs/promises");BK();SI();_I();RA();FK();Ra();q0();Xw();Ev();kL();$he=["ask-to-continue","credits-limit-daily","credits-limit-monthly","credits-limit-other","invalid-last-message"],Ztt=["initial-with-url","initial-without-url","success"],ja=class t{#n;#g;#l;#t=[];#c;#o;#e;#s;#B;#h;#N;#b;#S;#x;#i=!!(process.env.DEBUG||process.env.FUSION_DEBUG==="true");#f=!1;#r=ke("Agent",{debug:()=>this.#i});#u=new ux.default;#W=new Map;#T;#fe;#_;#j;#ne=[];#Oe=void 0;#at="";#Z;#At=Promise.resolve(void 0);#Y=[];#M;#G=[];#me;#X=new Map;#xe=[];#ie;#kt=0;#oe;#q;#d;#m;#ct;#Ke;#He;#Fe=!1;#he;#Ce=void 0;#Je;#$e;#ke;#se;#C;#p=[];#w;#ut;#I;#je;#Ie;#Ee=0;#ae;#y;#lt=[];#gt=new Set;#A;#Q;#P;#pt;#O;#Ye;#Re=!1;#dt=0;#Ae=null;#ce=0;#ee=!1;#F=!1;#Ne;#Te;#te;#ft;#mt;#ue=[];#Me=[];#qe=!1;#ht=new Map;#Pe=new Map;#Be={};#K={};#Rt=new Set;#ye;#k={};#ze;#Ve=[];#Qe=null;#Ct=void 0;#D=new Map;#E={watcher:null,listeners:new Set,debounceMs:300,pendingEvents:[]};#It=!1;#a=null;#_e=new Set;#Le=new Map;#De=new Map;#we=new Map;static#Et=3e4;get primaryGitPath(){return this.#p[0]?.path||this.#C}#ve(e){if(!e)return this.primaryGitPath;let r=this.#p.find(n=>n.folderName===e);if(!r)throw new Error(`Folder "${e}" not found in git-enabled folders`);return r.path}#Bt(e,r){if(typeof e!="string")throw new TypeError(`#parsePathWithFolder: 'path' must be a string, received ${typeof e}: ${ta(e)}`);if(r)return{repoPath:this.#ve(r),relativePath:e};for(let n of this.#p){let i=`${n.folderName}/`;if(e.startsWith(i))return{repoPath:n.path,relativePath:e.slice(i.length)}}return{repoPath:this.primaryGitPath,relativePath:e}}constructor(e){if(this.#e=e.sys,this.#O=e.modelOverride,this.#s=e.credentials,"initialUrl"in e){let n=nCe(e.initialUrl).id;n?this.#q=n:this.#B=e.initialUrl}typeof e.autoImportLocalMCPs=="boolean"&&(this.#It=e.autoImportLocalMCPs),"sessionOrCompletionId"in e?this.#q=e.sessionOrCompletionId:this.#q=e.fusionConfig?.sessionId;let r=e.workingDirectory??e.fusionConfig?.workingDirectory;if(this.#C=r?e.sys.resolve(e.sys.cwd(),r):e.sys.getCwdDir(),this.#N=e.skipFileDiff??!0,this.#h=e.position,this.#T=e.mode,this.#M=e.privacyMode??e.fusionConfig?.privacyMode,this.#d=e.devServerOrchestrator,this.#m=e.git??!1,this.#m&&(process.env.GIT_CEILING_DIRECTORIES=this.#C),this.#ct=e.gitAutoInit??!1,this.#A=e.fusionConfig,this.#qe=e.asyncSubAgents??!1,this.#c=e.queueMode??"next-turn",this.#fe=e.fusionConfig?.autoPush,this.#Q=e.fusionConfig?.projectId,this.#P=e.fusionConfig?.branchName,this.#_=e.fusionConfig?.featureBranch,this.#j=e.fusionConfig?.aiBranch,this.#Ne=e.fusionConfig?.proxyOrigin,this.#Te=e.fusionConfig?.proxyDefaultOrigin,this.#Ke=e.fusionStatusMonitor,process.env.FUSION_ENV_ORIGIN&&(this.#ft=process.env.FUSION_ENV_ORIGIN),this.#te=e.agentType,e.enabledTools)this.#y=sx(this.#A,e.enabledTools);else if(this.#T==="quality-v3"){let n=["write_file","search_replace_file","view_path","get_rule","get_style_inspiration","grep_search","web_search","find_media",process.platform==="win32"?"powershell":"bash"];this.#d&&n.push("dev_server_control"),this.#y=sx(this.#A,n)}else if(this.#T==="quality-v4"){let n=["Write","Edit","Read","MultiEdit","Grep","Glob","ReadRule","TodoRead","TodoWrite","Agent","Media","WebFetch","AskUserQuestion","ExitPlanMode","EnterPlanMode",process.platform==="win32"?"PowerShell":"Bash"],i=!!(this.#M?.enabled||this.#M?.redactUserMessages||this.#M?.redactLLMMessages);i||n.push("WebSearch"),this.#Q&&!i&&this.getCommitMode()!=="commits"&&n.push("SearchMemories"),i||n.push("GetScreenshot"),n.push("NavigatePreview"),this.#d&&(n.push("DevServerLogs"),n.push("DevServerRestart"),n.push("ProposeEnvVariable")),process.env.FUSION_IDE_PORT&&n.push("IDEDiagnostics"),this.#y=sx(this.#A,n)}if(this.#ut=e.maxTokens,this.#Ye=e.reasoning,this.#Je=e.builtInCustomInstructions??[],this.#$e=e.builtInCustomAgents??[],this.#ke=e.builtInMCPServerConfig??{},this.#se=e.systemPromptOverride,this.#I=e.fusionConfig?.workspace,this.#je=e.mcpServers??!1,this.#w=this.#C,this.#p=[],this.#I?.folders.length){let n=this.#I.folders.filter(i=>i.enableGit);this.#p=n.map(i=>({folderName:i.name??i.path,path:this.#e.resolve(this.#C,i.path),branchName:i.branchName||"main",repoUrl:i.repoUrl,originalRepoUrl:i.originalRepoUrl,repoName:i.repoName}));for(let i of n){let o=i.backupMetadata?.check.backup,s=i.name??i.path,a=$I({version:o?.version,originalRepoUrl:o?.repoUrl,commitHash:o?.lastCommitHash});a&&(this.#Be[s]=a)}}this.#p.length===0&&(this.#p=[{folderName:JI,path:this.#C,branchName:"main"}]),this.#ye=pCe(this.#I),this.#I?.folders[0]&&this.#R()&&(this.#w=this.#e.resolve(this.#C,this.#I.folders[0].path)),this.#u.on("idle",()=>{eu(this.#s,"/events/publish",{event:hoe,extraData:{sessionId:this.getSessionId(),lastMessage:this.getLastMessage(),projectId:this.#Q,branchName:this.#P,hasPlanToApply:this.#F,sessionMode:this.getSessionMode()}})})}get fusionConfig(){return this.#A}get gitEnabledFolder(){return this.#I?.folders.find(e=>e.enableGit)}get gitEnabledFolders(){return this.#I?.folders.filter(e=>e.enableGit)||[]}get gitRepoContexts(){return this.#p}get workingDirectory(){return this.#C}get bashWorkingDirectory(){return this.#w}getSessionMode(){return this.#n?.sessionMode??"normal"}async switchSessionMode(e){let r=this.getSessionContext();r.sessionMode!==e&&(r.sessionMode=e,this.#F=!1,await this.#de())}async switchModelOverride(e){this.#O=e||void 0,await this.#de()}removeSystemReminder(e){let r=this.#G.findIndex(n=>n.tag===e);r!==-1&&this.#G.splice(r,1)}getMemoriesForFile(e){let r=Hhe(this.#lt,e).filter(n=>!this.#gt.has(n.id));for(let n of r)this.#gt.add(n.id);return r}queueSystemReminder(e){let r=e.tag?this.#G.findIndex(n=>n.tag===e.tag):-1;return r!==-1?e.text?(this.#G[r]=e,{operation:"update"}):(this.#G.splice(r,1),{operation:"delete"}):e.text?(this.#G.push(e),{operation:"add"}):{operation:"noop"}}setDefaultAutoPush(e){this.#fe=e}async setPrivacyMode(e){if(e&&e.enabled){if(!e.encryptKey&&!this.#me)this.#me=await mhe();else if(e.encryptKey){if(!await tx(e.encryptKey))throw new Error("Invalid encryption key: key failed validation");this.#me=e.encryptKey}}else this.#me=void 0;this.#M=e}async initializeSession(e={}){return this.#He||(this.#He=this.#Mt(e)),await this.#He}async loadHistory(){let e=this.getSessionContext(),r=await cx(this.#e,this.#s,e.sessionId,!1,this.#i),n=new Map,i=new Map;for(let a of r.turns)for(let A of[a.beforeCommit,a.afterCommit,a.lastCommit]){if(!A)continue;let c=Pf(A,this.gitRepoContexts[0]?.folderName);n.set(A,c);for(let[u,l]of Object.entries(c))i.has(u)||i.set(u,new Set),i.get(u).add(l)}let o=new Map;for(let[a,A]of i.entries()){let c=this.gitRepoContexts.find(l=>l.folderName===a);if(!c||A.size===0)continue;let u=new Set;try{let d=(await this.git(["cat-file","--batch-check","--buffer"],{sys:this.#e,cwd:c.path,stdin:Array.from(A).map(p=>`${p}^{commit}`).join(`
1847
+ `):void 0})}return r}var dhe=N(()=>{"use strict";h()});var xl,fhe=N(()=>{"use strict";h();xl=(...t)=>{typeof process<"u"&&process.env.DEBUG==="true"&&console.debug("[DEBUG] ",...t)}});var Uet,$m,mhe,Get,Oet,Ket,tx,BK=N(()=>{"use strict";h();fhe();Uet=()=>{if(typeof globalThis<"u"&&globalThis.crypto)return globalThis.crypto;if(typeof require<"u")try{let t=require("crypto");if(t.webcrypto)return t.webcrypto}catch{}throw new Error("Web Crypto API is not available. Requires Node.js 15+ or a browser environment.")},$m=Uet(),mhe=async()=>{let t=await $m.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]),e=await $m.subtle.exportKey("jwk",t);return JSON.stringify(e)},Get=async()=>$m.getRandomValues(new Uint8Array(16)),Oet=async(t,e,r)=>{let n=await $m.subtle.encrypt({name:"AES-GCM",iv:e,tagLength:128},t,typeof r=="string"?new TextEncoder().encode(r):r);return Buffer.from(n)},Ket=async(t,e,r)=>{let n=await $m.subtle.decrypt({name:"AES-GCM",iv:e,tagLength:128},t,r);return new TextDecoder().decode(n)},tx=async t=>{try{xl("validateEncryptionKey: Validating encryption key");let e=JSON.parse(t);xl("validateEncryptionKey: Parsed JWK");let r=await $m.subtle.importKey("jwk",e,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]);xl("validateEncryptionKey: Imported crypto key");let n="test",i=await Get();xl("validateEncryptionKey: Generated test IV",i);let o=await Oet(r,i,n);xl("validateEncryptionKey: Encrypted test data",o);let s=new Uint8Array(o);xl("validateEncryptionKey: Encrypted test data array",s);let a=await Ket(r,i,s);return xl("validateEncryptionKey: Decrypted test data",a),a===n}catch(e){return console.error("Could not validate encryption key:",e),!1}}});var yK,hhe,Het,Che=N(()=>{h();yK=(t,e,r)=>{let n=t instanceof RegExp?hhe(t,r):t,i=e instanceof RegExp?hhe(e,r):e,o=n!==null&&i!=null&&Het(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)}},hhe=(t,e)=>{let r=e.match(t);return r?r[0]:null},Het=(t,e,r)=>{let n,i,o,s,a,A=r.indexOf(t),c=r.indexOf(e,A+1),u=A;if(A>=0&&c>0){if(t===e)return[A,c];for(n=[],o=r.length;u>=0&&!a;){if(u===A)n.push(u),A=r.indexOf(t,u+1);else if(n.length===1){let l=n.pop();l!==void 0&&(a=[l,c])}else i=n.pop(),i!==void 0&&i<o&&(o=i,s=c),c=r.indexOf(e,u+1);u=A<c&&A>=0?A:c}n.length&&s!==void 0&&(a=[o,s])}return a}});function QK(t){return isNaN(t)?t.charCodeAt(0):parseInt(t,10)}function ttt(t){return t.replace(zet,Ihe).replace(Vet,Ehe).replace(Wet,DK).replace(Zet,Bhe).replace(Xet,yhe)}function rtt(t){return t.replace(Jet,"\\").replace($et,"{").replace(jet,"}").replace(Yet,",").replace(qet,".")}function Qhe(t){if(!t)return[""];let e=[],r=yK("{","}",t);if(!r)return t.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=Qhe(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),e.push.apply(e,s),e}function Dhe(t,e={}){if(!t)return[];let{max:r=ett}=e;return t.slice(0,2)==="{}"&&(t="\\{\\}"+t.slice(2)),ly(ttt(t),r,!0).map(rtt)}function ntt(t){return"{"+t+"}"}function itt(t){return/^-?0\d/.test(t)}function ott(t,e){return t<=e}function stt(t,e){return t>=e}function ly(t,e,r){let n=[],i=yK("{","}",t);if(!i)return[t];let o=i.pre,s=i.post.length?ly(i.post,e,!1):[""];if(/\$$/.test(i.pre))for(let a=0;a<s.length&&a<e;a++){let A=o+"{"+i.body+"}"+s[a];n.push(A)}else{let a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),A=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),c=a||A,u=i.body.indexOf(",")>=0;if(!c&&!u)return i.post.match(/,(?!,).*\}/)?(t=i.pre+"{"+i.body+DK+i.post,ly(t,e,!0)):[t];let l;if(c)l=i.body.split(/\.\./);else if(l=Qhe(i.body),l.length===1&&l[0]!==void 0&&(l=ly(l[0],e,!1).map(ntt),l.length===1))return s.map(g=>i.pre+l[0]+g);let d;if(c&&l[0]!==void 0&&l[1]!==void 0){let g=QK(l[0]),p=QK(l[1]),f=Math.max(l[0].length,l[1].length),m=l.length===3&&l[2]!==void 0?Math.abs(QK(l[2])):1,C=ott;p<g&&(m*=-1,C=stt);let B=l.some(itt);d=[];for(let E=g;C(E,p);E+=m){let y;if(A)y=String.fromCharCode(E),y==="\\"&&(y="");else if(y=String(E),B){let Q=f-y.length;if(Q>0){let b=new Array(Q+1).join("0");E<0?y="-"+b+y.slice(1):y=b+y}}d.push(y)}}else{d=[];for(let g=0;g<l.length;g++)d.push.apply(d,ly(l[g],e,!1))}for(let g=0;g<d.length;g++)for(let p=0;p<s.length&&n.length<e;p++){let f=o+d[g]+s[p];(!r||c||f)&&n.push(f)}}return n}var Ihe,Ehe,DK,Bhe,yhe,Jet,$et,jet,Yet,qet,zet,Vet,Wet,Zet,Xet,ett,whe=N(()=>{h();Che();Ihe="\0SLASH"+Math.random()+"\0",Ehe="\0OPEN"+Math.random()+"\0",DK="\0CLOSE"+Math.random()+"\0",Bhe="\0COMMA"+Math.random()+"\0",yhe="\0PERIOD"+Math.random()+"\0",Jet=new RegExp(Ihe,"g"),$et=new RegExp(Ehe,"g"),jet=new RegExp(DK,"g"),Yet=new RegExp(Bhe,"g"),qet=new RegExp(yhe,"g"),zet=/\\\\/g,Vet=/\\{/g,Wet=/\\}/g,Zet=/\\,/g,Xet=/\\\./g,ett=1e5});var gy,vhe=N(()=>{h();gy=t=>{if(typeof t!="string")throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")}});var att,py,Att,bhe,She,xhe=N(()=>{h();att={"[: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]},py=t=>t.replace(/[[\]\\-]/g,"\\$&"),Att=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),bhe=t=>t.join(""),She=(t,e)=>{let r=e;if(t.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],o=r+1,s=!1,a=!1,A=!1,c=!1,u=r,l="";e:for(;o<t.length;){let f=t.charAt(o);if((f==="!"||f==="^")&&o===r+1){c=!0,o++;continue}if(f==="]"&&s&&!A){u=o+1;break}if(s=!0,f==="\\"&&!A){A=!0,o++;continue}if(f==="["&&!A){for(let[m,[C,I,B]]of Object.entries(att))if(t.startsWith(m,o)){if(l)return["$.",!1,t.length-r,!0];o+=m.length,B?i.push(C):n.push(C),a=a||I;continue e}}if(A=!1,l){f>l?n.push(py(l)+"-"+py(f)):f===l&&n.push(py(f)),l="",o++;continue}if(t.startsWith("-]",o+1)){n.push(py(f+"-")),o+=2;continue}if(t.startsWith("-",o+1)){l=f,o+=2;continue}n.push(py(f)),o++}if(u<o)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,t.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!c){let f=n[0].length===2?n[0].slice(-1):n[0];return[Att(f),!1,u-r,!1]}let d="["+(c?"^":"")+bhe(n)+"]",g="["+(c?"":"^")+bhe(i)+"]";return[n.length&&i.length?"("+d+"|"+g+")":n.length?d:g,a,u-r,!0]}});var Fl,rx=N(()=>{h();Fl=(t,{windowsPathsNoEscape:e=!1,magicalBraces:r=!0}={})=>r?e?t.replace(/\[([^\/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):e?t.replace(/\[([^\/\\{}])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1")});var zo,ctt,wK,Fhe,utt,ltt,gtt,khe,ptt,nx,dtt,ftt,mtt,htt,vK,Rhe,Nhe,Ctt,bp,bK=N(()=>{h();xhe();rx();ctt=new Set(["!","?","+","*","@"]),wK=t=>ctt.has(t),Fhe=t=>wK(t.type),utt=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),ltt=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),gtt=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),khe=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),ptt="(?!(?:^|/)\\.\\.?(?:$|/))",nx="(?!\\.)",dtt=new Set(["[","."]),ftt=new Set(["..","."]),mtt=new Set("().*{}+?[]^$\\!"),htt=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),vK="[^/]",Rhe=vK+"*?",Nhe=vK+"+?",Ctt=0,bp=class{type;#n;#g;#l=!1;#t=[];#c;#o;#e;#s=!1;#B;#h;#N=!1;id=++Ctt;get depth(){return(this.#c?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#n.id,parent:this.#c?.id,depth:this.depth,partsLength:this.#t.length,parts:this.#t}}constructor(e,r,n={}){this.type=e,e&&(this.#g=!0),this.#c=r,this.#n=this.#c?this.#c.#n:this,this.#B=this.#n===this?n:this.#n.#B,this.#e=this.#n===this?[]:this.#n.#e,e==="!"&&!this.#n.#s&&this.#e.push(this),this.#o=this.#c?this.#c.#t.length:0}get hasMagic(){if(this.#g!==void 0)return this.#g;for(let e of this.#t)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#g=!0;return this.#g}toString(){return this.#h!==void 0?this.#h:this.type?this.#h=this.type+"("+this.#t.map(e=>String(e)).join("|")+")":this.#h=this.#t.map(e=>String(e)).join("")}#b(){if(this!==this.#n)throw new Error("should only call on root");if(this.#s)return this;this.toString(),this.#s=!0;let e;for(;e=this.#e.pop();){if(e.type!=="!")continue;let r=e,n=r.#c;for(;n;){for(let i=r.#o+1;!n.type&&i<n.#t.length;i++)for(let o of e.#t){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#t[i])}r=n,n=r.#c}}return this}push(...e){for(let r of e)if(r!==""){if(typeof r!="string"&&!(r instanceof zo&&r.#c===this))throw new Error("invalid part: "+r);this.#t.push(r)}}toJSON(){let e=this.type===null?this.#t.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#t.map(r=>r.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#n||this.#n.#s&&this.#c?.type==="!")&&e.push({}),e}isStart(){if(this.#n===this)return!0;if(!this.#c?.isStart())return!1;if(this.#o===0)return!0;let e=this.#c;for(let r=0;r<this.#o;r++){let n=e.#t[r];if(!(n instanceof zo&&n.type==="!"))return!1}return!0}isEnd(){if(this.#n===this||this.#c?.type==="!")return!0;if(!this.#c?.isEnd())return!1;if(!this.type)return this.#c?.isEnd();let e=this.#c?this.#c.#t.length:0;return this.#o===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let r=new zo(this.type,e);for(let n of this.#t)r.copyIn(n);return r}static#S(e,r,n,i,o){let s=i.maxExtglobRecursion??2,a=!1,A=!1,c=-1,u=!1;if(r.type===null){let f=n,m="";for(;f<e.length;){let C=e.charAt(f++);if(a||C==="\\"){a=!a,m+=C;continue}if(A){f===c+1?(C==="^"||C==="!")&&(u=!0):C==="]"&&!(f===c+2&&u)&&(A=!1),m+=C;continue}else if(C==="["){A=!0,c=f,u=!1,m+=C;continue}if(!i.noext&&wK(C)&&e.charAt(f)==="("&&o<=s){r.push(m),m="";let B=new zo(C,r);f=zo.#S(e,B,f,i,o+1),r.push(B);continue}m+=C}return r.push(m),f}let l=n+1,d=new zo(null,r),g=[],p="";for(;l<e.length;){let f=e.charAt(l++);if(a||f==="\\"){a=!a,p+=f;continue}if(A){l===c+1?(f==="^"||f==="!")&&(u=!0):f==="]"&&!(l===c+2&&u)&&(A=!1),p+=f;continue}else if(f==="["){A=!0,c=l,u=!1,p+=f;continue}if(!i.noext&&wK(f)&&e.charAt(l)==="("&&(o<=s||r&&r.#f(f))){let C=r&&r.#f(f)?0:1;d.push(p),p="";let I=new zo(f,d);d.push(I),l=zo.#S(e,I,l,i,o+C);continue}if(f==="|"){d.push(p),p="",g.push(d),d=new zo(null,r);continue}if(f===")")return p===""&&r.#t.length===0&&(r.#N=!0),d.push(p),p="",r.push(...g,d),l;p+=f}return r.type=null,r.#g=void 0,r.#t=[e.substring(n-1)],l}#x(e){return this.#i(e,ltt)}#i(e,r=utt){if(!e||typeof e!="object"||e.type!==null||e.#t.length!==1||this.type===null)return!1;let n=e.#t[0];return!n||typeof n!="object"||n.type===null?!1:this.#f(n.type,r)}#f(e,r=gtt){return!!r.get(this.type)?.includes(e)}#r(e,r){let n=e.#t[0],i=new zo(null,n,this.options);i.#t.push(""),n.push(i),this.#u(e,r)}#u(e,r){let n=e.#t[0];this.#t.splice(r,1,...n.#t);for(let i of n.#t)typeof i=="object"&&(i.#c=this);this.#h=void 0}#W(e){return!!khe.get(this.type)?.has(e)}#T(e){if(!e||typeof e!="object"||e.type!==null||e.#t.length!==1||this.type===null||this.#t.length!==1)return!1;let r=e.#t[0];return!r||typeof r!="object"||r.type===null?!1:this.#W(r.type)}#fe(e){let r=khe.get(this.type),n=e.#t[0],i=r?.get(n.type);if(!i)return!1;this.#t=n.#t;for(let o of this.#t)typeof o=="object"&&(o.#c=this);this.type=i,this.#h=void 0,this.#N=!1}static fromGlob(e,r={}){let n=new zo(null,void 0,r);return zo.#S(e,n,0,r,0),n}toMMPattern(){if(this!==this.#n)return this.#n.toMMPattern();let e=this.toString(),[r,n,i,o]=this.toRegExpSource();if(!(i||this.#g||this.#B.nocase&&!this.#B.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#B.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:e})}get options(){return this.#B}toRegExpSource(e){let r=e??!!this.#B.dot;if(this.#n===this&&(this.#L(),this.#b()),!Fhe(this)){let A=this.isStart()&&this.isEnd()&&!this.#t.some(g=>typeof g!="string"),c=this.#t.map(g=>{let[p,f,m,C]=typeof g=="string"?zo.#ne(g,this.#g,A):g.toRegExpSource(e);return this.#g=this.#g||m,this.#l=this.#l||C,p}).join(""),u="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&ftt.has(this.#t[0]))){let p=dtt,f=r&&p.has(c.charAt(0))||c.startsWith("\\.")&&p.has(c.charAt(2))||c.startsWith("\\.\\.")&&p.has(c.charAt(4)),m=!r&&!e&&p.has(c.charAt(0));u=f?ptt:m?nx:""}let l="";return this.isEnd()&&this.#n.#s&&this.#c?.type==="!"&&(l="(?:$|\\/)"),[u+c+l,Fl(c),this.#g=!!this.#g,this.#l]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#j(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let A=this.toString(),c=this;return c.#t=[A],c.type=null,c.#g=void 0,[A,Fl(this.toString()),!1,!1]}let s=!n||e||r||!nx?"":this.#j(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#N)a=(this.isStart()&&!r?nx:"")+Nhe;else{let A=this.type==="!"?"))"+(this.isStart()&&!r&&!e?nx:"")+Rhe+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+A}return[a,Fl(o),this.#g=!!this.#g,this.#l]}#L(){if(Fhe(this)){let e=0,r=!1;do{r=!0;for(let n=0;n<this.#t.length;n++){let i=this.#t[n];typeof i=="object"&&(i.#L(),this.#i(i)?(r=!1,this.#u(i,n)):this.#x(i)?(r=!1,this.#r(i,n)):this.#T(i)&&(r=!1,this.#fe(i)))}}while(!r&&++e<10)}else for(let e of this.#t)typeof e=="object"&&e.#L();this.#h=void 0}#j(e){return this.#t.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,o,s]=r.toRegExpSource(e);return this.#l=this.#l||s,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#ne(e,r,n=!1){let i=!1,o="",s=!1,a=!1;for(let A=0;A<e.length;A++){let c=e.charAt(A);if(i){i=!1,o+=(mtt.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(e)?Nhe:Rhe,r=!0;continue}else a=!1;if(c==="\\"){A===e.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,l,d,g]=She(e,A);if(d){o+=u,s=s||l,A+=d-1,r=r||g;continue}}if(c==="?"){o+=vK,r=!0;continue}o+=htt(c)}return[o,Fl(e),!!r,s]}};zo=bp});var SK,xK=N(()=>{h();SK=(t,{windowsPathsNoEscape:e=!1,magicalBraces:r=!1}={})=>r?e?t.replace(/[?*()[\]{}]/g,"[$&]"):t.replace(/[?*()[\]\\{}]/g,"\\$&"):e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&")});var ki,Itt,Ett,Btt,ytt,Qtt,Dtt,wtt,vtt,btt,Stt,xtt,Ftt,ktt,Rtt,Ntt,Ttt,Mtt,Ptt,Phe,_he,Lhe,The,_tt,eo,Ltt,Utt,Gtt,Ott,Ktt,ea,Htt,Uhe,Jtt,$tt,Mhe,jtt,jm,Ghe=N(()=>{h();whe();vhe();bK();xK();rx();bK();xK();rx();ki=(t,e,r={})=>(gy(e),!r.nocomment&&e.charAt(0)==="#"?!1:new jm(e,r).match(t)),Itt=/^\*+([^+@!?\*\[\(]*)$/,Ett=t=>e=>!e.startsWith(".")&&e.endsWith(t),Btt=t=>e=>e.endsWith(t),ytt=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),Qtt=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),Dtt=/^\*+\.\*+$/,wtt=t=>!t.startsWith(".")&&t.includes("."),vtt=t=>t!=="."&&t!==".."&&t.includes("."),btt=/^\.\*+$/,Stt=t=>t!=="."&&t!==".."&&t.startsWith("."),xtt=/^\*+$/,Ftt=t=>t.length!==0&&!t.startsWith("."),ktt=t=>t.length!==0&&t!=="."&&t!=="..",Rtt=/^\?+([^+@!?\*\[\(]*)?$/,Ntt=([t,e=""])=>{let r=Phe([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},Ttt=([t,e=""])=>{let r=_he([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},Mtt=([t,e=""])=>{let r=_he([t]);return e?n=>r(n)&&n.endsWith(e):r},Ptt=([t,e=""])=>{let r=Phe([t]);return e?n=>r(n)&&n.endsWith(e):r},Phe=([t])=>{let e=t.length;return r=>r.length===e&&!r.startsWith(".")},_he=([t])=>{let e=t.length;return r=>r.length===e&&r!=="."&&r!==".."},Lhe=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",The={win32:{sep:"\\"},posix:{sep:"/"}},_tt=Lhe==="win32"?The.win32.sep:The.posix.sep;ki.sep=_tt;eo=Symbol("globstar **");ki.GLOBSTAR=eo;Ltt="[^/]",Utt=Ltt+"*?",Gtt="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Ott="(?:(?!(?:\\/|^)\\.).)*?",Ktt=(t,e={})=>r=>ki(r,t,e);ki.filter=Ktt;ea=(t,e={})=>Object.assign({},t,e),Htt=t=>{if(!t||typeof t!="object"||!Object.keys(t).length)return ki;let e=ki;return Object.assign((n,i,o={})=>e(n,i,ea(t,o)),{Minimatch:class extends e.Minimatch{constructor(i,o={}){super(i,ea(t,o))}static defaults(i){return e.defaults(ea(t,i)).Minimatch}},AST:class extends e.AST{constructor(i,o,s={}){super(i,o,ea(t,s))}static fromGlob(i,o={}){return e.AST.fromGlob(i,ea(t,o))}},unescape:(n,i={})=>e.unescape(n,ea(t,i)),escape:(n,i={})=>e.escape(n,ea(t,i)),filter:(n,i={})=>e.filter(n,ea(t,i)),defaults:n=>e.defaults(ea(t,n)),makeRe:(n,i={})=>e.makeRe(n,ea(t,i)),braceExpand:(n,i={})=>e.braceExpand(n,ea(t,i)),match:(n,i,o={})=>e.match(n,i,ea(t,o)),sep:e.sep,GLOBSTAR:eo})};ki.defaults=Htt;Uhe=(t,e={})=>(gy(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:Dhe(t,{max:e.braceExpandMax}));ki.braceExpand=Uhe;Jtt=(t,e={})=>new jm(t,e).makeRe();ki.makeRe=Jtt;$tt=(t,e,r={})=>{let n=new jm(e,r);return t=t.filter(i=>n.match(i)),n.options.nonull&&!t.length&&t.push(e),t};ki.match=$tt;Mhe=/[?*]|[+@!]\(.*?\)|\[|\]/,jtt=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),jm=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,r={}){gy(e),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=e,this.platform=r.platform||Lhe,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 e of this.set)for(let r of e)if(typeof r!="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,r=this.options;if(!r.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){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 A=o[0]===""&&o[1]===""&&(o[2]==="?"||!Mhe.test(o[2]))&&!Mhe.test(o[3]),c=/^[a-z]:/i.test(o[0]);if(A)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(A=>this.parse(A))});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(e){if(this.options.noglobstar)for(let n=0;n<e.length;n++)for(let i=0;i<e[n].length;i++)e[n][i]==="**"&&(e[n][i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):r>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.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(e){return e.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(e){Array.isArray(e)||(e=this.slashSplit(e));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let o=e[i];i===1&&o===""&&e[0]===""||(o==="."||o==="")&&(r=!0,e.splice(i,1),i--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(r=!0,e.pop())}let n=0;for(;(n=e.indexOf("..",n+1))!==-1;){let i=e[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&(r=!0,e.splice(n-1,2),n-=2)}}while(r);return e.length===0?[""]:e}firstPhasePreProcess(e){let r=!1;do{r=!1;for(let n of e){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],A=n[i+2],c=n[i+3];if(a!==".."||!A||A==="."||A===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",e.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 A=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...A),n.length===0&&n.push(""),o-=2}}}}while(r);return e}secondPhasePreProcess(e){for(let r=0;r<e.length-1;r++)for(let n=r+1;n<e.length;n++){let i=this.partsMatch(e[r],e[n],!this.preserveMultipleSlashes);if(i){e[r]=[],e[n]=i;break}}return e.filter(r=>r.length)}partsMatch(e,r,n=!1){let i=0,o=0,s=[],a="";for(;i<e.length&&o<r.length;)if(e[i]===r[o])s.push(a==="b"?r[o]:e[i]),i++,o++;else if(n&&e[i]==="**"&&r[o]===e[i+1])s.push(e[i]),i++;else if(n&&r[o]==="**"&&e[i]===r[o+1])s.push(r[o]),o++;else if(e[i]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",s.push(e[i]),i++,o++}else if(r[o]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(a==="a")return!1;a="b",s.push(r[o]),i++,o++}else return!1;return e.length===r.length&&s}parseNegate(){if(this.nonegate)return;let e=this.pattern,r=!1,n=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=e.slice(n)),this.negate=r}matchOne(e,r,n=!1){let i=0,o=0;if(this.isWindows){let a=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),A=!a&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[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]),l=A?3:a?0:void 0,d=u?3:c?0:void 0;if(typeof l=="number"&&typeof d=="number"){let[g,p]=[e[l],r[d]];g.toLowerCase()===p.toLowerCase()&&(r[d]=g,o=d,i=l)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(e=this.levelTwoFileOptimize(e)),r.includes(eo)?this.#n(e,r,n,i,o):this.#l(e,r,n,i,o)}#n(e,r,n,i,o){let s=r.indexOf(eo,o),a=r.lastIndexOf(eo),[A,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(A.length){let I=e.slice(i,i+A.length);if(!this.#l(I,A,n,0,0))return!1;i+=A.length,o+=A.length}let l=0;if(u.length){if(u.length+i>e.length)return!1;let I=e.length-u.length;if(this.#l(e,u,n,I,0))l=u.length;else{if(e[e.length-1]!==""||i+u.length===e.length||(I--,!this.#l(e,u,n,I,0)))return!1;l=u.length+1}}if(!c.length){let I=!!l;for(let B=i;B<e.length-l;B++){let E=String(e[B]);if(I=!0,E==="."||E===".."||!this.options.dot&&E.startsWith("."))return!1}return n||I}let d=[[[],0]],g=d[0],p=0,f=[0];for(let I of c)I===eo?(f.push(p),g=[[],0],d.push(g)):(g[0].push(I),p++);let m=d.length-1,C=e.length-l;for(let I of d)I[1]=C-(f[m--]+I[0].length);return!!this.#g(e,d,i,0,n,0,!!l)}#g(e,r,n,i,o,s,a){let A=r[i];if(!A){for(let l=n;l<e.length;l++){a=!0;let d=e[l];if(d==="."||d===".."||!this.options.dot&&d.startsWith("."))return!1}return a}let[c,u]=A;for(;n<=u;){if(this.#l(e.slice(0,n+c.length),c,o,n,0)&&s<this.maxGlobstarRecursion){let g=this.#g(e,r,n+c.length,i+1,o,s+1,a);if(g!==!1)return g}let d=e[n];if(d==="."||d===".."||!this.options.dot&&d.startsWith("."))return!1;n++}return o||null}#l(e,r,n,i,o){let s,a,A,c;for(s=i,a=o,c=e.length,A=r.length;s<c&&a<A;s++,a++){this.debug("matchOne loop");let u=r[a],l=e[s];if(this.debug(r,u,l),u===!1||u===eo)return!1;let d;if(typeof u=="string"?(d=l===u,this.debug("string match",u,l,d)):(d=u.test(l),this.debug("pattern match",u,l,d)),!d)return!1}if(s===c&&a===A)return!0;if(s===c)return n;if(a===A)return s===c-1&&e[s]==="";throw new Error("wtf?")}braceExpand(){return Uhe(this.pattern,this.options)}parse(e){gy(e);let r=this.options;if(e==="**")return eo;if(e==="")return"";let n,i=null;(n=e.match(xtt))?i=r.dot?ktt:Ftt:(n=e.match(Itt))?i=(r.nocase?r.dot?Qtt:ytt:r.dot?Btt:Ett)(n[1]):(n=e.match(Rtt))?i=(r.nocase?r.dot?Ttt:Ntt:r.dot?Mtt:Ptt)(n):(n=e.match(Dtt))?i=r.dot?vtt:wtt:(n=e.match(btt))&&(i=Stt);let o=bp.fromGlob(e,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 e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?Utt:r.dot?Gtt:Ott,i=new Set(r.nocase?["i"]:[]),o=e.map(A=>{let c=A.map(l=>{if(l instanceof RegExp)for(let d of l.flags.split(""))i.add(d);return typeof l=="string"?jtt(l):l===eo?eo:l._src});c.forEach((l,d)=>{let g=c[d+1],p=c[d-1];l!==eo||p===eo||(p===void 0?g!==void 0&&g!==eo?c[d+1]="(?:\\/|"+n+"\\/)?"+g:c[d]=n:g===void 0?c[d-1]=p+"(?:\\/|\\/"+n+")?":g!==eo&&(c[d-1]=p+"(?:\\/|\\/"+n+"\\/)"+g,c[d+1]=eo))});let u=c.filter(l=>l!==eo);if(this.partial&&u.length>=1){let l=[];for(let d=1;d<=u.length;d++)l.push(u.slice(0,d).join("/"));return"(?:"+l.join("|")+")"}return u.join("/")}).join("|"),[s,a]=e.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(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,r=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&r)return!0;let n=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);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=0;a<o.length;a++){let A=o[a],c=i;if(n.matchBase&&A.length===1&&(c=[s]),this.matchOne(c,A,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return ki.defaults(e).Minimatch}};ki.AST=bp;ki.Minimatch=jm;ki.escape=SK;ki.unescape=Fl});async function Ytt(t,e,r){let n=t.builderPublicKey;if(!n)return[];let i=new URL(`${Je}/projects/memories`);i.searchParams.set("apiKey",n),i.searchParams.set("projectId",e),t.userId&&i.searchParams.set("userId",t.userId);let o={"Content-Type":"application/json"};t.builderPrivateKey&&(o.Authorization=`Bearer ${t.builderPrivateKey}`);let a=await(await Ge(i,{method:"GET",headers:o,keepalive:!0,signal:r})).json();return Array.isArray(a?.memories)?a.memories:[]}function qtt(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Ohe(t){return t.replace(/[*?{}[\]!]/g,"").replace(/\/+/g,"/").toLowerCase()}async function ztt(t,e){let r=new Map;for(let i of t){let o=i.category||"general";r.has(o)||r.set(o,[]),r.get(o).push(i)}if(r.size===0)return;await ix.default.mkdir(e,{recursive:!0});let n=[];for(let[i,o]of r){let s=`${qtt(i)}.md`,a=Khe.default.join(e,s),A=o.filter(g=>g.glob),c=o.filter(g=>!g.glob),u=new Map;for(let g of A){let p=g.glob;u.has(p)||u.set(p,[]),u.get(p).push(g)}let l=[...u.keys()].sort((g,p)=>Ohe(g).localeCompare(Ohe(p))),d=[];if(d.push(`# ${i}`),d.push(""),l.length>0){d.push("## File-specific"),d.push("");for(let g of l){let p=u.get(g);d.push(`### \`${g}\``),d.push("");for(let f of p)d.push(`- **When**: ${f.when}`),d.push(` ${f.memory}`),d.push("")}}if(c.length>0){d.push("## General"),d.push("");for(let g of c)d.push(`- **When**: ${g.when}`),d.push(` ${g.memory}`),d.push("")}n.push(ix.default.writeFile(a,d.join(`
1848
+ `),"utf-8"))}await Promise.all(n)}function Vtt(t){let e=[],r=0,n=0;for(let i=0;i<t.length;i++){let o=t[i];o==="{"?r++:o==="}"&&r>0?r--:o===","&&r===0&&(e.push(t.slice(n,i)),n=i+1)}return e.push(t.slice(n)),e.map(i=>i.trim()).filter(Boolean)}function Hhe(t,e){if(!e)return[];let r=e.replace(/\\/g,"/");return t.filter(n=>n.glob?Vtt(n.glob).some(o=>{try{return ki(r,o.replace(/\\/g,"/"),{matchBase:!0})}catch{return!1}}):!1)}async function Jhe(t,e,r,n){try{return await Ytt(e,r,n)}catch(i){return t.Sentry?.captureException(new Error("Failed to load memories",{cause:i})),[]}}async function ox(t,e,r){try{await ix.default.rm(r,{recursive:!0,force:!0}),e.length>0&&await ztt(e,r)}catch(n){t.Sentry?.captureException(new Error("Failed to sync memories to disk",{cause:n}))}}var ix,Khe,FK=N(()=>{"use strict";h();ix=Z(require("node:fs/promises"),1),Khe=Z(require("node:path"),1);Ghe();pn();nn()});function Wtt(){if(dy!==void 0)return dy;try{return dy=require("prettier"),dy}catch{return dy=null,null}}function ta(t){try{return JSON.stringify(t)}catch{return String(t)}}var kl,kK,ax,jhe,ux,Ax,Yhe,dy,$he,Ztt,ja,sx,qm=N(()=>{"use strict";h();Zg();Tae();bn();Mo();pn();nn();kl=Z(require("node:fs"),1),kK=require("node:crypto");EL();Lae();Kae();vL();D1();QI();jae();ax=Z(require("node:os"),1);Ii();_t();qae();hv();sAe();cAe();cs();FL();jhe=Z(require("chokidar"),1);RL();LK();dAe();OK();Er();ux=Z(require("node:events"),1);xI();Ax=require("node:crypto");zI();yAe();S1();bI();Rg();phe();Vg();dhe();Yhe=require("node:fs/promises");BK();SI();_I();RA();FK();Ra();q0();Xw();Ev();kL();$he=["ask-to-continue","credits-limit-daily","credits-limit-monthly","credits-limit-other","invalid-last-message"],Ztt=["initial-with-url","initial-without-url","success"],ja=class t{#n;#g;#l;#t=[];#c;#o;#e;#s;#B;#h;#N;#b;#S;#x;#i=!!(process.env.DEBUG||process.env.FUSION_DEBUG==="true");#f=!1;#r=ke("Agent",{debug:()=>this.#i});#u=new ux.default;#W=new Map;#T;#fe;#L;#j;#ne=[];#Ke=void 0;#At="";#Z;#ct=Promise.resolve(void 0);#Y=[];#M;#O=[];#me;#X=new Map;#xe=[];#ie;#kt=0;#oe;#q;#d;#m;#ut;#He;#Je;#Fe=!1;#he;#Ce=void 0;#$e;#je;#ke;#se;#C;#p=[];#w;#lt;#I;#Ye;#Ie;#Ee=0;#ae;#y;#gt=[];#pt=new Set;#A;#Q;#P;#dt;#_;#qe;#Re=!1;#ft=0;#Ae=null;#ce=0;#ee=!1;#F=!1;#Ne;#Te;#te;#mt;#Me;#ue=[];#Pe=[];#ze=!1;#ht=new Map;#_e=new Map;#Be={};#K={};#Rt=new Set;#ye;#k={};#Ve;#We=[];#Qe=null;#Ct=void 0;#D=new Map;#E={watcher:null,listeners:new Set,debounceMs:300,pendingEvents:[]};#It=!1;#a=null;#Le=new Set;#Ue=new Map;#De=new Map;#we=new Map;static#Et=3e4;get primaryGitPath(){return this.#p[0]?.path||this.#C}#ve(e){if(!e)return this.primaryGitPath;let r=this.#p.find(n=>n.folderName===e);if(!r)throw new Error(`Folder "${e}" not found in git-enabled folders`);return r.path}#Bt(e,r){if(typeof e!="string")throw new TypeError(`#parsePathWithFolder: 'path' must be a string, received ${typeof e}: ${ta(e)}`);if(r)return{repoPath:this.#ve(r),relativePath:e};for(let n of this.#p){let i=`${n.folderName}/`;if(e.startsWith(i))return{repoPath:n.path,relativePath:e.slice(i.length)}}return{repoPath:this.primaryGitPath,relativePath:e}}constructor(e){if(this.#e=e.sys,this.#_=e.modelOverride,this.#s=e.credentials,"initialUrl"in e){let n=nCe(e.initialUrl).id;n?this.#q=n:this.#B=e.initialUrl}typeof e.autoImportLocalMCPs=="boolean"&&(this.#It=e.autoImportLocalMCPs),"sessionOrCompletionId"in e?this.#q=e.sessionOrCompletionId:this.#q=e.fusionConfig?.sessionId;let r=e.workingDirectory??e.fusionConfig?.workingDirectory;if(this.#C=r?e.sys.resolve(e.sys.cwd(),r):e.sys.getCwdDir(),this.#N=e.skipFileDiff??!0,this.#h=e.position,this.#T=e.mode,this.#M=e.privacyMode??e.fusionConfig?.privacyMode,this.#d=e.devServerOrchestrator,this.#m=e.git??!1,this.#m&&(process.env.GIT_CEILING_DIRECTORIES=this.#C),this.#ut=e.gitAutoInit??!1,this.#A=e.fusionConfig,this.#ze=e.asyncSubAgents??!1,this.#c=e.queueMode??"next-turn",this.#fe=e.fusionConfig?.autoPush,this.#Q=e.fusionConfig?.projectId,this.#P=e.fusionConfig?.branchName,this.#L=e.fusionConfig?.featureBranch,this.#j=e.fusionConfig?.aiBranch,this.#Ne=e.fusionConfig?.proxyOrigin,this.#Te=e.fusionConfig?.proxyDefaultOrigin,this.#He=e.fusionStatusMonitor,process.env.FUSION_ENV_ORIGIN&&(this.#mt=process.env.FUSION_ENV_ORIGIN),this.#te=e.agentType,e.enabledTools)this.#y=sx(this.#A,e.enabledTools);else if(this.#T==="quality-v3"){let n=["write_file","search_replace_file","view_path","get_rule","get_style_inspiration","grep_search","web_search","find_media",process.platform==="win32"?"powershell":"bash"];this.#d&&n.push("dev_server_control"),this.#y=sx(this.#A,n)}else if(this.#T==="quality-v4"){let n=["Write","Edit","Read","MultiEdit","Grep","Glob","ReadRule","TodoRead","TodoWrite","Agent","Media","WebFetch","AskUserQuestion","ExitPlanMode","EnterPlanMode",process.platform==="win32"?"PowerShell":"Bash"],i=!!(this.#M?.enabled||this.#M?.redactUserMessages||this.#M?.redactLLMMessages);i||n.push("WebSearch"),this.#Q&&!i&&this.getCommitMode()!=="commits"&&n.push("SearchMemories"),i||n.push("GetScreenshot"),n.push("NavigatePreview"),this.#d&&(n.push("DevServerLogs"),n.push("DevServerRestart"),n.push("ProposeEnvVariable")),process.env.FUSION_IDE_PORT&&n.push("IDEDiagnostics"),this.#y=sx(this.#A,n)}if(this.#lt=e.maxTokens,this.#qe=e.reasoning,this.#$e=e.builtInCustomInstructions??[],this.#je=e.builtInCustomAgents??[],this.#ke=e.builtInMCPServerConfig??{},this.#se=e.systemPromptOverride,this.#I=e.fusionConfig?.workspace,this.#Ye=e.mcpServers??!1,this.#w=this.#C,this.#p=[],this.#I?.folders.length){let n=this.#I.folders.filter(i=>i.enableGit);this.#p=n.map(i=>({folderName:i.name??i.path,path:this.#e.resolve(this.#C,i.path),branchName:i.branchName||"main",repoUrl:i.repoUrl,originalRepoUrl:i.originalRepoUrl,repoName:i.repoName}));for(let i of n){let o=i.backupMetadata?.check.backup,s=i.name??i.path,a=$I({version:o?.version,originalRepoUrl:o?.repoUrl,commitHash:o?.lastCommitHash});a&&(this.#Be[s]=a)}}this.#p.length===0&&(this.#p=[{folderName:JI,path:this.#C,branchName:"main"}]),this.#ye=pCe(this.#I),this.#I?.folders[0]&&this.#R()&&(this.#w=this.#e.resolve(this.#C,this.#I.folders[0].path)),this.#u.on("idle",()=>{eu(this.#s,"/events/publish",{event:hoe,extraData:{sessionId:this.getSessionId(),lastMessage:this.getLastMessage(),projectId:this.#Q,branchName:this.#P,hasPlanToApply:this.#F,sessionMode:this.getSessionMode()}})})}get fusionConfig(){return this.#A}get gitEnabledFolder(){return this.#I?.folders.find(e=>e.enableGit)}get gitEnabledFolders(){return this.#I?.folders.filter(e=>e.enableGit)||[]}get gitRepoContexts(){return this.#p}get workingDirectory(){return this.#C}get bashWorkingDirectory(){return this.#w}getSessionMode(){return this.#n?.sessionMode??"normal"}async switchSessionMode(e){let r=this.getSessionContext();r.sessionMode!==e&&(r.sessionMode=e,this.#F=!1,await this.#de())}async switchModelOverride(e){this.#_=e||void 0,await this.#de()}removeSystemReminder(e){let r=this.#O.findIndex(n=>n.tag===e);r!==-1&&this.#O.splice(r,1)}getMemoriesForFile(e){let r=Hhe(this.#gt,e).filter(n=>!this.#pt.has(n.id));for(let n of r)this.#pt.add(n.id);return r}queueSystemReminder(e){let r=e.tag?this.#O.findIndex(n=>n.tag===e.tag):-1;return r!==-1?e.text?(this.#O[r]=e,{operation:"update"}):(this.#O.splice(r,1),{operation:"delete"}):e.text?(this.#O.push(e),{operation:"add"}):{operation:"noop"}}setDefaultAutoPush(e){this.#fe=e}async setPrivacyMode(e){if(e&&e.enabled){if(!e.encryptKey&&!this.#me)this.#me=await mhe();else if(e.encryptKey){if(!await tx(e.encryptKey))throw new Error("Invalid encryption key: key failed validation");this.#me=e.encryptKey}}else this.#me=void 0;this.#M=e}async initializeSession(e={}){return this.#Je||(this.#Je=this.#Mt(e)),await this.#Je}async loadHistory(){let e=this.getSessionContext(),r=await cx(this.#e,this.#s,e.sessionId,!1,this.#i),n=new Map,i=new Map;for(let a of r.turns)for(let A of[a.beforeCommit,a.afterCommit,a.lastCommit]){if(!A)continue;let c=Pf(A,this.gitRepoContexts[0]?.folderName);n.set(A,c);for(let[u,l]of Object.entries(c))i.has(u)||i.set(u,new Set),i.get(u).add(l)}let o=new Map;for(let[a,A]of i.entries()){let c=this.gitRepoContexts.find(l=>l.folderName===a);if(!c||A.size===0)continue;let u=new Set;try{let d=(await this.git(["cat-file","--batch-check","--buffer"],{sys:this.#e,cwd:c.path,stdin:Array.from(A).map(p=>`${p}^{commit}`).join(`
1849
1849
  `)})).trim().split(`
1850
- `),g=new Set;for(let p of d)if(p.includes("missing")){let f=p.split(/\s+/)[0].replace("^{commit}","");g.add(f)}for(let p of A)g.has(p)||u.add(p)}catch(l){this.#e.Sentry?.captureException(l)}o.set(a,u)}let s=r.turns.filter(a=>{for(let A of[a.beforeCommit,a.afterCommit,a.lastCommit]){if(!A)continue;let c=n.get(A);if(c)for(let[u,l]of Object.entries(c)){if(!this.gitRepoContexts.find(p=>p.folderName===u))continue;let g=o.get(u);if(!g||!g.has(l))return!1}}return!0});return{sessionId:e.sessionId,title:e.title,beforeCommit:e.beforeCommit,createdUnixTime:e.createdUnixTime,updatedUnixTime:e.updatedUnixTime,turns:s}}async loadWholeSession(e={}){let{getAll:r=!0}=e,n=this.getSessionContext(),i=0;for(;n.canLoadMore&&n.canLoadMore;){let o=await this.loadMoreTurns();i+=o.length}return{sessionId:n.sessionId,title:n.title,beforeCommit:n.beforeCommit,createdUnixTime:n.createdUnixTime,updatedUnixTime:n.updatedUnixTime,addedTurns:i,turns:r?n.turns:n.turns.slice(0,i)}}async loadMoreTurns(){return this.#he||(this.#he=this.#Nt().then(e=>(this.#he=void 0,e))),this.#he}async#Nt(){let e=this.getSessionContext();if(e.canLoadMore){let r=e.turns[0]?.completionId,n=await cx(this.#e,this.#s,e.sessionId,!0,this.#i,r);return n.turns.length>0&&e.turns.unshift(...n.turns),e.canLoadMore=n.canLoadMore,n.turns}return[]}async#Tt(){try{let e=Wtt();if(!e)return null;let r=this.#e.join(this.primaryGitPath,"file.tsx");return await e.resolveConfig(r)}catch{return null}}async setCustomInstructions(e){this.#Je=e,this.#n&&(this.#n.customInstructions=await this.#be())}async setCustomAgents(e){this.#$e=e,this.#n&&(this.#n.customAgents=await this.#Ue())}async#be(){let r=(await Promise.all(this.#p.map(n=>GK({sys:this.#e,projectDir:this.#C,currentDir:n.path,rootDir:"/",allowedCommands:j0(this.#A?.allowedCommands??[]),skipCommandSecurity:this.#A?.skipCommandSecurity===!0})))).flat();return RK(this.#Je??[],r)}async#Ue(){if(!this.#y?.includes("Agent"))return[];let r=(await Promise.all(this.#p.map(n=>pAe({sys:this.#e,projectDir:this.#C,currentDir:n.path,rootDir:"/"})))).flat();return RK(this.#$e??[],r)}async#Mt(e){try{if(this.#Re)throw new Error("Code session already closed");if(this.#n)throw new Error("Session context already initialized");this.#r.debug(`Current AI working directory: ${this.#C}`),await this.setPrivacyMode(this.#M);let r=await this.#_t(),n=await this.#Tt();r&&(this.#k=await this.#L());let i=this.#p[0]?.repoUrl;this.#pt=await xL(i);let o,s;this.#q||(this.#q=r?.sessionId),this.#q?e.skipSessionLoading?o=this.#q:(s=await cx(this.#e,this.#s,this.#q,!0,this.#i,void 0,e.signal),o=s.sessionId,this.#r.debug(`Session recovered (sessionId=${o}, turnsCount=${s.turns.length})`)):o=(0,Ax.randomUUID)(),this.#_||(this.#_=r?.featureBranch?.trim());let a={turns:s?.turns??[],sessionId:o,customInstructions:await this.#be(),customAgents:await this.#Ue(),title:s?.title,beforeCommit:s?.beforeCommit,createdUnixTime:s?.createdUnixTime??Date.now(),updatedUnixTime:s?.updatedUnixTime??Date.now(),userContext:await gx(this.#e,this.primaryGitPath),prettierConfig:n,canLoadMore:s?.canLoadMore??!1,state:s?.turns.length?"success":this.#B?"initial-with-url":"initial-without-url",sessionMode:s?.sessionMode??"normal"};if(this.#K=s?.metadata??{},s?.hasPlanToApply&&(this.#F=!0),s){let c=zA(s.turns);c?.completionId!==s.lastCompletionId&&this.#e.Sentry?.captureException(new Error("Last completion id mismatch"),{tags:{operation:"codegen-initialize-session"},extra:{lastTurn:c,sessionMetadata:s}})}if(this.#i&&this.#u.on("step",c=>{c.type!=="delta"&&this.#r.debug(`(${c.type}): ${Df(JSON.stringify(c),400)}`)}),await this.#Ut(a),this.#n=a,this.#te){let c=await this.getNamedAgentConfig(this.#te,this.getSessionId(),e.signal);if(c.success){if(this.#b=c.options.includeMemories,this.#y=c.options.enabledTools,this.#O=c.options.modelOverride,this.#T=c.options.mode,this.#se=c.options.systemPromptOverride,this.#h=c.options.position,this.#c=c.options.queueMode??"next-turn",this.#qe=c.options.asyncSubAgents??!1,this.#ke={...this.#ke,...c.options.builtInMCPServerConfig},c.options.builtInMCPServerConfig?.chrome&&!this.#tt){let u=new KI(this.getSessionId(),{framesDir:this.#e.join(ax.default.homedir(),".builder","recordings"),debug:this.#i});this.setTimeline(u)}typeof c.options.mcpServers=="boolean"&&(this.#je=c.options.mcpServers)}else this.#r.error(c.response)}try{let c=await ghe(this.#e,this.primaryGitPath,this.#ke,this.#It,e.signal);c.length>0?(this.#r.debug(`Initializing ${c.length} local MCP server(s)...`),this.#Ie=await lhe(c,this.#e,this.primaryGitPath,e.signal)):this.#r.debug(`No local MCP servers found in: ${this.primaryGitPath}`)}catch(c){this.#r.error("Failed to initialize local MCP servers:",c,{loggerOptions:{debug:!0}})}if(this.#m&&this.#Q&&this.#y?.includes("SearchMemories")){let c=await Jhe(this.#e,this.#s,this.#Q,e.signal);await ox(this.#e,c,this.#e.join(this.#w,".builder","memories")),this.#lt=c,this.#y&&c.length===0&&(this.#y=this.#y.filter(u=>u!=="SearchMemories"))}let A=this.#d;if(A){let c=()=>{this.#u.emit("step",_K(A,this.#A))},u=()=>{this.#u.emit("step",_K(A,this.#A)),this.#de(),this.#ge()},l=d=>{d==="ok-2xx"&&this.requestRefresh()};A.emitter.on("setupState",u),A.emitter.on("devState",u),A.emitter.on("httpServerData",u),A.emitter.on("httpServerState",l),A.emitter.on("validateState",c),this.#xe.push(()=>{A.emitter.off("setupState",u),A.emitter.off("devState",u),A.emitter.off("httpServerData",u),A.emitter.off("httpServerState",l),A.emitter.off("validateState",c)})}}catch(r){throw this.#r.error(r),this.#e.Sentry?.captureException(r,{tags:{operation:"codegen-initialize-session"}}),r}}async#We(e,r){let n="reminder:health";this.removeSystemReminder(n);let i=this.#d;if(!i||!(this.#y?.includes("DevServerLogs")||this.#y?.includes("DevServerRestart")||this.#y?.includes("DevServerControl")||this.#y?.includes("ProposeEnvVariable")))return;let s=this.getSessionContext();if(s.sessionMode!=="normal")return;e&&await i.waitUntilIdle(500,500);let a=i.setupState,A=await this.#Xe(),c=i.devCommand,u=i.devState,l=i.state,d=i.setupCommand,g=await i.getOpenPorts(),p=i.proxyTarget,f=i.httpServerState.state,m=i.lastServerStatus,C=f==="error-fetch",I=!1;this.#m&&(I=await this.getCurrentBranch()!==this.getAiBranch());let B=f==="error-5xx"||f==="error-4xx"&&m!==401&&m!==404,E="",y=!1,Q=!1;l==="install-failed"||l==="install-aborted"?E=i.getSetupOutput():(E=i.getCheckpoints(1,u!=="running"?"err":"all"),y=sCe(E??""));let b="",w="",D="error",x="Try to fix",S="repair-unknown";if(l==="not-installed"||l==="install-failed"||l==="install-aborted"||l==="failed"||I||C||B||y||A.length>0){if(I&&(S="repair-bad-branch",w+=`- The current git branch is not the AI branch (${this.getAiBranch()}).
1850
+ `),g=new Set;for(let p of d)if(p.includes("missing")){let f=p.split(/\s+/)[0].replace("^{commit}","");g.add(f)}for(let p of A)g.has(p)||u.add(p)}catch(l){this.#e.Sentry?.captureException(l)}o.set(a,u)}let s=r.turns.filter(a=>{for(let A of[a.beforeCommit,a.afterCommit,a.lastCommit]){if(!A)continue;let c=n.get(A);if(c)for(let[u,l]of Object.entries(c)){if(!this.gitRepoContexts.find(p=>p.folderName===u))continue;let g=o.get(u);if(!g||!g.has(l))return!1}}return!0});return{sessionId:e.sessionId,title:e.title,beforeCommit:e.beforeCommit,createdUnixTime:e.createdUnixTime,updatedUnixTime:e.updatedUnixTime,turns:s}}async loadWholeSession(e={}){let{getAll:r=!0}=e,n=this.getSessionContext(),i=0;for(;n.canLoadMore&&n.canLoadMore;){let o=await this.loadMoreTurns();i+=o.length}return{sessionId:n.sessionId,title:n.title,beforeCommit:n.beforeCommit,createdUnixTime:n.createdUnixTime,updatedUnixTime:n.updatedUnixTime,addedTurns:i,turns:r?n.turns:n.turns.slice(0,i)}}async loadMoreTurns(){return this.#he||(this.#he=this.#Nt().then(e=>(this.#he=void 0,e))),this.#he}async#Nt(){let e=this.getSessionContext();if(e.canLoadMore){let r=e.turns[0]?.completionId,n=await cx(this.#e,this.#s,e.sessionId,!0,this.#i,r);return n.turns.length>0&&e.turns.unshift(...n.turns),e.canLoadMore=n.canLoadMore,n.turns}return[]}async#Tt(){try{let e=Wtt();if(!e)return null;let r=this.#e.join(this.primaryGitPath,"file.tsx");return await e.resolveConfig(r)}catch{return null}}async setCustomInstructions(e){this.#$e=e,this.#n&&(this.#n.customInstructions=await this.#be())}async setCustomAgents(e){this.#je=e,this.#n&&(this.#n.customAgents=await this.#Ge())}async#be(){let r=(await Promise.all(this.#p.map(n=>GK({sys:this.#e,projectDir:this.#C,currentDir:n.path,rootDir:"/",allowedCommands:j0(this.#A?.allowedCommands??[]),skipCommandSecurity:this.#A?.skipCommandSecurity===!0})))).flat();return RK(this.#$e??[],r)}async#Ge(){if(!this.#y?.includes("Agent"))return[];let r=(await Promise.all(this.#p.map(n=>pAe({sys:this.#e,projectDir:this.#C,currentDir:n.path,rootDir:"/"})))).flat();return RK(this.#je??[],r)}async#Mt(e){try{if(this.#Re)throw new Error("Code session already closed");if(this.#n)throw new Error("Session context already initialized");this.#r.debug(`Current AI working directory: ${this.#C}`),await this.setPrivacyMode(this.#M);let r=await this.#_t(),n=await this.#Tt();r&&(this.#k=await this.#U());let i=this.#p[0]?.repoUrl;this.#dt=await xL(i);let o,s;this.#q||(this.#q=r?.sessionId),this.#q?e.skipSessionLoading?o=this.#q:(s=await cx(this.#e,this.#s,this.#q,!0,this.#i,void 0,e.signal),o=s.sessionId,this.#r.debug(`Session recovered (sessionId=${o}, turnsCount=${s.turns.length})`)):o=(0,Ax.randomUUID)(),this.#L||(this.#L=r?.featureBranch?.trim());let a={turns:s?.turns??[],sessionId:o,customInstructions:await this.#be(),customAgents:await this.#Ge(),title:s?.title,beforeCommit:s?.beforeCommit,createdUnixTime:s?.createdUnixTime??Date.now(),updatedUnixTime:s?.updatedUnixTime??Date.now(),userContext:await gx(this.#e,this.primaryGitPath),prettierConfig:n,canLoadMore:s?.canLoadMore??!1,state:s?.turns.length?"success":this.#B?"initial-with-url":"initial-without-url",sessionMode:s?.sessionMode??"normal"};if(this.#K=s?.metadata??{},s?.hasPlanToApply&&(this.#F=!0),s){let c=zA(s.turns);c?.completionId!==s.lastCompletionId&&this.#e.Sentry?.captureException(new Error("Last completion id mismatch"),{tags:{operation:"codegen-initialize-session"},extra:{lastTurn:c,sessionMetadata:s}})}if(this.#i&&this.#u.on("step",c=>{c.type!=="delta"&&this.#r.debug(`(${c.type}): ${Df(JSON.stringify(c),400)}`)}),await this.#Ut(a),this.#n=a,this.#te){let c=await this.getNamedAgentConfig(this.#te,this.getSessionId(),e.signal);if(c.success){if(this.#b=c.options.includeMemories,this.#y=c.options.enabledTools,this.#_=c.options.modelOverride,this.#T=c.options.mode,this.#se=c.options.systemPromptOverride,this.#h=c.options.position,this.#c=c.options.queueMode??"next-turn",this.#ze=c.options.asyncSubAgents??!1,this.#ke={...this.#ke,...c.options.builtInMCPServerConfig},c.options.builtInMCPServerConfig?.chrome&&!this.#rt){let u=new KI(this.getSessionId(),{framesDir:this.#e.join(ax.default.homedir(),".builder","recordings"),debug:this.#i});this.setTimeline(u)}typeof c.options.mcpServers=="boolean"&&(this.#Ye=c.options.mcpServers)}else this.#r.error(c.response)}try{let c=await ghe(this.#e,this.primaryGitPath,this.#ke,this.#It,e.signal);c.length>0?(this.#r.debug(`Initializing ${c.length} local MCP server(s)...`),this.#Ie=await lhe(c,this.#e,this.primaryGitPath,e.signal)):this.#r.debug(`No local MCP servers found in: ${this.primaryGitPath}`)}catch(c){this.#r.error("Failed to initialize local MCP servers:",c,{loggerOptions:{debug:!0}})}if(this.#m&&this.#Q&&this.#y?.includes("SearchMemories")){let c=await Jhe(this.#e,this.#s,this.#Q,e.signal);await ox(this.#e,c,this.#e.join(this.#w,".builder","memories")),this.#gt=c,this.#y&&c.length===0&&(this.#y=this.#y.filter(u=>u!=="SearchMemories"))}let A=this.#d;if(A){let c=()=>{this.#u.emit("step",_K(A,this.#A))},u=()=>{this.#u.emit("step",_K(A,this.#A)),this.#de(),this.#ge()},l=d=>{d==="ok-2xx"&&this.requestRefresh()};A.emitter.on("setupState",u),A.emitter.on("devState",u),A.emitter.on("httpServerData",u),A.emitter.on("httpServerState",l),A.emitter.on("validateState",c),this.#xe.push(()=>{A.emitter.off("setupState",u),A.emitter.off("devState",u),A.emitter.off("httpServerData",u),A.emitter.off("httpServerState",l),A.emitter.off("validateState",c)})}}catch(r){throw this.#r.error(r),this.#e.Sentry?.captureException(r,{tags:{operation:"codegen-initialize-session"}}),r}}async#Ze(e,r){let n="reminder:health";this.removeSystemReminder(n);let i=this.#d;if(!i||!(this.#y?.includes("DevServerLogs")||this.#y?.includes("DevServerRestart")||this.#y?.includes("DevServerControl")||this.#y?.includes("ProposeEnvVariable")))return;let s=this.getSessionContext();if(s.sessionMode!=="normal")return;e&&await i.waitUntilIdle(500,500);let a=i.setupState,A=await this.#et(),c=i.devCommand,u=i.devState,l=i.state,d=i.setupCommand,g=await i.getOpenPorts(),p=i.proxyTarget,f=i.httpServerState.state,m=i.lastServerStatus,C=f==="error-fetch",I=!1;this.#m&&(I=await this.getCurrentBranch()!==this.getAiBranch());let B=f==="error-5xx"||f==="error-4xx"&&m!==401&&m!==404,E="",y=!1,Q=!1;l==="install-failed"||l==="install-aborted"?E=i.getSetupOutput():(E=i.getCheckpoints(1,u!=="running"?"err":"all"),y=sCe(E??""));let b="",w="",D="error",x="Try to fix",S="repair-unknown";if(l==="not-installed"||l==="install-failed"||l==="install-aborted"||l==="failed"||I||C||B||y||A.length>0){if(I&&(S="repair-bad-branch",w+=`- The current git branch is not the AI branch (${this.getAiBranch()}).
1851
1851
  `,w+=`- Please switch to the AI branch using the 'git' tool.
1852
- `,b=`The current branch is not the AI branch (${this.getAiBranch()}).`),A.length>0){S="repair-merge-conflict",x="Resolve conflict",b="Merge conflict detected - changes from different sources need to be combined";let K=this.#ze,M=K?`
1852
+ `,b=`The current branch is not the AI branch (${this.getAiBranch()}).`),A.length>0){S="repair-merge-conflict",x="Resolve conflict",b="Merge conflict detected - changes from different sources need to be combined";let K=this.#Ve,M=K?`
1853
1853
  ours (:2:) = ${K.ourBranch} (AI branch), theirs (:3:) = ${K.theirBranch} (${K.theirIsMain?"main \u2014 prefer preserving these changes":"AI remote"})`:"";w+=`Merge conflict detected. Resolve ALL conflicted files:
1854
1854
  ${A.join(`
1855
1855
  `)}
@@ -1898,20 +1898,20 @@ ${i.getSetupOutput().slice(-8e3)}
1898
1898
  `:E&&(w+=`<dev_logs>
1899
1899
  ${E}
1900
1900
  </dev_logs>
1901
- `)}(r==="all"||r==="critical"&&!Q)&&this.queueSystemReminder({text:Df(w,2e3),tag:n});let L={devServerState:u,setupState:a,httpServerState:f,proxyServer:p,devCommand:c,setupCommand:d,hasMergeConflict:A.length>0,hasConfigurationIssue:Q,logs:E,prompt:"Debug and fix the issue before continuing.",message:b},H=this.#t.length===0&&Ztt.includes(s.state);return{actionButtonText:x,type:"build-error",level:D,canAutoApply:H,healthStatus:L,message:L.message,userMessage:{userPrompt:L.prompt,repair:!0,category:S,displayPrompt:L.message}}}}async#Pt(){let e=await this.#We(!1,"critical"),r=!!(e&&!e.healthStatus.hasConfigurationIssue);return r&&this.#d?.addCheckpoint(),{hasHealthIssue:r}}async#_t(){let e;if(this.#m)try{if(this.#r.debug("Initializing Fusion session for AI side-car branch workflow..."),e=await this.#e.getRepoInfo(this.primaryGitPath),!e.hasGit)if(this.#ct){this.#r.warn("No git repository detected. Initializing a new git repository...",{loggerOptions:{debug:!0}});try{await this.git(["init"]),await this.git(["add","."]),await this.git(["branch","-M","main"]),await this.git(["commit","--allow-empty","--quiet","--no-verify","--no-gpg-sign","-m","Initial commit for Fusion workflow"]),this.#r.debug("Successfully initialized a new git repository")}catch(r){this.#r.error("Failed to initialize git repository:",r);return}}else{this.#r.error("Not in a git repository. Fusion requires a git repository.");return}return await Qv({sys:this.#e,gitWorkingDirectory:this.primaryGitPath,strict:!0})}catch(r){G.error(`\u274C Error initializing Fusion session: ${r}`);let n=new Error("Initialize Git failed",{cause:r});throw this.#e.Sentry?.captureException(n,{level:"fatal",tags:{operation:"codegen-initialize-session"},extra:{repoInfo:e}}),n}}async#Lt(e,r){try{await this.git(["checkout",e],{cwd:r})}catch{await this.git(["checkout","-b",e],{cwd:r})}}async#Ut(e){if(!this.#m)return;if(!this.#j){let o=CAe(this.getFeatureBranch(),e.sessionId);this.#j=o}let r=this.getAiBranch();await this.#H(async o=>{await this.getCurrentBranch(o.path)!==r&&await this.#Lt(r,o.path);try{await this.git(["branch","--set-upstream-to",`refs/remotes/origin/${this.#le(o)}`],{cwd:o.path})}catch{}});let n=zA(e.turns),i=n?.afterCommit??n?.lastCommit;if(i)for(let o of this.gitRepoContexts){let s=this.gitRepoContexts[0]?.folderName,a=tl(i,o.folderName,s);if(a){let A=await this.getCurrentCommitHash("HEAD",o.path);A&&A!==a&&this.#e.Sentry?.captureException(new Error(`Init: After commit mismatch for ${o.folderName}`),{tags:{operation:"codegen-initialize-session",folderName:o.folderName},extra:{sessionId:e.sessionId,targetCommit:a,currentCommitHash:A,lastTurn:n}})}}if(e.beforeCommit)for(let o of this.gitRepoContexts){let s=this.gitRepoContexts[0]?.folderName,a=tl(e.beforeCommit,o.folderName,s);if(a)try{await this.git(["rev-parse","--quiet","--verify",a],{cwd:o.path})}catch(A){this.#e.Sentry?.captureException(new Error(`Init: Before commit not found for ${o.folderName}`,{cause:A}),{tags:{operation:"codegen-initialize-session",folderName:o.folderName},extra:{sessionId:e.sessionId,beforeCommit:a,turnStates:e.turns.length,lastCompletionId:zA(e.turns)?.completionId}})}}}async#Gt(e,r){let n;try{n=(await this.git(["remote","get-url","origin"],r)).trim()}catch{}let{url:i,token:o,provider:s}=e;try{new URL(i)}catch{throw this.#e.Sentry?.captureException(new Error("Provided remote url is invalid"),{tags:{operation:"codegen-git"},extra:{url:i,currentOriginUrl:n}}),new Error("Provided remote url is invalid")}n!==i&&(this.#Be={},n?await this.git(["remote","set-url","origin",i],r):await this.git(["remote","add","origin",i],r),(s==="github"||s==="selfHostedGithub")&&o&&(process.env.GH_TOKEN=o))}async pushRepoV2(e){return await this.#J(this.#Se({pullFirst:!1,updateRepo:e,refreshRemote:!0}),"pushRepoV2",!0)}async ensureGitAuth(){return this.#m?this.#Ze():{success:!0,message:"Git is not enabled, skipping auth"}}async#Ze({force:e}={}){if(!this.#m)return{success:!0,message:"Git is not enabled"};let n=Date.now()-this.#dt,i=300*1e3;if(!e&&n<=i)return{success:!0,message:"Git auth still valid (within 5min)"};if(this.#Ae){if(!e)return this.#Ae;await this.#Ae.catch(()=>{})}return this.#Ae=this.#Ot().then(o=>(o.success&&(this.#dt=Date.now()),o)).finally(()=>{this.#Ae=null}),this.#Ae}async#Ot(){let e;try{let r=this.gitEnabledFolders;if(r.length===0)throw new Error("No git-enabled repos found");let n=r.filter(o=>!o.initializationCommand&&!o.repoUrl?.startsWith("ssh://"));if(n.length===0)return{success:!0,message:"Git remote URLs update not needed"};if(!this.#Q)throw new Error("Project ID is required to update git URLs");let i=await _f(this.#s,this.#Q,this.#i);if(!i.success)throw i.error;e=i.gitConfigs;for(let o of n){if(!o.repoName)continue;let s=e?.[o.repoName];if(s?.url){let a=this.#e.resolve(this.#C,o.path);await this.#Gt(s,a)}}return{success:!0,message:"Git remote URLs updated"}}catch(r){let n=`Failed to update git remote URLs: ${Sp(r)}`;return this.#r.error(n,{loggerOptions:{debug:!0}}),this.#u.emit("step",{type:"error",message:n,code:"git-update-error"}),this.#e.Sentry?.captureException(r,{tags:{operation:"codegen-git",endpoint:"updateGitUrls"},extra:{projectId:this.#Q,workspaceFolders:this.#I?.folders,gitConfigs:e}}),{success:!1,message:n,error:r instanceof Error?r:new Error(n)}}}async zipFolder(e){if(typeof e!="string")throw new TypeError(`zipFolder: 'folderName' must be a string, received ${typeof e}: ${ta(e)}`);let{resolvedPath:r}=this.resolveWorkspacePath(e,!1),n=Date.now(),i=Math.random().toString(36).substring(2,8),o=`zip-${n}-${i}.zip`,s="/tmp",a=this.#e.join(s,o);return kl.default.mkdirSync(s,{recursive:!0}),await PA("zip",["-r",a,".","-x","**/node_modules/**"],{cwd:r,sys:this.#e}),a}async archiveProject(){if(!this.#m)throw new Error("Can not archive project in non git mode");try{let e=Date.now(),r=Math.random().toString(36).substring(2,8),n=`project-${e}-${r}.zip`,i="/tmp",o=this.#e.join(i,n);return kl.default.mkdirSync(i,{recursive:!0}),await this.git(["archive","--format=zip","-o",o,"HEAD"]),o}catch(e){throw new Error("Failed to archive project",{cause:e})}}isIdle(){let e=this.getSessionContext(),r=["generating","replay"];return!this.#ae&&!r.includes(e.state)&&this.#ue.length===0}async needsBackup(){if(!this.#m||!this.#Q||!this.#P)return!1;for(let e of this.#p){let r=e.originalRepoUrl??e.repoUrl;if(!r)continue;let n=await this.getCurrentCommitHash("HEAD",e.path);if(!n)continue;let i=$I({version:"v2",originalRepoUrl:r,commitHash:n});if(this.#Be[e.folderName]!==i)return!0}return!1}async uploadBackup(e=!1){try{await this.waitUntilBlockingPendingPromises(),await this.#re(!1);let r=this.#Q,n=this.#P;if(!this.#m)throw new Error("Cannot upload backup in non-git mode");if(!r)throw new Error("Project ID is required for backup upload");if(!n)throw new Error("Branch ID is required for backup upload");let i=this.getAiBranch(),o=this.getFeatureBranch(),s=await this.#L();await mv(this.#e,this.#s,{commits:s,projectId:r,branchName:n},this.#i);let a=performance.now(),A=[];for(let l of this.#p){let d=l.originalRepoUrl??l.repoUrl;if(!d)continue;let g=await this.#wt(()=>dv({sys:this.#e,credentials:this.#s,projectId:r,branchName:n,repoPath:l.path,aiBranch:i,featureBranch:l.branchName||o,workspace:this.#I,debug:this.#i,isConnectedToProvider:!0,forcedFullBackup:e,canAbortMerge:this.#Re,folderName:l.folderName,repoUrl:d}));if(!g.success)return g;A.push({result:g,folderName:l.folderName})}if(A.length===0)return{success:!1,error:new Error("No repos to backup")};let c=A.map(l=>l.result.backupEntry),u=performance.now()-a;await fv(this.#s,c,u,this.#i);for(let{result:l,folderName:d}of A)l.backupRef&&(this.#Be[d]=l.backupRef);return A[0].result}catch(r){if(this.#r.error("Failed to upload backup",r),this.#Be={},this.#e.Sentry?.captureException(r,{tags:{operation:"codegen-backup",backupError:""}}),r instanceof Error&&r.message.includes("Commit(s) not found on remote"))throw r instanceof Error?r:new Error(String(r));return{success:!1,error:r instanceof Error?r:new Error(String(r))}}}getCommitMode(){return this.#A?.commitMode??"prs"}#le(e){return this.getCommitMode()==="commits"?`${e?.branchName||this.getFeatureBranch()}`:`${this.getAiBranch()}`}async#yt(e,r){let n=this.getCommitMode(),i=this.#le(r),o=await this.getCurrentBranch(r?.path);return n==="commits"?["push","--no-verify","--set-upstream",...e?["-f"]:[],"origin",`${o}:${i}`]:["push","--no-verify","--set-upstream",...e?["-f"]:[],"origin",i]}async pushChanges(e){let r=performance.now(),n=await this.#J(this.#Se(e),"pushChanges",!0);return this.#U("git_push_changes_total",performance.now()-r,{success:String(n.success!==!1)}),n}async#Se(e){let{pullFirst:r,updateRepo:n,actor:i,refreshRemote:o,forcePush:s,folderName:a,requireFastForward:A,abortOnMergeConflict:c}=uCe(e);try{if(!this.#m)throw new Error("Can not push changes in non-git mode");if(this.#A?.isFork)throw new Error("Cannot push changes to fork PRs. Fork PRs are read-only. You can only review and validate changes locally.");if(n){let m=this.#I?.folders.find(C=>C.enableGit);m&&(m.repoName=n.repoFullName,m.originalRepoUrl=n.repoUrl)}if(o||n){let m=performance.now(),C=await this.#Ze({force:!!o});if(this.#U("git_push_ensure_auth",performance.now()-m),!C.success)throw C.error}let u=a?this.#p.find(m=>m.folderName===a):this.#p[0];if(!u)throw new Error(a?`Folder "${a}" not found in workspace`:"No git repos configured");if(A&&await this.#Kt(u),r){let m=performance.now(),C=await this.#Ht({requestRefresh:!1,abortOnMergeConflict:c,ctx:u});if(this.#U("git_push_pull_latest",performance.now()-m,{success:String(C.success!==!1)}),!C.success)throw C.error??new Error(C.message)}if((await this.#z(u.path)).length>0)throw new Error(`Merge conflict detected in ${u.folderName}, please resolve before pushing`);let d=await this.#yt(s??!1,u),g=performance.now(),p=!0;try{await this.git(d,{cwd:u.path})}catch(m){throw p=!1,m}finally{this.#U("git_push_push",performance.now()-g,{success:String(p)})}await this.#v();let f=await this.#L();return await this.#pe({lastCommit:Os(f)}),this.queueGitStatusReminder({trigger:"push-success",pushedToRemote:!0}),{success:!0}}catch(u){this.#e.Sentry?.captureException(u,{tags:{operation:"codegen-git",endpoint:"pushChanges",actor:i},extra:{pullFirst:r,forcePush:s,requireFastForward:A,abortOnMergeConflict:c,commitMode:this.getCommitMode(),updateRepo:n,refreshRemote:o}});let l=Sp(u);return{success:!1,message:l,error:u instanceof Error?u:new Error(l)}}}async#Kt(e){let r=this.#le(e);await this.git(["fetch","origin",r],{cwd:e.path});let i=this.getCommitMode()==="commits"?await this.getCurrentBranch(e.path):r;try{await this.git(["merge-base","--is-ancestor",`origin/${r}`,i],{cwd:e.path})}catch{throw new Error("[GIT_PUSH_ERROR] Cannot push: remote has diverged from local branch. Fast-forward push is not possible. Please pull the latest changes first or use a different push mode.")}}async#Ht(e){if(e?.abortOnMergeConflict){let n=e.ctx?[e.ctx]:this.#p;if(n.length===0)return{success:!1,message:"No git repos configured",error:new Error("No git repos configured")};try{for(let i of n){let o=this.#le(i),s=performance.now();await this.git(["fetch","origin",o],{cwd:i.path}),this.#U("git_push_fetch",performance.now()-s,{folder:i.folderName,mode:"abort-on-conflict"});let a=performance.now(),A=!0;try{await this.git(["merge",`origin/${o}`],{cwd:i.path})}catch(c){if(A=!1,(await this.#z(i.path)).length>0){try{await this.git(["merge","--abort"],{cwd:i.path})}catch(l){this.#e.Sentry?.captureException(l,{tags:{operation:"codegen-git",endpoint:"pullLatestFromRemote-abort-merge-conflict",folderName:i.folderName}})}throw new Error(`[GIT_PUSH_ERROR] Cannot push: merge conflict detected in ${i.folderName} when pulling latest changes. The merge has been aborted. Please resolve conflicts manually.`)}throw c}finally{this.#U("git_push_merge",performance.now()-a,{folder:i.folderName,mode:"abort-on-conflict",success:String(A)})}}return{success:!0}}catch(i){this.#e.Sentry?.captureException(i,{tags:{operation:"codegen-git",endpoint:"pullLatestFromRemote"}});let o=Sp(i);return{success:!1,message:o,error:i instanceof Error?i:new Error(o)}}}return await this.#J(this.#Qt({branches:[],allowUnrelatedHistory:!1,canPush:!1,uncommittedChanges:"commit",fastForward:"auto",requestRefresh:e?.requestRefresh??!0,syncRemoteBranch:!0}),"syncChangesFromBranches",!0)}async abortMerge(e=!0){try{let r=await this.#H(async n=>{try{return await this.git(["merge","--abort"],{cwd:n.path}),!0}catch{return!1}});return this.#ze=void 0,e&&r.results.some(n=>n.result===!0)&&(await this.#v(),await this.#de(),this.requestRefresh()),r.success?{success:!0,message:"Merge aborted"}:{success:!1,message:`Failed to abort merge in: ${r.results.filter(i=>!i.success).map(i=>i.folderName).join(", ")}`,error:new Error("Merge abort failed in some repositories")}}catch(r){await this.#v();let n=Sp(r);return{success:!1,message:n,error:r instanceof Error?r:new Error(n)}}}async syncChangesFromRemote(e){let r=[],n=e?.remoteBranches??"both";return n==="both"?r.push(this.getAiBranch(),this.getFeatureBranch()):n==="main"?r.push(this.getFeatureBranch()):n==="ai"&&r.push(this.getAiBranch()),await this.#J(this.#Qt({branches:r,allowUnrelatedHistory:e?.allowUnrelatedHistory??!0,canPush:e?.canPush??!1,uncommittedChanges:e?.uncommittedChanges??"commit",requestRefresh:e?.requestRefresh,fastForward:e?.fastForward??"auto"}),"syncChangesFromRemote",!0)}async#z(e){try{return(await this.git(["--no-pager","diff","--name-only","--diff-filter=U"],{cwd:e})).trim().split(`
1902
- `).filter(i=>i.length>0)}catch{return[]}}async#Xe(){return(await this.#H(async r=>{let n=await this.#z(r.path);return this.#R()?n:n.map(i=>this.#e.join(r.path,i))})).results.flatMap(r=>r.success?r.result??[]:[])}async#Jt(e){let r=n=>n.split(`
1903
- `).map(i=>i.trim().slice(0,400)).filter(i=>i.length>0).slice(0,20);try{let n=this.#_||"main",i=await this.git(["log",n,"-n","20","--format=%s"],{cwd:e});return r(i)}catch{try{let n=await this.git(["log","-n","20","--format=%s"],{cwd:e});return r(n)}catch{return[]}}}async#Qt({branches:e,allowUnrelatedHistory:r,canPush:n,fastForward:i,uncommittedChanges:o,requestRefresh:s=!1,syncRemoteBranch:a=!1}){try{if(!this.#m)throw new Error("Can not pull changes in non-git mode");if(!a&&!e.length)throw new Error("At least one branch name is required");let A=this.getAiBranch(),c=this.getFeatureBranch(),u=[],l=performance.now();await this.#re(!1),this.#U("git_sync_commit_accumulated",performance.now()-l);let g=(await this.#H(async p=>{let f=p.path,m;a?m=[this.#le(p)]:m=e.map(w=>w===c?p.branchName:w);let C=await this.getCurrentBranch(f);if(C!==A)throw new Error(`Repo ${p.folderName} not on AI branch: ${C} != ${A}`);let I=await this.#z(f);if(I.length>0)throw new Error(`Merge conflict in ${p.folderName}:
1901
+ `)}(r==="all"||r==="critical"&&!Q)&&this.queueSystemReminder({text:Df(w,2e3),tag:n});let L={devServerState:u,setupState:a,httpServerState:f,proxyServer:p,devCommand:c,setupCommand:d,hasMergeConflict:A.length>0,hasConfigurationIssue:Q,logs:E,prompt:"Debug and fix the issue before continuing.",message:b},H=this.#t.length===0&&Ztt.includes(s.state);return{actionButtonText:x,type:"build-error",level:D,canAutoApply:H,healthStatus:L,message:L.message,userMessage:{userPrompt:L.prompt,repair:!0,category:S,displayPrompt:L.message}}}}async#Pt(){let e=await this.#Ze(!1,"critical"),r=!!(e&&!e.healthStatus.hasConfigurationIssue);return r&&this.#d?.addCheckpoint(),{hasHealthIssue:r}}async#_t(){let e;if(this.#m)try{if(this.#r.debug("Initializing Fusion session for AI side-car branch workflow..."),e=await this.#e.getRepoInfo(this.primaryGitPath),!e.hasGit)if(this.#ut){this.#r.warn("No git repository detected. Initializing a new git repository...",{loggerOptions:{debug:!0}});try{await this.git(["init"]),await this.git(["add","."]),await this.git(["branch","-M","main"]),await this.git(["commit","--allow-empty","--quiet","--no-verify","--no-gpg-sign","-m","Initial commit for Fusion workflow"]),this.#r.debug("Successfully initialized a new git repository")}catch(r){this.#r.error("Failed to initialize git repository:",r);return}}else{this.#r.error("Not in a git repository. Fusion requires a git repository.");return}return await Qv({sys:this.#e,gitWorkingDirectory:this.primaryGitPath,strict:!0})}catch(r){G.error(`\u274C Error initializing Fusion session: ${r}`);let n=new Error("Initialize Git failed",{cause:r});throw this.#e.Sentry?.captureException(n,{level:"fatal",tags:{operation:"codegen-initialize-session"},extra:{repoInfo:e}}),n}}async#Lt(e,r){try{await this.git(["checkout",e],{cwd:r})}catch{await this.git(["checkout","-b",e],{cwd:r})}}async#Ut(e){if(!this.#m)return;if(!this.#j){let o=CAe(this.getFeatureBranch(),e.sessionId);this.#j=o}let r=this.getAiBranch();await this.#H(async o=>{await this.getCurrentBranch(o.path)!==r&&await this.#Lt(r,o.path);try{await this.git(["branch","--set-upstream-to",`refs/remotes/origin/${this.#le(o)}`],{cwd:o.path})}catch{}});let n=zA(e.turns),i=n?.afterCommit??n?.lastCommit;if(i)for(let o of this.gitRepoContexts){let s=this.gitRepoContexts[0]?.folderName,a=tl(i,o.folderName,s);if(a){let A=await this.getCurrentCommitHash("HEAD",o.path);A&&A!==a&&this.#e.Sentry?.captureException(new Error(`Init: After commit mismatch for ${o.folderName}`),{tags:{operation:"codegen-initialize-session",folderName:o.folderName},extra:{sessionId:e.sessionId,targetCommit:a,currentCommitHash:A,lastTurn:n}})}}if(e.beforeCommit)for(let o of this.gitRepoContexts){let s=this.gitRepoContexts[0]?.folderName,a=tl(e.beforeCommit,o.folderName,s);if(a)try{await this.git(["rev-parse","--quiet","--verify",a],{cwd:o.path})}catch(A){this.#e.Sentry?.captureException(new Error(`Init: Before commit not found for ${o.folderName}`,{cause:A}),{tags:{operation:"codegen-initialize-session",folderName:o.folderName},extra:{sessionId:e.sessionId,beforeCommit:a,turnStates:e.turns.length,lastCompletionId:zA(e.turns)?.completionId}})}}}async#Gt(e,r){let n;try{n=(await this.git(["remote","get-url","origin"],r)).trim()}catch{}let{url:i,token:o,provider:s}=e;try{new URL(i)}catch{throw this.#e.Sentry?.captureException(new Error("Provided remote url is invalid"),{tags:{operation:"codegen-git"},extra:{url:i,currentOriginUrl:n}}),new Error("Provided remote url is invalid")}n!==i&&(this.#Be={},n?await this.git(["remote","set-url","origin",i],r):await this.git(["remote","add","origin",i],r),(s==="github"||s==="selfHostedGithub")&&o&&(process.env.GH_TOKEN=o))}async pushRepoV2(e){return await this.#J(this.#Se({pullFirst:!1,updateRepo:e,refreshRemote:!0}),"pushRepoV2",!0)}async ensureGitAuth(){return this.#m?this.#Xe():{success:!0,message:"Git is not enabled, skipping auth"}}async#Xe({force:e}={}){if(!this.#m)return{success:!0,message:"Git is not enabled"};let n=Date.now()-this.#ft,i=300*1e3;if(!e&&n<=i)return{success:!0,message:"Git auth still valid (within 5min)"};if(this.#Ae){if(!e)return this.#Ae;await this.#Ae.catch(()=>{})}return this.#Ae=this.#Ot().then(o=>(o.success&&(this.#ft=Date.now()),o)).finally(()=>{this.#Ae=null}),this.#Ae}async#Ot(){let e;try{let r=this.gitEnabledFolders;if(r.length===0)throw new Error("No git-enabled repos found");let n=r.filter(o=>!o.initializationCommand&&!o.repoUrl?.startsWith("ssh://"));if(n.length===0)return{success:!0,message:"Git remote URLs update not needed"};if(!this.#Q)throw new Error("Project ID is required to update git URLs");let i=await _f(this.#s,this.#Q,this.#i);if(!i.success)throw i.error;e=i.gitConfigs;for(let o of n){if(!o.repoName)continue;let s=e?.[o.repoName];if(s?.url){let a=this.#e.resolve(this.#C,o.path);await this.#Gt(s,a)}}return{success:!0,message:"Git remote URLs updated"}}catch(r){let n=`Failed to update git remote URLs: ${Sp(r)}`;return this.#r.error(n,{loggerOptions:{debug:!0}}),this.#u.emit("step",{type:"error",message:n,code:"git-update-error"}),this.#e.Sentry?.captureException(r,{tags:{operation:"codegen-git",endpoint:"updateGitUrls"},extra:{projectId:this.#Q,workspaceFolders:this.#I?.folders,gitConfigs:e}}),{success:!1,message:n,error:r instanceof Error?r:new Error(n)}}}async zipFolder(e){if(typeof e!="string")throw new TypeError(`zipFolder: 'folderName' must be a string, received ${typeof e}: ${ta(e)}`);let{resolvedPath:r}=this.resolveWorkspacePath(e,!1),n=Date.now(),i=Math.random().toString(36).substring(2,8),o=`zip-${n}-${i}.zip`,s="/tmp",a=this.#e.join(s,o);return kl.default.mkdirSync(s,{recursive:!0}),await PA("zip",["-r",a,".","-x","**/node_modules/**"],{cwd:r,sys:this.#e}),a}async archiveProject(){if(!this.#m)throw new Error("Can not archive project in non git mode");try{let e=Date.now(),r=Math.random().toString(36).substring(2,8),n=`project-${e}-${r}.zip`,i="/tmp",o=this.#e.join(i,n);return kl.default.mkdirSync(i,{recursive:!0}),await this.git(["archive","--format=zip","-o",o,"HEAD"]),o}catch(e){throw new Error("Failed to archive project",{cause:e})}}isIdle(){let e=this.getSessionContext(),r=["generating","replay"];return!this.#ae&&!r.includes(e.state)&&this.#ue.length===0}async needsBackup(){if(!this.#m||!this.#Q||!this.#P)return!1;for(let e of this.#p){let r=e.originalRepoUrl??e.repoUrl;if(!r)continue;let n=await this.getCurrentCommitHash("HEAD",e.path);if(!n)continue;let i=$I({version:"v2",originalRepoUrl:r,commitHash:n});if(this.#Be[e.folderName]!==i)return!0}return!1}async uploadBackup(e=!1){try{await this.waitUntilBlockingPendingPromises(),await this.#re(!1);let r=this.#Q,n=this.#P;if(!this.#m)throw new Error("Cannot upload backup in non-git mode");if(!r)throw new Error("Project ID is required for backup upload");if(!n)throw new Error("Branch ID is required for backup upload");let i=this.getAiBranch(),o=this.getFeatureBranch(),s=await this.#U();await mv(this.#e,this.#s,{commits:s,projectId:r,branchName:n},this.#i);let a=performance.now(),A=[];for(let l of this.#p){let d=l.originalRepoUrl??l.repoUrl;if(!d)continue;let g=await this.#wt(()=>dv({sys:this.#e,credentials:this.#s,projectId:r,branchName:n,repoPath:l.path,aiBranch:i,featureBranch:l.branchName||o,workspace:this.#I,debug:this.#i,isConnectedToProvider:!0,forcedFullBackup:e,canAbortMerge:this.#Re,folderName:l.folderName,repoUrl:d}));if(!g.success)return g;A.push({result:g,folderName:l.folderName})}if(A.length===0)return{success:!1,error:new Error("No repos to backup")};let c=A.map(l=>l.result.backupEntry),u=performance.now()-a;await fv(this.#s,c,u,this.#i);for(let{result:l,folderName:d}of A)l.backupRef&&(this.#Be[d]=l.backupRef);return A[0].result}catch(r){if(this.#r.error("Failed to upload backup",r),this.#Be={},this.#e.Sentry?.captureException(r,{tags:{operation:"codegen-backup",backupError:""}}),r instanceof Error&&r.message.includes("Commit(s) not found on remote"))throw r instanceof Error?r:new Error(String(r));return{success:!1,error:r instanceof Error?r:new Error(String(r))}}}getCommitMode(){return this.#A?.commitMode??"prs"}#le(e){return this.getCommitMode()==="commits"?`${e?.branchName||this.getFeatureBranch()}`:`${this.getAiBranch()}`}async#yt(e,r){let n=this.getCommitMode(),i=this.#le(r),o=await this.getCurrentBranch(r?.path);return n==="commits"?["push","--no-verify","--set-upstream",...e?["-f"]:[],"origin",`${o}:${i}`]:["push","--no-verify","--set-upstream",...e?["-f"]:[],"origin",i]}async pushChanges(e){let r=performance.now(),n=await this.#J(this.#Se(e),"pushChanges",!0);return this.#G("git_push_changes_total",performance.now()-r,{success:String(n.success!==!1)}),n}async#Se(e){let{pullFirst:r,updateRepo:n,actor:i,refreshRemote:o,forcePush:s,folderName:a,requireFastForward:A,abortOnMergeConflict:c}=uCe(e);try{if(!this.#m)throw new Error("Can not push changes in non-git mode");if(this.#A?.isFork)throw new Error("Cannot push changes to fork PRs. Fork PRs are read-only. You can only review and validate changes locally.");if(n){let m=this.#I?.folders.find(C=>C.enableGit);m&&(m.repoName=n.repoFullName,m.originalRepoUrl=n.repoUrl)}if(o||n){let m=performance.now(),C=await this.#Xe({force:!!o});if(this.#G("git_push_ensure_auth",performance.now()-m),!C.success)throw C.error}let u=a?this.#p.find(m=>m.folderName===a):this.#p[0];if(!u)throw new Error(a?`Folder "${a}" not found in workspace`:"No git repos configured");if(A&&await this.#Kt(u),r){let m=performance.now(),C=await this.#Ht({requestRefresh:!1,abortOnMergeConflict:c,ctx:u});if(this.#G("git_push_pull_latest",performance.now()-m,{success:String(C.success!==!1)}),!C.success)throw C.error??new Error(C.message)}if((await this.#z(u.path)).length>0)throw new Error(`Merge conflict detected in ${u.folderName}, please resolve before pushing`);let d=await this.#yt(s??!1,u),g=performance.now(),p=!0;try{await this.git(d,{cwd:u.path})}catch(m){throw p=!1,m}finally{this.#G("git_push_push",performance.now()-g,{success:String(p)})}await this.#v();let f=await this.#U();return await this.#pe({lastCommit:Os(f)}),this.queueGitStatusReminder({trigger:"push-success",pushedToRemote:!0}),{success:!0}}catch(u){this.#e.Sentry?.captureException(u,{tags:{operation:"codegen-git",endpoint:"pushChanges",actor:i},extra:{pullFirst:r,forcePush:s,requireFastForward:A,abortOnMergeConflict:c,commitMode:this.getCommitMode(),updateRepo:n,refreshRemote:o}});let l=Sp(u);return{success:!1,message:l,error:u instanceof Error?u:new Error(l)}}}async#Kt(e){let r=this.#le(e);await this.git(["fetch","origin",r],{cwd:e.path});let i=this.getCommitMode()==="commits"?await this.getCurrentBranch(e.path):r;try{await this.git(["merge-base","--is-ancestor",`origin/${r}`,i],{cwd:e.path})}catch{throw new Error("[GIT_PUSH_ERROR] Cannot push: remote has diverged from local branch. Fast-forward push is not possible. Please pull the latest changes first or use a different push mode.")}}async#Ht(e){if(e?.abortOnMergeConflict){let n=e.ctx?[e.ctx]:this.#p;if(n.length===0)return{success:!1,message:"No git repos configured",error:new Error("No git repos configured")};try{for(let i of n){let o=this.#le(i),s=performance.now();await this.git(["fetch","origin",o],{cwd:i.path}),this.#G("git_push_fetch",performance.now()-s,{folder:i.folderName,mode:"abort-on-conflict"});let a=performance.now(),A=!0;try{await this.git(["merge",`origin/${o}`],{cwd:i.path})}catch(c){if(A=!1,(await this.#z(i.path)).length>0){try{await this.git(["merge","--abort"],{cwd:i.path})}catch(l){this.#e.Sentry?.captureException(l,{tags:{operation:"codegen-git",endpoint:"pullLatestFromRemote-abort-merge-conflict",folderName:i.folderName}})}throw new Error(`[GIT_PUSH_ERROR] Cannot push: merge conflict detected in ${i.folderName} when pulling latest changes. The merge has been aborted. Please resolve conflicts manually.`)}throw c}finally{this.#G("git_push_merge",performance.now()-a,{folder:i.folderName,mode:"abort-on-conflict",success:String(A)})}}return{success:!0}}catch(i){this.#e.Sentry?.captureException(i,{tags:{operation:"codegen-git",endpoint:"pullLatestFromRemote"}});let o=Sp(i);return{success:!1,message:o,error:i instanceof Error?i:new Error(o)}}}return await this.#J(this.#Qt({branches:[],allowUnrelatedHistory:!1,canPush:!1,uncommittedChanges:"commit",fastForward:"auto",requestRefresh:e?.requestRefresh??!0,syncRemoteBranch:!0}),"syncChangesFromBranches",!0)}async abortMerge(e=!0){try{let r=await this.#H(async n=>{try{return await this.git(["merge","--abort"],{cwd:n.path}),!0}catch{return!1}});return this.#Ve=void 0,e&&r.results.some(n=>n.result===!0)&&(await this.#v(),await this.#de(),this.requestRefresh()),r.success?{success:!0,message:"Merge aborted"}:{success:!1,message:`Failed to abort merge in: ${r.results.filter(i=>!i.success).map(i=>i.folderName).join(", ")}`,error:new Error("Merge abort failed in some repositories")}}catch(r){await this.#v();let n=Sp(r);return{success:!1,message:n,error:r instanceof Error?r:new Error(n)}}}async syncChangesFromRemote(e){let r=[],n=e?.remoteBranches??"both";return n==="both"?r.push(this.getAiBranch(),this.getFeatureBranch()):n==="main"?r.push(this.getFeatureBranch()):n==="ai"&&r.push(this.getAiBranch()),await this.#J(this.#Qt({branches:r,allowUnrelatedHistory:e?.allowUnrelatedHistory??!0,canPush:e?.canPush??!1,uncommittedChanges:e?.uncommittedChanges??"commit",requestRefresh:e?.requestRefresh,fastForward:e?.fastForward??"auto"}),"syncChangesFromRemote",!0)}async#z(e){try{return(await this.git(["--no-pager","diff","--name-only","--diff-filter=U"],{cwd:e})).trim().split(`
1902
+ `).filter(i=>i.length>0)}catch{return[]}}async#et(){return(await this.#H(async r=>{let n=await this.#z(r.path);return this.#R()?n:n.map(i=>this.#e.join(r.path,i))})).results.flatMap(r=>r.success?r.result??[]:[])}async#Jt(e){let r=n=>n.split(`
1903
+ `).map(i=>i.trim().slice(0,400)).filter(i=>i.length>0).slice(0,20);try{let n=this.#L||"main",i=await this.git(["log",n,"-n","20","--format=%s"],{cwd:e});return r(i)}catch{try{let n=await this.git(["log","-n","20","--format=%s"],{cwd:e});return r(n)}catch{return[]}}}async#Qt({branches:e,allowUnrelatedHistory:r,canPush:n,fastForward:i,uncommittedChanges:o,requestRefresh:s=!1,syncRemoteBranch:a=!1}){try{if(!this.#m)throw new Error("Can not pull changes in non-git mode");if(!a&&!e.length)throw new Error("At least one branch name is required");let A=this.getAiBranch(),c=this.getFeatureBranch(),u=[],l=performance.now();await this.#re(!1),this.#G("git_sync_commit_accumulated",performance.now()-l);let g=(await this.#H(async p=>{let f=p.path,m;a?m=[this.#le(p)]:m=e.map(w=>w===c?p.branchName:w);let C=await this.getCurrentBranch(f);if(C!==A)throw new Error(`Repo ${p.folderName} not on AI branch: ${C} != ${A}`);let I=await this.#z(f);if(I.length>0)throw new Error(`Merge conflict in ${p.folderName}:
1904
1904
  ${I.join(`
1905
- `)}`);let B=!1;if(!await this.#ot(f))switch(o){case"stash":await this.git(["stash","--include-untracked"],{cwd:f}),B=!0;break;case"commit":await this.git(["add","-A","."],{cwd:f}),await this.git(["commit","--no-verify","--no-gpg-sign","-m","Commit unstaged changes"],{cwd:f});break;default:throw new Error(`Uncommitted changes in ${p.folderName}`)}let y=performance.now();await this.git(["fetch","origin","--prune"],{cwd:f}),this.#U("git_sync_fetch",performance.now()-y,{folder:p.folderName});let Q=await this.git(["for-each-ref","refs/remotes/origin"],{cwd:f}),b=m.filter(w=>Q.includes(`refs/remotes/origin/${w}`));for(let w of b){w!==A&&await this.git(["update-ref",`refs/heads/${w}`,`refs/remotes/origin/${w}`],{cwd:f});try{let D=performance.now(),x=!0,S;try{S=await this.git(["merge",...i==="never"?["--no-ff"]:[],...i==="required"?["--ff-only"]:[],...i==="auto"?["--ff"]:[],...r?["--allow-unrelated-histories"]:[],`refs/remotes/origin/${w}`],{cwd:f})}catch(M){throw x=!1,M}finally{this.#U("git_sync_merge",performance.now()-D,{folder:p.folderName,branch:w,success:String(x)})}let L=w===p.branchName,H=S?.includes("Already up to date"),K=this.#R()?"":`[${p.folderName}] `;H||u.push(`${K}Successfully merged branch "${w}" into ${A}${L?" (this was the main/feature branch \u2014 its changes are now in your working branch)":" (AI branch synced with remote)"}.`)}catch(D){let x=w===p.branchName,S=this.#R()?"":`[${p.folderName}] `;throw this.#ze={ourBranch:A,theirBranch:w,theirIsMain:x},D instanceof ra&&u.push(`${S}The user tries to sync git changes, but something failed:
1905
+ `)}`);let B=!1;if(!await this.#st(f))switch(o){case"stash":await this.git(["stash","--include-untracked"],{cwd:f}),B=!0;break;case"commit":await this.git(["add","-A","."],{cwd:f}),await this.git(["commit","--no-verify","--no-gpg-sign","-m","Commit unstaged changes"],{cwd:f});break;default:throw new Error(`Uncommitted changes in ${p.folderName}`)}let y=performance.now();await this.git(["fetch","origin","--prune"],{cwd:f}),this.#G("git_sync_fetch",performance.now()-y,{folder:p.folderName});let Q=await this.git(["for-each-ref","refs/remotes/origin"],{cwd:f}),b=m.filter(w=>Q.includes(`refs/remotes/origin/${w}`));for(let w of b){w!==A&&await this.git(["update-ref",`refs/heads/${w}`,`refs/remotes/origin/${w}`],{cwd:f});try{let D=performance.now(),x=!0,S;try{S=await this.git(["merge",...i==="never"?["--no-ff"]:[],...i==="required"?["--ff-only"]:[],...i==="auto"?["--ff"]:[],...r?["--allow-unrelated-histories"]:[],`refs/remotes/origin/${w}`],{cwd:f})}catch(M){throw x=!1,M}finally{this.#G("git_sync_merge",performance.now()-D,{folder:p.folderName,branch:w,success:String(x)})}let L=w===p.branchName,H=S?.includes("Already up to date"),K=this.#R()?"":`[${p.folderName}] `;H||u.push(`${K}Successfully merged branch "${w}" into ${A}${L?" (this was the main/feature branch \u2014 its changes are now in your working branch)":" (AI branch synced with remote)"}.`)}catch(D){let x=w===p.branchName,S=this.#R()?"":`[${p.folderName}] `;throw this.#Ve={ourBranch:A,theirBranch:w,theirIsMain:x},D instanceof ra&&u.push(`${S}The user tries to sync git changes, but something failed:
1906
1906
  - our branch (ours): ${A} -- this is the AI's working branch
1907
1907
  - their branch (theirs): refs/remotes/origin/${w} ${x?" -- this is main/feature branch (work here needs to be preserved)":"-- same branch pushed by remote"}
1908
- `),D}}if(n){let w=await this.#yt(!0,p);await this.git(w,{cwd:p.path})}if(B)try{await this.git(["stash","pop"],{cwd:f})}catch(w){this.#e.Sentry?.captureException(w,{tags:{operation:"codegen-git",endpoint:"syncChanges-stash-pop"}})}})).results.filter(p=>!p.success||p.error);if(g.length>0){let p=g.map(f=>f.error?.message||`${f.folderName} failed`).join("; ");throw new Error(`Sync failed: ${p}`)}if(n){let p=await this.#Se(!1);if(!p.success)throw p.error}else{await this.#v();let p=await this.#L();this.#k={...this.#k,...p},await this.#pe({lastCommit:Os(p)})}return u.length>0&&this.queueSystemReminder({text:u.join(`
1908
+ `),D}}if(n){let w=await this.#yt(!0,p);await this.git(w,{cwd:p.path})}if(B)try{await this.git(["stash","pop"],{cwd:f})}catch(w){this.#e.Sentry?.captureException(w,{tags:{operation:"codegen-git",endpoint:"syncChanges-stash-pop"}})}})).results.filter(p=>!p.success||p.error);if(g.length>0){let p=g.map(f=>f.error?.message||`${f.folderName} failed`).join("; ");throw new Error(`Sync failed: ${p}`)}if(n){let p=await this.#Se(!1);if(!p.success)throw p.error}else{await this.#v();let p=await this.#U();this.#k={...this.#k,...p},await this.#pe({lastCommit:Os(p)})}return u.length>0&&this.queueSystemReminder({text:u.join(`
1909
1909
 
1910
- `)}),s&&this.requestRefresh(),{success:!0,message:`Successfully merged ${e.join(", ")} in all repos`}}catch(A){this.#r.error(`Error syncing changes from branches: ${A}`,{loggerOptions:{debug:!0}}),await this.#v();let c=await this.#L();this.#k={...this.#k,...c},this.#e.Sentry?.captureException(A,{tags:{operation:"codegen-git",endpoint:"syncChangesFromBranches"},extra:{branches:e,allowUnrelatedHistory:r}});let u=Sp(A);return{success:!1,message:u,error:A instanceof Error?A:new Error(u)}}}async getCurrentCommitHash(e="HEAD",r){if(this.#m)try{let n=["rev-parse",e];return(await this.git(n,{sys:this.#e,cwd:r})).trim()}catch{return}}async#L(e="HEAD"){let r={};for(let n of this.gitRepoContexts)try{let i=await this.getCurrentCommitHash(e,n.path);i&&(r[n.folderName]=i)}catch(i){this.#r.warn(`Failed to get commit for ${n.folderName}:`,i)}return r}async getCurrentBranch(e){return(await this.git(["branch","--show-current"],{cwd:e})).trim()}getFeatureBranch(){if(!this.#_)throw new Error("Feature branch is missing");return this.#_}getAiBranch(){if(!this.#j)throw new Error("AI branch is missing");return this.#j}async git(e,r){if(!this.#m)throw new Error("Can not execute git command in non-git mode.");let n=e[0];(n==="push"||n==="fetch"||n==="pull")&&await this.#Ze();let o=typeof r=="object"?{sys:this.#e,...r}:r,s=await this.#wt(()=>this.#qt(e,o));return this.#jt(n)&&(this.#we.clear(),this.#De.clear()),s}static#$t=new Set(["commit","merge","rebase","checkout","switch","pull","fetch","reset","cherry-pick","revert","am","stash","push"]);#jt(e){return!!e&&t.#$t.has(e)}async#H(e){if(this.#p.length===0)return{success:!0,partialSuccess:!1,results:[]};let n=(await Promise.allSettled(this.#p.map(s=>e(s)))).map((s,a)=>({folderName:this.#p[a].folderName,success:s.status==="fulfilled",result:s.status==="fulfilled"?s.value:void 0,error:s.status==="rejected"?s.reason:void 0,message:s.status==="rejected"?s.reason?.message:void 0})),i=n.filter(s=>s.success),o=n.filter(s=>!s.success);return{success:o.length===0,partialSuccess:i.length>0&&o.length>0,results:n}}#Dt(e){let r=ls(e),n=this.#p.find(a=>{let A=ls(a.folderName);return r.startsWith(A+"/")||r===A});if(n)return n;let i=e.startsWith("/")||e.includes(":")?e:this.#e.resolve(this.#C,e),o=ls(i);return this.#p.find(a=>{let A=ls(a.path);return o.startsWith(A+"/")||o===A})}#Yt(e){let r=new Map;for(let n of e){let i=this.#Dt(n);if(i){let o=r.get(i.folderName)||[];o.push(n),r.set(i.folderName,o)}}return r}#wt(e){let r=this.#At.then(()=>e());return this.#At=r.catch(()=>{}),r}async#qt(e,r){if(!this.#m)throw new Error(`Can not execute git command in non-git mode: git ${e.join(" ")}`);let n=`git ${e.join(" ")}`;this.#ae&&this.#e.Sentry?.captureException(new Error(`currentGitCommand is not finished yet. Current command: ${this.#ae}, New command Received: ${n}`),{tags:{operation:"codegen-git"},extra:{oldCommand:this.#ae,newCommand:n}});try{this.#ae=n;let i=typeof r=="object"?r:void 0,o=typeof r=="string"?r:i?.cwd??this.primaryGitPath;return await PA("git",e,{...i,cwd:o,sys:this.#e,timeout:60*1e3})}finally{this.#ae=void 0}}setDebug(e){this.#i=e,e&&!process.env.DEBUG?(process.env.DEBUG="1",this.#f=!0):!e&&this.#f&&(delete process.env.DEBUG,this.#f=!1)}async createTerminal(e){let r=this.#d,n=e?.terminalId||`pty_${Date.now()}_${(0,Ax.randomUUID)()}`,i=this.#et().find(B=>B.terminalId===n),o=new Set,s=new Set;if(i&&e?.terminalId){if(!e?.force)return i;let B=this.#D.get(e.terminalId);if(!B)return i;B.onDataListeners.forEach(E=>{o.add(E)}),B.onExitListeners.forEach(E=>{s.add(E)}),this.disposeTerminal({terminalId:n,emitTerminals:!1})}let a=e?.shell||(process.platform==="win32"?"powershell.exe":process.env.SHELL||"/bin/bash"),A=e?.cols??120,c=e?.rows??30,u={...process.env,...r?.envVars,...e?.env};e?.inheritCredentials&&(u.BUILDER_USER_ID=e.createdBy??this.#s.userId,u.BUILDER_PUBLIC_KEY=this.#s.builderPublicKey,u.BUILDER_PRIVATE_KEY=this.#s.builderPrivateKey);let l=[],d=B=>{for(let E of o)E(B)},g=({exitCode:B,error:E})=>{let y=this.#D.get(n);y&&(y.state=E?"error":"exited",y.exitCode=B);for(let Q of s)Q(B);this.#D.delete(n),l.forEach(Q=>Q())},p=e?.cwd||this.#w,f,m;if(e?.readonly){f="starting";let B=!r?.hasSetupEnvVars,E=kA(a,e?.initialCommand??"true",{cwd:p,env:u,stdio:["ignore","pipe","pipe"]},B);E.on("spawn",()=>{let y=this.#D.get(n);y&&(y.state="running")}),E.stdout.on("data",y=>{d(y.toString())}),E.stderr.on("data",y=>{d(y.toString())}),E.on("error",y=>{g({exitCode:1,error:y})}),E.on("exit",y=>{g({exitCode:y??0})}),l.push(()=>{try{E.removeAllListeners()}catch{}E.kill()}),m=E}else{f="running";let B=dL(this.#e);if(!B)throw new Error("Could not import node-pty");let E=a.includes("bash")||a.includes("zsh"),y=a.includes("zsh")?"%~ $ ":"\\w $ ",Q=B.spawn(a,[],{name:"xterm-color",cwd:p,cols:A,rows:c,env:E?{...u,PS1:y}:u}),b=Q.onData(d);l.push(()=>{try{b?.dispose?.()}catch{}});let w=Q.onExit(g);l.push(()=>{try{w?.dispose?.()}catch{}});let D=e?.initialCommand;D&&(D.endsWith(`
1910
+ `)}),s&&this.requestRefresh(),{success:!0,message:`Successfully merged ${e.join(", ")} in all repos`}}catch(A){this.#r.error(`Error syncing changes from branches: ${A}`,{loggerOptions:{debug:!0}}),await this.#v();let c=await this.#U();this.#k={...this.#k,...c},this.#e.Sentry?.captureException(A,{tags:{operation:"codegen-git",endpoint:"syncChangesFromBranches"},extra:{branches:e,allowUnrelatedHistory:r}});let u=Sp(A);return{success:!1,message:u,error:A instanceof Error?A:new Error(u)}}}async getCurrentCommitHash(e="HEAD",r){if(this.#m)try{let n=["rev-parse",e];return(await this.git(n,{sys:this.#e,cwd:r})).trim()}catch{return}}async#U(e="HEAD"){let r={};for(let n of this.gitRepoContexts)try{let i=await this.getCurrentCommitHash(e,n.path);i&&(r[n.folderName]=i)}catch(i){this.#r.warn(`Failed to get commit for ${n.folderName}:`,i)}return r}async getCurrentBranch(e){return(await this.git(["branch","--show-current"],{cwd:e})).trim()}getFeatureBranch(){if(!this.#L)throw new Error("Feature branch is missing");return this.#L}getAiBranch(){if(!this.#j)throw new Error("AI branch is missing");return this.#j}async git(e,r){if(!this.#m)throw new Error("Can not execute git command in non-git mode.");let n=e[0];(n==="push"||n==="fetch"||n==="pull")&&await this.#Xe();let o=typeof r=="object"?{sys:this.#e,...r}:r,s=await this.#wt(()=>this.#qt(e,o));return this.#jt(n)&&(this.#we.clear(),this.#De.clear()),s}static#$t=new Set(["commit","merge","rebase","checkout","switch","pull","fetch","reset","cherry-pick","revert","am","stash","push"]);#jt(e){return!!e&&t.#$t.has(e)}async#H(e){if(this.#p.length===0)return{success:!0,partialSuccess:!1,results:[]};let n=(await Promise.allSettled(this.#p.map(s=>e(s)))).map((s,a)=>({folderName:this.#p[a].folderName,success:s.status==="fulfilled",result:s.status==="fulfilled"?s.value:void 0,error:s.status==="rejected"?s.reason:void 0,message:s.status==="rejected"?s.reason?.message:void 0})),i=n.filter(s=>s.success),o=n.filter(s=>!s.success);return{success:o.length===0,partialSuccess:i.length>0&&o.length>0,results:n}}#Dt(e){let r=ls(e),n=this.#p.find(a=>{let A=ls(a.folderName);return r.startsWith(A+"/")||r===A});if(n)return n;let i=e.startsWith("/")||e.includes(":")?e:this.#e.resolve(this.#C,e),o=ls(i);return this.#p.find(a=>{let A=ls(a.path);return o.startsWith(A+"/")||o===A})}#Yt(e){let r=new Map;for(let n of e){let i=this.#Dt(n);if(i){let o=r.get(i.folderName)||[];o.push(n),r.set(i.folderName,o)}}return r}#wt(e){let r=this.#ct.then(()=>e());return this.#ct=r.catch(()=>{}),r}async#qt(e,r){if(!this.#m)throw new Error(`Can not execute git command in non-git mode: git ${e.join(" ")}`);let n=`git ${e.join(" ")}`;this.#ae&&this.#e.Sentry?.captureException(new Error(`currentGitCommand is not finished yet. Current command: ${this.#ae}, New command Received: ${n}`),{tags:{operation:"codegen-git"},extra:{oldCommand:this.#ae,newCommand:n}});try{this.#ae=n;let i=typeof r=="object"?r:void 0,o=typeof r=="string"?r:i?.cwd??this.primaryGitPath;return await PA("git",e,{...i,cwd:o,sys:this.#e,timeout:60*1e3})}finally{this.#ae=void 0}}setDebug(e){this.#i=e,e&&!process.env.DEBUG?(process.env.DEBUG="1",this.#f=!0):!e&&this.#f&&(delete process.env.DEBUG,this.#f=!1)}async createTerminal(e){let r=this.#d,n=e?.terminalId||`pty_${Date.now()}_${(0,Ax.randomUUID)()}`,i=this.#tt().find(B=>B.terminalId===n),o=new Set,s=new Set;if(i&&e?.terminalId){if(!e?.force)return i;let B=this.#D.get(e.terminalId);if(!B)return i;B.onDataListeners.forEach(E=>{o.add(E)}),B.onExitListeners.forEach(E=>{s.add(E)}),this.disposeTerminal({terminalId:n,emitTerminals:!1})}let a=e?.shell||(process.platform==="win32"?"powershell.exe":process.env.SHELL||"/bin/bash"),A=e?.cols??120,c=e?.rows??30,u={...process.env,...r?.envVars,...e?.env};e?.inheritCredentials&&(u.BUILDER_USER_ID=e.createdBy??this.#s.userId,u.BUILDER_PUBLIC_KEY=this.#s.builderPublicKey,u.BUILDER_PRIVATE_KEY=this.#s.builderPrivateKey);let l=[],d=B=>{for(let E of o)E(B)},g=({exitCode:B,error:E})=>{let y=this.#D.get(n);y&&(y.state=E?"error":"exited",y.exitCode=B);for(let Q of s)Q(B);this.#D.delete(n),l.forEach(Q=>Q())},p=e?.cwd||this.#w,f,m;if(e?.readonly){f="starting";let B=!r?.hasSetupEnvVars,E=kA(a,e?.initialCommand??"true",{cwd:p,env:u,stdio:["ignore","pipe","pipe"]},B);E.on("spawn",()=>{let y=this.#D.get(n);y&&(y.state="running")}),E.stdout.on("data",y=>{d(y.toString())}),E.stderr.on("data",y=>{d(y.toString())}),E.on("error",y=>{g({exitCode:1,error:y})}),E.on("exit",y=>{g({exitCode:y??0})}),l.push(()=>{try{E.removeAllListeners()}catch{}E.kill()}),m=E}else{f="running";let B=dL(this.#e);if(!B)throw new Error("Could not import node-pty");let E=a.includes("bash")||a.includes("zsh"),y=a.includes("zsh")?"%~ $ ":"\\w $ ",Q=B.spawn(a,[],{name:"xterm-color",cwd:p,cols:A,rows:c,env:E?{...u,PS1:y}:u}),b=Q.onData(d);l.push(()=>{try{b?.dispose?.()}catch{}});let w=Q.onExit(g);l.push(()=>{try{w?.dispose?.()}catch{}});let D=e?.initialCommand;D&&(D.endsWith(`
1911
1911
  `)||(D+=`
1912
- `),Q.write(D)),m=Q}let C=Date.now(),I={terminalId:n,title:e?.title||`Terminal ${this.#D.size+1}`,cwd:p,createdAt:C,lastWrittenAt:C,createdBy:e?.createdBy||"unknown",readonly:e?.readonly??!1,initialCommand:e?.initialCommand,builtIn:!1,state:f,stale:!1,exitCode:void 0,command:void 0};return this.#D.set(n,{...I,pty:m,onDataListeners:o,onExitListeners:s,disposeFns:l,env:e?.env,shell:a,inheritCredentials:e?.inheritCredentials}),(e?.emitTerminals??!0)&&this.#ge(),I}#et(){let e=this.getSessionContext(),r=Array.from(this.#D.values()).map(o=>({terminalId:o.terminalId,title:o.title,cwd:o.cwd,createdAt:o.createdAt,lastWrittenAt:o.lastWrittenAt,createdBy:o.createdBy,readonly:o.readonly,builtIn:o.builtIn,exitCode:o.exitCode,state:o.state,stale:o.stale,command:o.command})),n=[];this.#y?.includes("Bash")&&n.push({terminalId:"bash-tools",title:"Bash",cwd:this.#w,createdAt:e.createdUnixTime,lastWrittenAt:Date.now(),createdBy:"fusion",readonly:!0,builtIn:!0,exitCode:void 0,state:"running",command:void 0});let i=this.#d;if(i){let o=Date.now();if(i.devState!=="unset"&&n.push({terminalId:"dev-command",title:"Dev Command",cwd:this.#w,createdAt:e.createdUnixTime,lastWrittenAt:o,createdBy:"fusion",readonly:!i.devCommandProcess?.write,builtIn:!0,state:i.devState==="running"?"running":"exited",exitCode:void 0,command:i.devCommand}),i.setupCommand&&n.push({terminalId:"setup-command",title:"Setup Command",cwd:this.#w,createdAt:e.createdUnixTime,lastWrittenAt:o,createdBy:"fusion",readonly:!0,builtIn:!0,state:i.setupState==="installing"?"running":"exited",exitCode:void 0,command:i.setupCommand}),i.validateCommandState!=="unset"){let s;switch(i.validateCommandState){case"running":s="running";break;case"success":s="exited";break;case"failure":s="error";break;case"stopped":s="exited";break}n.unshift({terminalId:"validate-command",title:"Validate Command",cwd:this.#w,createdAt:e.createdUnixTime,lastWrittenAt:o,createdBy:"fusion",readonly:!0,builtIn:!0,state:s,exitCode:void 0,command:i.validateCommand})}}return n.push(...r),n}#ge(){this.#u.emit("step",{type:"terminals",terminals:this.#et()})}updateTerminal({terminalId:e,cols:r,rows:n,title:i}){if(e==="dev-command"){if(r||n){let s=this.#d;if(s?.devCommandProcess?.resize)return s.devCommandProcess.resize(r,n),!0}return!1}let o=this.#D.get(e);return o?("resize"in o.pty&&(r||n)&&o.pty.resize(r??o.pty.cols,n??o.pty.rows),i&&(o.title=i,this.#ge()),!0):!1}writeTerminal({terminalId:e,data:r}){if(e==="dev-command"){let i=this.#d;return i?.devCommandProcess?.write?(i.devCommandProcess.write(r),!0):!1}let n=this.#D.get(e);return!n||n.readonly?!1:("write"in n.pty&&n.pty.write(r),n.lastWrittenAt=Date.now(),!0)}signalTerminal({terminalId:e,signal:r}){if(e==="dev-command"){let i=this.#d;return i?.devCommandProcess?.kill?(i.devCommandProcess.kill(r),!0):!1}let n=this.#D.get(e);if(!n||n.readonly)return!1;try{"write"in n.pty?process.platform==="win32"?n.pty.kill():(r==="SIGINT"&&n.pty.write(""),n.pty.kill(r)):n.pty.kill(r)}catch{}return!0}disposeTerminal({terminalId:e,emitTerminals:r=!0}){let n=this.#D.get(e);if(!n)return!1;try{n.pty.kill()}catch{}return n.disposeFns.forEach(i=>{try{i()}catch{}}),n.onDataListeners.clear(),n.onExitListeners.clear(),n.disposeFns=[],this.#D.delete(e),r&&this.#ge(),!0}async restartTerminal({terminalId:e}){if(e==="dev-command"){let i=this.#d;if(i)try{return await i.restart(),!0}catch(o){return this.#e.Sentry?.captureException(o),!1}return!1}if(e==="setup-command"){let i=this.#d;if(i)try{return await i.runSetupCommand(),!0}catch(o){return this.#e.Sentry?.captureException(o),!1}return!1}if(e==="validate-command"){if(this.#d)try{return await this.#xt(),!0}catch(o){return this.#e.Sentry?.captureException(o),!1}return!1}if(e==="bash-tools")return!1;let r=this.#D.get(e);return r?(await this.createTerminal({terminalId:e,title:r.title,cwd:r.cwd,env:r.env,shell:r.shell,cols:"cols"in r.pty?r.pty.cols:void 0,rows:"rows"in r.pty?r.pty.rows:void 0,createdBy:r.createdBy,emitTerminals:!1,initialCommand:r.initialCommand,readonly:r.readonly,inheritCredentials:r.inheritCredentials,force:!0}),this.#D.get(e)?(this.#ge(),!0):!1):!1}subscribeTerminal({terminalId:e,onData:r,onExit:n}){if(e==="dev-command"){let i=this.#d;if(i){let o=i.getDevWrite();return o&&r(o),i.emitter.on("stdout",r),i.emitter.on("stderr",r),()=>{i.emitter.off("stdout",r),i.emitter.off("stderr",r)}}}else if(e==="setup-command"){let i=this.#d;if(i){let o=i.getSetupOutput();return o&&r(o),i.emitter.on("installStdout",r),i.emitter.on("installStderr",r),()=>{i.emitter.off("installStdout",r),i.emitter.off("installStderr",r)}}}else if(e==="validate-command"){let i=this.#d;if(i){let o=i.getValidateOutput();return o&&r(o),i.emitter.on("validateStdout",r),i.emitter.on("validateStderr",r),()=>{i.emitter.off("validateStdout",r),i.emitter.off("validateStderr",r)}}}else if(e==="bash-tools"){let i=o=>{o.type==="stdio"&&o.source==="tool-command"&&r(o.content)};return this.#u.on("step",i),()=>{this.#u.off("step",i)}}else{let i=this.#D.get(e);if(!i)throw new Error("Terminal not found");return i.onDataListeners.add(r),n&&i.onExitListeners.add(n),()=>{i.onDataListeners.delete(r),n&&i.onExitListeners.delete(n)}}}async getAllFiles(e={}){let{getDotFiles:r=!1,globbyPattern:n="**/*",includePattern:i,gitignore:o,deep:s,truncate:a,maxFiles:A=5e4,onlyFiles:c=!0}=e,u=this.#A?.accessControl,l=u?.entries?.filter(f=>f.action==="allow"&&f.permissions.includes("list")).map(f=>(f.resource.startsWith("/")?f.resource.slice(1):f.resource)||".")??[];if(!this.#I?.folders?.length){let f=await Wg({basePath:this.#C,globPattern:[i??n,...l],extraIgnorePatterns:Y0(u).deny,dot:r,gitignore:o,sys:this.#e,deep:s,onlyFiles:c,maxFiles:A});return b1(f,a)}let d=[],g=await this.#e.readdir(this.#C);for(let f of g)KK(f)&&d.push(f);!d.includes("AGENTS.md")&&this.#I.agentsMD&&d.push("AGENTS.md");for(let f of this.#I.folders){let m=this.#e.resolve(this.#C,f.path),C=await Wg({basePath:m,globPattern:[n,...l],dot:r,gitignore:o,sys:this.#e,deep:s,onlyFiles:c,maxFiles:A}),I=this.#R()?".":f.name||this.#e.basename(m);for(let B of C)I!=="."?d.push(this.#e.join(I,B)):d.push(B)}let p=wf({files:d,policy:u,filterPattern:i,getDotFiles:r});return b1(p,a)}async searchFiles(e){let{query:r,caseInsensitive:n=!0,includeGlob:i,excludeGlob:o,maxResults:s=1e3,contextBefore:a=0,contextAfter:A=0}=e,c=await Ym(this.#e),u=["--path-separator","/","--json","--line-number","--column","--hidden","--max-columns","500"];return n&&u.push("-i"),a>0&&u.push("-B",a.toString()),A>0&&u.push("-A",A.toString()),i&&u.push("--glob",i),o&&u.push("--glob",`!${o}`),u.push("--ignore-file",".builderignore"),u.push("--",r),new Promise(l=>{let d=FA({command:c,args:u,options:{env:process.env,cwd:this.#w,stdio:["ignore","pipe","pipe"]}}),g=new Qi(5e4);d.stdout.on("data",p=>{g.write(p.toString())}),d.on("error",()=>{l({matches:[],totalMatches:0,filesWithMatches:0,truncated:!1})}),d.on("close",p=>{if(p!==0)l({matches:[],totalMatches:0,filesWithMatches:0,truncated:!1});else{let f=[],m=new Set,I=g.getContent().split(`
1912
+ `),Q.write(D)),m=Q}let C=Date.now(),I={terminalId:n,title:e?.title||`Terminal ${this.#D.size+1}`,cwd:p,createdAt:C,lastWrittenAt:C,createdBy:e?.createdBy||"unknown",readonly:e?.readonly??!1,initialCommand:e?.initialCommand,builtIn:!1,state:f,stale:!1,exitCode:void 0,command:void 0};return this.#D.set(n,{...I,pty:m,onDataListeners:o,onExitListeners:s,disposeFns:l,env:e?.env,shell:a,inheritCredentials:e?.inheritCredentials}),(e?.emitTerminals??!0)&&this.#ge(),I}#tt(){let e=this.getSessionContext(),r=Array.from(this.#D.values()).map(o=>({terminalId:o.terminalId,title:o.title,cwd:o.cwd,createdAt:o.createdAt,lastWrittenAt:o.lastWrittenAt,createdBy:o.createdBy,readonly:o.readonly,builtIn:o.builtIn,exitCode:o.exitCode,state:o.state,stale:o.stale,command:o.command})),n=[];this.#y?.includes("Bash")&&n.push({terminalId:"bash-tools",title:"Bash",cwd:this.#w,createdAt:e.createdUnixTime,lastWrittenAt:Date.now(),createdBy:"fusion",readonly:!0,builtIn:!0,exitCode:void 0,state:"running",command:void 0});let i=this.#d;if(i){let o=Date.now();if(i.devState!=="unset"&&n.push({terminalId:"dev-command",title:"Dev Command",cwd:this.#w,createdAt:e.createdUnixTime,lastWrittenAt:o,createdBy:"fusion",readonly:!i.devCommandProcess?.write,builtIn:!0,state:i.devState==="running"?"running":"exited",exitCode:void 0,command:i.devCommand}),i.setupCommand&&n.push({terminalId:"setup-command",title:"Setup Command",cwd:this.#w,createdAt:e.createdUnixTime,lastWrittenAt:o,createdBy:"fusion",readonly:!0,builtIn:!0,state:i.setupState==="installing"?"running":"exited",exitCode:void 0,command:i.setupCommand}),i.validateCommandState!=="unset"){let s;switch(i.validateCommandState){case"running":s="running";break;case"success":s="exited";break;case"failure":s="error";break;case"stopped":s="exited";break}n.unshift({terminalId:"validate-command",title:"Validate Command",cwd:this.#w,createdAt:e.createdUnixTime,lastWrittenAt:o,createdBy:"fusion",readonly:!0,builtIn:!0,state:s,exitCode:void 0,command:i.validateCommand})}}return n.push(...r),n}#ge(){this.#u.emit("step",{type:"terminals",terminals:this.#tt()})}updateTerminal({terminalId:e,cols:r,rows:n,title:i}){if(e==="dev-command"){if(r||n){let s=this.#d;if(s?.devCommandProcess?.resize)return s.devCommandProcess.resize(r,n),!0}return!1}let o=this.#D.get(e);return o?("resize"in o.pty&&(r||n)&&o.pty.resize(r??o.pty.cols,n??o.pty.rows),i&&(o.title=i,this.#ge()),!0):!1}writeTerminal({terminalId:e,data:r}){if(e==="dev-command"){let i=this.#d;return i?.devCommandProcess?.write?(i.devCommandProcess.write(r),!0):!1}let n=this.#D.get(e);return!n||n.readonly?!1:("write"in n.pty&&n.pty.write(r),n.lastWrittenAt=Date.now(),!0)}signalTerminal({terminalId:e,signal:r}){if(e==="dev-command"){let i=this.#d;return i?.devCommandProcess?.kill?(i.devCommandProcess.kill(r),!0):!1}let n=this.#D.get(e);if(!n||n.readonly)return!1;try{"write"in n.pty?process.platform==="win32"?n.pty.kill():(r==="SIGINT"&&n.pty.write(""),n.pty.kill(r)):n.pty.kill(r)}catch{}return!0}disposeTerminal({terminalId:e,emitTerminals:r=!0}){let n=this.#D.get(e);if(!n)return!1;try{n.pty.kill()}catch{}return n.disposeFns.forEach(i=>{try{i()}catch{}}),n.onDataListeners.clear(),n.onExitListeners.clear(),n.disposeFns=[],this.#D.delete(e),r&&this.#ge(),!0}async restartTerminal({terminalId:e}){if(e==="dev-command"){let i=this.#d;if(i)try{return await i.restart(),!0}catch(o){return this.#e.Sentry?.captureException(o),!1}return!1}if(e==="setup-command"){let i=this.#d;if(i)try{return await i.runSetupCommand(),!0}catch(o){return this.#e.Sentry?.captureException(o),!1}return!1}if(e==="validate-command"){if(this.#d)try{return await this.#xt(),!0}catch(o){return this.#e.Sentry?.captureException(o),!1}return!1}if(e==="bash-tools")return!1;let r=this.#D.get(e);return r?(await this.createTerminal({terminalId:e,title:r.title,cwd:r.cwd,env:r.env,shell:r.shell,cols:"cols"in r.pty?r.pty.cols:void 0,rows:"rows"in r.pty?r.pty.rows:void 0,createdBy:r.createdBy,emitTerminals:!1,initialCommand:r.initialCommand,readonly:r.readonly,inheritCredentials:r.inheritCredentials,force:!0}),this.#D.get(e)?(this.#ge(),!0):!1):!1}subscribeTerminal({terminalId:e,onData:r,onExit:n}){if(e==="dev-command"){let i=this.#d;if(i){let o=i.getDevWrite();return o&&r(o),i.emitter.on("stdout",r),i.emitter.on("stderr",r),()=>{i.emitter.off("stdout",r),i.emitter.off("stderr",r)}}}else if(e==="setup-command"){let i=this.#d;if(i){let o=i.getSetupOutput();return o&&r(o),i.emitter.on("installStdout",r),i.emitter.on("installStderr",r),()=>{i.emitter.off("installStdout",r),i.emitter.off("installStderr",r)}}}else if(e==="validate-command"){let i=this.#d;if(i){let o=i.getValidateOutput();return o&&r(o),i.emitter.on("validateStdout",r),i.emitter.on("validateStderr",r),()=>{i.emitter.off("validateStdout",r),i.emitter.off("validateStderr",r)}}}else if(e==="bash-tools"){let i=o=>{o.type==="stdio"&&o.source==="tool-command"&&r(o.content)};return this.#u.on("step",i),()=>{this.#u.off("step",i)}}else{let i=this.#D.get(e);if(!i)throw new Error("Terminal not found");return i.onDataListeners.add(r),n&&i.onExitListeners.add(n),()=>{i.onDataListeners.delete(r),n&&i.onExitListeners.delete(n)}}}async getAllFiles(e={}){let{getDotFiles:r=!1,globbyPattern:n="**/*",includePattern:i,gitignore:o,deep:s,truncate:a,maxFiles:A=5e4,onlyFiles:c=!0}=e,u=this.#A?.accessControl,l=u?.entries?.filter(f=>f.action==="allow"&&f.permissions.includes("list")).map(f=>(f.resource.startsWith("/")?f.resource.slice(1):f.resource)||".")??[];if(!this.#I?.folders?.length){let f=await Wg({basePath:this.#C,globPattern:[i??n,...l],extraIgnorePatterns:Y0(u).deny,dot:r,gitignore:o,sys:this.#e,deep:s,onlyFiles:c,maxFiles:A});return b1(f,a)}let d=[],g=await this.#e.readdir(this.#C);for(let f of g)KK(f)&&d.push(f);!d.includes("AGENTS.md")&&this.#I.agentsMD&&d.push("AGENTS.md");for(let f of this.#I.folders){let m=this.#e.resolve(this.#C,f.path),C=await Wg({basePath:m,globPattern:[n,...l],dot:r,gitignore:o,sys:this.#e,deep:s,onlyFiles:c,maxFiles:A}),I=this.#R()?".":f.name||this.#e.basename(m);for(let B of C)I!=="."?d.push(this.#e.join(I,B)):d.push(B)}let p=wf({files:d,policy:u,filterPattern:i,getDotFiles:r});return b1(p,a)}async searchFiles(e){let{query:r,caseInsensitive:n=!0,includeGlob:i,excludeGlob:o,maxResults:s=1e3,contextBefore:a=0,contextAfter:A=0}=e,c=await Ym(this.#e),u=["--path-separator","/","--json","--line-number","--column","--hidden","--max-columns","500"];return n&&u.push("-i"),a>0&&u.push("-B",a.toString()),A>0&&u.push("-A",A.toString()),i&&u.push("--glob",i),o&&u.push("--glob",`!${o}`),u.push("--ignore-file",".builderignore"),u.push("--",r),new Promise(l=>{let d=FA({command:c,args:u,options:{env:process.env,cwd:this.#w,stdio:["ignore","pipe","pipe"]}}),g=new Qi(5e4);d.stdout.on("data",p=>{g.write(p.toString())}),d.on("error",()=>{l({matches:[],totalMatches:0,filesWithMatches:0,truncated:!1})}),d.on("close",p=>{if(p!==0)l({matches:[],totalMatches:0,filesWithMatches:0,truncated:!1});else{let f=[],m=new Set,I=g.getContent().split(`
1913
1913
  `),B=[],E=null;for(let Q of I)if(Q.trim())try{let b=JSON.parse(Q);if(b.type==="match"){let w=b.data.path.text,D=b.data.line_number,x=b.data.lines.text.trimEnd(),S=b.data.submatches||[],L,H;S.length>0&&(L=S[0].start,H=S[0].end),m.add(w);let K={filePath:w,lineNumber:D,lineContent:x,columnStart:L,columnEnd:H,contextBefore:B,contextAfter:[]};if(B=[],E=K,f.push(K),f.length>=s)break}else if(b.type==="context"){let w=b.data.line_number,D=b.data.lines.text.trimEnd();E&&w>E.lineNumber?E.contextAfter.push(D):B.push(D)}}catch{continue}let y=f.length>=s;l({matches:f,totalMatches:f.length,filesWithMatches:m.size,truncated:y})}})})}async searchFileTree(e){let{query:r,excludeGlob:n,maxResults:i=100}=e,o=await Ym(this.#e),s=["--files","--path-separator","/"],a=$ae(r);a&&s.push("--glob",a),n&&s.push("--glob",`!${n}`);let A=this.#A?.accessControl,c=Y0(A).deny;for(let l of c)s.push("--glob",`!${l}`);s.push("--ignore-file",".builderignore");let u=r.toLowerCase();return new Promise(l=>{let d=FA({command:o,args:s,options:{env:process.env,cwd:this.#w,stdio:["ignore","pipe","pipe"]}}),g=new Qi(1e5);d.stdout.on("data",p=>{g.write(p.toString())}),d.on("error",()=>{l({matches:[],totalMatches:0,truncated:!1})}),d.on("close",p=>{if(p!==0&&p!==1){l({matches:[],totalMatches:0,truncated:!1});return}let f=g.getContent(),m=[...new Set(f.split(`
1914
- `).filter(B=>B.trim()))];m=wf({files:m,policy:A,getDotFiles:!0});let C=[];for(let B of m){let E=B.lastIndexOf("/"),y=E>=0?B.slice(E+1):B,Q=E>=0?B.slice(0,E):"",b=Hae(u,B.toLowerCase()),w=Jae(u,B,b);C.push({filePath:B,fileName:y,parentPath:Q,matchIndices:b,score:w})}C.sort((B,E)=>E.score-B.score);let I=C.slice(0,i).map(({score:B,...E})=>E);l({matches:I,totalMatches:m.length,truncated:m.length>i})})})}async collectRepoMetrics(e={}){let r=this.#ve(e.folderName);return e.rootPath&&(r=this.#e.join(r,e.rootPath)),oAe(this.#e,r)}getSessionId(){return this.getSessionContext().sessionId}updateMetadata(e){this.#rt(e,!1)}getMetadata(){return this.#K}#tt=null;setTimeline(e){this.#tt=e}getTimeline(){return this.#tt}getSpaceId(){return this.#s.builderPublicKey}async revertToCommitSnapshot(e){this.#F=!1,await this.waitUntilBlockingPendingPromises(),await this.abortMerge(!1),await this.#re(!1);let n=(await this.#H(async a=>{let A=tl(e,a.folderName,this.gitRepoContexts[0]?.folderName);return A?(await this.git(["revert","--no-commit",`${A}..HEAD`],{cwd:a.path}),await this.git(["commit","--allow-empty","--quiet","--no-verify","--no-gpg-sign","-m","Revert changes"],{cwd:a.path}),{commitHash:await this.getCurrentCommitHash("HEAD",a.path)}):(this.#r.warn(`No commit found for ${a.folderName}, skipping revert`),{skipped:!0})})).results.filter(a=>!a.success);if(n.length>0)throw new Error(`Failed to revert ${n.length} repos`);let i=await this.#L();if(this.#k={...this.#k,...i},!(await this.#v())?.currentCommit){this.#e.Sentry?.captureException(new Error("Failed to get current commit hash after revert"),{tags:{operation:"codegen-git",endpoint:"revertToCommitHash"}});return}this.requestRefresh(),await this.#pe({lastCommit:Os(i)})}async revertToCommitHash(e){let r=Pf(e,this.gitRepoContexts[0]?.folderName),n=Object.keys(r).length===0?e:Os(r);return this.revertToCommitSnapshot(n)}async resetToCommitSnapshot(e,r=!0){this.#F=!1,await this.waitUntilBlockingPendingPromises(),await this.abortMerge(!1),await this.#re(!1);let i=(await this.#H(async s=>{let a=tl(e,s.folderName,this.gitRepoContexts[0]?.folderName);if(!a)return this.#r.warn(`No commit found for ${s.folderName}, skipping reset`),{skipped:!0};await this.git(["reset","--quiet","--hard",a],{cwd:s.path}),await this.git(["clean","-fd"],{cwd:s.path});let A=await this.getCurrentCommitHash("HEAD",s.path);if(A!==a)throw new Error(`Failed to reset commit hash for ${s.folderName}: expected ${a}, got ${A}`);return{commitHash:A}})).results.filter(s=>!s.success);if(i.length>0)throw new Error(`Failed to reset ${i.length} repos`);let o=Pf(e,this.gitRepoContexts[0]?.folderName);this.#k={...this.#k,...o},await this.#v(),r&&this.requestRefresh()}async resetToCommitHash(e,r=!0){let n=Pf(e,this.gitRepoContexts[0]?.folderName),i=Object.keys(n).length===0?e:Os(n);return this.resetToCommitSnapshot(i,r)}async restore({location:e,predicate:r,revert:n=!1,dryRun:i=!1,forceReplay:o=!1,debug:s}){let a=this.getSessionContext(),A=a.turns.length,c=null;for(let p=A-1;p>=-1;p--)if(r(p>=0?a.turns[p]:null,p)){c=p;break}if(c===null)return{undone:null,message:"Could not find the target to restore to, the completion id could be wrong"};n||await this.abort({cleanCurrentMessage:!0});let u=new Map,l=!!this.#m,d=a.turns,g=Math.max(0,e==="before"?c:c+1);for(let p=d.length-1;p>=g;p--){let f=d[p];for(let m of f.applyResults)u.set(m.filePath,m.oldContent??"")}if(!i){let p;if(l){c===-1?a.beforeCommit?p=a.beforeCommit:d.length>0&&(p=d[0].beforeCommit):c<d.length&&(e==="after"?(p=d[c].afterCommit,!p&&c+1<d.length&&(p=d[c+1].beforeCommit)):p=d[c].beforeCommit);let I={commitSnapshot:p,sessionId:a.sessionId,sessionBeforeCommit:a.beforeCommit,turnsLength:d.length,targetIndex:c,currentTurn:d[d.length-1],targetTurn:d[c],targetTurnNext:d[c+1],location:e,forceReplay:o,dryRun:i,debug:s};if(!p)return this.#e.Sentry?.captureException(new Error("No commit snapshot found for restore"),{tags:{operation:"codegen-git",endpoint:"revertToCommitHash"},contexts:{restore:I}}),{undone:null,message:"Could not find the target to restore to, the git history is missing"};try{n?await this.revertToCommitSnapshot(p):await this.resetToCommitSnapshot(p)}catch(B){return this.#e.Sentry?.captureException(new Error("Error resetting git",{cause:B}),{tags:{operation:"codegen-git",endpoint:"resetToCommitHash"},contexts:{restore:I}}),{undone:null,message:"Failed to reset/restore, the file history is missing"}}}else for(let[I,B]of u.entries())try{B?await this.writeFile(I,B):await this.deleteFile(I)}catch{}if(n)return{undone:[],message:"The revert operation was successful"};let f=d.splice(g,d.length-g),m=zA(d);m&&m?.afterCommit!==p&&(this.#e.Sentry?.captureException(new Error("Reset After commit snapshot mismatch"),{tags:{operation:"codegen-git",endpoint:"resetToCommitHash"},extra:{lastTurn:m,commitSnapshot:p}}),m.lastCommit=p,await this.#pe({completionId:m.completionId,lastCommit:p}));let C=m?.completionId;if(f.length>0&&(await MK(this.#e,this.#s,{lastCompletionId:C,sessionId:a.sessionId},!!this.#i),a.updatedUnixTime=Date.now()),o){let I=a.state;this.#u.emit("step",{type:"batch",steps:[{type:"state",newState:"replay",abortable:!1,previousState:I},...this.#St(),{type:"restore",files:Array.from(u.keys()),lastCompletionId:C,location:e},{type:"state",newState:I,abortable:!1,previousState:"replay"}]})}else f.length>0&&this.#u.emit("step",{type:"restore",files:Array.from(u.keys()),lastCompletionId:C,location:e})}return await this.#vt(),{undone:Array.from(u.keys()),message:"The restore operation was successful"}}async#vt(e){return await this.#d?.ensureDevCommand(e)}async restoreFromCompletionId({location:e,completionId:r,forceReplay:n}){let i=this.getSessionContext();return i.turns.find(s=>s.completionId===r)?this.restore({location:e,predicate:s=>s?.completionId===r,forceReplay:n,debug:`restore to: ${r}`}):(await this.#he,i.turns=[],i.canLoadMore=!0,await MK(this.#e,this.#s,{sessionId:i.sessionId,lastCompletionId:r},!!this.#i),await this.loadMoreTurns(),this.restore({location:e,predicate:()=>!0,forceReplay:!0,debug:"restore after history"}))}async restoreBeforeCompletionId(e){return this.restoreFromCompletionId({location:"before",completionId:e,forceReplay:!1})}async undoLastUserMessage(e=!1){return this.restore({location:"before",predicate:r=>r?.user.role==="user",dryRun:e})}getLastUserCompletionId(){let e=this.getSessionContext();return Zhe(e)?.completionId}getLastCompletionId(){let e=this.getSessionContext();return NK(e)?.completionId}getCurrentState(){return this.getSessionContext().state}getLastApplyResultsTurn(){let e=this.getSessionContext();return Xhe(e)}getLastTurn(){let e=this.getSessionContext();return NK(e)}getLastMessage(){return this.getLastTurn()?.actions.find(r=>r.type==="text")?.content}getNextUrl(){return this.getLastTurn()?.nextUrl}async sendFeedback(e){if(process.env.NODE_ENV==="test")return;if(e.feedbackSentiment){let n=e.feedbackSentiment==="positive"?`User provided positive feedback (thumbs up) on the previous completion.${e.feedbackText??""}`:`User provided negative feedback (thumbs down) on the previous completion.${e.feedbackText??""}`;this.queueSystemReminder({text:n,tag:"reminder:user-feedback"})}Qt("quality code feedback given",{spaceId:this.#s.builderPublicKey,sentiment:e.feedbackSentiment,mode:"cli"});let r=e.id??this.getLastCompletionId();r&&await this.#zt({...e,id:r})}#pe(e){let r=e.completionId;if(!r){let i=this.getLastTurn();i&&e.lastCommit&&(i.lastCommit=e.lastCommit),r=i?.completionId}let n=TK(this.#e,this.#s,"/codegen/finalize",{completionId:r,projectId:this.#A?.projectId,branchName:this.#A?.branchName,userCompletionId:this.getLastUserCompletionId(),sessionId:this.getSessionId(),metadata:this.#K,hasPlanToApply:this.#F,...e},this.#i);return this.#J(n,"completionFinalize")}#zt(e){let r=TK(this.#e,this.#s,"/codegen/feedback",e,this.#i);return this.#J(r,"completionFeedback")}#U(e,r,n={}){this.#d?.emitter.emit("metrics",{durations:[{key:e,ms:r,attributes:n}]})}#J(e,r,n=!1){let i=$a();this.#r.debug(`(addToPendingPromises-${i}): adding ${r} (blocking: ${n})`),this.#ue.push(e),n&&this.#Me.push(e);let o=new Error(`Deadlock detected in codegen (function: ${r})`),s=setTimeout(()=>{this.#e.Sentry?.captureException(o,{level:"fatal",tags:{operation:"codegen-stream",functionName:r,sessionId:this.getSessionId(),projectId:this.#Q,branchName:this.#P}})},300*1e3);return e.finally(()=>{clearTimeout(s),this.#r.debug(`(addToPendingPromises-${i}): removing ${r} (blocking: ${n})`);let a=this.#Me.indexOf(e);a!==-1&&this.#Me.splice(a,1);let A=this.#ue.indexOf(e);A!==-1&&this.#ue.splice(A,1)})}async lastTurnHasChanges(){let e=await this.undoLastUserMessage(!0);return e.undone?e.undone.length>0:!1}#$(e){let r=this.getSessionContext(),n=r.state;return n!==e?(r.state=e,this.#u.emit("step",{type:"state",abortable:e==="generating",previousState:n,newState:e}),!0):!1}waitUntilState(e,r=1e4){return new Promise(n=>{if(this.getSessionContext().state===e){n();return}let o,s=a=>{a.type==="state"&&a.newState===e&&(clearTimeout(o),this.#u.removeListener("step",s),n())};o=setTimeout(()=>{this.#u.removeListener("step",s),n()},r),this.#u.on("step",s)})}getProxyConfig(){return Hoe({devServerUrl:this.#A?.serverUrl,proxyOrigin:this.#Ne,proxyDefaultOrigin:this.#Te,proxyDestination:this.#ft})}async clearSession(){this.#r.debug("(clearSession): clearing session"),await this.abort({cleanCurrentMessage:!0,flushMessageQueue:!1});let e=this.getSessionContext();e.turns=[],e.customInstructions=await this.#be(),e.customAgents=await this.#Ue(),this.#G.length=0,this.#F=!1,this.#K={},this.#Z=void 0,this.#Fe=!1,this.clearMessageQueue(),this.queueGitStatusReminder({trigger:"session-start"})}async clearMessageQueue(e=!1){let r=[];if(e)for(let n of this.#t)n.user&&r.push({type:"user",displayPrompt:n.displayPrompt,user:n.user,role:n.user.role,compacting:!1,idempotencyKey:n.idempotencyKey});this.#t.length=0,this.#Ge(),r.length>0&&this.#u.emit("step",{type:"batch",steps:r})}updateMessage(e){if(e.type==="delete"){let r=this.#t.findIndex(n=>n.idempotencyKey===e.idempotencyKey);r>=0&&this.#t.splice(r,1)}else if(e.type==="move"){let r=this.#t.findIndex(n=>n.idempotencyKey===e.idempotencyKey);r>=0&&gCe(this.#t,r,r+e.delta)}this.#Ge()}async flushMessageQueue(){this.#r.debug("(flushMessageQueue): flushing message queue"),await this.abort({cleanCurrentMessage:!1,flushMessageQueue:!0}),this.#l&&this.#l()}#bt(e){let r=e.idempotencyKey;if(r){let n=this.#t.findIndex(i=>i.idempotencyKey===r);if(n>=0)return this.#t[n]=e,!1}else e.idempotencyKey=(0,Ax.randomUUID)();if(e.queue==null&&(e.queue=!0),e.user?e.user={...this.#Z,...e.user}:e.user=this.#Z,e.userPrompt==="___BROWSER_AUTOMATION_PROMPT___"){let n=this.getProxyConfig();e.userPrompt=Yae(n.proxyDefaultOrigin,this.#ye||void 0)}return this.#t.push(e),!0}async sendMessage(e){this.#Fe=!1;let r=0;if(Array.isArray(e))for(let i of e)this.#bt(i)&&r++;else this.#bt(e)&&r++;if(r===0)return null;this.#r.debug(`(sendMessage): added messages(${r}) to queue(${this.#t.length})`),this.#Ge();let n=this.#t[this.#t.length-1];return n?(this.#F=!1,this.cancelAllPendingToolFulfilments(n.userPrompt),n.queue?this.#l&&this.#l():await this.flushMessageQueue(),await el(),n.idempotencyKey):null}#Vt(){if(this.#c==="until-idle")return;let e=this.#t;if(e.length!==0){for(let r of e)if(r.systemReminders)for(let n of r.systemReminders)this.queueSystemReminder(n);return this.#o=PK(e),this.#Z=this.#o.user,this.#o.softContextWindow&&(this.#S=Math.min(this.#S??3e4,this.#o.softContextWindow)),this.clearMessageQueue(!0),this.#o}}#Wt(){let e=this.#t.length===0||this.#Fe,r=new Promise(n=>{e?this.#l=n:n()}).then(()=>{let n=this.#t;if(n.length!==0)if(this.#c==="until-idle"){let i=this.#t.shift();if(i.user&&(this.#Z=i.user,this.#u.emit("step",{type:"user",displayPrompt:i.displayPrompt,user:i.user,role:i.user.role,compacting:!1,idempotencyKey:i.idempotencyKey})),i.systemReminders)for(let o of i.systemReminders)this.queueSystemReminder(o);return this.#o=i,this.#Z=i.user,this.#o.softContextWindow&&(this.#S=Math.min(this.#S??3e4,this.#o.softContextWindow)),this.#Ge(),i}else{for(let o of n)if(o.systemReminders)for(let s of o.systemReminders)this.queueSystemReminder(s);let i=PK(n);if(!i.dropAbortedPrompt&&this.#o){let o=i.idempotencyKey;i=HK(this.#o,i),i.idempotencyKey=o}return this.clearMessageQueue(!0),this.#o=i,this.#Z=i.user,i}});return{shouldWait:e,promise:r}}#Ge(){this.#u.emit("step",{type:"message-queue",queue:this.#t.map(e=>({idempotencyKey:e.idempotencyKey,displayPrompt:e.displayPrompt,user:e.user}))})}#rt(e,r=!1){r&&(this.#K={}),Object.assign(this.#K,e),this.#u.emit("step",{type:"metadata",...this.#K})}async waitForSetupCommand(e){let r=this.#d;if(!r)return{state:"installed",shouldProceed:!0};if(r.setupState==="installing")try{await Fc(r.setupCommandPromise,e)}catch{}let n=r.setupState;return n==="not-installed"||n==="install-failed"||n==="install-aborted"?{state:n,shouldProceed:!0}:{state:"installed",shouldProceed:!0}}async waitForDevServer(e,r,n){if(!this.#d&&this.#A?.serverUrl)return{shouldProceed:!0,message:"Dev server is ready.",serverUrl:this.#A.serverUrl};let i=await this.waitForSetupCommand(e);if(!i.shouldProceed)return{shouldProceed:!1,message:`Project setup command did not completed. State: ${i.state}`};let o=this.#d;if(o){await o.ensureDevCommand(e);let s=await o.waitUntilServer(e,r,n);return s.ok?{shouldProceed:!0,message:"Dev server is ready.",serverUrl:o.serverUrl?.toString()}:{shouldProceed:!1,message:s.message,serverUrl:void 0}}return{shouldProceed:!1,message:"Dev server is not ready.",serverUrl:void 0}}async getNamedAgentConfig(e,r,n){let i=this.getSessionContext(),o=i.customAgents,s=e?o.find(L=>L.name.toLowerCase()===e.toLowerCase()):void 0,a=s?.name??"explorer",{mcpServers:A=!1,model:c,mode:u="quality-v4-agent",systemPrompt:l,subagent_type:d,includeMemories:g,needDevServer:p,needValidation:f,queueMode:m,asyncSubAgents:C,resetAfterRun:I=!1,reasoning:B}={mcpServers:s?.mcpServers,subagent_type:a,systemPrompt:s?.systemPrompt,model:(()=>{if(s?.roundRobinModels?.length){let L=s.name,H=this.#ht.get(L)??0;return this.#ht.set(L,H+1),s.roundRobinModels[H%s.roundRobinModels.length]}return s?.model})(),mode:s?.mode,includeMemories:s?.includeMemories??a==="explorer",needDevServer:s?.needDevServer,needValidation:s?.needValidation,resetAfterRun:s?.resetAfterRun,queueMode:s?.queueMode,asyncSubAgents:s?.asyncSubAgents,reasoning:s?.reasoning??this.#Ye},E=["Read","Glob","ReadRule","Grep","WebSearch","SearchMemories"];i.sessionMode==="deep-research"&&E.push("Bash","WebFetch"),E=E.filter(L=>this.#y?this.#y.includes(L):!0),E.push("ExplorationMetadata");let y=sx(this.#A,s?.tools??E),Q=c===void 0?d==="explorer"?"opa5-mini":void 0:c,b=this.#d;if(p&&n){if(!b)return{success:!1,response:`The ${d} agent can not be used on this session. Do no try again.`};if(b.httpServerState.state==="stopped"||b.httpServerState.state==="connecting"||b.httpServerState.state==="error-fetch")try{if(b.state==="not-installed")throw new Error(`The ${d} agent can not be used until the setupCommand finish successfully. However, the dev server is not installed.`);if(b.state==="install-failed")throw new Error(`The ${d} agent can not be used until the setupCommand finish successfully. However, last time we try to run the install script, it failed.`);if(b.state==="install-aborted")throw new Error(`The ${d} agent can not be used until the setupCommand finish successfully. However, last time we try to run the install script, it was aborted.`);await this.waitForSetupCommand(n),await b.ensureDevCommand(n)}catch(H){return{success:!1,response:H instanceof Error?H.message:String(H)}}if(f&&b.validateCommand&&this.#ee){let H=await b.runValidateCommand(void 0,n);if(H.status==="failure")return{success:!1,response:`The Agent could not start yet, because the validate command failed:
1914
+ `).filter(B=>B.trim()))];m=wf({files:m,policy:A,getDotFiles:!0});let C=[];for(let B of m){let E=B.lastIndexOf("/"),y=E>=0?B.slice(E+1):B,Q=E>=0?B.slice(0,E):"",b=Hae(u,B.toLowerCase()),w=Jae(u,B,b);C.push({filePath:B,fileName:y,parentPath:Q,matchIndices:b,score:w})}C.sort((B,E)=>E.score-B.score);let I=C.slice(0,i).map(({score:B,...E})=>E);l({matches:I,totalMatches:m.length,truncated:m.length>i})})})}async collectRepoMetrics(e={}){let r=this.#ve(e.folderName);return e.rootPath&&(r=this.#e.join(r,e.rootPath)),oAe(this.#e,r)}getSessionId(){return this.getSessionContext().sessionId}updateMetadata(e){this.#nt(e,!1)}getMetadata(){return this.#K}#rt=null;setTimeline(e){this.#rt=e}getTimeline(){return this.#rt}getSpaceId(){return this.#s.builderPublicKey}async revertToCommitSnapshot(e){this.#F=!1,await this.waitUntilBlockingPendingPromises(),await this.abortMerge(!1),await this.#re(!1);let n=(await this.#H(async a=>{let A=tl(e,a.folderName,this.gitRepoContexts[0]?.folderName);return A?(await this.git(["revert","--no-commit",`${A}..HEAD`],{cwd:a.path}),await this.git(["commit","--allow-empty","--quiet","--no-verify","--no-gpg-sign","-m","Revert changes"],{cwd:a.path}),{commitHash:await this.getCurrentCommitHash("HEAD",a.path)}):(this.#r.warn(`No commit found for ${a.folderName}, skipping revert`),{skipped:!0})})).results.filter(a=>!a.success);if(n.length>0)throw new Error(`Failed to revert ${n.length} repos`);let i=await this.#U();if(this.#k={...this.#k,...i},!(await this.#v())?.currentCommit){this.#e.Sentry?.captureException(new Error("Failed to get current commit hash after revert"),{tags:{operation:"codegen-git",endpoint:"revertToCommitHash"}});return}this.requestRefresh(),await this.#pe({lastCommit:Os(i)})}async revertToCommitHash(e){let r=Pf(e,this.gitRepoContexts[0]?.folderName),n=Object.keys(r).length===0?e:Os(r);return this.revertToCommitSnapshot(n)}async resetToCommitSnapshot(e,r=!0){this.#F=!1,await this.waitUntilBlockingPendingPromises(),await this.abortMerge(!1),await this.#re(!1);let i=(await this.#H(async s=>{let a=tl(e,s.folderName,this.gitRepoContexts[0]?.folderName);if(!a)return this.#r.warn(`No commit found for ${s.folderName}, skipping reset`),{skipped:!0};await this.git(["reset","--quiet","--hard",a],{cwd:s.path}),await this.git(["clean","-fd"],{cwd:s.path});let A=await this.getCurrentCommitHash("HEAD",s.path);if(A!==a)throw new Error(`Failed to reset commit hash for ${s.folderName}: expected ${a}, got ${A}`);return{commitHash:A}})).results.filter(s=>!s.success);if(i.length>0)throw new Error(`Failed to reset ${i.length} repos`);let o=Pf(e,this.gitRepoContexts[0]?.folderName);this.#k={...this.#k,...o},await this.#v(),r&&this.requestRefresh()}async resetToCommitHash(e,r=!0){let n=Pf(e,this.gitRepoContexts[0]?.folderName),i=Object.keys(n).length===0?e:Os(n);return this.resetToCommitSnapshot(i,r)}async restore({location:e,predicate:r,revert:n=!1,dryRun:i=!1,forceReplay:o=!1,debug:s}){let a=this.getSessionContext(),A=a.turns.length,c=null;for(let p=A-1;p>=-1;p--)if(r(p>=0?a.turns[p]:null,p)){c=p;break}if(c===null)return{undone:null,message:"Could not find the target to restore to, the completion id could be wrong"};n||await this.abort({cleanCurrentMessage:!0});let u=new Map,l=!!this.#m,d=a.turns,g=Math.max(0,e==="before"?c:c+1);for(let p=d.length-1;p>=g;p--){let f=d[p];for(let m of f.applyResults)u.set(m.filePath,m.oldContent??"")}if(!i){let p;if(l){c===-1?a.beforeCommit?p=a.beforeCommit:d.length>0&&(p=d[0].beforeCommit):c<d.length&&(e==="after"?(p=d[c].afterCommit,!p&&c+1<d.length&&(p=d[c+1].beforeCommit)):p=d[c].beforeCommit);let I={commitSnapshot:p,sessionId:a.sessionId,sessionBeforeCommit:a.beforeCommit,turnsLength:d.length,targetIndex:c,currentTurn:d[d.length-1],targetTurn:d[c],targetTurnNext:d[c+1],location:e,forceReplay:o,dryRun:i,debug:s};if(!p)return this.#e.Sentry?.captureException(new Error("No commit snapshot found for restore"),{tags:{operation:"codegen-git",endpoint:"revertToCommitHash"},contexts:{restore:I}}),{undone:null,message:"Could not find the target to restore to, the git history is missing"};try{n?await this.revertToCommitSnapshot(p):await this.resetToCommitSnapshot(p)}catch(B){return this.#e.Sentry?.captureException(new Error("Error resetting git",{cause:B}),{tags:{operation:"codegen-git",endpoint:"resetToCommitHash"},contexts:{restore:I}}),{undone:null,message:"Failed to reset/restore, the file history is missing"}}}else for(let[I,B]of u.entries())try{B?await this.writeFile(I,B):await this.deleteFile(I)}catch{}if(n)return{undone:[],message:"The revert operation was successful"};let f=d.splice(g,d.length-g),m=zA(d);m&&m?.afterCommit!==p&&(this.#e.Sentry?.captureException(new Error("Reset After commit snapshot mismatch"),{tags:{operation:"codegen-git",endpoint:"resetToCommitHash"},extra:{lastTurn:m,commitSnapshot:p}}),m.lastCommit=p,await this.#pe({completionId:m.completionId,lastCommit:p}));let C=m?.completionId;if(f.length>0&&(await MK(this.#e,this.#s,{lastCompletionId:C,sessionId:a.sessionId},!!this.#i),a.updatedUnixTime=Date.now()),o){let I=a.state;this.#u.emit("step",{type:"batch",steps:[{type:"state",newState:"replay",abortable:!1,previousState:I},...this.#St(),{type:"restore",files:Array.from(u.keys()),lastCompletionId:C,location:e},{type:"state",newState:I,abortable:!1,previousState:"replay"}]})}else f.length>0&&this.#u.emit("step",{type:"restore",files:Array.from(u.keys()),lastCompletionId:C,location:e})}return await this.#vt(),{undone:Array.from(u.keys()),message:"The restore operation was successful"}}async#vt(e){return await this.#d?.ensureDevCommand(e)}async restoreFromCompletionId({location:e,completionId:r,forceReplay:n}){let i=this.getSessionContext();return i.turns.find(s=>s.completionId===r)?this.restore({location:e,predicate:s=>s?.completionId===r,forceReplay:n,debug:`restore to: ${r}`}):(await this.#he,i.turns=[],i.canLoadMore=!0,await MK(this.#e,this.#s,{sessionId:i.sessionId,lastCompletionId:r},!!this.#i),await this.loadMoreTurns(),this.restore({location:e,predicate:()=>!0,forceReplay:!0,debug:"restore after history"}))}async restoreBeforeCompletionId(e){return this.restoreFromCompletionId({location:"before",completionId:e,forceReplay:!1})}async undoLastUserMessage(e=!1){return this.restore({location:"before",predicate:r=>r?.user.role==="user",dryRun:e})}getLastUserCompletionId(){let e=this.getSessionContext();return Zhe(e)?.completionId}getLastCompletionId(){let e=this.getSessionContext();return NK(e)?.completionId}getCurrentState(){return this.getSessionContext().state}getLastApplyResultsTurn(){let e=this.getSessionContext();return Xhe(e)}getLastTurn(){let e=this.getSessionContext();return NK(e)}getLastMessage(){return this.getLastTurn()?.actions.find(r=>r.type==="text")?.content}getNextUrl(){return this.getLastTurn()?.nextUrl}async sendFeedback(e){if(process.env.NODE_ENV==="test")return;if(e.feedbackSentiment){let n=e.feedbackSentiment==="positive"?`User provided positive feedback (thumbs up) on the previous completion.${e.feedbackText??""}`:`User provided negative feedback (thumbs down) on the previous completion.${e.feedbackText??""}`;this.queueSystemReminder({text:n,tag:"reminder:user-feedback"})}Qt("quality code feedback given",{spaceId:this.#s.builderPublicKey,sentiment:e.feedbackSentiment,mode:"cli"});let r=e.id??this.getLastCompletionId();r&&await this.#zt({...e,id:r})}#pe(e){let r=e.completionId;if(!r){let i=this.getLastTurn();i&&e.lastCommit&&(i.lastCommit=e.lastCommit),r=i?.completionId}let n=TK(this.#e,this.#s,"/codegen/finalize",{completionId:r,projectId:this.#A?.projectId,branchName:this.#A?.branchName,userCompletionId:this.getLastUserCompletionId(),sessionId:this.getSessionId(),metadata:this.#K,hasPlanToApply:this.#F,...e},this.#i);return this.#J(n,"completionFinalize")}#zt(e){let r=TK(this.#e,this.#s,"/codegen/feedback",e,this.#i);return this.#J(r,"completionFeedback")}#G(e,r,n={}){this.#d?.emitter.emit("metrics",{durations:[{key:e,ms:r,attributes:n}]})}#J(e,r,n=!1){let i=$a();this.#r.debug(`(addToPendingPromises-${i}): adding ${r} (blocking: ${n})`),this.#ue.push(e),n&&this.#Pe.push(e);let o=new Error(`Deadlock detected in codegen (function: ${r})`),s=setTimeout(()=>{this.#e.Sentry?.captureException(o,{level:"fatal",tags:{operation:"codegen-stream",functionName:r,sessionId:this.getSessionId(),projectId:this.#Q,branchName:this.#P}})},300*1e3);return e.finally(()=>{clearTimeout(s),this.#r.debug(`(addToPendingPromises-${i}): removing ${r} (blocking: ${n})`);let a=this.#Pe.indexOf(e);a!==-1&&this.#Pe.splice(a,1);let A=this.#ue.indexOf(e);A!==-1&&this.#ue.splice(A,1)})}async lastTurnHasChanges(){let e=await this.undoLastUserMessage(!0);return e.undone?e.undone.length>0:!1}#$(e){let r=this.getSessionContext(),n=r.state;return n!==e?(r.state=e,this.#u.emit("step",{type:"state",abortable:e==="generating",previousState:n,newState:e}),!0):!1}waitUntilState(e,r=1e4){return new Promise(n=>{if(this.getSessionContext().state===e){n();return}let o,s=a=>{a.type==="state"&&a.newState===e&&(clearTimeout(o),this.#u.removeListener("step",s),n())};o=setTimeout(()=>{this.#u.removeListener("step",s),n()},r),this.#u.on("step",s)})}getProxyConfig(){return Hoe({devServerUrl:this.#A?.serverUrl,proxyOrigin:this.#Ne,proxyDefaultOrigin:this.#Te,proxyDestination:this.#mt})}async clearSession(){this.#r.debug("(clearSession): clearing session"),await this.abort({cleanCurrentMessage:!0,flushMessageQueue:!1});let e=this.getSessionContext();e.turns=[],e.customInstructions=await this.#be(),e.customAgents=await this.#Ge(),this.#O.length=0,this.#F=!1,this.#K={},this.#Z=void 0,this.#Fe=!1,this.clearMessageQueue(),this.queueGitStatusReminder({trigger:"session-start"})}async clearMessageQueue(e=!1){let r=[];if(e)for(let n of this.#t)n.user&&r.push({type:"user",displayPrompt:n.displayPrompt,user:n.user,role:n.user.role,compacting:!1,idempotencyKey:n.idempotencyKey});this.#t.length=0,this.#Oe(),r.length>0&&this.#u.emit("step",{type:"batch",steps:r})}updateMessage(e){if(e.type==="delete"){let r=this.#t.findIndex(n=>n.idempotencyKey===e.idempotencyKey);r>=0&&this.#t.splice(r,1)}else if(e.type==="move"){let r=this.#t.findIndex(n=>n.idempotencyKey===e.idempotencyKey);r>=0&&gCe(this.#t,r,r+e.delta)}this.#Oe()}async flushMessageQueue(){this.#r.debug("(flushMessageQueue): flushing message queue"),await this.abort({cleanCurrentMessage:!1,flushMessageQueue:!0}),this.#l&&this.#l()}#bt(e){let r=e.idempotencyKey;if(r){let n=this.#t.findIndex(i=>i.idempotencyKey===r);if(n>=0)return this.#t[n]=e,!1}else e.idempotencyKey=(0,Ax.randomUUID)();if(e.queue==null&&(e.queue=!0),e.user?e.user={...this.#Z,...e.user}:e.user=this.#Z,e.userPrompt==="___BROWSER_AUTOMATION_PROMPT___"){let n=this.getProxyConfig();e.userPrompt=Yae(n.proxyDefaultOrigin,this.#ye||void 0)}return this.#t.push(e),!0}async sendMessage(e){this.#Fe=!1;let r=0;if(Array.isArray(e))for(let i of e)this.#bt(i)&&r++;else this.#bt(e)&&r++;if(r===0)return null;this.#r.debug(`(sendMessage): added messages(${r}) to queue(${this.#t.length})`),this.#Oe();let n=this.#t[this.#t.length-1];return n?(this.#F=!1,this.cancelAllPendingToolFulfilments(n.userPrompt),n.queue?this.#l&&this.#l():await this.flushMessageQueue(),await el(),n.idempotencyKey):null}#Vt(){if(this.#c==="until-idle")return;let e=this.#t;if(e.length!==0){for(let r of e)if(r.systemReminders)for(let n of r.systemReminders)this.queueSystemReminder(n);return this.#o=PK(e),this.#Z=this.#o.user,this.#o.softContextWindow&&(this.#S=Math.min(this.#S??3e4,this.#o.softContextWindow)),this.clearMessageQueue(!0),this.#o}}#Wt(){let e=this.#t.length===0||this.#Fe,r=new Promise(n=>{e?this.#l=n:n()}).then(()=>{let n=this.#t;if(n.length!==0)if(this.#c==="until-idle"){let i=this.#t.shift();if(i.user&&(this.#Z=i.user,this.#u.emit("step",{type:"user",displayPrompt:i.displayPrompt,user:i.user,role:i.user.role,compacting:!1,idempotencyKey:i.idempotencyKey})),i.systemReminders)for(let o of i.systemReminders)this.queueSystemReminder(o);return this.#o=i,this.#Z=i.user,this.#o.softContextWindow&&(this.#S=Math.min(this.#S??3e4,this.#o.softContextWindow)),this.#Oe(),i}else{for(let o of n)if(o.systemReminders)for(let s of o.systemReminders)this.queueSystemReminder(s);let i=PK(n);if(!i.dropAbortedPrompt&&this.#o){let o=i.idempotencyKey;i=HK(this.#o,i),i.idempotencyKey=o}return this.clearMessageQueue(!0),this.#o=i,this.#Z=i.user,i}});return{shouldWait:e,promise:r}}#Oe(){this.#u.emit("step",{type:"message-queue",queue:this.#t.map(e=>({idempotencyKey:e.idempotencyKey,displayPrompt:e.displayPrompt,user:e.user}))})}#nt(e,r=!1){r&&(this.#K={}),Object.assign(this.#K,e),this.#u.emit("step",{type:"metadata",...this.#K})}async waitForSetupCommand(e){let r=this.#d;if(!r)return{state:"installed",shouldProceed:!0};if(r.setupState==="installing")try{await Fc(r.setupCommandPromise,e)}catch{}let n=r.setupState;return n==="not-installed"||n==="install-failed"||n==="install-aborted"?{state:n,shouldProceed:!0}:{state:"installed",shouldProceed:!0}}async waitForDevServer(e,r,n){if(!this.#d&&this.#A?.serverUrl)return{shouldProceed:!0,message:"Dev server is ready.",serverUrl:this.#A.serverUrl};let i=await this.waitForSetupCommand(e);if(!i.shouldProceed)return{shouldProceed:!1,message:`Project setup command did not completed. State: ${i.state}`};let o=this.#d;if(o){await o.ensureDevCommand(e);let s=await o.waitUntilServer(e,r,n);return s.ok?{shouldProceed:!0,message:"Dev server is ready.",serverUrl:o.serverUrl?.toString()}:{shouldProceed:!1,message:s.message,serverUrl:void 0}}return{shouldProceed:!1,message:"Dev server is not ready.",serverUrl:void 0}}async getNamedAgentConfig(e,r,n){let i=this.getSessionContext(),o=i.customAgents,s=e?o.find(L=>L.name.toLowerCase()===e.toLowerCase()):void 0,a=s?.name??"explorer",{mcpServers:A=!1,model:c,mode:u="quality-v4-agent",systemPrompt:l,subagent_type:d,includeMemories:g,needDevServer:p,needValidation:f,queueMode:m,asyncSubAgents:C,resetAfterRun:I=!1,reasoning:B}={mcpServers:s?.mcpServers,subagent_type:a,systemPrompt:s?.systemPrompt,model:(()=>{if(s?.roundRobinModels?.length){let L=s.name,H=this.#ht.get(L)??0;return this.#ht.set(L,H+1),s.roundRobinModels[H%s.roundRobinModels.length]}return s?.model})(),mode:s?.mode,includeMemories:s?.includeMemories??a==="explorer",needDevServer:s?.needDevServer,needValidation:s?.needValidation,resetAfterRun:s?.resetAfterRun,queueMode:s?.queueMode,asyncSubAgents:s?.asyncSubAgents,reasoning:s?.reasoning??this.#qe},E=["Read","Glob","ReadRule","Grep","WebSearch","SearchMemories"];i.sessionMode==="deep-research"&&E.push("Bash","WebFetch"),E=E.filter(L=>this.#y?this.#y.includes(L):!0),E.push("ExplorationMetadata");let y=sx(this.#A,s?.tools??E),Q=c===void 0?d==="explorer"?"opa5-mini":void 0:c,b=this.#d;if(p&&n){if(!b)return{success:!1,response:`The ${d} agent can not be used on this session. Do no try again.`};if(b.httpServerState.state==="stopped"||b.httpServerState.state==="connecting"||b.httpServerState.state==="error-fetch")try{if(b.state==="not-installed")throw new Error(`The ${d} agent can not be used until the setupCommand finish successfully. However, the dev server is not installed.`);if(b.state==="install-failed")throw new Error(`The ${d} agent can not be used until the setupCommand finish successfully. However, last time we try to run the install script, it failed.`);if(b.state==="install-aborted")throw new Error(`The ${d} agent can not be used until the setupCommand finish successfully. However, last time we try to run the install script, it was aborted.`);await this.waitForSetupCommand(n),await b.ensureDevCommand(n)}catch(H){return{success:!1,response:H instanceof Error?H.message:String(H)}}if(f&&b.validateCommand&&this.#ee){let H=await b.runValidateCommand(void 0,n);if(H.status==="failure")return{success:!1,response:`The Agent could not start yet, because the validate command failed:
1915
1915
  <command>
1916
1916
  ${H.command}
1917
1917
  </command>
@@ -1920,17 +1920,17 @@ ${H.output}
1920
1920
  </logs>
1921
1921
 
1922
1922
  Make the necessary changes and try again.`};if(H.status==="aborted")return{success:!1,response:"The Agent could not start yet, because the validate command was aborted by the user."};this.#ee=!1}let L=await this.waitForDevServer(n);if(!L.shouldProceed)return{success:!1,response:L.message}}let w=this.#h.replace(/-agent$/,""),D={};if(y.includes("mcp:chrome")){let L=await this.#Zt(r,n);if(L)D.chrome={command:"npx",args:["-y","chrome-devtools-mcp@latest","--wsEndpoint",L,"--categoryEmulation=false"],retries:5};else{let H=["mcp:chrome","RecordFrame","CompileRecording","DevServerLogs"];for(let K of H){let M=y.indexOf(K);M!==-1&&y.splice(M,1)}this.#r.debug("Chrome MCP not available \u2014 browser tools removed from agent")}}let x=["## Workspace Context","",`**Bash tool Working Directory:** ${this.#w}`,"","**Git Repositories:**",...this.#p.map(L=>`- repository: ${L.repoName} in folder: ${L.folderName}`)].join(`
1923
- `),S=l?uv(l,{cwd:this.#w,env:{FUSION_CONTEXT:x,FUSION_TEST_PROMPT:this.#A?.browserAutomationInstructions??"",...b?.envVars??process.env},allowedCommands:j0(this.#A?.allowedCommands??[]),skipCommandSecurity:this.#A?.skipCommandSecurity===!0}):void 0;return{success:!0,subagent_type:d,resetAfterRun:I,options:{sys:this.#e,credentials:this.#s,position:s?.position??`${w}-agent`,mode:u,includeMemories:g,modelOverride:Of(Q)??this.#mt??this.#O,sessionOrCompletionId:r,workingDirectory:this.#C,mcpServers:A,fusionStatusMonitor:this.#Ke,autoImportLocalMCPs:!1,fusionConfig:this.#A,privacyMode:this.#M,enabledTools:y,builtInMCPServerConfig:D,systemPromptOverride:S,queueMode:m,asyncSubAgents:C,reasoning:B,devServerOrchestrator:y.includes("DevServerLogs")||y.includes("DevServerRestart")||y.includes("DevServerControl")||y.includes("ProposeEnvVariable")?this.#d:void 0}}}async spawnNamedAgent(e,r){let n=r.resume??r.sessionId,i=await this.getNamedAgentConfig(e,n,r.signal);if(!i.success)return{success:!1,response:i.response};await this.waitUntilBlockingPendingPromises(),await this.#re(!0);let o;if(i.resetAfterRun){if(this.#m&&!await this.#ot())return{success:!1,response:`Cannot run browser automation with uncommitted changes. The "${i.subagent_type}" agent modifies code during testing and automatically resets changes afterward. Your uncommitted changes would be permanently lost.
1923
+ `),S=l?uv(l,{cwd:this.#w,env:{FUSION_CONTEXT:x,FUSION_TEST_PROMPT:this.#A?.browserAutomationInstructions??"",...b?.envVars??process.env},allowedCommands:j0(this.#A?.allowedCommands??[]),skipCommandSecurity:this.#A?.skipCommandSecurity===!0}):void 0;return{success:!0,subagent_type:d,resetAfterRun:I,options:{sys:this.#e,credentials:this.#s,position:s?.position??`${w}-agent`,mode:u,includeMemories:g,modelOverride:s?.inheritSessionModel&&(this.#Me??this.#_)?this.#Me??this.#_:Of(Q)??this.#Me??this.#_,sessionOrCompletionId:r,workingDirectory:this.#C,mcpServers:A,fusionStatusMonitor:this.#He,autoImportLocalMCPs:!1,fusionConfig:this.#A,privacyMode:this.#M,enabledTools:y,builtInMCPServerConfig:D,systemPromptOverride:S,queueMode:m,asyncSubAgents:C,reasoning:B,devServerOrchestrator:y.includes("DevServerLogs")||y.includes("DevServerRestart")||y.includes("DevServerControl")||y.includes("ProposeEnvVariable")?this.#d:void 0}}}async spawnNamedAgent(e,r){let n=r.resume??r.sessionId,i=await this.getNamedAgentConfig(e,n,r.signal);if(!i.success)return{success:!1,response:i.response};await this.waitUntilBlockingPendingPromises(),await this.#re(!0);let o;if(i.resetAfterRun){if(this.#m&&!await this.#st())return{success:!1,response:`Cannot run browser automation with uncommitted changes. The "${i.subagent_type}" agent modifies code during testing and automatically resets changes afterward. Your uncommitted changes would be permanently lost.
1924
1924
 
1925
- Please commit or stash your changes first, then try again.`};o=(await this.#v())?.currentCommit}let s=i.subagent_type,a=new t(i.options),A=r.sessionId??r.resume??n,c=Promise.withResolvers();this.#Pe.set(A,{description:r.prompt.substring(0,200),startedAt:Date.now(),promise:c.promise}),await a.initializeSession({skipSessionLoading:!r.resume,signal:r.signal}),r.resume&&i.options.builtInMCPServerConfig?.chrome&&a.queueSystemReminder({text:"The connected browser might have restarted. This means cookies and open pages might have been cleared."});let u=a.getSessionId(),l={important_files:[]},d=new KI(u,{framesDir:this.#e.join(ax.default.homedir(),".builder","recordings"),debug:this.#i}),g=[],p={value:null},f=[],m=r.maxCompletions,C=a.connectToEventLoop(!1,E=>{try{if(E.type==="tool_result"&&E.result.tool_name==="ExplorationMetadata"&&typeof E.result.content=="string")try{l=JSON.parse(E.result.content)}catch(y){this.#e.Sentry?.captureException(y,{extra:{contentPreview:E.result.content.substring(0,500),contentLength:E.result.content.length},tags:{operation:"exploration-metadata-parse"}})}else E.type==="done"&&(m--,m<10&&a.queueSystemReminder({text:`The agent has been working for a while. Please try to wrap up soon because soon it will be interrupted. T-minus ${m} turns.`})),this.#u.emit("step",{type:"agent",id:u,step:E,subagent_type:s});if(E.type==="tool"&&d.onToolCall(E.name,E.id,E.content),E.type==="planning"&&d.onThinking(E.content),E.type==="tool_result"){let y=d.getFrameCount();if(d.onToolResult(E.result,zhe()),E.result.tool_name==="RecordFrame")try{let Q=JSON.parse(E.result.tool_input||"{}");d.onRecordFrame(Q)}catch{d.onRecordFrame({title:"Untitled",frame:"last-image"})}if(d.getFrameCount()>y&&this.#rt({timeline_progress:d.getProgressSnapshot()},!1),E.result.tool_name==="ReportUIIssue")try{let Q=JSON.parse(E.result.tool_input||"{}");Q.title&&Q.description&&g.push({title:Q.title,description:Q.description,debugInfo:Q.debugInfo})}catch{}if(E.result.tool_name==="ReportTestOutcome")try{let Q=JSON.parse(E.result.tool_input||"{}");Q.outcome&&Q.summary&&(p.value={outcome:Q.outcome,summary:Q.summary,details:Q.details})}catch{}if(E.result.tool_name==="ReportIssue")try{let Q=JSON.parse(E.result.tool_input||"{}");Q.file_path&&Q.line&&Q.title&&Q.severity&&Q.body&&f.push({file_path:Q.file_path,line:Q.line,...Q.start_line?{start_line:Q.start_line}:{},title:Q.title,severity:Q.severity,body:Q.body})}catch{}}}catch{}}),I=async()=>{C(),await a.close(!1)};if(r.signal?.aborted){await I(),this.#Pe.delete(A);let E={success:!1,response:"Agent task aborted"};return c.resolve(E),E}let B=async()=>{await I()};r.signal&&r.signal.addEventListener("abort",B);try{let E=r.attachmentUrls?.map(w=>({type:"url",value:w}));await a.sendMessage({userPrompt:r.prompt,user:r.user,maxCompletions:r.maxCompletions,category:"background-subagent",includeRelevantMemories:i.options.includeMemories,queue:!0,...E?.length&&{attachments:E}}),await a.waitUntilIdle(r.signal);let y=a.getLastTurn();if(!y)return{success:!1,response:"Agent task failed"};let Q=y.actions.filter(w=>w.type==="text").map(w=>w.content).join(`
1925
+ Please commit or stash your changes first, then try again.`};o=(await this.#v())?.currentCommit}let s=i.subagent_type,a=new t(i.options),A=r.sessionId??r.resume??n,c=Promise.withResolvers();this.#_e.set(A,{description:r.prompt.substring(0,200),startedAt:Date.now(),promise:c.promise}),await a.initializeSession({skipSessionLoading:!r.resume,signal:r.signal}),r.resume&&i.options.builtInMCPServerConfig?.chrome&&a.queueSystemReminder({text:"The connected browser might have restarted. This means cookies and open pages might have been cleared."});let u=a.getSessionId(),l={important_files:[]},d=new KI(u,{framesDir:this.#e.join(ax.default.homedir(),".builder","recordings"),debug:this.#i}),g=[],p={value:null},f=[],m=r.maxCompletions,C=a.connectToEventLoop(!1,E=>{try{if(E.type==="tool_result"&&E.result.tool_name==="ExplorationMetadata"&&typeof E.result.content=="string")try{l=JSON.parse(E.result.content)}catch(y){this.#e.Sentry?.captureException(y,{extra:{contentPreview:E.result.content.substring(0,500),contentLength:E.result.content.length},tags:{operation:"exploration-metadata-parse"}})}else E.type==="done"&&(m--,m<10&&a.queueSystemReminder({text:`The agent has been working for a while. Please try to wrap up soon because soon it will be interrupted. T-minus ${m} turns.`})),this.#u.emit("step",{type:"agent",id:u,step:E,subagent_type:s});if(E.type==="tool"&&d.onToolCall(E.name,E.id,E.content),E.type==="planning"&&d.onThinking(E.content),E.type==="tool_result"){let y=d.getFrameCount();if(d.onToolResult(E.result,zhe()),E.result.tool_name==="RecordFrame")try{let Q=JSON.parse(E.result.tool_input||"{}");d.onRecordFrame(Q)}catch{d.onRecordFrame({title:"Untitled",frame:"last-image"})}if(d.getFrameCount()>y&&this.#nt({timeline_progress:d.getProgressSnapshot()},!1),E.result.tool_name==="ReportUIIssue")try{let Q=JSON.parse(E.result.tool_input||"{}");Q.title&&Q.description&&g.push({title:Q.title,description:Q.description,debugInfo:Q.debugInfo})}catch{}if(E.result.tool_name==="ReportTestOutcome")try{let Q=JSON.parse(E.result.tool_input||"{}");Q.outcome&&Q.summary&&(p.value={outcome:Q.outcome,summary:Q.summary,details:Q.details})}catch{}if(E.result.tool_name==="ReportIssue")try{let Q=JSON.parse(E.result.tool_input||"{}");Q.file_path&&Q.line&&Q.title&&Q.severity&&Q.body&&f.push({file_path:Q.file_path,line:Q.line,...Q.start_line?{start_line:Q.start_line}:{},title:Q.title,severity:Q.severity,body:Q.body})}catch{}}}catch{}}),I=async()=>{C(),await a.close(!1)};if(r.signal?.aborted){await I(),this.#_e.delete(A);let E={success:!1,response:"Agent task aborted"};return c.resolve(E),E}let B=async()=>{await I()};r.signal&&r.signal.addEventListener("abort",B);try{let E=r.attachmentUrls?.map(w=>({type:"url",value:w}));await a.sendMessage({userPrompt:r.prompt,user:r.user,maxCompletions:r.maxCompletions,category:"background-subagent",includeRelevantMemories:i.options.includeMemories,queue:!0,...E?.length&&{attachments:E}}),await a.waitUntilIdle(r.signal);let y=a.getLastTurn();if(!y)return{success:!1,response:"Agent task failed"};let Q=y.actions.filter(w=>w.type==="text").map(w=>w.content).join(`
1926
1926
  `);if(g.length>0&&(Q=`<browser_automation_ui_issues>${JSON.stringify(g,null,2)}</browser_automation_ui_issues><browser_automation_summary>${Q}</browser_automation_summary>`),f.length>0&&(Q=`<code_review_issues>${JSON.stringify(f,null,2)}</code_review_issues><code_review_summary>${Q}</code_review_summary>`),d.hasAnyFrames())try{let w=a.getSessionId(),D=d.getHighlightImages(),x=D.length>0?d.getHighlightMetadataFrames():d.getLegacyMetadataFrames(),S=D.length>0?D:d.getExplicitImages(),L=`${w}.webp`,H=`${w}.json`,K=`${w}-timeline.json`,M=this.#e.join(ax.default.homedir(),".builder","recordings"),_=this.#e.join(M,L),j=this.#e.join(M,H),V=this.#e.join(M,K);await kl.default.promises.mkdir(M,{recursive:!0}),await kl.default.promises.writeFile(j,JSON.stringify(x,null,2));let U=await d.finalize();await kl.default.promises.writeFile(V,JSON.stringify(U,null,2)),l.timeline_id=K;let $=await eu(this.#s,"/codegen/timeline",{...U,projectId:this.#Q??null,branchName:this.#P??null,testOutcome:p.value?.outcome??null,testSummary:p.value?.summary??null,testDetails:p.value?.details??null,uiIssues:g.length>0?g:null});if($?.recording_id&&(l.recording_id=$.recording_id),S.length>0){let O=D.length>0?d.getHighlightFrameDurations():d.getExplicitFrameDurations();if(await _ae(S,{duration:"1",frameDurations:O.length>0?O:void 0,outputPath:_,cleanup:!1,sys:this.#e,debug:this.#i,signal:r.signal})&&(l.gif_id=L??void 0,this.#r.debug(`(subagent=${s}): Generated recording from ${S.length} frames: ${L}`),L)){let de=x.map(fe=>fe.title);Q=`<browser_automation_gif_id>${L}</browser_automation_gif_id>
1927
1927
  <browser_automation_timeline_id>${K}</browser_automation_timeline_id>
1928
1928
  <browser_automation_recorded_frames>${JSON.stringify(de)}</browser_automation_recorded_frames>
1929
1929
 
1930
- ${Q}`}}this.#rt({gif_id:l.gif_id,gif_frames:x,timeline_id:K,recording_id:l.recording_id},!1),l.recording_id&&d.cleanupSessionFiles().catch(O=>{this.#r.warn(`[${s}] Failed to clean up local recording files: ${O instanceof Error?O.message:String(O)}`)})}catch(w){this.#r.warn(`[${s}] Failed to generate recording (non-critical): ${w instanceof Error?w.message:String(w)}`),this.#e.Sentry?.captureException(w,{level:"warning",tags:{component:"gif-generator",operation:"generateGifFromImages",subagent_type:s},extra:{sessionId:a.getSessionId(),frameCount:d.getFrameCount()}})}let b={success:!0,response:Q,metadata:l,sessionId:u,lastTurn:y};return c.resolve(b),b}catch(E){let y={success:!1,response:`Agent task failed: ${E instanceof Error?E.message:String(E)}`,metadata:{important_files:[]}};return c.resolve(y),y}finally{this.#Pe.delete(A),r.signal?.removeEventListener("abort",B);try{await I()}catch(E){this.#r.warn(`[${s}] Cleanup failed: ${E instanceof Error?E.message:String(E)}`)}if(i.resetAfterRun&&o)try{await this.resetToCommitHash(o,!1)}catch(E){this.#r.warn(`[${s}] Failed to reset changes: ${E instanceof Error?E.message:String(E)}`)}}}getRunningSubAgents(){return Array.from(this.#Pe.entries()).map(([e,r])=>({id:e,description:r.description,startedAt:r.startedAt}))}canHandleTool(e){return(this.#W.get(e)??0)>0}setProxyOrigin(e,r){if(e!==this.#Ne||r!==this.#Te){this.#Ne=e,this.#Te=r;let n=this.getProxyConfig();n.proxyDestination&&n.proxyDefaultOrigin&&this.queueSystemReminder({text:`The dev server is running at ${n.proxyDefaultOrigin}. e.g. for taking screenshots of a "/foo" route take a screenshot of ${n.proxyDefaultOrigin}/foo`,tag:"reminder:url"})}}async#Zt(e,r){let n=this.getProxyConfig();if(n.proxyOrigin&&!n.proxyDestination)return;let i=await eu(this.#s,"/codegen/get-browser-connection",{sessionId:e,projectId:this.#Q,branchName:this.#P,proxyOrigin:n.proxyOrigin,proxyDefaultOrigin:n.proxyDefaultOrigin,proxyDst:n.proxyDestination},{signal:r,debug:this.#i});return typeof i?.wsUrl=="string"?i.wsUrl:void 0}getTurns(){let e=this.getSessionContext();return structuredClone(e.turns)}getSessionContext(){if(!this.#n)throw new Error("Session context not initialized");return this.#n}async runSetupCommand(){return await this.#d?.runSetupCommand()}abortSetupCommand(){return this.#d?.abortSetupCommand()}abortValidateCommand(){return this.#d?.abortValidateCommand()}toolsRunning(){return this.#Y.length>0}abortAllTools(){for(let e of this.#Y)e.abortController.abort()}toolFullfilment(e,r){return typeof r=="string"&&(r={toolResult:r,isError:!1}),this.fulfillToolCall(e,r)}cancelAllPendingToolFulfilments(e){for(let[r,n]of Array.from(this.#X.entries()))n.messageValid&&e?this.fulfillToolCall(r,{toolResult:"The user answered with a follow-up message (see the next user message in the conversation).",isError:!1,title:"Resolved by user message"}):this.fulfillToolCall(r,{toolResult:"Aborted by the user. So the task could not be completed.",isError:!0,title:"Aborted by the user."});this.#X.clear()}fulfillToolCall(e,r){let n=this.#X.get(e);return n?(n.resolve(r),this.#X.delete(e),!0):!1}abortToolCall(e,r){let n=this.#Y.find(o=>o.id===e),i=Bn(r??"The user manually aborted the tool call.");if(n)return n.abortController.abort(i),!0;if(this.#Y.length===0){let o=new AbortController;return o.abort(i),this.#Y.push({id:e,abortController:o,input:{id:e},name:"bash"}),!0}return!1}async acceptCode(){if(this.#it()){let e=this.getLinesStats();await this.sendFeedback({position:this.#h,acceptedLines:e.net,linesOfCodeAdded:e.added,linesOfCodeRemoved:e.removed})}}async abort(e){this.#i&&this.#r.debug(`(abort): ${JSON.stringify(e)}`);let r=!1,n=!0;return typeof e=="boolean"?r=e:(r=e?.cleanCurrentMessage??!1,n=e?.flushMessageQueue??!0),r&&(this.#o=void 0,this.clearMessageQueue()),this.#Fe=!n,this.cancelAllPendingToolFulfilments(),this.#ce=0,this.#g?(this.#g.abort(),this.#g=void 0,!0):!1}async stopEventLoop(){await this.abort({cleanCurrentMessage:!0}),this.#x?.abort(),this.#x=void 0,this.#l&&this.#l()}requestRefresh(){this.#u.emit("step",{type:"builder-action",action:"refresh",metadata:{}})}async configureDevOrchestrator(e){let r=this.#d,n={devCommand:!1,hosts:!1,setupCommand:!1,proxyServer:!1,validateCommand:!1,env:!1,fileOverrides:!1,setupResult:void 0,devResult:void 0,validateResult:void 0};if(r){let i=[];if(e.env&&(e.replaceEnvs&&(r.environmentVariables.length>0&&(n.env=!0),r.clearEnvVariables()),Object.entries(e.env).forEach(([o,s])=>{r.setEnvVariable(o,s??void 0)&&(n.env=!0)}),this.queueSystemReminder({text:`The system has the following environment variables:
1931
- ${dCe(r.environmentVariables)}`,tag:"reminder:environment-variables"})),e.proxyServer?i.push(r?.setProxyServer(e.proxyServer).then(o=>{n.proxyServer=o.updatedProxyServer,n.hosts=o.updatedHosts})):e.proxyPort&&i.push(r?.setPort(e.proxyPort).then(o=>n.proxyServer=o)),e.fileOverrides&&(n.fileOverrides=r.setFileOverrides(e.fileOverrides)),e.setupCommand!==void 0||e.setupDependencies!==void 0?i.push(r.setSetupCommand({setupDependencies:e.setupDependencies,setupCommand:e.setupCommand,forceRestart:e.forceSetupCommand}).then(o=>{n.setupCommand=!!o,n.setupResult=o??void 0})):(e.forceSetupCommand||n.fileOverrides||n.env&&r.setupState!=="installed")&&i.push(r?.runSetupCommand().then(o=>{n.setupCommand=!!o,n.setupResult=o??void 0})),e.devCommand!==void 0?i.push(r.setDevCommand(e.devCommand??void 0,e.forceDevCommand||n.env).then(o=>{n.devCommand=o.status==="success",n.devResult=o??void 0})):(e.forceDevCommand||n.env)&&i.push(r?.restart().then(o=>{n.devCommand=!0,n.devResult=o??void 0})),e.autoDetectDevServer!==void 0&&i.push(r.setAutoDetectSettings(e.autoDetectDevServer,e.autoDetectDevServerPatterns).then(o=>n.proxyServer=n.proxyServer||o)),e.validateCommand!==void 0&&i.push(r.runValidateCommand(e.validateCommand).then(o=>n.validateResult=o)),await Promise.allSettled(i),n.env){let o=!1;for(let s of this.#D.values())(s.state==="running"||s.state==="starting")&&(s.stale=!0,o=!0);o&&this.#ge()}}return n}#Xt(){for(let e of Array.from(this.#D.keys()))try{this.disposeTerminal({terminalId:e})}catch{}this.#D.clear()}async#nt(){if(this.#E.debounceTimer&&clearTimeout(this.#E.debounceTimer),this.#E.pendingEvents=[],this.#E.listeners.clear(),this.#E.watcher){try{await this.#E.watcher.close()}catch{}this.#E.watcher=null}}#er(){if(this.#E.watcher)return;let e=this.#p.map(A=>A.path),r=new Map;for(let A of this.#p)r.set(A.path,UK(A.path));let n=A=>{for(let c of this.#p)if(A.startsWith(c.path+"/")||A===c.path)return c.path;return null},i=A=>{let c=n(A);if(!c)return!1;let u=this.#e.relative(c,A).replace(/\\/g,"/");if(!u)return!1;if(this.#Ft(u))return!0;let l=r.get(c);return l?l(u):!1},o,s=!1;try{o=jhe.default.watch(e,{ignored:i,ignoreInitial:!0,persistent:!0,awaitWriteFinish:{stabilityThreshold:200,pollInterval:100},ignorePermissionErrors:!0,followSymlinks:!1,usePolling:!0,interval:1e3,binaryInterval:3e5,atomic:!0})}catch(A){this.#e.Sentry?.captureException(A,{tags:{operation:"global-file-watch-init"}}),this.#r.error(`Failed to initialize file watcher: ${A instanceof Error?A.message:String(A)}`),this.#r.error("File watching will be disabled. Code generation will still work but may not detect all changes automatically.");return}let a=(A,c)=>{let u=n(c),l=u?this.#e.relative(u,c).replace(/\\/g,"/"):this.#e.relative(this.primaryGitPath,c).replace(/\\/g,"/");if(this.#p.length>1&&u){let g=this.#p.find(p=>p.path===u);g&&!this.#R()&&(l=`${g.folderName}/${l}`)}let d={type:"folder-watch",watchId:"global",event:A,path:l,timestamp:Date.now()};this.#E.pendingEvents.push(d),this.#E.debounceTimer&&clearTimeout(this.#E.debounceTimer),this.#E.debounceTimer=setTimeout(()=>{let g=this.#E.pendingEvents;this.#E.pendingEvents=[];for(let p of g)for(let f of this.#E.listeners)try{f(p)}catch(m){this.#e.Sentry?.captureException(m)}},this.#E.debounceMs)};o.on("add",A=>a("add",A)).on("change",A=>a("change",A)).on("unlink",A=>a("unlink",A)).on("addDir",A=>a("addDir",A)).on("unlinkDir",A=>a("unlinkDir",A)).on("error",A=>{s||(s=!0,this.#e.Sentry?.captureException(A,{tags:{operation:"global-file-watch"}}),this.#r.error(`File watcher error: ${A instanceof Error?A.message:String(A)}`),this.#r.error("Closing file watcher to prevent further errors. File watching will be disabled."),this.#nt().catch(()=>{}))}),this.#E.watcher=o,this.#r.debug(`Initialized global file watcher on: ${e.join(", ")}`)}subscribeToFileChanges(e){return this.#E.listeners.size===0&&this.#er(),this.#E.listeners.add(e),this.#r.debug(`Subscribed to file changes(${this.#E.listeners.size} active listeners)`),async()=>{this.#E.listeners.delete(e),this.#r.debug(`Unsubscribed from file changes(${this.#E.listeners.size} remaining listeners)`),this.#E.listeners.size===0&&this.#E.watcher&&(await this.#nt(),this.#r.debug("Closed global file watcher (no more listeners)"))}}async tsServerInit(){try{return this.#a?{ok:!0,cwd:this.#C}:(this.#a=new Iv(this.#C),this.#a.setEventHandler(e=>{for(let r of this.#_e)r(e)}),await this.#a.start(),{ok:!0,cwd:this.#C})}catch(e){return this.#a=null,{ok:!1,error:e?.message||"Failed to start tsserver"}}}async tsServerOpenFile(e,r){this.#a&&await this.#a.openFile(e,r)}async tsServerChangeFile(e,r){this.#a&&await this.#a.changeFile(e,r)}async tsServerCloseFile(e){this.#a&&await this.#a.closeFile(e)}async tsServerGetCompletions(e,r,n,i){return this.#a?this.#a.getCompletions(e,r,n,i):{success:!1,body:null}}async tsServerGetCompletionDetails(e,r,n,i){return this.#a?this.#a.getCompletionDetails(e,r,n,i):{success:!1,body:null}}async tsServerGetDefinition(e,r,n){return this.#a?this.#a.getDefinition(e,r,n):{success:!1,body:null}}async tsServerGetTypeDefinition(e,r,n){return this.#a?this.#a.getTypeDefinition(e,r,n):{success:!1,body:null}}async tsServerGetQuickInfo(e,r,n){return this.#a?this.#a.getQuickInfo(e,r,n):{success:!1,body:null}}async tsServerGetReferences(e,r,n){return this.#a?this.#a.getReferences(e,r,n):{success:!1,body:null}}async tsServerGetSignatureHelp(e,r,n){return this.#a?this.#a.getSignatureHelp(e,r,n):{success:!1,body:null}}async tsServerRequestDiagnostics(e){this.#a&&await this.#a.requestDiagnostics(e)}async tsServerGetRenameLocations(e,r,n){return this.#a?this.#a.getRenameLocations(e,r,n):{success:!1,body:null}}async tsServerGetNavTree(e){return this.#a?this.#a.getNavTree(e):{success:!1,body:null}}async tsServerOrganizeImports(e){return this.#a?this.#a.organizeImports(e):{success:!1,body:null}}async tsServerGetInlayHints(e){return this.#a?this.#a.getInlayHints(e):{success:!1,body:null}}async tsServerGetCodeFixes(e,r,n,i,o,s){return this.#a?this.#a.getCodeFixes(e,r,n,i,o,s):{success:!1,body:null}}async tsServerGetApplicableRefactors(e,r,n,i,o){return this.#a?this.#a.getApplicableRefactors(e,r,n,i,o):{success:!1,body:null}}async tsServerGetEditsForRefactor(e,r,n,i,o,s,a){return this.#a?this.#a.getEditsForRefactor(e,r,n,i,o,s,a):{success:!1,body:null}}async tsServerGetImplementation(e,r,n){return this.#a?this.#a.getImplementation(e,r,n):{success:!1,body:null}}async tsServerGetSelectionRange(e,r){return this.#a?this.#a.getSelectionRange(e,r):{success:!1,body:null}}async tsServerGetLinkedEditingRange(e,r,n){return this.#a?this.#a.getLinkedEditingRange(e,r,n):{success:!1,body:null}}async tsServerGetFormatRange(e,r,n,i,o){return this.#a?this.#a.getFormatRange(e,r,n,i,o):{success:!1,body:null}}subscribeToDiagnostics(e){return this.#_e.add(e),()=>{this.#_e.delete(e)}}async close(e=!1){if(!this.#Re){if(this.#Re=!0,this.#f&&(delete process.env.DEBUG,this.#f=!1),this.#xe.forEach(r=>r()),this.#Xt(),await this.#nt(),this.#a&&(this.#a.dispose(),this.#a=null),this.#_e.clear(),this.#Ie)try{this.#r.debug("Cleaning up local MCP servers"),await this.#Ie.cleanup()}catch(r){this.#e.Sentry?.captureException(r,{level:"warning",tags:{operation:"local-mcp-cleanup"}})}if(await this.stopEventLoop(),await this.waitUntilState("close",5e3),this.#u.removeAllListeners(),await Promise.allSettled(this.#ue),e){let r=await this.needsBackup();this.#i&&this.#r.debug(`Closing code gen server: ${JSON.stringify({uploadGitBackup:e,needsBackup:r})}`),r&&await this.uploadBackup()}else this.#i&&this.#r.debug(`Closing code gen server: ${JSON.stringify({uploadGitBackup:e})}`)}}async#v(){if(!this.#m||this.#p.length===0)return null;let r=(await this.#H(async i=>this.#rr(i))).results.filter(i=>i.success&&i.result).map(i=>i.result);if(r.length===0)return null;for(let i of r)this.#u.emit("step",i);return this.#ne=r,this.#J(this.#tr(r),"updateBranchUnpushedStatus",!1),r.some(i=>i.hasMergeConflict)&&await this.#de(),r[0]}async#tr(e){if(!this.#Q||!this.#P||!this.#s.builderPublicKey||!this.#s.userId||!this.#s.builderPrivateKey)return;let r=e.some(n=>n.ahead>0||n.isSessionDirty);try{let n=new URL("/projects/branches",Je);n.searchParams.set("apiKey",this.#s.builderPublicKey),n.searchParams.set("userId",this.#s.userId),n.searchParams.set("projectId",this.#Q),n.searchParams.set("branchName",this.#P);let i=await Ge(n,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.#s.builderPrivateKey}`},body:JSON.stringify({hasUnpushedChanges:r}),signal:AbortSignal.timeout(1e4)},this.#i);i.ok||this.#r.error(`Failed to update branch unpushed status: ${i.status} ${i.statusText}`,{loggerOptions:{debug:!0}})}catch(n){this.#r.error("Failed to update branch unpushed status:",n,{loggerOptions:{debug:!0}})}}async sendMessageToOrgAgent(e){try{let r=new URL("/projects/org-agent/send-message",Je);this.#s.builderPublicKey&&r.searchParams.set("apiKey",this.#s.builderPublicKey),this.#s.userId&&r.searchParams.set("userId",this.#s.userId);let n=await Ge(r,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.#s.builderPrivateKey}`},body:JSON.stringify(e),signal:AbortSignal.timeout(1e4)},this.#i),i=await n.json();return n.ok?{status:"success"}:{status:"error",error:i.error??`HTTP ${n.status}`}}catch(r){return{status:"error",error:r?.message??"Unknown error"}}}queueGitStatusReminder(e){if(this.#ne.length===0||this.#te||this.#T!=="quality-v4")return;let r=this.#ne.map(n=>fCe(n,this.gitEnabledFolders,e));this.queueSystemReminder({text:r.join(`
1930
+ ${Q}`}}this.#nt({gif_id:l.gif_id,gif_frames:x,timeline_id:K,recording_id:l.recording_id},!1),l.recording_id&&d.cleanupSessionFiles().catch(O=>{this.#r.warn(`[${s}] Failed to clean up local recording files: ${O instanceof Error?O.message:String(O)}`)})}catch(w){this.#r.warn(`[${s}] Failed to generate recording (non-critical): ${w instanceof Error?w.message:String(w)}`),this.#e.Sentry?.captureException(w,{level:"warning",tags:{component:"gif-generator",operation:"generateGifFromImages",subagent_type:s},extra:{sessionId:a.getSessionId(),frameCount:d.getFrameCount()}})}let b={success:!0,response:Q,metadata:l,sessionId:u,lastTurn:y};return c.resolve(b),b}catch(E){let y={success:!1,response:`Agent task failed: ${E instanceof Error?E.message:String(E)}`,metadata:{important_files:[]}};return c.resolve(y),y}finally{this.#_e.delete(A),r.signal?.removeEventListener("abort",B);try{await I()}catch(E){this.#r.warn(`[${s}] Cleanup failed: ${E instanceof Error?E.message:String(E)}`)}if(i.resetAfterRun&&o)try{await this.resetToCommitHash(o,!1)}catch(E){this.#r.warn(`[${s}] Failed to reset changes: ${E instanceof Error?E.message:String(E)}`)}}}getRunningSubAgents(){return Array.from(this.#_e.entries()).map(([e,r])=>({id:e,description:r.description,startedAt:r.startedAt}))}canHandleTool(e){return(this.#W.get(e)??0)>0}setProxyOrigin(e,r){if(e!==this.#Ne||r!==this.#Te){this.#Ne=e,this.#Te=r;let n=this.getProxyConfig();n.proxyDestination&&n.proxyDefaultOrigin&&this.queueSystemReminder({text:`The dev server is running at ${n.proxyDefaultOrigin}. e.g. for taking screenshots of a "/foo" route take a screenshot of ${n.proxyDefaultOrigin}/foo`,tag:"reminder:url"})}}async#Zt(e,r){let n=this.getProxyConfig();if(n.proxyOrigin&&!n.proxyDestination)return;let i=await eu(this.#s,"/codegen/get-browser-connection",{sessionId:e,projectId:this.#Q,branchName:this.#P,proxyOrigin:n.proxyOrigin,proxyDefaultOrigin:n.proxyDefaultOrigin,proxyDst:n.proxyDestination},{signal:r,debug:this.#i});return typeof i?.wsUrl=="string"?i.wsUrl:void 0}getTurns(){let e=this.getSessionContext();return structuredClone(e.turns)}getSessionContext(){if(!this.#n)throw new Error("Session context not initialized");return this.#n}async runSetupCommand(){return await this.#d?.runSetupCommand()}abortSetupCommand(){return this.#d?.abortSetupCommand()}abortValidateCommand(){return this.#d?.abortValidateCommand()}toolsRunning(){return this.#Y.length>0}abortAllTools(){for(let e of this.#Y)e.abortController.abort()}toolFullfilment(e,r){return typeof r=="string"&&(r={toolResult:r,isError:!1}),this.fulfillToolCall(e,r)}cancelAllPendingToolFulfilments(e){for(let[r,n]of Array.from(this.#X.entries()))n.messageValid&&e?this.fulfillToolCall(r,{toolResult:"The user answered with a follow-up message (see the next user message in the conversation).",isError:!1,title:"Resolved by user message"}):this.fulfillToolCall(r,{toolResult:"Aborted by the user. So the task could not be completed.",isError:!0,title:"Aborted by the user."});this.#X.clear()}fulfillToolCall(e,r){let n=this.#X.get(e);return n?(n.resolve(r),this.#X.delete(e),!0):!1}abortToolCall(e,r){let n=this.#Y.find(o=>o.id===e),i=Bn(r??"The user manually aborted the tool call.");if(n)return n.abortController.abort(i),!0;if(this.#Y.length===0){let o=new AbortController;return o.abort(i),this.#Y.push({id:e,abortController:o,input:{id:e},name:"bash"}),!0}return!1}async acceptCode(){if(this.#ot()){let e=this.getLinesStats();await this.sendFeedback({position:this.#h,acceptedLines:e.net,linesOfCodeAdded:e.added,linesOfCodeRemoved:e.removed})}}async abort(e){this.#i&&this.#r.debug(`(abort): ${JSON.stringify(e)}`);let r=!1,n=!0;return typeof e=="boolean"?r=e:(r=e?.cleanCurrentMessage??!1,n=e?.flushMessageQueue??!0),r&&(this.#o=void 0,this.clearMessageQueue()),this.#Fe=!n,this.cancelAllPendingToolFulfilments(),this.#ce=0,this.#g?(this.#g.abort(),this.#g=void 0,!0):!1}async stopEventLoop(){await this.abort({cleanCurrentMessage:!0}),this.#x?.abort(),this.#x=void 0,this.#l&&this.#l()}requestRefresh(){this.#u.emit("step",{type:"builder-action",action:"refresh",metadata:{}})}async configureDevOrchestrator(e){let r=this.#d,n={devCommand:!1,hosts:!1,setupCommand:!1,proxyServer:!1,validateCommand:!1,env:!1,fileOverrides:!1,setupResult:void 0,devResult:void 0,validateResult:void 0};if(r){let i=[];if(e.env&&(e.replaceEnvs&&(r.environmentVariables.length>0&&(n.env=!0),r.clearEnvVariables()),Object.entries(e.env).forEach(([o,s])=>{r.setEnvVariable(o,s??void 0)&&(n.env=!0)}),this.queueSystemReminder({text:`The system has the following environment variables:
1931
+ ${dCe(r.environmentVariables)}`,tag:"reminder:environment-variables"})),e.proxyServer?i.push(r?.setProxyServer(e.proxyServer).then(o=>{n.proxyServer=o.updatedProxyServer,n.hosts=o.updatedHosts})):e.proxyPort&&i.push(r?.setPort(e.proxyPort).then(o=>n.proxyServer=o)),e.fileOverrides&&(n.fileOverrides=r.setFileOverrides(e.fileOverrides)),e.setupCommand!==void 0||e.setupDependencies!==void 0?i.push(r.setSetupCommand({setupDependencies:e.setupDependencies,setupCommand:e.setupCommand,forceRestart:e.forceSetupCommand}).then(o=>{n.setupCommand=!!o,n.setupResult=o??void 0})):(e.forceSetupCommand||n.fileOverrides||n.env&&r.setupState!=="installed")&&i.push(r?.runSetupCommand().then(o=>{n.setupCommand=!!o,n.setupResult=o??void 0})),e.devCommand!==void 0?i.push(r.setDevCommand(e.devCommand??void 0,e.forceDevCommand||n.env).then(o=>{n.devCommand=o.status==="success",n.devResult=o??void 0})):(e.forceDevCommand||n.env)&&i.push(r?.restart().then(o=>{n.devCommand=!0,n.devResult=o??void 0})),e.autoDetectDevServer!==void 0&&i.push(r.setAutoDetectSettings(e.autoDetectDevServer,e.autoDetectDevServerPatterns).then(o=>n.proxyServer=n.proxyServer||o)),e.validateCommand!==void 0&&i.push(r.runValidateCommand(e.validateCommand).then(o=>n.validateResult=o)),await Promise.allSettled(i),n.env){let o=!1;for(let s of this.#D.values())(s.state==="running"||s.state==="starting")&&(s.stale=!0,o=!0);o&&this.#ge()}}return n}#Xt(){for(let e of Array.from(this.#D.keys()))try{this.disposeTerminal({terminalId:e})}catch{}this.#D.clear()}async#it(){if(this.#E.debounceTimer&&clearTimeout(this.#E.debounceTimer),this.#E.pendingEvents=[],this.#E.listeners.clear(),this.#E.watcher){try{await this.#E.watcher.close()}catch{}this.#E.watcher=null}}#er(){if(this.#E.watcher)return;let e=this.#p.map(A=>A.path),r=new Map;for(let A of this.#p)r.set(A.path,UK(A.path));let n=A=>{for(let c of this.#p)if(A.startsWith(c.path+"/")||A===c.path)return c.path;return null},i=A=>{let c=n(A);if(!c)return!1;let u=this.#e.relative(c,A).replace(/\\/g,"/");if(!u)return!1;if(this.#Ft(u))return!0;let l=r.get(c);return l?l(u):!1},o,s=!1;try{o=jhe.default.watch(e,{ignored:i,ignoreInitial:!0,persistent:!0,awaitWriteFinish:{stabilityThreshold:200,pollInterval:100},ignorePermissionErrors:!0,followSymlinks:!1,usePolling:!0,interval:1e3,binaryInterval:3e5,atomic:!0})}catch(A){this.#e.Sentry?.captureException(A,{tags:{operation:"global-file-watch-init"}}),this.#r.error(`Failed to initialize file watcher: ${A instanceof Error?A.message:String(A)}`),this.#r.error("File watching will be disabled. Code generation will still work but may not detect all changes automatically.");return}let a=(A,c)=>{let u=n(c),l=u?this.#e.relative(u,c).replace(/\\/g,"/"):this.#e.relative(this.primaryGitPath,c).replace(/\\/g,"/");if(this.#p.length>1&&u){let g=this.#p.find(p=>p.path===u);g&&!this.#R()&&(l=`${g.folderName}/${l}`)}let d={type:"folder-watch",watchId:"global",event:A,path:l,timestamp:Date.now()};this.#E.pendingEvents.push(d),this.#E.debounceTimer&&clearTimeout(this.#E.debounceTimer),this.#E.debounceTimer=setTimeout(()=>{let g=this.#E.pendingEvents;this.#E.pendingEvents=[];for(let p of g)for(let f of this.#E.listeners)try{f(p)}catch(m){this.#e.Sentry?.captureException(m)}},this.#E.debounceMs)};o.on("add",A=>a("add",A)).on("change",A=>a("change",A)).on("unlink",A=>a("unlink",A)).on("addDir",A=>a("addDir",A)).on("unlinkDir",A=>a("unlinkDir",A)).on("error",A=>{s||(s=!0,this.#e.Sentry?.captureException(A,{tags:{operation:"global-file-watch"}}),this.#r.error(`File watcher error: ${A instanceof Error?A.message:String(A)}`),this.#r.error("Closing file watcher to prevent further errors. File watching will be disabled."),this.#it().catch(()=>{}))}),this.#E.watcher=o,this.#r.debug(`Initialized global file watcher on: ${e.join(", ")}`)}subscribeToFileChanges(e){return this.#E.listeners.size===0&&this.#er(),this.#E.listeners.add(e),this.#r.debug(`Subscribed to file changes(${this.#E.listeners.size} active listeners)`),async()=>{this.#E.listeners.delete(e),this.#r.debug(`Unsubscribed from file changes(${this.#E.listeners.size} remaining listeners)`),this.#E.listeners.size===0&&this.#E.watcher&&(await this.#it(),this.#r.debug("Closed global file watcher (no more listeners)"))}}async tsServerInit(){try{return this.#a?{ok:!0,cwd:this.#C}:(this.#a=new Iv(this.#C),this.#a.setEventHandler(e=>{for(let r of this.#Le)r(e)}),await this.#a.start(),{ok:!0,cwd:this.#C})}catch(e){return this.#a=null,{ok:!1,error:e?.message||"Failed to start tsserver"}}}async tsServerOpenFile(e,r){this.#a&&await this.#a.openFile(e,r)}async tsServerChangeFile(e,r){this.#a&&await this.#a.changeFile(e,r)}async tsServerCloseFile(e){this.#a&&await this.#a.closeFile(e)}async tsServerGetCompletions(e,r,n,i){return this.#a?this.#a.getCompletions(e,r,n,i):{success:!1,body:null}}async tsServerGetCompletionDetails(e,r,n,i){return this.#a?this.#a.getCompletionDetails(e,r,n,i):{success:!1,body:null}}async tsServerGetDefinition(e,r,n){return this.#a?this.#a.getDefinition(e,r,n):{success:!1,body:null}}async tsServerGetTypeDefinition(e,r,n){return this.#a?this.#a.getTypeDefinition(e,r,n):{success:!1,body:null}}async tsServerGetQuickInfo(e,r,n){return this.#a?this.#a.getQuickInfo(e,r,n):{success:!1,body:null}}async tsServerGetReferences(e,r,n){return this.#a?this.#a.getReferences(e,r,n):{success:!1,body:null}}async tsServerGetSignatureHelp(e,r,n){return this.#a?this.#a.getSignatureHelp(e,r,n):{success:!1,body:null}}async tsServerRequestDiagnostics(e){this.#a&&await this.#a.requestDiagnostics(e)}async tsServerGetRenameLocations(e,r,n){return this.#a?this.#a.getRenameLocations(e,r,n):{success:!1,body:null}}async tsServerGetNavTree(e){return this.#a?this.#a.getNavTree(e):{success:!1,body:null}}async tsServerOrganizeImports(e){return this.#a?this.#a.organizeImports(e):{success:!1,body:null}}async tsServerGetInlayHints(e){return this.#a?this.#a.getInlayHints(e):{success:!1,body:null}}async tsServerGetCodeFixes(e,r,n,i,o,s){return this.#a?this.#a.getCodeFixes(e,r,n,i,o,s):{success:!1,body:null}}async tsServerGetApplicableRefactors(e,r,n,i,o){return this.#a?this.#a.getApplicableRefactors(e,r,n,i,o):{success:!1,body:null}}async tsServerGetEditsForRefactor(e,r,n,i,o,s,a){return this.#a?this.#a.getEditsForRefactor(e,r,n,i,o,s,a):{success:!1,body:null}}async tsServerGetImplementation(e,r,n){return this.#a?this.#a.getImplementation(e,r,n):{success:!1,body:null}}async tsServerGetSelectionRange(e,r){return this.#a?this.#a.getSelectionRange(e,r):{success:!1,body:null}}async tsServerGetLinkedEditingRange(e,r,n){return this.#a?this.#a.getLinkedEditingRange(e,r,n):{success:!1,body:null}}async tsServerGetFormatRange(e,r,n,i,o){return this.#a?this.#a.getFormatRange(e,r,n,i,o):{success:!1,body:null}}subscribeToDiagnostics(e){return this.#Le.add(e),()=>{this.#Le.delete(e)}}async close(e=!1){if(!this.#Re){if(this.#Re=!0,this.#f&&(delete process.env.DEBUG,this.#f=!1),this.#xe.forEach(r=>r()),this.#Xt(),await this.#it(),this.#a&&(this.#a.dispose(),this.#a=null),this.#Le.clear(),this.#Ie)try{this.#r.debug("Cleaning up local MCP servers"),await this.#Ie.cleanup()}catch(r){this.#e.Sentry?.captureException(r,{level:"warning",tags:{operation:"local-mcp-cleanup"}})}if(await this.stopEventLoop(),await this.waitUntilState("close",5e3),this.#u.removeAllListeners(),await Promise.allSettled(this.#ue),e){let r=await this.needsBackup();this.#i&&this.#r.debug(`Closing code gen server: ${JSON.stringify({uploadGitBackup:e,needsBackup:r})}`),r&&await this.uploadBackup()}else this.#i&&this.#r.debug(`Closing code gen server: ${JSON.stringify({uploadGitBackup:e})}`)}}async#v(){if(!this.#m||this.#p.length===0)return null;let r=(await this.#H(async i=>this.#rr(i))).results.filter(i=>i.success&&i.result).map(i=>i.result);if(r.length===0)return null;for(let i of r)this.#u.emit("step",i);return this.#ne=r,this.#J(this.#tr(r),"updateBranchUnpushedStatus",!1),r.some(i=>i.hasMergeConflict)&&await this.#de(),r[0]}async#tr(e){if(!this.#Q||!this.#P||!this.#s.builderPublicKey||!this.#s.userId||!this.#s.builderPrivateKey)return;let r=e.some(n=>n.ahead>0||n.isSessionDirty);try{let n=new URL("/projects/branches",Je);n.searchParams.set("apiKey",this.#s.builderPublicKey),n.searchParams.set("userId",this.#s.userId),n.searchParams.set("projectId",this.#Q),n.searchParams.set("branchName",this.#P);let i=await Ge(n,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.#s.builderPrivateKey}`},body:JSON.stringify({hasUnpushedChanges:r}),signal:AbortSignal.timeout(1e4)},this.#i);i.ok||this.#r.error(`Failed to update branch unpushed status: ${i.status} ${i.statusText}`,{loggerOptions:{debug:!0}})}catch(n){this.#r.error("Failed to update branch unpushed status:",n,{loggerOptions:{debug:!0}})}}async sendMessageToOrgAgent(e){try{let r=new URL("/projects/org-agent/send-message",Je);this.#s.builderPublicKey&&r.searchParams.set("apiKey",this.#s.builderPublicKey),this.#s.userId&&r.searchParams.set("userId",this.#s.userId);let n=await Ge(r,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.#s.builderPrivateKey}`},body:JSON.stringify(e),signal:AbortSignal.timeout(1e4)},this.#i),i=await n.json();return n.ok?{status:"success"}:{status:"error",error:i.error??`HTTP ${n.status}`}}catch(r){return{status:"error",error:r?.message??"Unknown error"}}}queueGitStatusReminder(e){if(this.#ne.length===0||this.#te||this.#T!=="quality-v4")return;let r=this.#ne.map(n=>fCe(n,this.gitEnabledFolders,e));this.queueSystemReminder({text:r.join(`
1932
1932
 
1933
- `),tag:"reminder:git-status"})}async manualCommit(e){if(!this.#m)return!1;let r=this.getSessionContext();if(!r.beforeCommit){let n=await this.#L();Object.keys(n).length>0&&(r.beforeCommit=Os(n))}return await this.commitWorkInProgress(e.commitMessage,[e.add]),await this.#re(!0),!0}getLastSuggestedAction(){return this.#oe}async#de(){let e=this.getSessionContext();if(e.state==="generating"||e.state==="close")return this.#oe=void 0,!1;let r=await this.#We(!0,"all");return e=this.getSessionContext(),e.state!=="generating"&&e.state!=="close"?(this.#oe=r,this.#u.emit("step",{type:"wait-for-input",id:this.getLastCompletionId()??"initial",state:e.state,suggestion:r,sessionMode:e.sessionMode,hasPlanToApply:this.#F,modelOverride:this.#O}),!0):!1}async#rr(e){if(!this.#m)return null;this.#Ee++;try{let r=this.getCommitMode(),n=this.getFeatureBranch(),i=this.#le(e),o=e.path,s=e.folderName===this.#p[0]?.folderName,a=this.getSessionContext(),A=!1,c=!1,u="",l=null;try{let E=await this.git(["rev-parse","--absolute-git-dir"],{cwd:o});l=this.#e.join(E.trim(),"FETCH_HEAD"),kl.default.existsSync(l)&&kl.default.unlinkSync(l)}catch(E){this.#e.Sentry?.captureException(E,{tags:{operation:"codegen-git",endpoint:"getGitStatus"},extra:{fetchHeadFilePath:l,isCheckingGitStatus:this.#Ee,folderName:e.folderName}}),l=null}try{u=await this.git(["fetch","--no-tags","origin",i],{cwd:o}),A=!0}catch{A=!1}let d=await this.#e.getRepoInfo(o),g=tl(a.beforeCommit,e.folderName,this.gitRepoContexts[0]?.folderName);!s&&!e.initialCommit&&d.commit&&(e.initialCommit=d.commit),!g&&e.initialCommit&&(g=e.initialCommit);let p=this.#it(e.folderName),f=p?1:0,m=0;if(A){if(n!==i)try{await this.git(["--no-pager","diff","--quiet",`refs/remotes/origin/${n}...refs/remotes/origin/${i}`],{cwd:o}),c=!1}catch{c=!0}else c=!0;try{let E=ACe(await this.git(["rev-list","--left-right","--count","HEAD...FETCH_HEAD"],{cwd:o}));f=E.ahead,m=E.behind}catch(E){let y=null;if(l)try{y=await this.#e.readFile(this.#e.join(o,".git/FETCH_HEAD")),y=`FETCH_HEAD: ${y} `}catch(Q){y=`FETCH_HEAD FAILED: ${String(Q)} `}else y="FETCH_HEAD MISSING";this.#e.Sentry?.captureException(E,{tags:{operation:"codegen-git",endpoint:"getGitStatus"},extra:{fetchOutput:u,fetchHead:y,remoteBranch:i,currentBranch:d.currentBranch,currentCommit:d.commit,isCheckingGitStatus:this.#Ee,folderName:e.folderName}})}}else!A&&r!=="commits"&&g&&g!==d.commit&&(f=Math.max(f,1));let C=await this.#z(o),I=C.length>0,B=await this.#lr(o);return{type:"git",folderName:e.folderName,remoteBranchExists:A,remoteBranchHasChanges:c,hasGeneratingPlaceholder:await this.#cr(),isSessionDirty:p||!!g&&g!==d.commit,canSync:(f>0||m>0||B)&&!I,canPush:(f>0||m>0)&&!I,hasStagedChanges:B,canPull:m>0&&A,ahead:f,hasMergeConflict:I,commitMode:r,behind:m,currentCommit:d.commit,currentBranch:d.currentBranch,pendingValidation:this.#ee,remoteBranch:i,unmergedFiles:C}}finally{this.#Ee--}}#St(){let e=this.getSessionContext(),r=e.turns,n=[];n.push({type:"session",title:e.title,beforeCommit:e.beforeCommit,createdUnixTime:e.createdUnixTime,updatedUnixTime:e.updatedUnixTime,turns:e.turns.length,id:e.sessionId,lastCompletionId:this.getLastCompletionId(),sessionMode:e.sessionMode,fusionConfig:yv(this.#A),hasBrowserAutomation:e.customAgents.some(i=>i.name==="browser-testing"),customInstructions:e.customInstructions.filter(i=>!i.hideUI).map(i=>({name:i.name,description:i.description??"",type:i.type??"always",glob:i.glob,isSkill:i.isSkill??i.filePath?.toLowerCase().includes("/skills/")??!1})),hasPlanToApply:this.#F}),Object.keys(this.#K).length>0&&n.push({type:"metadata",...this.#K}),this.#t.length>0&&n.push({type:"message-queue",queue:this.#t.map(i=>({idempotencyKey:i.idempotencyKey,displayPrompt:i.displayPrompt,user:i.user}))});for(let i of r){n.push({type:"user",displayPrompt:i.userMessage?i.userMessage.displayPrompt??i.userMessage.userPrompt:void 0,attachments:i.userMessage?.attachments,id:i.completionId,user:i.user,role:i.user.role,compacting:!1,idempotencyKey:i.userMessage?.idempotencyKey??""});for(let o of i.actions)if(o.type==="tool"||o.type==="text"||o.type==="thinking")if(n.push({type:"start",name:o.type,content:"",id:o.id??"",filePath:o.filePath??"",title:o.actionTitle??o.artifactTitle??o.filePath??""}),n.push({type:"delta",name:o.type,delta:o.content}),o.type==="tool"){if(n.push({type:o.type,id:o.id,name:o.filePath,content:o.content}),o.filePath==="UpdateSetupValue"||o.filePath==="ProposeConfig")try{let s=JSON.parse(o.content);if(o.filePath==="UpdateSetupValue")n.push({type:"update_setup_value",field:s.field,value:s.value,reason:s.reason});else{let a=s.config,A=a!=null&&!a.installCommand?.command&&(!a.runtimeDependencies||a.runtimeDependencies.length===0);n.push({type:"propose_config",config:a,message:s.message,noDependencies:A})}}catch{}}else o.type==="thinking"?n.push({type:"planning",content:o.content}):o.type==="text"&&n.push({type:"text",content:o.content})}return n}connectToEventLoop(e,r,n){let i=n?.canHandleTools??[];if(e){let o=[],s=this.getSessionContext();o.push({type:"state",newState:"replay",abortable:!1,previousState:s.state}),this.#Oe&&o.push(this.#Oe),o.push(...this.#ne),o.push(...this.#St()),this.#X.forEach(c=>{o.push({type:"tool-call-request",id:c.id,name:c.name,input:c.input})});let a=this.#Ce?zA(this.#Ce):void 0;if(a)switch(a.type){case"file":case"diff":case"text":case"thinking":case"suggestion":case"tool":o.push({type:"start",id:a.id,name:a.type,filePath:a.filePath??"",title:a.actionTitle??a.artifactTitle??"",content:""}),o.push({type:"delta",name:a.type,delta:a.content});break}o.push({type:"terminals",terminals:this.#et()});let A=this.#d;A?(o.push({type:"dev-server",devServerState:A.devState,setupState:A.setupState,httpServerState:A.httpServerState.state,devCommand:A.devCommand,setupCommand:A.setupCommand,proxyServer:A.proxyTarget,proxyServerSelection:A.proxyServerSelection,remoteAddress:A.httpServerState.remoteAddress,remotePort:A.httpServerState.remotePort,proxyServerReachable:!!this.#A?.isLocal,validateState:A.validateCommandState}),A.setupState!=="installed"&&o.push({type:"stdio",id:"setupCommand",command:A.setupCommand??"",content:A.getSetupWrite(),source:"run-command",stream:"stdout"}),o.push({type:"stdio",id:"devServer",command:A.devCommand,content:A.getDevWrite(),source:"run-command",stream:"stdout"})):r({type:"dev-server",devServerState:"running",setupState:"installed",httpServerState:"ok-2xx",devCommand:this.#A?.devCommand,setupCommand:this.#A?.setupCommand,proxyServer:this.#A?.serverUrl,proxyServerSelection:"hardcoded",remoteAddress:void 0,remotePort:void 0,proxyServerReachable:!!this.#A?.isLocal,validateState:"unset"}),o.push({type:"state",newState:s.state,abortable:s.state==="generating",previousState:"replay"}),this.#ie&&s.state!=="generating"&&o.push({type:"wait-for-input",id:this.getLastCompletionId()??"initial",state:s.state,suggestion:this.#oe,sessionMode:s.sessionMode,hasPlanToApply:this.#F}),r({type:"batch",steps:o})}this.#u.on("step",r);for(let o of i)this.#W.set(o,(this.#W.get(o)??0)+1);return this.waitForEventLoop(),()=>{this.#u.off("step",r);for(let o of i)this.#W.set(o,(this.#W.get(o)??0)-1)}}waitUntilPendingPromises(e){let r=$a();return this.#r.debug(`(waitUntilPendingPromises-${r}): started`),Fc(Promise.allSettled(this.#ue),e).then(()=>el()).then(()=>{this.#r.debug(`(waitUntilPendingPromises-${r}): finished`)})}waitUntilBlockingPendingPromises(e){let r=$a();return this.#r.debug(`(waitUntilBlockingPendingPromises-${r}): started`),Fc(Promise.allSettled(this.#Me),e).then(()=>el()).then(()=>{this.#r.debug(`(waitUntilBlockingPendingPromises-${r}): finished`)})}waitUntilIdle(e){let r=$a();return this.waitForEventLoop(),this.#r.debug(`(waitUntilIdle-${r}): started`),Fc(el().then(()=>this.waitUntilPendingPromises()).then(()=>{let n=this.getSessionContext();return this.#r.debug(`(waitUntilIdle-${r}): starting in ${n.state} `),n.state==="generating"?(0,ux.once)(this.#u,"idle"):Promise.resolve(void 0)}).then(()=>this.waitUntilPendingPromises()).then(()=>{this.#r.debug(`(waitUntilIdle-${r}): idle reached in ${this.getSessionContext().state} `)}),e)}async#xt(e){let r=this.#d;if(!r)throw new Error("Dev server not found");let n=await r.runValidateCommand(void 0,e);return n.status==="success"&&(this.#ee=!1,this.#m&&(await this.#Xe()).length===0&&(await this.#ot()||await this.manualCommit({add:".",commitMessage:"Validate command fixes"}))),n}waitForEventLoop(){return this.#ie?this.#ie:this.#ie=this.#nr()}async#nr(){if(this.#ie||this.#x)throw new Error("Event loop already started");this.#r.debug("(eventLoop): started");let e=aCe(),r=c=>{c.type==="error"&&this.#ce>0&&($he.includes(c.code)||(c.restoreCredits=this.#ce,this.#ce=0,tCe(this.#e,this.#s,o.sessionId,c.restoreCredits).catch(u=>{this.#e.Sentry?.captureException(u)}))),this.#u.emit("step",c)};this.#x=new AbortController;let n=this.#x.signal,i=this.#d,o=this.getSessionContext(),s=()=>this.getLastCompletionId();this.#e.Sentry?.setContext("codeGen",{sessionId:o.sessionId,get completionId(){return s()}}),await this.#J(this.#v(),"initial-emitGitStatus");let a=setInterval(()=>{this.canHandleTool("GetScreenshot")&&(this.#Ee>0||this.#v().catch(()=>{}))},6e4),A=()=>clearInterval(a);if(this.#xe.push(A),process.env.FUSION_IDE_PORT){let c=setInterval(()=>{$oe().then(u=>{let l=JSON.stringify(u);l!==this.#at&&(this.#at=l,this.#u.emit("step",{type:"ide",context:u}),this.queueSystemReminder({text:u?Yoe(u):"",tag:"reminder:ide-context"}))}).catch(()=>{})},1e3);this.#xe.push(()=>clearInterval(c))}this.queueGitStatusReminder({trigger:"session-start"}),i?.setupState==="not-installed"&&this.runSetupCommand();try{let c=0;for(;!n.aborted;){c++,this.#g=void 0;let u=this.#Wt();if(this.#r.debug(`(eventLoop-${c}): started (shouldWait: ${u.shouldWait})`),u.shouldWait){await this.#vt();let g=await this.#de();if(n.aborted)break;g&&lCe(u.promise,500).then(p=>{p&&(this.#r.debug(`(eventLoop-${c}): emitting idle on next message wait`),this.#u.emit("idle"))})}let l=await u.promise;if(n.aborted)break;if(!l)continue;this.#g=new AbortController;let d=Yn([n,this.#g.signal]);try{if(this.#oe=void 0,l.logsCheckpoint&&i?.addCheckpoint(),d?.aborted)throw Bn(d.reason);this.#$("generating"),i?.abortValidateCommand(),l.syncChanges&&(this.#r.debug(`(eventLoop-${c}): syncing changes from remote`),await this.syncChangesFromRemote(l.syncChanges),await this.#We(!1,"critical")),l.sessionMode&&l.sessionMode!==o.sessionMode&&this.switchSessionMode(l.sessionMode),await this.#ir(l,d,r),this.#$("success");let g=l.autoPush??this.#fe??"none";if(g!=="none"&&this.#m&&(this.#r.debug(`(eventLoop-${c}): autoPush: ${g}`),await this.waitUntilBlockingPendingPromises(),(await this.#Xe()).length===0)){let f=(()=>{switch(g){case"force-push":return{actor:"agent",forcePush:!0,pullFirst:!1};case"merge-push":return{actor:"agent",pullFirst:!0,forcePush:!1};case"ff-push":return{actor:"agent",requireFastForward:!0,pullFirst:!1};case"safe-push":return{actor:"agent",pullFirst:!0,abortOnMergeConflict:!0};default:return{actor:"agent"}}})();if(this.#p.length>1)for(let m of this.#p)await this.#Se({...f,folderName:m.folderName});else await this.#Se(f)}this.#oe=void 0}catch(g){g instanceof Error?g.name==="AbortError"?(r({type:"user-abort",hasContinueMessage:this.#t.length>0}),this.#$("abort")):g instanceof Ze?(this.#o=void 0,r({type:"error",code:"cli-network-error",message:g.message}),this.#e.Sentry?.captureException(g,{tags:{operation:"codegen-stream"}}),this.#$("error")):g instanceof $t?(this.#o=void 0,r({type:"error",code:"unknown",message:"An internal error occurred. Please try again."}),this.#e.Sentry?.captureException(g,{tags:{operation:"codegen-stream"}}),this.#$("error")):g instanceof Bi?(this.#o=void 0,r({type:"error",code:g.code,message:g.message}),$he.includes(g.code)||this.#e.Sentry?.captureException(g,{tags:{operation:"codegen-stream"}}),this.#$("error")):(this.#o=void 0,r({type:"error",code:"cli-genetic-error",message:g.message,metadata:{error:g}}),this.#e.Sentry?.captureException(g,{tags:{operation:"codegen-stream"}}),this.#$("error")):this.#$("error")}this.#kt++}}catch(c){throw this.#e.Sentry?.captureException(c,{level:"fatal"}),c}finally{A(),this.#x=void 0,this.#ie=void 0,e()}this.#r.debug("(eventLoop): emitting idle on close"),this.#u.emit("idle"),this.#$("close")}async#ir(e,r,n){this.#ce=0,this.#ee=!1;let i=this.getSessionContext(),o=e.displayPrompt||e.userPrompt||"";o&&this.#Ve.push(o);let s;if(e.agentType&&e.agentType!==this.#te){let y=await this.getNamedAgentConfig(e.agentType,this.getSessionId(),r);y.success&&(s={enabledTools:this.#y,modelOverride:this.#O,mode:this.#T,systemPromptOverride:this.#se,position:this.#h,includeMemories:this.#b},this.#y=y.options.enabledTools,this.#O=y.options.modelOverride,this.#T=y.options.mode,this.#se=y.options.systemPromptOverride,this.#h=y.options.position,this.#b=y.options.includeMemories)}let a=e.maxCompletions??this.#A?.maxAgentCompletions,A=a??lx,c=a??Whe,u=0,l=0,d=!0,g=!1,p=!1,f,m=0,C=0,I=!1,B=0;try{for(;;B++){if(this.#r.debug(`(agentCompletion-${B}): started`),this.#e.connectionTracker.getConnectionCount()>0&&l>=A||l>=c){n({type:"error",code:"ask-to-continue",message:"The agent has been working for a while. Do you want to continue?"});break}if(r?.aborted)throw Bn(r.reason);try{if(this.cancelAllPendingToolFulfilments(),f||(f=await this.#ar(e,d,r,n),f.modelOverride=e.modelOverride),f.user.role==="user"){let Q=f.files.filter(b=>(b.importance??0)>2.5&&b.content).map(b=>({filePath:b.filePath,size:b.content?.length??0,isCustomInstruction:!1,wasIncluded:b.wasIncluded}));i.customInstructions.forEach(b=>{b.filePath&&b.type==="always"&&Q.push({filePath:b.filePath,size:b.content?.length??0,isCustomInstruction:!0,wasIncluded:!0})}),n({type:"user-input",prompt:f.userMessage?.displayPrompt??f.userPrompt,files:Q})}try{let Q=await this.#or(i,f,r,n),{shouldContinue:b,completions:w,filesChanged:D}=Q;if(this.#i&&this.#r.debug(`(agentCompletion-${B}): completion: ${JSON.stringify(Q)}`),d=!1,f=void 0,u=0,g||=D,p||=D,l+=w,this.#ee||=D,this.#o=void 0,D&&this.#d?.addCheckpoint(),r?.aborted)throw Bn(r.reason);let{hasHealthIssue:x}=await this.#Pt();if(!b){if(r?.aborted)throw Bn(r.reason);let S=this.getSessionMode();if((S==="planning"||S==="auto-planning")&&!this.#F&&!I&&C<3){this.#r.debug(`(agentCompletion-${B}): adding reminder for missing plan`),I=!0,C++,this.queueSystemReminder({text:"Remember to always write the plan file and call the ExitPlanMode tool before finishing. Also, prefer using AskUserQuestion tool to ask questions to the user."});continue}if(x&&C<3){this.#r.debug(`(agentCompletion-${B}): has health issue, continuing`),C++;continue}let L=this.#Vt();if(L?.syncChanges&&await this.syncChangesFromRemote(L.syncChanges),L){this.#r.debug(`(agentCompletion-${B}): consumed queued messages`),d=!0,e=L,l=0;continue}let H=this.#d,K=e.runValidateCommand??!0;if(H?.validateCommand&&K&&m<2&&this.#ee){p=!0,m++,n({type:"start",name:"validate-command",id:"validate-command",title:"Validate Command",content:""});let M=e.autoPush;this.#r.debug(`(agentCompletion-${B}): running validate command`),this.#xt(r).then(_=>{if(this.#r.debug(`(validate-command): result status ${_.status}`),_.status==="failure"&&_.code){let j=_.output?TA(_.output,100,500):"";this.sendMessage({user:e.user,maxCompletions:e.maxCompletions,runValidateCommand:!0,userPrompt:`The validate command failed with code ${_.code}):
1933
+ `),tag:"reminder:git-status"})}async manualCommit(e){if(!this.#m)return!1;let r=this.getSessionContext();if(!r.beforeCommit){let n=await this.#U();Object.keys(n).length>0&&(r.beforeCommit=Os(n))}return await this.commitWorkInProgress(e.commitMessage,[e.add]),await this.#re(!0),!0}getLastSuggestedAction(){return this.#oe}async#de(){let e=this.getSessionContext();if(e.state==="generating"||e.state==="close")return this.#oe=void 0,!1;let r=await this.#Ze(!0,"all");return e=this.getSessionContext(),e.state!=="generating"&&e.state!=="close"?(this.#oe=r,this.#u.emit("step",{type:"wait-for-input",id:this.getLastCompletionId()??"initial",state:e.state,suggestion:r,sessionMode:e.sessionMode,hasPlanToApply:this.#F,modelOverride:this.#_}),!0):!1}async#rr(e){if(!this.#m)return null;this.#Ee++;try{let r=this.getCommitMode(),n=this.getFeatureBranch(),i=this.#le(e),o=e.path,s=e.folderName===this.#p[0]?.folderName,a=this.getSessionContext(),A=!1,c=!1,u="",l=null;try{let E=await this.git(["rev-parse","--absolute-git-dir"],{cwd:o});l=this.#e.join(E.trim(),"FETCH_HEAD"),kl.default.existsSync(l)&&kl.default.unlinkSync(l)}catch(E){this.#e.Sentry?.captureException(E,{tags:{operation:"codegen-git",endpoint:"getGitStatus"},extra:{fetchHeadFilePath:l,isCheckingGitStatus:this.#Ee,folderName:e.folderName}}),l=null}try{u=await this.git(["fetch","--no-tags","origin",i],{cwd:o}),A=!0}catch{A=!1}let d=await this.#e.getRepoInfo(o),g=tl(a.beforeCommit,e.folderName,this.gitRepoContexts[0]?.folderName);!s&&!e.initialCommit&&d.commit&&(e.initialCommit=d.commit),!g&&e.initialCommit&&(g=e.initialCommit);let p=this.#ot(e.folderName),f=p?1:0,m=0;if(A){if(n!==i)try{await this.git(["--no-pager","diff","--quiet",`refs/remotes/origin/${n}...refs/remotes/origin/${i}`],{cwd:o}),c=!1}catch{c=!0}else c=!0;try{let E=ACe(await this.git(["rev-list","--left-right","--count","HEAD...FETCH_HEAD"],{cwd:o}));f=E.ahead,m=E.behind}catch(E){let y=null;if(l)try{y=await this.#e.readFile(this.#e.join(o,".git/FETCH_HEAD")),y=`FETCH_HEAD: ${y} `}catch(Q){y=`FETCH_HEAD FAILED: ${String(Q)} `}else y="FETCH_HEAD MISSING";this.#e.Sentry?.captureException(E,{tags:{operation:"codegen-git",endpoint:"getGitStatus"},extra:{fetchOutput:u,fetchHead:y,remoteBranch:i,currentBranch:d.currentBranch,currentCommit:d.commit,isCheckingGitStatus:this.#Ee,folderName:e.folderName}})}}else!A&&r!=="commits"&&g&&g!==d.commit&&(f=Math.max(f,1));let C=await this.#z(o),I=C.length>0,B=await this.#lr(o);return{type:"git",folderName:e.folderName,remoteBranchExists:A,remoteBranchHasChanges:c,hasGeneratingPlaceholder:await this.#cr(),isSessionDirty:p||!!g&&g!==d.commit,canSync:(f>0||m>0||B)&&!I,canPush:(f>0||m>0)&&!I,hasStagedChanges:B,canPull:m>0&&A,ahead:f,hasMergeConflict:I,commitMode:r,behind:m,currentCommit:d.commit,currentBranch:d.currentBranch,pendingValidation:this.#ee,remoteBranch:i,unmergedFiles:C}}finally{this.#Ee--}}#St(){let e=this.getSessionContext(),r=e.turns,n=[];n.push({type:"session",title:e.title,beforeCommit:e.beforeCommit,createdUnixTime:e.createdUnixTime,updatedUnixTime:e.updatedUnixTime,turns:e.turns.length,id:e.sessionId,lastCompletionId:this.getLastCompletionId(),sessionMode:e.sessionMode,fusionConfig:yv(this.#A),hasBrowserAutomation:e.customAgents.some(i=>i.name==="browser-testing"),customInstructions:e.customInstructions.filter(i=>!i.hideUI).map(i=>({name:i.name,description:i.description??"",type:i.type??"always",glob:i.glob,isSkill:i.isSkill??i.filePath?.toLowerCase().includes("/skills/")??!1})),hasPlanToApply:this.#F}),Object.keys(this.#K).length>0&&n.push({type:"metadata",...this.#K}),this.#t.length>0&&n.push({type:"message-queue",queue:this.#t.map(i=>({idempotencyKey:i.idempotencyKey,displayPrompt:i.displayPrompt,user:i.user}))});for(let i of r){n.push({type:"user",displayPrompt:i.userMessage?i.userMessage.displayPrompt??i.userMessage.userPrompt:void 0,attachments:i.userMessage?.attachments,id:i.completionId,user:i.user,role:i.user.role,compacting:!1,idempotencyKey:i.userMessage?.idempotencyKey??""});for(let o of i.actions)if(o.type==="tool"||o.type==="text"||o.type==="thinking")if(n.push({type:"start",name:o.type,content:"",id:o.id??"",filePath:o.filePath??"",title:o.actionTitle??o.artifactTitle??o.filePath??""}),n.push({type:"delta",name:o.type,delta:o.content}),o.type==="tool"){if(n.push({type:o.type,id:o.id,name:o.filePath,content:o.content}),o.filePath==="UpdateSetupValue"||o.filePath==="ProposeConfig")try{let s=JSON.parse(o.content);if(o.filePath==="UpdateSetupValue")n.push({type:"update_setup_value",field:s.field,value:s.value,reason:s.reason});else{let a=s.config,A=a!=null&&!a.installCommand?.command&&(!a.runtimeDependencies||a.runtimeDependencies.length===0);n.push({type:"propose_config",config:a,message:s.message,noDependencies:A})}}catch{}}else o.type==="thinking"?n.push({type:"planning",content:o.content}):o.type==="text"&&n.push({type:"text",content:o.content})}return n}connectToEventLoop(e,r,n){let i=n?.canHandleTools??[];if(e){let o=[],s=this.getSessionContext();o.push({type:"state",newState:"replay",abortable:!1,previousState:s.state}),this.#Ke&&o.push(this.#Ke),o.push(...this.#ne),o.push(...this.#St()),this.#X.forEach(c=>{o.push({type:"tool-call-request",id:c.id,name:c.name,input:c.input})});let a=this.#Ce?zA(this.#Ce):void 0;if(a)switch(a.type){case"file":case"diff":case"text":case"thinking":case"suggestion":case"tool":o.push({type:"start",id:a.id,name:a.type,filePath:a.filePath??"",title:a.actionTitle??a.artifactTitle??"",content:""}),o.push({type:"delta",name:a.type,delta:a.content});break}o.push({type:"terminals",terminals:this.#tt()});let A=this.#d;A?(o.push({type:"dev-server",devServerState:A.devState,setupState:A.setupState,httpServerState:A.httpServerState.state,devCommand:A.devCommand,setupCommand:A.setupCommand,proxyServer:A.proxyTarget,proxyServerSelection:A.proxyServerSelection,remoteAddress:A.httpServerState.remoteAddress,remotePort:A.httpServerState.remotePort,proxyServerReachable:!!this.#A?.isLocal,validateState:A.validateCommandState}),A.setupState!=="installed"&&o.push({type:"stdio",id:"setupCommand",command:A.setupCommand??"",content:A.getSetupWrite(),source:"run-command",stream:"stdout"}),o.push({type:"stdio",id:"devServer",command:A.devCommand,content:A.getDevWrite(),source:"run-command",stream:"stdout"})):r({type:"dev-server",devServerState:"running",setupState:"installed",httpServerState:"ok-2xx",devCommand:this.#A?.devCommand,setupCommand:this.#A?.setupCommand,proxyServer:this.#A?.serverUrl,proxyServerSelection:"hardcoded",remoteAddress:void 0,remotePort:void 0,proxyServerReachable:!!this.#A?.isLocal,validateState:"unset"}),o.push({type:"state",newState:s.state,abortable:s.state==="generating",previousState:"replay"}),this.#ie&&s.state!=="generating"&&o.push({type:"wait-for-input",id:this.getLastCompletionId()??"initial",state:s.state,suggestion:this.#oe,sessionMode:s.sessionMode,hasPlanToApply:this.#F}),r({type:"batch",steps:o})}this.#u.on("step",r);for(let o of i)this.#W.set(o,(this.#W.get(o)??0)+1);return this.waitForEventLoop(),()=>{this.#u.off("step",r);for(let o of i)this.#W.set(o,(this.#W.get(o)??0)-1)}}waitUntilPendingPromises(e){let r=$a();return this.#r.debug(`(waitUntilPendingPromises-${r}): started`),Fc(Promise.allSettled(this.#ue),e).then(()=>el()).then(()=>{this.#r.debug(`(waitUntilPendingPromises-${r}): finished`)})}waitUntilBlockingPendingPromises(e){let r=$a();return this.#r.debug(`(waitUntilBlockingPendingPromises-${r}): started`),Fc(Promise.allSettled(this.#Pe),e).then(()=>el()).then(()=>{this.#r.debug(`(waitUntilBlockingPendingPromises-${r}): finished`)})}waitUntilIdle(e){let r=$a();return this.waitForEventLoop(),this.#r.debug(`(waitUntilIdle-${r}): started`),Fc(el().then(()=>this.waitUntilPendingPromises()).then(()=>{let n=this.getSessionContext();return this.#r.debug(`(waitUntilIdle-${r}): starting in ${n.state} `),n.state==="generating"?(0,ux.once)(this.#u,"idle"):Promise.resolve(void 0)}).then(()=>this.waitUntilPendingPromises()).then(()=>{this.#r.debug(`(waitUntilIdle-${r}): idle reached in ${this.getSessionContext().state} `)}),e)}async#xt(e){let r=this.#d;if(!r)throw new Error("Dev server not found");let n=await r.runValidateCommand(void 0,e);return n.status==="success"&&(this.#ee=!1,this.#m&&(await this.#et()).length===0&&(await this.#st()||await this.manualCommit({add:".",commitMessage:"Validate command fixes"}))),n}waitForEventLoop(){return this.#ie?this.#ie:this.#ie=this.#nr()}async#nr(){if(this.#ie||this.#x)throw new Error("Event loop already started");this.#r.debug("(eventLoop): started");let e=aCe(),r=c=>{c.type==="error"&&this.#ce>0&&($he.includes(c.code)||(c.restoreCredits=this.#ce,this.#ce=0,tCe(this.#e,this.#s,o.sessionId,c.restoreCredits).catch(u=>{this.#e.Sentry?.captureException(u)}))),this.#u.emit("step",c)};this.#x=new AbortController;let n=this.#x.signal,i=this.#d,o=this.getSessionContext(),s=()=>this.getLastCompletionId();this.#e.Sentry?.setContext("codeGen",{sessionId:o.sessionId,get completionId(){return s()}}),await this.#J(this.#v(),"initial-emitGitStatus");let a=setInterval(()=>{this.canHandleTool("GetScreenshot")&&(this.#Ee>0||this.#v().catch(()=>{}))},6e4),A=()=>clearInterval(a);if(this.#xe.push(A),process.env.FUSION_IDE_PORT){let c=setInterval(()=>{$oe().then(u=>{let l=JSON.stringify(u);l!==this.#At&&(this.#At=l,this.#u.emit("step",{type:"ide",context:u}),this.queueSystemReminder({text:u?Yoe(u):"",tag:"reminder:ide-context"}))}).catch(()=>{})},1e3);this.#xe.push(()=>clearInterval(c))}this.queueGitStatusReminder({trigger:"session-start"}),i?.setupState==="not-installed"&&this.runSetupCommand();try{let c=0;for(;!n.aborted;){c++,this.#g=void 0;let u=this.#Wt();if(this.#r.debug(`(eventLoop-${c}): started (shouldWait: ${u.shouldWait})`),u.shouldWait){await this.#vt();let g=await this.#de();if(n.aborted)break;g&&lCe(u.promise,500).then(p=>{p&&(this.#r.debug(`(eventLoop-${c}): emitting idle on next message wait`),this.#u.emit("idle"))})}let l=await u.promise;if(n.aborted)break;if(!l)continue;this.#g=new AbortController;let d=Yn([n,this.#g.signal]);try{if(this.#oe=void 0,l.logsCheckpoint&&i?.addCheckpoint(),d?.aborted)throw Bn(d.reason);this.#$("generating"),i?.abortValidateCommand(),l.syncChanges&&(this.#r.debug(`(eventLoop-${c}): syncing changes from remote`),await this.syncChangesFromRemote(l.syncChanges),await this.#Ze(!1,"critical")),l.sessionMode&&l.sessionMode!==o.sessionMode&&this.switchSessionMode(l.sessionMode),await this.#ir(l,d,r),this.#$("success");let g=l.autoPush??this.#fe??"none";if(g!=="none"&&this.#m&&(this.#r.debug(`(eventLoop-${c}): autoPush: ${g}`),await this.waitUntilBlockingPendingPromises(),(await this.#et()).length===0)){let f=(()=>{switch(g){case"force-push":return{actor:"agent",forcePush:!0,pullFirst:!1};case"merge-push":return{actor:"agent",pullFirst:!0,forcePush:!1};case"ff-push":return{actor:"agent",requireFastForward:!0,pullFirst:!1};case"safe-push":return{actor:"agent",pullFirst:!0,abortOnMergeConflict:!0};default:return{actor:"agent"}}})();if(this.#p.length>1)for(let m of this.#p)await this.#Se({...f,folderName:m.folderName});else await this.#Se(f)}this.#oe=void 0}catch(g){g instanceof Error?g.name==="AbortError"?(r({type:"user-abort",hasContinueMessage:this.#t.length>0}),this.#$("abort")):g instanceof Ze?(this.#o=void 0,r({type:"error",code:"cli-network-error",message:g.message}),this.#e.Sentry?.captureException(g,{tags:{operation:"codegen-stream"}}),this.#$("error")):g instanceof $t?(this.#o=void 0,r({type:"error",code:"unknown",message:"An internal error occurred. Please try again."}),this.#e.Sentry?.captureException(g,{tags:{operation:"codegen-stream"}}),this.#$("error")):g instanceof Bi?(this.#o=void 0,r({type:"error",code:g.code,message:g.message}),$he.includes(g.code)||this.#e.Sentry?.captureException(g,{tags:{operation:"codegen-stream"}}),this.#$("error")):(this.#o=void 0,r({type:"error",code:"cli-genetic-error",message:g.message,metadata:{error:g}}),this.#e.Sentry?.captureException(g,{tags:{operation:"codegen-stream"}}),this.#$("error")):this.#$("error")}this.#kt++}}catch(c){throw this.#e.Sentry?.captureException(c,{level:"fatal"}),c}finally{A(),this.#x=void 0,this.#ie=void 0,e()}this.#r.debug("(eventLoop): emitting idle on close"),this.#u.emit("idle"),this.#$("close")}async#ir(e,r,n){this.#ce=0,this.#ee=!1;let i=this.getSessionContext(),o=e.displayPrompt||e.userPrompt||"";o&&this.#We.push(o);let s;if(e.agentType&&e.agentType!==this.#te){let y=await this.getNamedAgentConfig(e.agentType,this.getSessionId(),r);y.success&&(s={enabledTools:this.#y,modelOverride:this.#_,mode:this.#T,systemPromptOverride:this.#se,position:this.#h,includeMemories:this.#b},this.#y=y.options.enabledTools,this.#_=y.options.modelOverride,this.#T=y.options.mode,this.#se=y.options.systemPromptOverride,this.#h=y.options.position,this.#b=y.options.includeMemories)}let a=e.maxCompletions??this.#A?.maxAgentCompletions,A=a??lx,c=a??Whe,u=0,l=0,d=!0,g=!1,p=!1,f,m=0,C=0,I=!1,B=0;try{for(;;B++){if(this.#r.debug(`(agentCompletion-${B}): started`),this.#e.connectionTracker.getConnectionCount()>0&&l>=A||l>=c){n({type:"error",code:"ask-to-continue",message:"The agent has been working for a while. Do you want to continue?"});break}if(r?.aborted)throw Bn(r.reason);try{if(this.cancelAllPendingToolFulfilments(),f||(f=await this.#ar(e,d,r,n),f.modelOverride=e.modelOverride),f.user.role==="user"){let Q=f.files.filter(b=>(b.importance??0)>2.5&&b.content).map(b=>({filePath:b.filePath,size:b.content?.length??0,isCustomInstruction:!1,wasIncluded:b.wasIncluded}));i.customInstructions.forEach(b=>{b.filePath&&b.type==="always"&&Q.push({filePath:b.filePath,size:b.content?.length??0,isCustomInstruction:!0,wasIncluded:!0})}),n({type:"user-input",prompt:f.userMessage?.displayPrompt??f.userPrompt,files:Q})}try{let Q=await this.#or(i,f,r,n),{shouldContinue:b,completions:w,filesChanged:D}=Q;if(this.#i&&this.#r.debug(`(agentCompletion-${B}): completion: ${JSON.stringify(Q)}`),d=!1,f=void 0,u=0,g||=D,p||=D,l+=w,this.#ee||=D,this.#o=void 0,D&&this.#d?.addCheckpoint(),r?.aborted)throw Bn(r.reason);let{hasHealthIssue:x}=await this.#Pt();if(!b){if(r?.aborted)throw Bn(r.reason);let S=this.getSessionMode();if((S==="planning"||S==="auto-planning")&&!this.#F&&!I&&C<3){this.#r.debug(`(agentCompletion-${B}): adding reminder for missing plan`),I=!0,C++,this.queueSystemReminder({text:"Remember to always write the plan file and call the ExitPlanMode tool before finishing. Also, prefer using AskUserQuestion tool to ask questions to the user."});continue}if(x&&C<3){this.#r.debug(`(agentCompletion-${B}): has health issue, continuing`),C++;continue}let L=this.#Vt();if(L?.syncChanges&&await this.syncChangesFromRemote(L.syncChanges),L){this.#r.debug(`(agentCompletion-${B}): consumed queued messages`),d=!0,e=L,l=0;continue}let H=this.#d,K=e.runValidateCommand??!0;if(H?.validateCommand&&K&&m<2&&this.#ee){p=!0,m++,n({type:"start",name:"validate-command",id:"validate-command",title:"Validate Command",content:""});let M=e.autoPush;this.#r.debug(`(agentCompletion-${B}): running validate command`),this.#xt(r).then(_=>{if(this.#r.debug(`(validate-command): result status ${_.status}`),_.status==="failure"&&_.code){let j=_.output?TA(_.output,100,500):"";this.sendMessage({user:e.user,maxCompletions:e.maxCompletions,runValidateCommand:!0,userPrompt:`The validate command failed with code ${_.code}):
1934
1934
  <validate_command>
1935
1935
  ${_.command}
1936
1936
  </validate_command>
@@ -1939,24 +1939,24 @@ ${_.command}
1939
1939
  ${j}
1940
1940
  </output>
1941
1941
 
1942
- failed with code ${_.code}`,dropAbortedPrompt:!0,attachments:void 0,displayPrompt:`The validation command ${_.command} failed with code ${_.code}.`,queue:!0,category:"repair-validate-command",syncChanges:void 0,autoPush:M})}})}break}}catch(Q){throw await this.#v(),Q}}catch(Q){let b=function(w){return!!(w instanceof Bi&&w.code==="abrupt-end"||w instanceof Error&&w.name==="HTTPStreamBroke"||w instanceof Ze&&[502,503].includes(w.statusCode??0)||w instanceof Ze&&!w.statusCode&&["connection_reset","connection_timeout","connection_aborted"].includes(w.type))};var E=b;if(u<3&&b(Q)){this.#r.debug(`(agentCompletion-${B}): retrying error`,Q),await Ng(u,r),u++;continue}throw Q}finally{eCe(i.turns)}}}finally{this.#r.debug(`(agentCompletion-${B}): finally block`),s&&(this.#y=s.enabledTools,this.#O=s.modelOverride,this.#T=s.mode,this.#se=s.systemPromptOverride,this.#h=s.position,this.#b=s.includeMemories),await this.#re(!0);let y=this.#A?.refreshPreview??!0;g&&y&&this.requestRefresh()}}async#or(e,r,n,i){if(n.aborted)throw Bn(n.reason);if(this.#Ce)throw new Error("generateCompletion already started");let o=$a(),s=this.getLastTurn()?.nextUrl??this.#B,a=!1,A=0;i({type:"start",id:"",name:"thinking",title:"Thinking",content:""});try{let c=this.#Ce=[];if(!e.beforeCommit){let D=await this.#L();Object.keys(D).length>0&&(e.beforeCommit=Os(D))}let u=await this.#L(),l=Os(u),d=this.#je;d&&this.#M?.enabled&&(d=!!this.#M.mcpServers);let g=r.userMessage?.uiContextPrompt;if(g&&!this.#R()){let D=this.#A?.workspace?.folders.find(x=>x.enableGit);D?.path&&(g=`Relative file paths are relative to: ${D.path}/`)}let p=this.#y,f={...e.userContext,fullstoryUrl:r.userMessage?.metadata?.fullstoryUrl,prNumber:r.userMessage?.metadata?.PR_NUMBER??e.userContext?.prNumber,prHeadSha:r.userMessage?.metadata?.PR_HEAD_SHA??e.userContext?.prHeadSha,repoFullName:r.userMessage?.metadata?.REPO_FULL_NAME??e.userContext?.repoFullName,hostname:r.userMessage?.metadata?.HOSTNAME??e.userContext?.hostname,checkRunId:r.userMessage?.metadata?.CHECK_RUN_ID??e.userContext?.checkRunId,containerUrl:process.env.FUSION_ENV_ORIGIN??e.userContext?.containerUrl};e.userContext=f,this.#mt=r.modelOverride;let m=this.#Ie?.listTools(),C={url:s,position:this.#h,eventName:"cli code",maxPages:2,autoContinue:1,codeGenMode:this.#T,userContext:f,systemReminders:r.systemReminders,files:r.files,skipFileDiff:this.#N,maxTokens:this.#ut,aclPolicy:this.#A?.accessControl,repoIndexingConfig:this.#A?.repoIndexingConfig,recommendedRoot:this.#ye,attachments:r.attachments,customInstructions:e.customInstructions,customAgents:e.customAgents.filter(D=>D.name!==this.#te).map(D=>({name:D.name,description:D.description})),systemPromptOverride:this.#se,sessionId:e.sessionId,userPrompt:r.userPrompt,metadata:{...f.prNumber&&{PR_NUMBER:f.prNumber},...f.prHeadSha&&{PR_HEAD_SHA:f.prHeadSha},...f.repoFullName&&{REPO_FULL_NAME:f.repoFullName},...f.hostname&&{HOSTNAME:f.hostname},...f.containerUrl&&{CONTAINER_URL:f.containerUrl},...f.checkRunId&&{CHECK_RUN_ID:f.checkRunId},...r.userMessage?.metadata},ephemeralUserPrompt:r.userMessage?.ephemeralUserPrompt,uiContextPrompt:r.userMessage?.uiContextPrompt,displayUserPrompt:r.userMessage?.displayPrompt,isManualContinue:r.userMessage?.isManualContinue,sessionMode:this.getSessionMode(),includeRelevantMemories:r.userMessage?r.userMessage.includeRelevantMemories??this.#b:void 0,projectId:this.#Q,branchName:this.#P,repoHash:this.#pt,pingEvents:!0,workingDirectory:this.#w,beforeCommit:l,toolResults:r.toolResults,role:r.user.role,user:r.user,repair:r.repair,category:r.category,enabledTools:p,enabledMCPs:d?r.enabledMCPs:void 0,localMCPTools:m,isLocal:this.#A?.isLocal,searchResponse:r.searchResponse,encryptKey:this.#me,maxAgentTiming:180*1e3,mcpServers:d,environmentVariables:cCe(this.#A?.environmentVariables??[],this.#d?.environmentVariables??[]),redactUserMessages:this.#M?.redactUserMessages,redactLLMMessages:this.#M?.redactLLMMessages,modelOverride:r.modelOverride??this.#O,reasoning:this.#Ye};this.#i&&this.#r.debug(`(generateCompletion-${o}): request partial body. ${JSON.stringify({url:C.url,userPrompt:C.userPrompt,systemReminders:C.systemReminders,toolResultsCount:C.toolResults?.length})}`);let I=rCe(this.#e,this.#s,C,n,this.#i),B,E=!1,y=!1,Q=async D=>{if(D.type==="user"){B&&B.state!=="done"&&this.#e.Sentry?.captureException(new Error("Turn was not completed before starting a new turn"),{tags:{operation:"codegen-stream"},extra:{lastTurn:B}});let x=B={state:"running",unixTime:Date.now(),title:"",sentiment:void 0,userMessage:r.userMessage,afterCommit:l,beforeCommit:l,lastCommit:void 0,creditsUsed:0,actions:[],applyResults:[],completionId:D.id??"",nextUrl:void 0,user:D.user,autoContinue:!1};B=x,e.turns.push(x),D.compacting&&(e.customInstructions=await this.#be(),e.customAgents=await this.#Ue()),i({type:"user",displayPrompt:D.displayPrompt,id:D.id,user:D.user,role:D.user.role,compacting:D.compacting,idempotencyKey:r.userMessage?.idempotencyKey})}else if(D.type==="mcp-status")this.#Oe=D,i(D);else{if(D.type==="mcp-auth-required")return y=!0,i(D),!0;if(D.type==="error")return y=!0,i(D),!0;if(D.type==="done"){A++,this.#G.length=0,this.#ce+=D.creditsUsed;let x=B=await this.#Ar(e,D,B,l);for(let H of D.actions??[])H.type==="tool_result"&&(H.filePath==="ExitPlanMode"&&(this.#F=!0),i({type:"tool_result",result:{content:H.content,tool_use_id:H.id,type:"tool_result",title:H.actionTitle,tool_name:H.filePath,is_error:!!H.errors?.length}}));await this.waitUntilBlockingPendingPromises(n);let S=await this.#gr(this.#e,x),L=S.length>0;L&&(a=!0),await this.commitWorkInProgress(`${B.title}
1942
+ failed with code ${_.code}`,dropAbortedPrompt:!0,attachments:void 0,displayPrompt:`The validation command ${_.command} failed with code ${_.code}.`,queue:!0,category:"repair-validate-command",syncChanges:void 0,autoPush:M})}})}break}}catch(Q){throw await this.#v(),Q}}catch(Q){let b=function(w){return!!(w instanceof Bi&&w.code==="abrupt-end"||w instanceof Error&&w.name==="HTTPStreamBroke"||w instanceof Ze&&[502,503].includes(w.statusCode??0)||w instanceof Ze&&!w.statusCode&&["connection_reset","connection_timeout","connection_aborted"].includes(w.type))};var E=b;if(u<3&&b(Q)){this.#r.debug(`(agentCompletion-${B}): retrying error`,Q),await Ng(u,r),u++;continue}throw Q}finally{eCe(i.turns)}}}finally{this.#r.debug(`(agentCompletion-${B}): finally block`),s&&(this.#y=s.enabledTools,this.#_=s.modelOverride,this.#T=s.mode,this.#se=s.systemPromptOverride,this.#h=s.position,this.#b=s.includeMemories),await this.#re(!0);let y=this.#A?.refreshPreview??!0;g&&y&&this.requestRefresh()}}async#or(e,r,n,i){if(n.aborted)throw Bn(n.reason);if(this.#Ce)throw new Error("generateCompletion already started");let o=$a(),s=this.getLastTurn()?.nextUrl??this.#B,a=!1,A=0;i({type:"start",id:"",name:"thinking",title:"Thinking",content:""});try{let c=this.#Ce=[];if(!e.beforeCommit){let D=await this.#U();Object.keys(D).length>0&&(e.beforeCommit=Os(D))}let u=await this.#U(),l=Os(u),d=this.#Ye;d&&this.#M?.enabled&&(d=!!this.#M.mcpServers);let g=r.userMessage?.uiContextPrompt;if(g&&!this.#R()){let D=this.#A?.workspace?.folders.find(x=>x.enableGit);D?.path&&(g=`Relative file paths are relative to: ${D.path}/`)}let p=this.#y,f={...e.userContext,fullstoryUrl:r.userMessage?.metadata?.fullstoryUrl,prNumber:r.userMessage?.metadata?.PR_NUMBER??e.userContext?.prNumber,prHeadSha:r.userMessage?.metadata?.PR_HEAD_SHA??e.userContext?.prHeadSha,repoFullName:r.userMessage?.metadata?.REPO_FULL_NAME??e.userContext?.repoFullName,hostname:r.userMessage?.metadata?.HOSTNAME??e.userContext?.hostname,checkRunId:r.userMessage?.metadata?.CHECK_RUN_ID??e.userContext?.checkRunId,containerUrl:process.env.FUSION_ENV_ORIGIN??e.userContext?.containerUrl};e.userContext=f,this.#Me=r.modelOverride;let m=this.#Ie?.listTools(),C={url:s,position:this.#h,eventName:"cli code",maxPages:2,autoContinue:1,codeGenMode:this.#T,userContext:f,systemReminders:r.systemReminders,files:r.files,skipFileDiff:this.#N,maxTokens:this.#lt,aclPolicy:this.#A?.accessControl,repoIndexingConfig:this.#A?.repoIndexingConfig,recommendedRoot:this.#ye,attachments:r.attachments,customInstructions:e.customInstructions,customAgents:e.customAgents.filter(D=>D.name!==this.#te).map(D=>({name:D.name,description:D.description})),systemPromptOverride:this.#se,sessionId:e.sessionId,userPrompt:r.userPrompt,metadata:{...f.prNumber&&{PR_NUMBER:f.prNumber},...f.prHeadSha&&{PR_HEAD_SHA:f.prHeadSha},...f.repoFullName&&{REPO_FULL_NAME:f.repoFullName},...f.hostname&&{HOSTNAME:f.hostname},...f.containerUrl&&{CONTAINER_URL:f.containerUrl},...f.checkRunId&&{CHECK_RUN_ID:f.checkRunId},...r.userMessage?.metadata},ephemeralUserPrompt:r.userMessage?.ephemeralUserPrompt,uiContextPrompt:r.userMessage?.uiContextPrompt,displayUserPrompt:r.userMessage?.displayPrompt,isManualContinue:r.userMessage?.isManualContinue,sessionMode:this.getSessionMode(),includeRelevantMemories:r.userMessage?r.userMessage.includeRelevantMemories??this.#b:void 0,projectId:this.#Q,branchName:this.#P,repoHash:this.#dt,pingEvents:!0,workingDirectory:this.#w,beforeCommit:l,toolResults:r.toolResults,role:r.user.role,user:r.user,repair:r.repair,category:r.category,enabledTools:p,enabledMCPs:d?r.enabledMCPs:void 0,localMCPTools:m,isLocal:this.#A?.isLocal,searchResponse:r.searchResponse,encryptKey:this.#me,maxAgentTiming:180*1e3,mcpServers:d,environmentVariables:cCe(this.#A?.environmentVariables??[],this.#d?.environmentVariables??[]),redactUserMessages:this.#M?.redactUserMessages,redactLLMMessages:this.#M?.redactLLMMessages,modelOverride:r.modelOverride??this.#_,reasoning:this.#qe};this.#i&&this.#r.debug(`(generateCompletion-${o}): request partial body. ${JSON.stringify({url:C.url,userPrompt:C.userPrompt,systemReminders:C.systemReminders,toolResultsCount:C.toolResults?.length})}`);let I=rCe(this.#e,this.#s,C,n,this.#i),B,E=!1,y=!1,Q=async D=>{if(D.type==="user"){B&&B.state!=="done"&&this.#e.Sentry?.captureException(new Error("Turn was not completed before starting a new turn"),{tags:{operation:"codegen-stream"},extra:{lastTurn:B}});let x=B={state:"running",unixTime:Date.now(),title:"",sentiment:void 0,userMessage:r.userMessage,afterCommit:l,beforeCommit:l,lastCommit:void 0,creditsUsed:0,actions:[],applyResults:[],completionId:D.id??"",nextUrl:void 0,user:D.user,autoContinue:!1};B=x,e.turns.push(x),D.compacting&&(e.customInstructions=await this.#be(),e.customAgents=await this.#Ge()),i({type:"user",displayPrompt:D.displayPrompt,id:D.id,user:D.user,role:D.user.role,compacting:D.compacting,idempotencyKey:r.userMessage?.idempotencyKey})}else if(D.type==="mcp-status")this.#Ke=D,i(D);else{if(D.type==="mcp-auth-required")return y=!0,i(D),!0;if(D.type==="error")return y=!0,i(D),!0;if(D.type==="done"){A++,this.#O.length=0,this.#ce+=D.creditsUsed;let x=B=await this.#Ar(e,D,B,l);for(let H of D.actions??[])H.type==="tool_result"&&(H.filePath==="ExitPlanMode"&&(this.#F=!0),i({type:"tool_result",result:{content:H.content,tool_use_id:H.id,type:"tool_result",title:H.actionTitle,tool_name:H.filePath,is_error:!!H.errors?.length}}));await this.waitUntilBlockingPendingPromises(n);let S=await this.#gr(this.#e,x),L=S.length>0;L&&(a=!0),await this.commitWorkInProgress(`${B.title}
1943
1943
  ${B.completionId}`,S),await this.#v(),this.#pe({completionId:x.completionId,beforeCommit:x.beforeCommit}),i({type:"done",stopReason:D.stopReason,id:D.id,applyResults:x.applyResults,actions:D.actions??[],creditsUsed:D.creditsUsed,sessionUsage:D.sessionUsage,contextWindow:D.contextWindow,model:D.model,usage:D.usage,url:D.nextUrl,promptVersion:D.promptVersion,hasChanges:L})}else{if(D.type==="continue")return E=D.autoContinue,y=!0,i({type:"continue",id:D.id,url:D.nextUrl,autoContinue:D.autoContinue}),!0;D.type==="thinking"&&(D.actionTitle="Planning"),"content"in D&&D.type!=="delta"&&i({type:"start",name:D.type,filePath:D.filePath??"",id:"id"in D?D.id:void 0,title:D.actionTitle??D.artifactTitle??D.filePath??"",content:D.content??""})}}return!1},b=D=>{if(D.type==="thinking"&&i({type:"planning",content:D.content}),D.type==="server_tool_result"){let x;try{x=JSON.parse(D.content)}catch(S){this.#e.Sentry?.captureException(S,{extra:{contentPreview:D.content?.substring(0,500),contentLength:D.content?.length},tags:{operation:"server-tool-result-parse"}}),x=D.content}i({type:"server_tool_result",content:x,title:D.actionTitle??D.artifactTitle??"Server Tool Result",id:D.id})}D.type==="file"&&D.filePath&&!D.synthetic&&i({type:"file",filePath:D.filePath,content:D.content,title:D.actionTitle??D.artifactTitle??"Created",id:D.id,errors:D.errors}),D.type==="diff"&&D.filePath&&!D.synthetic&&i({type:"diff",filePath:D.filePath,title:D.actionTitle??D.artifactTitle??"Updated",content:D.content,id:D.id,errors:D.errors}),D.type==="tool"&&D.filePath?i({type:"tool",name:D.filePath,id:D.id,content:D.content}):D.type==="text"&&i({type:"text",content:D.content})},w=(D,x)=>{i({type:"delta",name:D.type,delta:x})};for await(let D of I){if(D.type==="ping"){this.#r.debug(`(generateCompletion-${o}): ping`);continue}if(D.type==="delta"){let x=D.content,S=zA(c);S&&"content"in S&&(S.content+=x,w(S,x))}else{let x=zA(c);if(D.type==="thinking"&&x?.type==="thinking")continue;if(x&&"content"in x&&(x.incomplete=!1,b(x)),c.push(D),await Q(D))break}}if(!y)throw new Bi("Completion stream ended abruptly","abrupt-end");if(!B)throw new Bi("Completion stream ended abruptly","abrupt-end");return{completions:A,filesChanged:a,shouldContinue:E||B.actions.some(D=>D.type==="tool")||B.autoContinue}}finally{this.#Ce=void 0}}async commitWorkInProgress(e,r){if(!this.#m)return;let n=this.#Yt(r);await this.#H(async i=>{let o=n.get(i.folderName)||[],s=await this.#z(i.path);try{s.length>0?(o.length>0&&await this.git(["add",...o],{cwd:i.path,retry:2}),(await this.#z(i.path)).length===0&&await this.git(["add","-A","."],{cwd:i.path,retry:2})):await this.git(["add","-A","."],{cwd:i.path,retry:2})}catch(a){this.#e.Sentry?.captureException(new Error(`Error staging files in ${i.folderName}: ${a}`),{tags:{operation:"codegen-git-stage"}})}}),typeof this.#Qe=="string"?this.#Qe+=`
1944
- ${e}`:this.#Qe=e}async#re(e){if(!this.#m)return!1;let r=this.#Qe,n=this.#Ve,i=this.getLastTurn(),o=i?.completionId;this.#Qe=null,this.#Ve=[];let a=(async()=>{if(await this.#Ct,!r)return!1;this.#r.debug("(#commitAccumulatedChanges): committing pending changes");let A=!1;try{await this.#H(async l=>{let d="";try{await this.git(["--no-pager","diff","--cached","--quiet"],{cwd:l.path});return}catch{try{if(d=await this.git(["--no-pager","diff","--cached","--no-color"],{cwd:l.path}),!d.trim())return}catch{return}}let g=await this.#Jt(l.path),p=r,f=performance.now(),m=await eu(this.#s,"/codegen/commit-message",{diff:TA(d,500),userMessages:n,recentCommits:g,projectId:this.#Q},{signal:AbortSignal.timeout(2e4),debug:this.#i});this.#U("git_commit_message_llm",performance.now()-f,{folder:l.folderName});let B=(m?.message||p).split(`
1945
- `).flatMap(E=>["-m",E]);try{await this.git(["commit","--quiet","--no-verify","--no-gpg-sign",...B],{cwd:l.path}),A=!0}catch(E){this.#e.Sentry?.captureException(new Error(`Error in batch commit for ${l.folderName}: ${E}`),{tags:{operation:"codegen-git-batch-commit"}})}});let c=await this.#L(),u=Os(c);return u&&(this.#k={...this.#k,...c},i&&(i.afterCommit=u,i.lastCommit=u),this.#pe({completionId:o,beforeCommit:i?.beforeCommit,afterCommit:u,lastCommit:u,commitFailed:!1})),e&&await this.#v(),A}catch(c){return this.#e.Sentry?.captureException(new Error(`Error in #commitAccumulatedChanges: ${c}`),{tags:{operation:"codegen-git-batch-commit"}}),A}})();return this.#Ct=a,this.#J(a,"commitAccumulatedChanges",!0)}async#sr(e,r,n,i){let o=r.actions.filter(s=>s.type==="tool"&&s.id).map(s=>{let a=s.content.trim(),A={};try{A=a?JSON.parse(a):{}}catch{A={}}return{id:s.id,name:s.filePath,input:A,abortController:this.#Y.find(c=>c.id===s.id)?.abortController??new AbortController}})??[];if(o.length>0){this.#Y=o;try{let s={debug:this.#i,logger:ke("ToolContext",{debug:()=>!!(this.#i||process.env.DEBUG)}),sys:this.#e,credentials:this.#s,files:e.files,user:e.user,projectId:this.#Q,branchName:this.#P,position:this.#h,fusionConfig:this.#A,enabledTools:this.#y??[],sessionMode:this.getSessionMode(),fusionStatusMonitor:this.#Ke,asyncSubAgents:this.#qe,switchSessionMode:A=>this.switchSessionMode(A),signal:n,canCollapseWorkspace:this.#R(),emitter:this.#u,session:this,filterText:A=>(A=Uee(A,this.#w),this.#A?.accessControl?.secrets&&(A=Gee(A,this.#A.accessControl.secrets)),A),allowedCommands:j0(this.#A?.allowedCommands??[]),getAllFiles:A=>this.getAllFiles({getDotFiles:A.getDotFiles,includePattern:A.pattern,gitignore:!0,maxFiles:A.maxFiles}),workingDirectory:this.#C,bashWorkingDirectory:this.#w,workspaceFolders:this.#I?.folders??[],restore:A=>this.restore(A),patchFusionConfig:A=>{e.patchFusionConfig||(e.patchFusionConfig={});let c=e.patchFusionConfig.envVariables;Object.assign(e.patchFusionConfig,A),e.patchFusionConfig.envVariables={...c,...A.envVariables}},readFile:A=>this.readFile(A),writeFile:(A,c)=>this.writeFile(A,c),deleteFile:A=>this.deleteFile(A),fileExists:A=>this.fileExists(A),listDir:A=>this.listDir(A),evaluateAccess:(A,c)=>Na(A,c,this.#A?.accessControl,this.#V()),stat:A=>this.stat(A),localMCPManager:this.#Ie,passThrough:(A,c)=>new Promise((u,l)=>{let d=c?.messageValid??!1,g=c?.signal??new AbortController().signal;if(!this.canHandleTool(A.name)&&!d){l(new Error("The user is currently not present in the chat. Ie, he is not able to respond to the request"));return}let f=()=>{g.removeEventListener("abort",m),this.#X.delete(A.id)},m=()=>{f(),l(new Error("Aborted by the user. So the task could not be completed."))};if(g.aborted){m();return}g.addEventListener("abort",m,{once:!0}),this.#X.set(A.id,{id:A.id,name:A.name,input:A.input,messageValid:d,resolve:C=>{f(),u(C)}}),this.#u.emit("step",{type:"tool-call-request",id:A.id,name:A.name,input:A.input,messageValid:d})}),resolveWorkspacePath:(A,c)=>{if(typeof A!="string")throw new TypeError(`resolveWorkspacePath: 'path' must be a string, received ${typeof A}: ${ta(A)}`);return this.resolveWorkspacePath(A,c)},absolutePathToWorkspaceUrl:A=>this.absolutePathToWorkspaceUrl(A),setHasPlanToApply:A=>{this.#F=A},devServerOrchestrator:this.#d},a=await qhe(s,o,r.cachedToolResults,i);if(r.cachedToolResults=a,s.signal?.aborted)throw Bn(s.signal.reason);e.patchFusionConfig&&this.#u.emit("step",{type:"fusion-config-patch",patch:e.patchFusionConfig}),e.files=s.files,e.toolResults=a}finally{this.#Y=[]}}}async#ar(e,r,n,i){let o=this.getSessionContext(),s=zA(o.turns),a=structuredClone(e.user??s?.user??{source:"agent",role:"agent"}),A={userMessage:void 0,userPrompt:"",systemReminders:this.#G.slice(),files:[],attachments:[],searchResponse:null,rerankFiles:0,mostRelevantFile:null,toolResults:[],user:a,modelOverride:e.modelOverride,repair:e.repair,category:e.category,enabledMCPs:e.enabledMCPs},c=!!this.getLastTurn()?.nextUrl,u=o.turns.length<2||!c;if(r){let l=null;if(u){let d=Vhe(await this.getAllFiles({getDotFiles:!1,gitignore:!0,deep:4,truncate:2e4})),g=new Set,p=new Set;if(e.files)for(let B of e.files)g.add(Pee(B));let f=e.includeBaseFiles??o.turns.length===0,m=Array.from(g),C=B=>f&&oCe(B,this.#ye)?10:f&&iCe(B,this.#ye)?5:p.has(B)||m.some(E=>B.toLowerCase().startsWith(E.toLowerCase()))?2:0,I=n.aborted?[]:d.map(B=>{let E=C(B);if(E===0)return{filePath:B};let y=null;try{if(y=this.readFileSync(B),!y)return{filePath:B}}catch{return{filePath:B}}let Q=y.length<3e4;return{filePath:B,content:y,importance:Q?E:2}});A.files=I,A.attachments=e.attachments??[]}if(this.#m&&!this.#te){let d,g=await this.getChangesReport();if(g){for(let p of g.files)if(!A.files.some(f=>f.filePath===p))try{let f=await this.readFile(p);A.files.push({filePath:p,importance:0,content:f??void 0})}catch{A.files.push({filePath:p,importance:0})}g.diff.length<3e4?d=g.diff:d=g.files.map(p=>`- ${p}`).join(`
1944
+ ${e}`:this.#Qe=e}async#re(e){if(!this.#m)return!1;let r=this.#Qe,n=this.#We,i=this.getLastTurn(),o=i?.completionId;this.#Qe=null,this.#We=[];let a=(async()=>{if(await this.#Ct,!r)return!1;this.#r.debug("(#commitAccumulatedChanges): committing pending changes");let A=!1;try{await this.#H(async l=>{let d="";try{await this.git(["--no-pager","diff","--cached","--quiet"],{cwd:l.path});return}catch{try{if(d=await this.git(["--no-pager","diff","--cached","--no-color"],{cwd:l.path}),!d.trim())return}catch{return}}let g=await this.#Jt(l.path),p=r,f=performance.now(),m=await eu(this.#s,"/codegen/commit-message",{diff:TA(d,500),userMessages:n,recentCommits:g,projectId:this.#Q},{signal:AbortSignal.timeout(2e4),debug:this.#i});this.#G("git_commit_message_llm",performance.now()-f,{folder:l.folderName});let B=(m?.message||p).split(`
1945
+ `).flatMap(E=>["-m",E]);try{await this.git(["commit","--quiet","--no-verify","--no-gpg-sign",...B],{cwd:l.path}),A=!0}catch(E){this.#e.Sentry?.captureException(new Error(`Error in batch commit for ${l.folderName}: ${E}`),{tags:{operation:"codegen-git-batch-commit"}})}});let c=await this.#U(),u=Os(c);return u&&(this.#k={...this.#k,...c},i&&(i.afterCommit=u,i.lastCommit=u),this.#pe({completionId:o,beforeCommit:i?.beforeCommit,afterCommit:u,lastCommit:u,commitFailed:!1})),e&&await this.#v(),A}catch(c){return this.#e.Sentry?.captureException(new Error(`Error in #commitAccumulatedChanges: ${c}`),{tags:{operation:"codegen-git-batch-commit"}}),A}})();return this.#Ct=a,this.#J(a,"commitAccumulatedChanges",!0)}async#sr(e,r,n,i){let o=r.actions.filter(s=>s.type==="tool"&&s.id).map(s=>{let a=s.content.trim(),A={};try{A=a?JSON.parse(a):{}}catch{A={}}return{id:s.id,name:s.filePath,input:A,abortController:this.#Y.find(c=>c.id===s.id)?.abortController??new AbortController}})??[];if(o.length>0){this.#Y=o;try{let s={debug:this.#i,logger:ke("ToolContext",{debug:()=>!!(this.#i||process.env.DEBUG)}),sys:this.#e,credentials:this.#s,files:e.files,user:e.user,projectId:this.#Q,branchName:this.#P,position:this.#h,fusionConfig:this.#A,enabledTools:this.#y??[],sessionMode:this.getSessionMode(),fusionStatusMonitor:this.#He,asyncSubAgents:this.#ze,switchSessionMode:A=>this.switchSessionMode(A),signal:n,canCollapseWorkspace:this.#R(),emitter:this.#u,session:this,filterText:A=>(A=Uee(A,this.#w),this.#A?.accessControl?.secrets&&(A=Gee(A,this.#A.accessControl.secrets)),A),allowedCommands:j0(this.#A?.allowedCommands??[]),getAllFiles:A=>this.getAllFiles({getDotFiles:A.getDotFiles,includePattern:A.pattern,gitignore:!0,maxFiles:A.maxFiles}),workingDirectory:this.#C,bashWorkingDirectory:this.#w,workspaceFolders:this.#I?.folders??[],restore:A=>this.restore(A),patchFusionConfig:A=>{e.patchFusionConfig||(e.patchFusionConfig={});let c=e.patchFusionConfig.envVariables;Object.assign(e.patchFusionConfig,A),e.patchFusionConfig.envVariables={...c,...A.envVariables}},readFile:A=>this.readFile(A),writeFile:(A,c)=>this.writeFile(A,c),deleteFile:A=>this.deleteFile(A),fileExists:A=>this.fileExists(A),listDir:A=>this.listDir(A),evaluateAccess:(A,c)=>Na(A,c,this.#A?.accessControl,this.#V()),stat:A=>this.stat(A),localMCPManager:this.#Ie,passThrough:(A,c)=>new Promise((u,l)=>{let d=c?.messageValid??!1,g=c?.signal??new AbortController().signal;if(!this.canHandleTool(A.name)&&!d){l(new Error("The user is currently not present in the chat. Ie, he is not able to respond to the request"));return}let f=()=>{g.removeEventListener("abort",m),this.#X.delete(A.id)},m=()=>{f(),l(new Error("Aborted by the user. So the task could not be completed."))};if(g.aborted){m();return}g.addEventListener("abort",m,{once:!0}),this.#X.set(A.id,{id:A.id,name:A.name,input:A.input,messageValid:d,resolve:C=>{f(),u(C)}}),this.#u.emit("step",{type:"tool-call-request",id:A.id,name:A.name,input:A.input,messageValid:d})}),resolveWorkspacePath:(A,c)=>{if(typeof A!="string")throw new TypeError(`resolveWorkspacePath: 'path' must be a string, received ${typeof A}: ${ta(A)}`);return this.resolveWorkspacePath(A,c)},absolutePathToWorkspaceUrl:A=>this.absolutePathToWorkspaceUrl(A),setHasPlanToApply:A=>{this.#F=A},devServerOrchestrator:this.#d},a=await qhe(s,o,r.cachedToolResults,i);if(r.cachedToolResults=a,s.signal?.aborted)throw Bn(s.signal.reason);e.patchFusionConfig&&this.#u.emit("step",{type:"fusion-config-patch",patch:e.patchFusionConfig}),e.files=s.files,e.toolResults=a}finally{this.#Y=[]}}}async#ar(e,r,n,i){let o=this.getSessionContext(),s=zA(o.turns),a=structuredClone(e.user??s?.user??{source:"agent",role:"agent"}),A={userMessage:void 0,userPrompt:"",systemReminders:this.#O.slice(),files:[],attachments:[],searchResponse:null,rerankFiles:0,mostRelevantFile:null,toolResults:[],user:a,modelOverride:e.modelOverride,repair:e.repair,category:e.category,enabledMCPs:e.enabledMCPs},c=!!this.getLastTurn()?.nextUrl,u=o.turns.length<2||!c;if(r){let l=null;if(u){let d=Vhe(await this.getAllFiles({getDotFiles:!1,gitignore:!0,deep:4,truncate:2e4})),g=new Set,p=new Set;if(e.files)for(let B of e.files)g.add(Pee(B));let f=e.includeBaseFiles??o.turns.length===0,m=Array.from(g),C=B=>f&&oCe(B,this.#ye)?10:f&&iCe(B,this.#ye)?5:p.has(B)||m.some(E=>B.toLowerCase().startsWith(E.toLowerCase()))?2:0,I=n.aborted?[]:d.map(B=>{let E=C(B);if(E===0)return{filePath:B};let y=null;try{if(y=this.readFileSync(B),!y)return{filePath:B}}catch{return{filePath:B}}let Q=y.length<3e4;return{filePath:B,content:y,importance:Q?E:2}});A.files=I,A.attachments=e.attachments??[]}if(this.#m&&!this.#te){let d,g=await this.getChangesReport();if(g){for(let p of g.files)if(!A.files.some(f=>f.filePath===p))try{let f=await this.readFile(p);A.files.push({filePath:p,importance:0,content:f??void 0})}catch{A.files.push({filePath:p,importance:0})}g.diff.length<3e4?d=g.diff:d=g.files.map(p=>`- ${p}`).join(`
1946
1946
  `).trim().slice(0,3e4),d&&A.systemReminders.push({text:`
1947
1947
  Since last time, some files were changed by the user or tools (formatting for example):
1948
1948
  <modified-files-context>
1949
1949
  ${d}
1950
1950
  </modified-files-context>`,tag:"reminder:modified-files-context"})}}A.userMessage=e,A.userPrompt=e.userPrompt,A.attachments=e.attachments??[],A.searchResponse=l,A.rerankFiles=0,A.mostRelevantFile=null,A.toolResults=[]}else A.user.role="agent";return s&&await this.#sr(A,s,n,i),A}async#Ar(e,r,n,i){let{actions:o}=r,s=n||{state:"done",unixTime:r.unixTime??Date.now(),title:r.actionTitle,user:{source:"agent",role:"agent"},completionId:r.id??"",creditsUsed:r.creditsUsed??0,nextUrl:r.nextUrl,applyResults:[],actions:o??[],userMessage:void 0,beforeCommit:i,afterCommit:i,lastCommit:void 0,sentiment:void 0,autoContinue:r.autoContinue};if(s.state="done",s.title=r.actionTitle??"",s.creditsUsed=r.creditsUsed??0,s.nextUrl=r.nextUrl,s.autoContinue=r.autoContinue,s.actions=o??[],n||e.turns.push(s),Array.isArray(o))for(let a of o){let A=a.filePath;if(a.type==="file"&&A&&!a.incomplete){let u=!!await this.stat(A,!0),l=null,d=!0;if(u)try{l=this.readFileSync(A,!0)}catch{d=!1}if(l)if(a.content.trim()==="")s.applyResults.push({action:"delete",filePath:A,addedLines:0,removedLines:l.split(`
1951
1951
  `).length,content:"",oldContent:l});else{let g=Nae(l,a.content);s.applyResults.push({action:"update",filePath:A,addedLines:g.filter(p=>p.added).reduce((p,f)=>p+(f.count??0),0),removedLines:g.filter(p=>p.removed).reduce((p,f)=>p+(f.count??0),0),content:a.content,oldContent:l})}else u&&!d?s.applyResults.push({action:"update",filePath:A,addedLines:0,removedLines:0,content:a.content,oldContent:void 0}):s.applyResults.push({action:"create",filePath:A,addedLines:a.content.split(`
1952
- `).length,removedLines:0,content:a.content,oldContent:""})}}return s}#it(e){let r=this.getSessionContext();if(!e)return this.gitRepoContexts.some(A=>this.#it(A.folderName));let n=e,i=tl(r.beforeCommit,n,this.gitRepoContexts[0]?.folderName),o=r.turns.findLast(A=>A.afterCommit??A.beforeCommit),s=o?.afterCommit??o?.beforeCommit,a=tl(s,n,this.gitRepoContexts[0]?.folderName);return i&&a&&i!==a?!0:r.turns.some(A=>A.applyResults.some(c=>this.#Dt(c.filePath)?.folderName===e))}async#cr(){try{let e="{/* TODO: FUSION_GENERATION_APP_PLACEHOLDER replace everything here with the actual app! */}",r=await this.#e.readFile(this.resolveWorkspacePath("client/pages/Index.tsx",!0).resolvedPath);if((await this.#e.readFile(this.resolveWorkspacePath("client/App.tsx",!0).resolvedPath))?.includes('<Route path="/" element={<Index />} />')&&r&&r.includes(e))return!0}catch{}return!1}#Ft(e){let r=e.toLowerCase(),n=[".next/","dist/","build/","out/","node_modules/",".cache/","coverage/","__pycache__/","target/","vendor/",".gradle/",".build/"],i=[".gz",".zip",".tar",".tgz",".7z",".rar",".pack",".bin",".exe",".dll",".so",".dylib",".o",".a",".jar",".class",".pyc",".pyo",".wasm",".png",".jpg",".jpeg",".gif",".ico",".webp",".svg",".mp4",".mp3",".wav",".pdf",".woff",".woff2",".ttf",".eot",".map",".min.js",".min.css",".bundle.js",".chunk.js",".tsbuildinfo"];for(let o of n)if(r.includes(o))return!0;for(let o of i)if(r.endsWith(o))return!0;return!!(r.endsWith("package-lock.json")||r.endsWith("yarn.lock")||r.endsWith("pnpm-lock.yaml")||r.endsWith(".lock"))}async getChangesReport(){if(this.#m)try{let e=[],r=[];for(let i of this.#p){let o=this.#k[i.folderName];if(!o)continue;if((await this.#z(i.path)).length>0)return;try{let c=(await this.git(["--no-pager","diff","--name-only",o],{cwd:i.path})).trim().split(`
1952
+ `).length,removedLines:0,content:a.content,oldContent:""})}}return s}#ot(e){let r=this.getSessionContext();if(!e)return this.gitRepoContexts.some(A=>this.#ot(A.folderName));let n=e,i=tl(r.beforeCommit,n,this.gitRepoContexts[0]?.folderName),o=r.turns.findLast(A=>A.afterCommit??A.beforeCommit),s=o?.afterCommit??o?.beforeCommit,a=tl(s,n,this.gitRepoContexts[0]?.folderName);return i&&a&&i!==a?!0:r.turns.some(A=>A.applyResults.some(c=>this.#Dt(c.filePath)?.folderName===e))}async#cr(){try{let e="{/* TODO: FUSION_GENERATION_APP_PLACEHOLDER replace everything here with the actual app! */}",r=await this.#e.readFile(this.resolveWorkspacePath("client/pages/Index.tsx",!0).resolvedPath);if((await this.#e.readFile(this.resolveWorkspacePath("client/App.tsx",!0).resolvedPath))?.includes('<Route path="/" element={<Index />} />')&&r&&r.includes(e))return!0}catch{}return!1}#Ft(e){let r=e.toLowerCase(),n=[".next/","dist/","build/","out/","node_modules/",".cache/","coverage/","__pycache__/","target/","vendor/",".gradle/",".build/"],i=[".gz",".zip",".tar",".tgz",".7z",".rar",".pack",".bin",".exe",".dll",".so",".dylib",".o",".a",".jar",".class",".pyc",".pyo",".wasm",".png",".jpg",".jpeg",".gif",".ico",".webp",".svg",".mp4",".mp3",".wav",".pdf",".woff",".woff2",".ttf",".eot",".map",".min.js",".min.css",".bundle.js",".chunk.js",".tsbuildinfo"];for(let o of n)if(r.includes(o))return!0;for(let o of i)if(r.endsWith(o))return!0;return!!(r.endsWith("package-lock.json")||r.endsWith("yarn.lock")||r.endsWith("pnpm-lock.yaml")||r.endsWith(".lock"))}async getChangesReport(){if(this.#m)try{let e=[],r=[];for(let i of this.#p){let o=this.#k[i.folderName];if(!o)continue;if((await this.#z(i.path)).length>0)return;try{let c=(await this.git(["--no-pager","diff","--name-only",o],{cwd:i.path})).trim().split(`
1953
1953
  `).map(d=>d.trim()).filter(d=>d).filter(d=>!this.#Ft(d));if(c.length===0)continue;let u=c.map(d=>this.absolutePathToWorkspaceUrl(this.#e.join(i.path,d))).filter(d=>d!=null);e.push(...u);let l=await this.git(["--no-pager","diff","-U0","--no-color",o,"--",...c],{cwd:i.path}).then(d=>d.trim());l.length>0&&(this.#p.length>1?r.push(`
1954
1954
  ### Changes in ${i.folderName}:
1955
1955
  ${l}`):r.push(l))}catch(a){this.#e.Sentry?.captureException(a,{tags:{operation:"codegen-git",folderName:i.folderName}})}}if(e.length===0)return{files:[],diff:""};let n="";if(!this.#R()&&r.length>0)if(this.#p.length>1)n=`Notice: This is a multi-repo workspace with folders: ${this.#p.map(o=>o.folderName).join(", ")}. File paths are prefixed with their folder names when using Read/Write/Edit tools.
1956
1956
  `;else{let i=this.gitEnabledFolder;i&&(n=`Notice that all the relative paths, are inside "${i.name}/", remember that when using Read/Write/Edit tools:
1957
1957
  `)}return{files:e,diff:Df(`${n}${r.join(`
1958
- `)}`,1e4)}}catch(e){this.#e.Sentry?.captureException(e,{tags:{operation:"codegen-git"}});return}}#ur(){return["status","--porcelain=v1","-z","--ignore-submodules=dirty"]}async#ot(e){try{let r=this.#ur();return(await this.git(r,{cwd:e})).trim().length===0}catch{return!1}}async#lr(e){try{return await this.git(["diff","--cached","--quiet"],{cwd:e}),!1}catch{return!0}}async#gr(e,r){let n=r.applyResults,i=[];for(let o of n)try{if(o.action==="delete"){let s=await this.deleteFile(o.filePath);s&&i.push(s)}else if(o.content){let s=await this.writeFile(o.filePath,o.content);s&&(this.#Rt.add(s),i.push(s))}}catch(s){e.Sentry?.captureException(s)}return i}#R(){return this.#I?.folders?.length===1||!this.#I?.folders?.length}resolveWorkspacePath(e,r){if(typeof e!="string")throw new TypeError(`resolveWorkspacePath: 'filePath' must be a string, received ${typeof e}: ${ta(e)}`);return IAe({filePath:e,forceWorkspace:r,workspace:this.#I,workingDirectory:this.#C,sys:this.#e,canCollapseWorkspace:this.#R()})}#V(){try{let e=this.getSessionContext();return zA(e.turns)?.user.principals}catch{return}}absolutePathToWorkspaceUrl(e){return EAe({absolutePath:e,workspace:this.#I,workingDirectory:this.#C,sys:this.#e,canCollapseWorkspace:this.#R()})}async launchEditor(e={}){let r,n,i;return e.filePath?(r=this.resolveWorkspacePath(e.filePath,!1).resolvedPath,n=e.line??void 0,i=e.column??void 0):r=this.primaryGitPath,await this.#e.exists(r)?await this.#e.launchEditor({filePath:r,line:n,column:i}):{success:!1,message:`File not found: ${r}`}}async readFile(e,r){if(typeof e!="string")throw new TypeError(`readFile: 'filePath' must be a string, received ${typeof e}: ${ta(e)}`);if(!r){let n=Na(e,"read",this.#A?.accessControl,this.#V());if(!n.allowed)throw new $t(`ACL denied: ${n.message}`)}try{if(e==="AGENTS.md"&&this.#I?.agentsMD)return this.#I.agentsMD;let{resolvedPath:n}=this.resolveWorkspacePath(e,!!r),i=await this.#e.readFile(n);return i!==null?i:({resolvedPath:n}=this.resolveWorkspacePath(e,!0),await this.#e.readFile(n))}catch(n){this.#e.Sentry?.captureException(n,{extra:{filePath:e}})}return null}async readFileWithChecksum(e){let r=await this.readFile(e.filePath,e.skipAclCheck);if(r===null)return{content:null,checksum:null};let n=(0,kK.createHash)("md5").update(r).digest("hex");return e.previousChecksum&&n===e.previousChecksum?{content:null,checksum:n,notModified:!0}:{content:r,checksum:n}}async readBinaryFile(e){let r=Na(e,"read",this.#A?.accessControl,this.#V());if(!r.allowed)throw new $t(`ACL denied: ${r.message}`);try{let{resolvedPath:n}=this.resolveWorkspacePath(e,!1),i=await this.#e.readBinaryFile(n);if(i===null&&({resolvedPath:n}=this.resolveWorkspacePath(e,!0),i=await this.#e.readBinaryFile(n)),i)return Buffer.from(i).toString("base64")}catch(n){this.#e.Sentry?.captureException(n,{extra:{filePath:e}})}return null}async#st(e){let r;e?r=this.#p.find(o=>o.path===e)?.branchName:r=this.gitEnabledFolder?.branchName;let n=r?r.startsWith("origin/")?r:`origin/${r}`:await this.getDefaultBranch(e);if(!n)throw new Error("Could not find parent branch");return n}async#pr(e){let r=this.#De.get(e);if(r&&Date.now()-r.timestamp<t.#Et)return r.promise;let n=(async()=>{let i=await this.#st(e);try{return(await this.git(["merge-base",i,"HEAD"],{cwd:e})).trim()}catch{return i}})().catch(i=>{throw this.#De.get(e)?.promise===n&&this.#De.delete(e),i});return this.#De.set(e,{promise:n,timestamp:Date.now()}),n}async getFileAtRef(e,r,n){if(!this.#m)return null;try{let i,o;if(n)i=n,e.startsWith(i)?(o=e.substring(i.length),o.startsWith("/")&&(o=o.substring(1))):o=e;else{let{resolvedPath:u,workspaceFolder:l}=this.resolveWorkspacePath(e,!0);i=l?.path||this.#C,o=e,i&&u.startsWith(i)&&(o=u.substring(i.length),o.startsWith("/")&&(o=o.substring(1)))}let s=r??await this.#pr(i),a=`${i}:${s}:${o}`,A=this.#we.get(a);if(A&&Date.now()-A.timestamp<t.#Et)return A.promise;let c=this.git(["show",`${s}:${o}`],{cwd:i}).catch(u=>{let l=u instanceof Error?u.message:String(u);return l.includes("does not exist")||l.includes("exists on disk")||this.#we.get(a)?.promise===c&&this.#we.delete(a),null});return this.#we.set(a,{promise:c,timestamp:Date.now()}),c}catch{return null}}async getSingleFileDiff(e){if(e===null||typeof e!="string"&&typeof e!="object")throw new TypeError(`getSingleFileDiff: 'args' must be a string or object, received ${e===null?"null":typeof e}: ${ta(e)}`);let r=typeof e=="string"?{path:e}:e;if(typeof r.path!="string")throw new TypeError(`getSingleFileDiff: 'path' must be a string, received ${typeof r.path}: ${ta(r.path)}`);let n=typeof e=="object"?e.previousChecksum:void 0,{repoPath:i,relativePath:o}=this.#Bt(r.path,r.folderName),s=this.#e.join(i,o),[a,A]=await Promise.all([this.#e.readFile(s).catch(()=>null),this.getFileAtRef(o,void 0,i)]),c=A===null?"":`${A}`,u=a===null?"":`${a}`,l=(0,kK.createHash)("md5").update(`${c}\0${u}`).digest("hex"),d=A===null&&a!==null?"create":A!==null&&a===null?"delete":"update";return n===l?{oldContent:null,newContent:null,action:d,checksum:l,notModified:!0}:{oldContent:A,newContent:a,action:d,checksum:l}}async discardFileChanges(e){let r=typeof e=="string"?{filePath:e}:e;if(!this.#m)return{success:!1,error:"Git not configured"};try{let{repoPath:n,relativePath:i}=this.#Bt(r.filePath,r.folderName),o=this.#e.join(n,i),s=await this.#st(n),a;try{a=(await this.git(["merge-base",s,"HEAD"],{cwd:n})).trim()}catch{a=s}let A=await this.getFileAtRef(i,a,n),u=(await this.git(["--no-pager","diff",`${a}`,"HEAD","--",i],{cwd:n})).trim().length>0,d=(await this.git(["status","--porcelain","--",i],{cwd:n})).trim().length>0;if(!u&&!d)return{success:!0};if(A===null){try{await this.#e.exists(o)&&await this.#e.unlink(o)}catch{}let f=this.#e.dirname(i);if(f&&f!==".")try{await this.git(["clean","-fd",f],{cwd:n})}catch{}}else try{await this.git(["restore",`--source=${a}`,"--",i],{cwd:n})}catch(f){return{success:!1,error:`Failed to restore file: ${f}`}}await this.git(["add","--",i],{cwd:n});let g=`Discard changes to ${i}`;await this.git(["commit","--no-gpg-sign","-m",g],{cwd:n});let p=(await this.git(["rev-parse","HEAD"],{cwd:n})).trim();try{await this.#v()}catch(f){this.#e.Sentry?.captureException(f,{tags:{operation:"discard-file-changes",step:"emit-git-status"}})}return{success:!0,commitHash:p}}catch(n){try{await this.#v()}catch(i){this.#e.Sentry?.captureException(i,{tags:{operation:"discard-file-changes",step:"emit-git-status"}})}return{success:!1,error:n instanceof Error?n.message:String(n)}}}async revertDiscard(e){let{commitHash:r,folderName:n}=e;if(!this.#m)return{success:!1,error:"Git not configured"};try{let i=this.#ve(n);await this.git(["revert","--no-edit",r],{cwd:i});try{await this.#v()}catch(o){this.#e.Sentry?.captureException(o,{tags:{operation:"revert-discard",step:"emit-git-status"}})}return{success:!0}}catch(i){return{success:!1,error:i instanceof Error?i.message:String(i)}}}async fileExists(e){if(typeof e!="string")throw new TypeError(`fileExists: 'filePath' must be a string, received ${typeof e}: ${ta(e)}`);let r=n=>n.startsWith(this.#C)?this.#e.relative(this.#C,n):n;try{if(e==="AGENTS.md"&&this.#I?.agentsMD)return{absolutePath:e,recommendedPath:void 0,workspaceFolder:void 0,virtual:!0};let{resolvedPath:n,workspaceFolder:i}=this.resolveWorkspacePath(e,!1);return await this.#e.exists(n)?{absolutePath:n,recommendedPath:void 0,workspaceFolder:i,virtual:!1}:i?{absolutePath:void 0,recommendedPath:void 0,workspaceFolder:i,virtual:!1}:({resolvedPath:n,workspaceFolder:i}=this.resolveWorkspacePath(e,!0),await this.#e.exists(n)?{absolutePath:n,recommendedPath:r(n),workspaceFolder:i,virtual:!1}:{absolutePath:void 0,recommendedPath:r(n),workspaceFolder:i,virtual:!1})}catch(n){this.#e.Sentry?.captureException(n,{extra:{filePath:e}})}return{absolutePath:void 0,recommendedPath:void 0,workspaceFolder:void 0,virtual:!1}}readFileSync(e,r){if(!r){let n=Na(e,"read",this.#A?.accessControl,this.#V());if(!n.allowed)throw new $t(`ACL denied: ${n.message}`)}try{if(e==="AGENTS.md"&&this.#I?.agentsMD)return this.#I.agentsMD;let{resolvedPath:n}=this.resolveWorkspacePath(e,!1);if(this.#e.existsSync(n))return this.#e.readFileSync(n);if({resolvedPath:n}=this.resolveWorkspacePath(e,!0),this.#e.existsSync(n))return this.#e.readFileSync(n)}catch(n){this.#e.Sentry?.captureException(n,{extra:{filePath:e}})}return null}async writeFile(e,r,n){if(typeof e!="string")throw new TypeError(`writeFile: 'filePath' must be a string, received ${typeof e}: ${ta(e)}`);if(!n){let i=Na(e,"write",this.#A?.accessControl,this.#V());if(!i.allowed)throw new $t(`ACL denied: ${i.message}`)}try{let{resolvedPath:i}=this.resolveWorkspacePath(e,!!n);return await this.#e.writeFile(i,r),i}catch(i){return this.#e.Sentry?.captureException(i,{extra:{filePath:e}}),null}}async listDir(e){if(typeof e!="string")throw new TypeError(`listDir: 'dirPath' must be a string, received ${typeof e}: ${ta(e)}`);let r=Na(e,"list",this.#A?.accessControl,this.#V());if(!r.allowed)throw new $t(`ACL denied: ${r.message}`);try{let{resolvedPath:n,workspaceFolder:i}=this.resolveWorkspacePath(e,!1);if(!BAe({resolvedPath:n,workingDirectory:this.#C,workspace:this.#I,sys:this.#e}))throw new $t("Access denied: path outside working directory");if(!await this.#e.exists(n))return[];let A=(await(0,Yhe.readdir)(n,{withFileTypes:!0})).map(c=>c.name+(c.isDirectory()?"/":""));if(this.#R()){let c=A.map(u=>ls(this.#e.join(e,u)));return wf({files:c,policy:this.#A?.accessControl,getDotFiles:!0})}if(i&&this.#I?.folders){let c=i.name||i.path,u=e;e.startsWith(c+"/")?u=e.substring(c.length+1):e===c&&(u="");let l=A.map(d=>{let g=u?this.#e.join(u,d):d,p=ls(g);return`${c}/${p}`});return wf({files:l,policy:this.#A?.accessControl,getDotFiles:!0})}return wf({files:A,policy:this.#A?.accessControl,getDotFiles:!0})}catch(n){return this.#e.Sentry?.captureException(n,{extra:{dirPath:e}}),[]}}async listCustomInstructions(){return(await this.#be()).filter(r=>!r.hideUI).map(r=>({id:r.id,name:r.name,description:r.description,type:r.type,isSkill:r.isSkill??r.filePath?.toLowerCase().includes("/skills/")??!1,disableModelInvocation:r.disableModelInvocation,userInvocable:r.userInvocable}))}async stat(e,r){if(typeof e!="string")throw new TypeError(`stat: 'filePath' must be a string, received ${typeof e}: ${ta(e)}`);if(!r){let n=Na(e,"read",this.#A?.accessControl,this.#V());if(!n.allowed)throw new $t(`ACL denied: ${n.message}`)}try{let{resolvedPath:n}=this.resolveWorkspacePath(e,!1);if(await this.#e.exists(n))return await this.#e.stat(n)}catch(n){this.#e.Sentry?.captureException(n,{extra:{filePath:e}})}return null}async deleteFile(e,r){if(typeof e!="string")throw new TypeError(`deleteFile: 'filePath' must be a string, received ${typeof e}: ${ta(e)}`);if(!r){let n=Na(e,"write",this.#A?.accessControl,this.#V());if(!n.allowed)throw new $t(`ACL denied: ${n.message}`)}try{let{resolvedPath:n}=this.resolveWorkspacePath(e,!!r);return await this.#e.exists(n)?(await this.#e.unlink(n),n):null}catch(n){return this.#e.Sentry?.captureException(n,{extra:{filePath:e}}),null}}getLinesStats(){let e=this.#n?.turns.reduce((r,n)=>{let i=n.applyResults.reduce((o,s)=>({added:o.added+s.addedLines,removed:o.removed+s.removedLines}),{added:0,removed:0});return{added:r.added+i.added,removed:r.removed+i.removed}},{added:0,removed:0})??{added:0,removed:0};return{...e,net:e.added-e.removed}}async getDiffFromRemote({numberOfContextLines:e,includeFilesOnly:r,filePaths:n,folderName:i}){if(!this.#m)return[];let o=this.#ve(i);try{let s=(await this.git(["branch","--show-current"],{cwd:o})).trim();if(!s)throw new Error("Could not determine current branch");let a=!1;try{a=(await this.git(["remote"],{cwd:o})).includes("origin")}catch(d){throw this.#r.warn("No git remotes configured, cannot get diff from remote"),d}if(!a){this.#r.warn("Origin remote not found, trying to get diff from main branch");try{return await this.getDiffFromParentBranch({numberOfContextLines:e,includeFilesOnly:r,filePaths:n,folderName:i})}catch(d){throw this.#r.warn("Failed to get diff from main branch:",d),d}}let A=!1,c;try{let d=`origin/${s}`;if(A=(await this.git(["ls-remote","--heads","origin",s],{cwd:o})).trim().length>0,A)c=d;else return await this.getDiffFromParentBranch({numberOfContextLines:e,includeFilesOnly:r,filePaths:n,folderName:i})}catch(d){throw this.#r.warn("Failed to check remote branches:",d),d}let u=["diff",c];r?u.push("--raw","--numstat","--no-renames"):e!==void 0&&u.push(`-U${e}`),u.push("--"),n&&n.length>0&&u.push(...n);let l=await this.git(u,{cwd:o});return!l||l.trim()===""?[]:EK(l,r)}catch(s){throw s instanceof xp||this.#r.error("getDiffFromRemote error:",s),s}}async getDiff({mode:e="remote-parent-branch",numberOfContextLines:r,includeFilesOnly:n,filePaths:i,folderName:o}){if(!this.#m)return{state:"error",error:new Error("Git not configured")};try{switch(e){case"remote-parent-branch":return{state:"success",diff:await this.getDiffFromParentBranch({numberOfContextLines:r,includeFilesOnly:n,filePaths:i,folderName:o})};case"remote-current-branch":return{state:"success",diff:await this.getDiffFromRemote({numberOfContextLines:r,includeFilesOnly:n,filePaths:i,folderName:o})};default:throw new Error(`Unknown diff mode: ${e}`)}}catch(s){return s instanceof xp?{state:"error",error:s}:(this.#r.error(`getDiff error for mode '${e}':`,s),this.#e.Sentry?.captureException(s),{state:"error",error:s instanceof Error?s:new Error(String(s))})}}async getDefaultBranch(e){let r=e??"__primary__",n=this.#Le.get(r);if(n)return n;let i=this.#dr(e).catch(o=>{throw this.#Le.get(r)===i&&this.#Le.delete(r),o});return this.#Le.set(r,i),i}async#dr(e){try{let n=(await this.git(["remote","show","origin"],{cwd:e})).match(/HEAD branch: (.+)/);if(n)return`origin/${n[1].trim()}`}catch{}try{if((await this.git(["ls-remote","--heads","origin","main"],{cwd:e})).trim().length>0)return"origin/main"}catch{}try{if((await this.git(["ls-remote","--heads","origin","master"],{cwd:e})).trim().length>0)return"origin/master"}catch{}try{let n=(await this.git(["ls-remote","--heads","origin"],{cwd:e})).trim().split(`
1959
- `).map(i=>i.split(" ")[1]).filter(i=>i&&!i.includes("HEAD"));if(n.length>0)return`origin/${n[0].replace("refs/heads/","")}`}catch{}throw new Error("Could not determine default branch. No remote branches found.")}async getDiffFromParentBranch({numberOfContextLines:e,includeFilesOnly:r,filePaths:n,folderName:i}){let o=this.#ve(i);try{if(!(await this.git(["branch","--show-current"],{cwd:o})).trim())throw new Error("Could not determine current branch");let a=await this.#st(o),A;try{A=(await this.git(["merge-base",a,"HEAD"],{cwd:o})).trim()}catch(l){throw l instanceof ra&&l.code===128?new xp(a,{cause:l}):l}let c=["--no-pager","diff",A];r?c.push("--raw","--numstat","--no-renames"):e!==void 0&&c.push(`-U${e}`),c.push("--"),n&&n.length>0&&c.push(...n);let u=await this.git(c,{cwd:o});return!u||u.trim()===""?[]:EK(u,r)}catch(s){throw s instanceof xp||this.#r.error("getDiffFromParentBranch error:",s),s}}},sx=(t,e)=>e.filter(r=>!t?.disabledTools?.includes(r))});function mCe(t){return t instanceof Error?t.message:String(t)}function fy(t,e){if(JK(e).test(t))return!0;if(e.toLowerCase().includes("localhost")){let n=e.replace(/localhost/gi,"127.0.0.1");if(JK(n).test(t))return!0}else if(e.includes("127.0.0.1")){let n=e.replace(/127\.0\.0\.1/g,"localhost");if(JK(n).test(t))return!0}return!1}function JK(t){return t=String(t).replace(/\./g,"\\.").replace(/\?/g,".").replace(/\*/g,".*"),new RegExp(`^${t}$`,"i")}var px,hCe=N(()=>{"use strict";h();px=class{logger;currentOrigin=null;currentOriginPattern=null;currentDestination=null;currentOriginHost=null;constructor(e){this.logger=e}getCurrentOrigin(){return this.currentOrigin}getCurrentDestination(){return this.currentDestination}clearMapping(){this.currentOrigin=null,this.currentOriginPattern=null,this.currentDestination=null,this.currentOriginHost=null,this.logger?.info("[UrlMapper] Mapping cleared")}setMapping(e,r){if(e.includes("*")||!e.startsWith("https://")&&!e.startsWith("http://")){this.currentOriginPattern=e,this.currentOriginHost=null,this.currentOrigin=e;try{let i=new URL(r);this.currentDestination=`${i.protocol}//${i.hostname}${i.port?":"+i.port:""}`}catch(i){this.logger?.error(`[UrlMapper] Failed to parse destination URL: ${mCe(i)}`),this.currentDestination=r}this.logger?.info(`[UrlMapper] Set mapping (PATTERN): ${e} \u2192 ${r}`)}else{this.currentOriginPattern=null;try{let i=new URL(e),o=i.protocol==="https:"?"443":"80",s=i.port||o;this.currentOriginHost=`${i.hostname}:${s}`,this.currentOrigin=`${i.protocol}//${i.hostname}${i.port?":"+i.port:""}`;let a=new URL(r);this.currentDestination=`${a.protocol}//${a.hostname}${a.port?":"+a.port:""}`,this.logger?.info(`[UrlMapper] Set mapping (EXACT): ${e} \u2192 ${r}`),this.logger?.debug(`[UrlMapper] Normalized origin: ${this.currentOrigin} (host: ${this.currentOriginHost})`),this.logger?.debug(`[UrlMapper] Normalized destination: ${this.currentDestination}`)}catch(i){this.logger?.error(`[UrlMapper] Failed to parse origin/destination URL: ${mCe(i)}`),this.currentOriginHost=null,this.currentOrigin=e,this.currentDestination=r}}}getUpstream(e){if(!this.currentDestination)return null;if(this.currentOriginPattern){let r=this.currentOriginPattern.replace(/^https?:\/\//g,""),n=r.split(":")[0],i=e.split(":")[0];return fy(i,n)?(this.logger?.debug(`[UrlMapper] PATTERN MATCH FOUND getUpstream(${e}) matched hostname: ${n} -> ${this.currentDestination}`),this.currentDestination):fy(e,r)?(this.logger?.debug(`[UrlMapper] PATTERN MATCH FOUND getUpstream(${e}) matched host: ${r} -> ${this.currentDestination}`),this.currentDestination):(this.logger?.debug(`[UrlMapper] NO PATTERN MATCH getUpstream(${e}) !== ${r}`),null)}return this.currentOriginHost?fy(e,this.currentOriginHost)?(this.logger?.debug(`[UrlMapper] MATCH FOUND getUpstream(${e}) -> ${this.currentDestination}`),this.currentDestination):fy(`${e}:80`,this.currentOriginHost)?(this.logger?.debug(`[UrlMapper] MATCH FOUND getUpstream(${e}) (HTTP) -> ${this.currentDestination}`),this.currentDestination):fy(`${e}:443`,this.currentOriginHost)?(this.logger?.debug(`[UrlMapper] MATCH FOUND getUpstream(${e}) (TLS) -> ${this.currentDestination}`),this.currentDestination):(this.logger?.debug(`[UrlMapper] NO MATCH getUpstream(${e}) !== ${this.currentOriginHost}`),null):null}buildUpstreamUrl(e,r="/"){let n=r||"/";n=n.replace(/^\/+/,"/");let i=new URL(n,e),o=new URL(e);return o.pathname=i.pathname.replace(/\/+/g,"/"),o.search=i.search,o.hash=i.hash,o}mapUrl(e){let r=e.host,n=this.getUpstream(r);if(!n)return e;let i=e.pathname+e.search+e.hash;return this.buildUpstreamUrl(n,i)}isOriginHttps(e=443){let r=this.currentOrigin?.split("://")[0];return r==="http"||r==="https"?r==="https":e===443}}});var CCe,ert,$K,ICe=N(()=>{"use strict";h();CCe=Z(require("node:os"),1);_t();ert=ke("Priority"),$K=(t,e)=>{try{CCe.default.setPriority(t,e)}catch(r){ert.error(`Failed to set priority to ${e}: ${r}`)}}});function ECe(t){qK=t}async function zm(){if(qK){if(jK){YK=!0;return}jK=!0;try{await qK()}finally{jK=!1,YK&&(YK=!1,zm())}}}var qK,jK,YK,zK=N(()=>{"use strict";h();jK=!1,YK=!1});async function*trt(t){for await(let e of af(t.body))if(e.length)try{yield JSON.parse(e)}catch{}}function rrt(t){t.toolContext.session.sendMessage({userPrompt:Foe({originChannelId:t.originChannelId,senderDisplayName:t.senderDisplayName,projectId:t.projectId,branchName:t.branchName,content:t.content}),category:"background-subagent",user:{...t.toolContext.user,role:"agent",source:"builder.io"},queue:!0})}function nrt(t,e){return e??("builderUserId"in t.user?t.user.builderUserId:t.user.source==="builder.io"?t.user.userId:t.credentials.userId)}function BCe(t,e){let{credentials:r}=t,{project_id:n,message:i}=e,o,s=new Promise(g=>o=g),a=!1,A,c,u,l;return(async()=>{let g=new URL("/projects/branch",Je);g.searchParams.set("apiKey",r.builderPublicKey);let p=nrt(t,e.builder_user_id);p&&g.searchParams.set("userId",p);let f=e.model&&e.model!=="auto"?Of(e.model):void 0,m=e.attachment_urls?.map(y=>({type:"url",value:y})),C=e.origin_channel_id??t.user.channelId,I={projectId:n,userMessage:{userPrompt:i,user:{...t.user,channelId:C,role:"user"},...e.session_mode&&{sessionMode:e.session_mode},...f&&{modelOverride:f},...m?.length&&{attachments:m}},hidden:e.hidden,actor:"org-agent",metadata:{origin_channel_id:C}},B=await Ge(g,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r.builderPrivateKey}`},body:JSON.stringify(I)},t.debug);if(!B.ok){let y=await B.text();throw new Error(`Failed to spawn branch: ${y}`)}let E;for await(let y of trt(B))if(y.type==="branch-created")E=y;else if(y.type==="error")E=y;else if(!a&&y.type==="setting-up-container")a=!0,c||(c=y.projectName),u||(u=y.branchFriendlyName??void 0),l||(l=y.branchName),o(y);else{let Q=Qoe(y);Q&&(A=Q.plan)}if(!E)throw new Error("Stream ended unexpectedly");return E})().then(g=>{a||o(null);let p=c??g.projectName??n,f=u??l??g.branchName,m=`https://builder.io/app/projects/${n}/${l??g.branchName}`;if(g.type!=="error"){let C=`Branch \`${f}\` in \`${p}\` completed.
1958
+ `)}`,1e4)}}catch(e){this.#e.Sentry?.captureException(e,{tags:{operation:"codegen-git"}});return}}#ur(){return["status","--porcelain=v1","-z","--ignore-submodules=dirty"]}async#st(e){try{let r=this.#ur();return(await this.git(r,{cwd:e})).trim().length===0}catch{return!1}}async#lr(e){try{return await this.git(["diff","--cached","--quiet"],{cwd:e}),!1}catch{return!0}}async#gr(e,r){let n=r.applyResults,i=[];for(let o of n)try{if(o.action==="delete"){let s=await this.deleteFile(o.filePath);s&&i.push(s)}else if(o.content){let s=await this.writeFile(o.filePath,o.content);s&&(this.#Rt.add(s),i.push(s))}}catch(s){e.Sentry?.captureException(s)}return i}#R(){return this.#I?.folders?.length===1||!this.#I?.folders?.length}resolveWorkspacePath(e,r){if(typeof e!="string")throw new TypeError(`resolveWorkspacePath: 'filePath' must be a string, received ${typeof e}: ${ta(e)}`);return IAe({filePath:e,forceWorkspace:r,workspace:this.#I,workingDirectory:this.#C,sys:this.#e,canCollapseWorkspace:this.#R()})}#V(){try{let e=this.getSessionContext();return zA(e.turns)?.user.principals}catch{return}}absolutePathToWorkspaceUrl(e){return EAe({absolutePath:e,workspace:this.#I,workingDirectory:this.#C,sys:this.#e,canCollapseWorkspace:this.#R()})}async launchEditor(e={}){let r,n,i;return e.filePath?(r=this.resolveWorkspacePath(e.filePath,!1).resolvedPath,n=e.line??void 0,i=e.column??void 0):r=this.primaryGitPath,await this.#e.exists(r)?await this.#e.launchEditor({filePath:r,line:n,column:i}):{success:!1,message:`File not found: ${r}`}}async readFile(e,r){if(typeof e!="string")throw new TypeError(`readFile: 'filePath' must be a string, received ${typeof e}: ${ta(e)}`);if(!r){let n=Na(e,"read",this.#A?.accessControl,this.#V());if(!n.allowed)throw new $t(`ACL denied: ${n.message}`)}try{if(e==="AGENTS.md"&&this.#I?.agentsMD)return this.#I.agentsMD;let{resolvedPath:n}=this.resolveWorkspacePath(e,!!r),i=await this.#e.readFile(n);return i!==null?i:({resolvedPath:n}=this.resolveWorkspacePath(e,!0),await this.#e.readFile(n))}catch(n){this.#e.Sentry?.captureException(n,{extra:{filePath:e}})}return null}async readFileWithChecksum(e){let r=await this.readFile(e.filePath,e.skipAclCheck);if(r===null)return{content:null,checksum:null};let n=(0,kK.createHash)("md5").update(r).digest("hex");return e.previousChecksum&&n===e.previousChecksum?{content:null,checksum:n,notModified:!0}:{content:r,checksum:n}}async readBinaryFile(e){let r=Na(e,"read",this.#A?.accessControl,this.#V());if(!r.allowed)throw new $t(`ACL denied: ${r.message}`);try{let{resolvedPath:n}=this.resolveWorkspacePath(e,!1),i=await this.#e.readBinaryFile(n);if(i===null&&({resolvedPath:n}=this.resolveWorkspacePath(e,!0),i=await this.#e.readBinaryFile(n)),i)return Buffer.from(i).toString("base64")}catch(n){this.#e.Sentry?.captureException(n,{extra:{filePath:e}})}return null}async#at(e){let r;e?r=this.#p.find(o=>o.path===e)?.branchName:r=this.gitEnabledFolder?.branchName;let n=r?r.startsWith("origin/")?r:`origin/${r}`:await this.getDefaultBranch(e);if(!n)throw new Error("Could not find parent branch");return n}async#pr(e){let r=this.#De.get(e);if(r&&Date.now()-r.timestamp<t.#Et)return r.promise;let n=(async()=>{let i=await this.#at(e);try{return(await this.git(["merge-base",i,"HEAD"],{cwd:e})).trim()}catch{return i}})().catch(i=>{throw this.#De.get(e)?.promise===n&&this.#De.delete(e),i});return this.#De.set(e,{promise:n,timestamp:Date.now()}),n}async getFileAtRef(e,r,n){if(!this.#m)return null;try{let i,o;if(n)i=n,e.startsWith(i)?(o=e.substring(i.length),o.startsWith("/")&&(o=o.substring(1))):o=e;else{let{resolvedPath:u,workspaceFolder:l}=this.resolveWorkspacePath(e,!0);i=l?.path||this.#C,o=e,i&&u.startsWith(i)&&(o=u.substring(i.length),o.startsWith("/")&&(o=o.substring(1)))}let s=r??await this.#pr(i),a=`${i}:${s}:${o}`,A=this.#we.get(a);if(A&&Date.now()-A.timestamp<t.#Et)return A.promise;let c=this.git(["show",`${s}:${o}`],{cwd:i}).catch(u=>{let l=u instanceof Error?u.message:String(u);return l.includes("does not exist")||l.includes("exists on disk")||this.#we.get(a)?.promise===c&&this.#we.delete(a),null});return this.#we.set(a,{promise:c,timestamp:Date.now()}),c}catch{return null}}async getSingleFileDiff(e){if(e===null||typeof e!="string"&&typeof e!="object")throw new TypeError(`getSingleFileDiff: 'args' must be a string or object, received ${e===null?"null":typeof e}: ${ta(e)}`);let r=typeof e=="string"?{path:e}:e;if(typeof r.path!="string")throw new TypeError(`getSingleFileDiff: 'path' must be a string, received ${typeof r.path}: ${ta(r.path)}`);let n=typeof e=="object"?e.previousChecksum:void 0,{repoPath:i,relativePath:o}=this.#Bt(r.path,r.folderName),s=this.#e.join(i,o),[a,A]=await Promise.all([this.#e.readFile(s).catch(()=>null),this.getFileAtRef(o,void 0,i)]),c=A===null?"":`${A}`,u=a===null?"":`${a}`,l=(0,kK.createHash)("md5").update(`${c}\0${u}`).digest("hex"),d=A===null&&a!==null?"create":A!==null&&a===null?"delete":"update";return n===l?{oldContent:null,newContent:null,action:d,checksum:l,notModified:!0}:{oldContent:A,newContent:a,action:d,checksum:l}}async discardFileChanges(e){let r=typeof e=="string"?{filePath:e}:e;if(!this.#m)return{success:!1,error:"Git not configured"};try{let{repoPath:n,relativePath:i}=this.#Bt(r.filePath,r.folderName),o=this.#e.join(n,i),s=await this.#at(n),a;try{a=(await this.git(["merge-base",s,"HEAD"],{cwd:n})).trim()}catch{a=s}let A=await this.getFileAtRef(i,a,n),u=(await this.git(["--no-pager","diff",`${a}`,"HEAD","--",i],{cwd:n})).trim().length>0,d=(await this.git(["status","--porcelain","--",i],{cwd:n})).trim().length>0;if(!u&&!d)return{success:!0};if(A===null){try{await this.#e.exists(o)&&await this.#e.unlink(o)}catch{}let f=this.#e.dirname(i);if(f&&f!==".")try{await this.git(["clean","-fd",f],{cwd:n})}catch{}}else try{await this.git(["restore",`--source=${a}`,"--",i],{cwd:n})}catch(f){return{success:!1,error:`Failed to restore file: ${f}`}}await this.git(["add","--",i],{cwd:n});let g=`Discard changes to ${i}`;await this.git(["commit","--no-gpg-sign","-m",g],{cwd:n});let p=(await this.git(["rev-parse","HEAD"],{cwd:n})).trim();try{await this.#v()}catch(f){this.#e.Sentry?.captureException(f,{tags:{operation:"discard-file-changes",step:"emit-git-status"}})}return{success:!0,commitHash:p}}catch(n){try{await this.#v()}catch(i){this.#e.Sentry?.captureException(i,{tags:{operation:"discard-file-changes",step:"emit-git-status"}})}return{success:!1,error:n instanceof Error?n.message:String(n)}}}async revertDiscard(e){let{commitHash:r,folderName:n}=e;if(!this.#m)return{success:!1,error:"Git not configured"};try{let i=this.#ve(n);await this.git(["revert","--no-edit",r],{cwd:i});try{await this.#v()}catch(o){this.#e.Sentry?.captureException(o,{tags:{operation:"revert-discard",step:"emit-git-status"}})}return{success:!0}}catch(i){return{success:!1,error:i instanceof Error?i.message:String(i)}}}async fileExists(e){if(typeof e!="string")throw new TypeError(`fileExists: 'filePath' must be a string, received ${typeof e}: ${ta(e)}`);let r=n=>n.startsWith(this.#C)?this.#e.relative(this.#C,n):n;try{if(e==="AGENTS.md"&&this.#I?.agentsMD)return{absolutePath:e,recommendedPath:void 0,workspaceFolder:void 0,virtual:!0};let{resolvedPath:n,workspaceFolder:i}=this.resolveWorkspacePath(e,!1);return await this.#e.exists(n)?{absolutePath:n,recommendedPath:void 0,workspaceFolder:i,virtual:!1}:i?{absolutePath:void 0,recommendedPath:void 0,workspaceFolder:i,virtual:!1}:({resolvedPath:n,workspaceFolder:i}=this.resolveWorkspacePath(e,!0),await this.#e.exists(n)?{absolutePath:n,recommendedPath:r(n),workspaceFolder:i,virtual:!1}:{absolutePath:void 0,recommendedPath:r(n),workspaceFolder:i,virtual:!1})}catch(n){this.#e.Sentry?.captureException(n,{extra:{filePath:e}})}return{absolutePath:void 0,recommendedPath:void 0,workspaceFolder:void 0,virtual:!1}}readFileSync(e,r){if(!r){let n=Na(e,"read",this.#A?.accessControl,this.#V());if(!n.allowed)throw new $t(`ACL denied: ${n.message}`)}try{if(e==="AGENTS.md"&&this.#I?.agentsMD)return this.#I.agentsMD;let{resolvedPath:n}=this.resolveWorkspacePath(e,!1);if(this.#e.existsSync(n))return this.#e.readFileSync(n);if({resolvedPath:n}=this.resolveWorkspacePath(e,!0),this.#e.existsSync(n))return this.#e.readFileSync(n)}catch(n){this.#e.Sentry?.captureException(n,{extra:{filePath:e}})}return null}async writeFile(e,r,n){if(typeof e!="string")throw new TypeError(`writeFile: 'filePath' must be a string, received ${typeof e}: ${ta(e)}`);if(!n){let i=Na(e,"write",this.#A?.accessControl,this.#V());if(!i.allowed)throw new $t(`ACL denied: ${i.message}`)}try{let{resolvedPath:i}=this.resolveWorkspacePath(e,!!n);return await this.#e.writeFile(i,r),i}catch(i){return this.#e.Sentry?.captureException(i,{extra:{filePath:e}}),null}}async listDir(e){if(typeof e!="string")throw new TypeError(`listDir: 'dirPath' must be a string, received ${typeof e}: ${ta(e)}`);let r=Na(e,"list",this.#A?.accessControl,this.#V());if(!r.allowed)throw new $t(`ACL denied: ${r.message}`);try{let{resolvedPath:n,workspaceFolder:i}=this.resolveWorkspacePath(e,!1);if(!BAe({resolvedPath:n,workingDirectory:this.#C,workspace:this.#I,sys:this.#e}))throw new $t("Access denied: path outside working directory");if(!await this.#e.exists(n))return[];let A=(await(0,Yhe.readdir)(n,{withFileTypes:!0})).map(c=>c.name+(c.isDirectory()?"/":""));if(this.#R()){let c=A.map(u=>ls(this.#e.join(e,u)));return wf({files:c,policy:this.#A?.accessControl,getDotFiles:!0})}if(i&&this.#I?.folders){let c=i.name||i.path,u=e;e.startsWith(c+"/")?u=e.substring(c.length+1):e===c&&(u="");let l=A.map(d=>{let g=u?this.#e.join(u,d):d,p=ls(g);return`${c}/${p}`});return wf({files:l,policy:this.#A?.accessControl,getDotFiles:!0})}return wf({files:A,policy:this.#A?.accessControl,getDotFiles:!0})}catch(n){return this.#e.Sentry?.captureException(n,{extra:{dirPath:e}}),[]}}async listCustomInstructions(){return(await this.#be()).filter(r=>!r.hideUI).map(r=>({id:r.id,name:r.name,description:r.description,type:r.type,isSkill:r.isSkill??r.filePath?.toLowerCase().includes("/skills/")??!1,disableModelInvocation:r.disableModelInvocation,userInvocable:r.userInvocable}))}async stat(e,r){if(typeof e!="string")throw new TypeError(`stat: 'filePath' must be a string, received ${typeof e}: ${ta(e)}`);if(!r){let n=Na(e,"read",this.#A?.accessControl,this.#V());if(!n.allowed)throw new $t(`ACL denied: ${n.message}`)}try{let{resolvedPath:n}=this.resolveWorkspacePath(e,!1);if(await this.#e.exists(n))return await this.#e.stat(n)}catch(n){this.#e.Sentry?.captureException(n,{extra:{filePath:e}})}return null}async deleteFile(e,r){if(typeof e!="string")throw new TypeError(`deleteFile: 'filePath' must be a string, received ${typeof e}: ${ta(e)}`);if(!r){let n=Na(e,"write",this.#A?.accessControl,this.#V());if(!n.allowed)throw new $t(`ACL denied: ${n.message}`)}try{let{resolvedPath:n}=this.resolveWorkspacePath(e,!!r);return await this.#e.exists(n)?(await this.#e.unlink(n),n):null}catch(n){return this.#e.Sentry?.captureException(n,{extra:{filePath:e}}),null}}getLinesStats(){let e=this.#n?.turns.reduce((r,n)=>{let i=n.applyResults.reduce((o,s)=>({added:o.added+s.addedLines,removed:o.removed+s.removedLines}),{added:0,removed:0});return{added:r.added+i.added,removed:r.removed+i.removed}},{added:0,removed:0})??{added:0,removed:0};return{...e,net:e.added-e.removed}}async getDiffFromRemote({numberOfContextLines:e,includeFilesOnly:r,filePaths:n,folderName:i}){if(!this.#m)return[];let o=this.#ve(i);try{let s=(await this.git(["branch","--show-current"],{cwd:o})).trim();if(!s)throw new Error("Could not determine current branch");let a=!1;try{a=(await this.git(["remote"],{cwd:o})).includes("origin")}catch(d){throw this.#r.warn("No git remotes configured, cannot get diff from remote"),d}if(!a){this.#r.warn("Origin remote not found, trying to get diff from main branch");try{return await this.getDiffFromParentBranch({numberOfContextLines:e,includeFilesOnly:r,filePaths:n,folderName:i})}catch(d){throw this.#r.warn("Failed to get diff from main branch:",d),d}}let A=!1,c;try{let d=`origin/${s}`;if(A=(await this.git(["ls-remote","--heads","origin",s],{cwd:o})).trim().length>0,A)c=d;else return await this.getDiffFromParentBranch({numberOfContextLines:e,includeFilesOnly:r,filePaths:n,folderName:i})}catch(d){throw this.#r.warn("Failed to check remote branches:",d),d}let u=["diff",c];r?u.push("--raw","--numstat","--no-renames"):e!==void 0&&u.push(`-U${e}`),u.push("--"),n&&n.length>0&&u.push(...n);let l=await this.git(u,{cwd:o});return!l||l.trim()===""?[]:EK(l,r)}catch(s){throw s instanceof xp||this.#r.error("getDiffFromRemote error:",s),s}}async getDiff({mode:e="remote-parent-branch",numberOfContextLines:r,includeFilesOnly:n,filePaths:i,folderName:o}){if(!this.#m)return{state:"error",error:new Error("Git not configured")};try{switch(e){case"remote-parent-branch":return{state:"success",diff:await this.getDiffFromParentBranch({numberOfContextLines:r,includeFilesOnly:n,filePaths:i,folderName:o})};case"remote-current-branch":return{state:"success",diff:await this.getDiffFromRemote({numberOfContextLines:r,includeFilesOnly:n,filePaths:i,folderName:o})};default:throw new Error(`Unknown diff mode: ${e}`)}}catch(s){return s instanceof xp?{state:"error",error:s}:(this.#r.error(`getDiff error for mode '${e}':`,s),this.#e.Sentry?.captureException(s),{state:"error",error:s instanceof Error?s:new Error(String(s))})}}async getDefaultBranch(e){let r=e??"__primary__",n=this.#Ue.get(r);if(n)return n;let i=this.#dr(e).catch(o=>{throw this.#Ue.get(r)===i&&this.#Ue.delete(r),o});return this.#Ue.set(r,i),i}async#dr(e){try{let n=(await this.git(["remote","show","origin"],{cwd:e})).match(/HEAD branch: (.+)/);if(n)return`origin/${n[1].trim()}`}catch{}try{if((await this.git(["ls-remote","--heads","origin","main"],{cwd:e})).trim().length>0)return"origin/main"}catch{}try{if((await this.git(["ls-remote","--heads","origin","master"],{cwd:e})).trim().length>0)return"origin/master"}catch{}try{let n=(await this.git(["ls-remote","--heads","origin"],{cwd:e})).trim().split(`
1959
+ `).map(i=>i.split(" ")[1]).filter(i=>i&&!i.includes("HEAD"));if(n.length>0)return`origin/${n[0].replace("refs/heads/","")}`}catch{}throw new Error("Could not determine default branch. No remote branches found.")}async getDiffFromParentBranch({numberOfContextLines:e,includeFilesOnly:r,filePaths:n,folderName:i}){let o=this.#ve(i);try{if(!(await this.git(["branch","--show-current"],{cwd:o})).trim())throw new Error("Could not determine current branch");let a=await this.#at(o),A;try{A=(await this.git(["merge-base",a,"HEAD"],{cwd:o})).trim()}catch(l){throw l instanceof ra&&l.code===128?new xp(a,{cause:l}):l}let c=["--no-pager","diff",A];r?c.push("--raw","--numstat","--no-renames"):e!==void 0&&c.push(`-U${e}`),c.push("--"),n&&n.length>0&&c.push(...n);let u=await this.git(c,{cwd:o});return!u||u.trim()===""?[]:EK(u,r)}catch(s){throw s instanceof xp||this.#r.error("getDiffFromParentBranch error:",s),s}}},sx=(t,e)=>e.filter(r=>!t?.disabledTools?.includes(r))});function mCe(t){return t instanceof Error?t.message:String(t)}function fy(t,e){if(JK(e).test(t))return!0;if(e.toLowerCase().includes("localhost")){let n=e.replace(/localhost/gi,"127.0.0.1");if(JK(n).test(t))return!0}else if(e.includes("127.0.0.1")){let n=e.replace(/127\.0\.0\.1/g,"localhost");if(JK(n).test(t))return!0}return!1}function JK(t){return t=String(t).replace(/\./g,"\\.").replace(/\?/g,".").replace(/\*/g,".*"),new RegExp(`^${t}$`,"i")}var px,hCe=N(()=>{"use strict";h();px=class{logger;currentOrigin=null;currentOriginPattern=null;currentDestination=null;currentOriginHost=null;constructor(e){this.logger=e}getCurrentOrigin(){return this.currentOrigin}getCurrentDestination(){return this.currentDestination}clearMapping(){this.currentOrigin=null,this.currentOriginPattern=null,this.currentDestination=null,this.currentOriginHost=null,this.logger?.info("[UrlMapper] Mapping cleared")}setMapping(e,r){if(e.includes("*")||!e.startsWith("https://")&&!e.startsWith("http://")){this.currentOriginPattern=e,this.currentOriginHost=null,this.currentOrigin=e;try{let i=new URL(r);this.currentDestination=`${i.protocol}//${i.hostname}${i.port?":"+i.port:""}`}catch(i){this.logger?.error(`[UrlMapper] Failed to parse destination URL: ${mCe(i)}`),this.currentDestination=r}this.logger?.info(`[UrlMapper] Set mapping (PATTERN): ${e} \u2192 ${r}`)}else{this.currentOriginPattern=null;try{let i=new URL(e),o=i.protocol==="https:"?"443":"80",s=i.port||o;this.currentOriginHost=`${i.hostname}:${s}`,this.currentOrigin=`${i.protocol}//${i.hostname}${i.port?":"+i.port:""}`;let a=new URL(r);this.currentDestination=`${a.protocol}//${a.hostname}${a.port?":"+a.port:""}`,this.logger?.info(`[UrlMapper] Set mapping (EXACT): ${e} \u2192 ${r}`),this.logger?.debug(`[UrlMapper] Normalized origin: ${this.currentOrigin} (host: ${this.currentOriginHost})`),this.logger?.debug(`[UrlMapper] Normalized destination: ${this.currentDestination}`)}catch(i){this.logger?.error(`[UrlMapper] Failed to parse origin/destination URL: ${mCe(i)}`),this.currentOriginHost=null,this.currentOrigin=e,this.currentDestination=r}}}getUpstream(e){if(!this.currentDestination)return null;if(this.currentOriginPattern){let r=this.currentOriginPattern.replace(/^https?:\/\//g,""),n=r.split(":")[0],i=e.split(":")[0];return fy(i,n)?(this.logger?.debug(`[UrlMapper] PATTERN MATCH FOUND getUpstream(${e}) matched hostname: ${n} -> ${this.currentDestination}`),this.currentDestination):fy(e,r)?(this.logger?.debug(`[UrlMapper] PATTERN MATCH FOUND getUpstream(${e}) matched host: ${r} -> ${this.currentDestination}`),this.currentDestination):(this.logger?.debug(`[UrlMapper] NO PATTERN MATCH getUpstream(${e}) !== ${r}`),null)}return this.currentOriginHost?fy(e,this.currentOriginHost)?(this.logger?.debug(`[UrlMapper] MATCH FOUND getUpstream(${e}) -> ${this.currentDestination}`),this.currentDestination):fy(`${e}:80`,this.currentOriginHost)?(this.logger?.debug(`[UrlMapper] MATCH FOUND getUpstream(${e}) (HTTP) -> ${this.currentDestination}`),this.currentDestination):fy(`${e}:443`,this.currentOriginHost)?(this.logger?.debug(`[UrlMapper] MATCH FOUND getUpstream(${e}) (TLS) -> ${this.currentDestination}`),this.currentDestination):(this.logger?.debug(`[UrlMapper] NO MATCH getUpstream(${e}) !== ${this.currentOriginHost}`),null):null}buildUpstreamUrl(e,r="/"){let n=r||"/";n=n.replace(/^\/+/,"/");let i=new URL(n,e),o=new URL(e);return o.pathname=i.pathname.replace(/\/+/g,"/"),o.search=i.search,o.hash=i.hash,o}mapUrl(e){let r=e.host,n=this.getUpstream(r);if(!n)return e;let i=e.pathname+e.search+e.hash;return this.buildUpstreamUrl(n,i)}isOriginHttps(e=443){let r=this.currentOrigin?.split("://")[0];return r==="http"||r==="https"?r==="https":e===443}}});var CCe,ert,$K,ICe=N(()=>{"use strict";h();CCe=Z(require("node:os"),1);_t();ert=ke("Priority"),$K=(t,e)=>{try{CCe.default.setPriority(t,e)}catch(r){ert.error(`Failed to set priority to ${e}: ${r}`)}}});function ECe(t){qK=t}async function zm(){if(qK){if(jK){YK=!0;return}jK=!0;try{await qK()}finally{jK=!1,YK&&(YK=!1,zm())}}}var qK,jK,YK,zK=N(()=>{"use strict";h();jK=!1,YK=!1});async function*trt(t){for await(let e of af(t.body))if(e.length)try{yield JSON.parse(e)}catch{}}function rrt(t){t.toolContext.session.sendMessage({userPrompt:Foe({originChannelId:t.originChannelId,senderDisplayName:t.senderDisplayName,projectId:t.projectId,branchName:t.branchName,content:t.content}),category:"background-subagent",user:{...t.toolContext.user,role:"agent",source:"builder.io"},queue:!0})}function nrt(t,e){return e??("builderUserId"in t.user?t.user.builderUserId:t.user.source==="builder.io"?t.user.userId:t.credentials.userId)}function BCe(t,e){let{credentials:r}=t,{project_id:n,message:i}=e,o,s=new Promise(g=>o=g),a=!1,A,c,u,l;return(async()=>{let g=new URL("/projects/branch",Je);g.searchParams.set("apiKey",r.builderPublicKey);let p=nrt(t,e.builder_user_id);p&&g.searchParams.set("userId",p);let f=e.model&&e.model!=="auto"?Of(e.model):void 0,m=e.attachment_urls?.map(y=>({type:"url",value:y})),C=e.origin_channel_id??t.user.channelId,I={projectId:n,userMessage:{userPrompt:i,user:{...t.user,channelId:C,role:"user"},...e.session_mode&&{sessionMode:e.session_mode},...f&&{modelOverride:f},...m?.length&&{attachments:m}},hidden:e.hidden,actor:"org-agent",metadata:{origin_channel_id:C}},B=await Ge(g,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r.builderPrivateKey}`},body:JSON.stringify(I)},t.debug);if(!B.ok){let y=await B.text();throw new Error(`Failed to spawn branch: ${y}`)}let E;for await(let y of trt(B))if(y.type==="branch-created")E=y;else if(y.type==="error")E=y;else if(!a&&y.type==="setting-up-container")a=!0,c||(c=y.projectName),u||(u=y.branchFriendlyName??void 0),l||(l=y.branchName),o(y);else{let Q=Qoe(y);Q&&(A=Q.plan)}if(!E)throw new Error("Stream ended unexpectedly");return E})().then(g=>{a||o(null);let p=c??g.projectName??n,f=u??l??g.branchName,m=`https://builder.io/app/projects/${n}/${l??g.branchName}`;if(g.type!=="error"){let C=`Branch \`${f}\` in \`${p}\` completed.
1960
1960
  - Url: \`${m}\`
1961
1961
 
1962
1962
  ==================
@@ -2789,7 +2789,7 @@ return fn.apply(this, arguments)
2789
2789
  `)+`\r
2790
2790
  \r
2791
2791
  `+r)}function jp(t,e,r,n,i,o){if(t.listenerCount("wsClientError")){let s=new Error(i);Error.captureStackTrace(s,jp),t.emit("wsClientError",s,r,e)}else oQ(r,n,i,o)}});var Wbe=k((Nur,Vbe)=>{h();var Kj=class{constructor(e,r,n){this.etaBufferLength=e||100,this.valueBuffer=[n],this.timeBuffer=[r],this.eta="0"}update(e,r,n){this.valueBuffer.push(r),this.timeBuffer.push(e),this.calculate(n-r)}getTime(){return this.eta}calculate(e){let r=this.valueBuffer.length,n=Math.min(this.etaBufferLength,r),i=this.valueBuffer[r-1]-this.valueBuffer[r-n],o=this.timeBuffer[r-1]-this.timeBuffer[r-n],s=i/o;this.valueBuffer=this.valueBuffer.slice(-this.etaBufferLength),this.timeBuffer=this.timeBuffer.slice(-this.etaBufferLength);let a=Math.ceil(e/s/1e3);isNaN(a)?this.eta="NULL":isFinite(a)?a>1e7?this.eta="INF":a<0?this.eta=0:this.eta=a:this.eta="INF"}};Vbe.exports=Kj});var Jj=k((Mur,Zbe)=>{h();var qp=require("readline"),Hj=class{constructor(e){this.stream=e,this.linewrap=!0,this.dy=0}cursorSave(){this.stream.isTTY&&this.stream.write("\x1B7")}cursorRestore(){this.stream.isTTY&&this.stream.write("\x1B8")}cursor(e){this.stream.isTTY&&(e?this.stream.write("\x1B[?25h"):this.stream.write("\x1B[?25l"))}cursorTo(e=null,r=null){this.stream.isTTY&&qp.cursorTo(this.stream,e,r)}cursorRelative(e=null,r=null){this.stream.isTTY&&(this.dy=this.dy+r,qp.moveCursor(this.stream,e,r))}cursorRelativeReset(){this.stream.isTTY&&(qp.moveCursor(this.stream,0,-this.dy),qp.cursorTo(this.stream,0,null),this.dy=0)}clearRight(){this.stream.isTTY&&qp.clearLine(this.stream,1)}clearLine(){this.stream.isTTY&&qp.clearLine(this.stream,0)}clearBottom(){this.stream.isTTY&&qp.clearScreenDown(this.stream)}newline(){this.stream.write(`
2792
- `),this.dy++}write(e,r=!1){this.linewrap===!0&&r===!1?this.stream.write(e.substr(0,this.getWidth())):this.stream.write(e)}lineWrapping(e){this.stream.isTTY&&(this.linewrap=e,e?this.stream.write("\x1B[?7h"):this.stream.write("\x1B[?7l"))}isTTY(){return this.stream.isTTY===!0}getWidth(){return this.stream.columns||(this.stream.isTTY?80:200)}};Zbe.exports=Hj});var eSe=k((_ur,$j)=>{"use strict";h();var Xbe=t=>Number.isNaN(t)?!1:t>=4352&&(t<=4447||t===9001||t===9002||11904<=t&&t<=12871&&t!==12351||12880<=t&&t<=19903||19968<=t&&t<=42182||43360<=t&&t<=43388||44032<=t&&t<=55203||63744<=t&&t<=64255||65040<=t&&t<=65049||65072<=t&&t<=65131||65281<=t&&t<=65376||65504<=t&&t<=65510||110592<=t&&t<=110593||127488<=t&&t<=127569||131072<=t&&t<=262141);$j.exports=Xbe;$j.exports.default=Xbe});var rSe=k((Uur,tSe)=>{"use strict";h();tSe.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var iSe=k((Our,jj)=>{"use strict";h();var Omt=k1(),Kmt=eSe(),Hmt=rSe(),nSe=t=>{if(typeof t!="string"||t.length===0||(t=Omt(t),t.length===0))return 0;t=t.replace(Hmt()," ");let e=0;for(let r=0;r<t.length;r++){let n=t.codePointAt(r);n<=31||n>=127&&n<=159||n>=768&&n<=879||(n>65535&&r++,e+=Kmt(n)?2:1)}return e};jj.exports=nSe;jj.exports.default=nSe});var Yj=k((Hur,oSe)=>{h();oSe.exports=function(e,r,n){if(r.autopadding!==!0)return e;function i(o,s){return(r.autopaddingChar+o).slice(-s)}return n==="percentage"?i(e,3):e}});var qj=k(($ur,sSe)=>{h();sSe.exports=function(e,r){let n=Math.round(e*r.barsize),i=r.barsize-n;return r.barCompleteString.substr(0,n)+r.barGlue+r.barIncompleteString.substr(0,i)}});var zj=k((Yur,aSe)=>{h();aSe.exports=function(e,r,n){function i(s){return n?n*Math.round(s/n):s}function o(s){return(r.autopaddingChar+s).slice(-2)}return e>3600?o(Math.floor(e/3600))+"h"+o(i(e%3600/60))+"m":e>60?o(Math.floor(e/60))+"m"+o(i(e%60))+"s":e>10?o(i(e))+"s":o(e)+"s"}});var Vj=k((zur,ASe)=>{h();var Jmt=iSe(),$mt=Yj(),jmt=qj(),Ymt=zj();ASe.exports=function(e,r,n){let i=e.format,o=e.formatTime||Ymt,s=e.formatValue||$mt,a=e.formatBar||jmt,A=Math.floor(r.progress*100)+"",c=r.stopTime||Date.now(),u=Math.round((c-r.startTime)/1e3),l=Object.assign({},n,{bar:a(r.progress,e),percentage:s(A,e,"percentage"),total:s(r.total,e,"total"),value:s(r.value,e,"value"),eta:s(r.eta,e,"eta"),eta_formatted:o(r.eta,e,5),duration:s(u,e,"duration"),duration_formatted:o(u,e,1)});i=i.replace(/\{(\w+)\}/g,function(p,f){return typeof l[f]<"u"?l[f]:p});let d=Math.max(0,r.maxWidth-Jmt(i)-2),g=Math.floor(d/2);switch(e.align){case"right":i=d>0?" ".repeat(d)+i:i;break;case"center":i=g>0?" ".repeat(g)+i:i;break;default:break}return i}});var ik=k((Wur,cSe)=>{h();function Pr(t,e){return typeof t>"u"||t===null?e:t}cSe.exports={parse:function(e,r){let n={},i=Object.assign({},r,e);return n.throttleTime=1e3/Pr(i.fps,10),n.stream=Pr(i.stream,process.stderr),n.terminal=Pr(i.terminal,null),n.clearOnComplete=Pr(i.clearOnComplete,!1),n.stopOnComplete=Pr(i.stopOnComplete,!1),n.barsize=Pr(i.barsize,40),n.align=Pr(i.align,"left"),n.hideCursor=Pr(i.hideCursor,!1),n.linewrap=Pr(i.linewrap,!1),n.barGlue=Pr(i.barGlue,""),n.barCompleteChar=Pr(i.barCompleteChar,"="),n.barIncompleteChar=Pr(i.barIncompleteChar,"-"),n.format=Pr(i.format,"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}"),n.formatTime=Pr(i.formatTime,null),n.formatValue=Pr(i.formatValue,null),n.formatBar=Pr(i.formatBar,null),n.etaBufferLength=Pr(i.etaBuffer,10),n.etaAsynchronousUpdate=Pr(i.etaAsynchronousUpdate,!1),n.progressCalculationRelative=Pr(i.progressCalculationRelative,!1),n.synchronousUpdate=Pr(i.synchronousUpdate,!0),n.noTTYOutput=Pr(i.noTTYOutput,!1),n.notTTYSchedule=Pr(i.notTTYSchedule,2e3),n.emptyOnZero=Pr(i.emptyOnZero,!1),n.forceRedraw=Pr(i.forceRedraw,!1),n.autopadding=Pr(i.autopadding,!1),n.gracefulExit=Pr(i.gracefulExit,!1),n},assignDerivedOptions:function(e){return e.barCompleteString=e.barCompleteChar.repeat(e.barsize+1),e.barIncompleteString=e.barIncompleteChar.repeat(e.barsize+1),e.autopaddingChar=e.autopadding?Pr(e.autopaddingChar," "):"",e}}});var Wj=k((elr,lSe)=>{h();var uSe=Wbe(),qmt=Jj(),zmt=Vj(),Vmt=ik(),Wmt=require("events");lSe.exports=class extends Wmt{constructor(e){super(),this.options=Vmt.assignDerivedOptions(e),this.terminal=this.options.terminal?this.options.terminal:new qmt(this.options.stream),this.value=0,this.startValue=0,this.total=100,this.lastDrawnString=null,this.startTime=null,this.stopTime=null,this.lastRedraw=Date.now(),this.eta=new uSe(this.options.etaBufferLength,0,0),this.payload={},this.isActive=!1,this.formatter=typeof this.options.format=="function"?this.options.format:zmt}render(e=!1){let r={progress:this.getProgress(),eta:this.eta.getTime(),startTime:this.startTime,stopTime:this.stopTime,total:this.total,value:this.value,maxWidth:this.terminal.getWidth()};this.options.etaAsynchronousUpdate&&this.updateETA();let n=this.formatter(this.options,r,this.payload);(e||this.options.forceRedraw||this.options.noTTYOutput&&!this.terminal.isTTY()||this.lastDrawnString!=n)&&(this.emit("redraw-pre"),this.terminal.cursorTo(0,null),this.terminal.write(n),this.terminal.clearRight(),this.lastDrawnString=n,this.lastRedraw=Date.now(),this.emit("redraw-post"))}start(e,r,n){this.value=r||0,this.total=typeof e<"u"&&e>=0?e:100,this.startValue=r||0,this.payload=n||{},this.startTime=Date.now(),this.stopTime=null,this.lastDrawnString="",this.eta=new uSe(this.options.etaBufferLength,this.startTime,this.value),this.isActive=!0,this.emit("start",e,r)}stop(){this.isActive=!1,this.stopTime=Date.now(),this.emit("stop",this.total,this.value)}update(e,r={}){typeof e=="number"&&(this.value=e,this.eta.update(Date.now(),e,this.total));let n=(typeof e=="object"?e:r)||{};this.emit("update",this.total,this.value);for(let i in n)this.payload[i]=n[i];this.value>=this.getTotal()&&this.options.stopOnComplete&&this.stop()}getProgress(){let e=this.value/this.total;return this.options.progressCalculationRelative&&(e=(this.value-this.startValue)/(this.total-this.startValue)),isNaN(e)&&(e=this.options&&this.options.emptyOnZero?0:1),e=Math.min(Math.max(e,0),1),e}increment(e=1,r={}){typeof e=="object"?this.update(this.value+1,e):this.update(this.value+e,r)}getTotal(){return this.total}setTotal(e){typeof e<"u"&&e>=0&&(this.total=e)}updateETA(){this.eta.update(Date.now(),this.value,this.total)}}});var pSe=k((nlr,gSe)=>{h();var Zmt=Wj(),Xmt=ik();gSe.exports=class extends Zmt{constructor(e,r){super(Xmt.parse(e,r)),this.timer=null,this.options.noTTYOutput&&this.terminal.isTTY()===!1&&(this.options.synchronousUpdate=!1),this.schedulingRate=this.terminal.isTTY()?this.options.throttleTime:this.options.notTTYSchedule,this.sigintCallback=null}render(){this.timer&&(clearTimeout(this.timer),this.timer=null),super.render(),this.options.noTTYOutput&&this.terminal.isTTY()===!1&&this.terminal.newline(),this.timer=setTimeout(this.render.bind(this),this.schedulingRate)}update(e,r){this.timer&&(super.update(e,r),this.options.synchronousUpdate&&this.lastRedraw+this.options.throttleTime*2<Date.now()&&this.render())}start(e,r,n){this.options.noTTYOutput===!1&&this.terminal.isTTY()===!1||(this.sigintCallback===null&&this.options.gracefulExit&&(this.sigintCallback=this.stop.bind(this),process.once("SIGINT",this.sigintCallback),process.once("SIGTERM",this.sigintCallback)),this.terminal.cursorSave(),this.options.hideCursor===!0&&this.terminal.cursor(!1),this.options.linewrap===!1&&this.terminal.lineWrapping(!1),super.start(e,r,n),this.render())}stop(){this.timer&&(this.sigintCallback&&(process.removeListener("SIGINT",this.sigintCallback),process.removeListener("SIGTERM",this.sigintCallback),this.sigintCallback=null),this.render(),super.stop(),clearTimeout(this.timer),this.timer=null,this.options.hideCursor===!0&&this.terminal.cursor(!0),this.options.linewrap===!1&&this.terminal.lineWrapping(!0),this.terminal.cursorRestore(),this.options.clearOnComplete?(this.terminal.cursorTo(0,null),this.terminal.clearLine()):this.terminal.newline())}}});var fSe=k((slr,dSe)=>{h();var eht=Jj(),tht=Wj(),rht=ik(),nht=require("events");dSe.exports=class extends nht{constructor(e,r){super(),this.bars=[],this.options=rht.parse(e,r),this.options.synchronousUpdate=!1,this.terminal=this.options.terminal?this.options.terminal:new eht(this.options.stream),this.timer=null,this.isActive=!1,this.schedulingRate=this.terminal.isTTY()?this.options.throttleTime:this.options.notTTYSchedule,this.loggingBuffer=[],this.sigintCallback=null}create(e,r,n,i={}){let o=new tht(Object.assign({},this.options,{terminal:this.terminal},i));return this.bars.push(o),this.options.noTTYOutput===!1&&this.terminal.isTTY()===!1||(this.sigintCallback===null&&this.options.gracefulExit&&(this.sigintCallback=this.stop.bind(this),process.once("SIGINT",this.sigintCallback),process.once("SIGTERM",this.sigintCallback)),this.isActive||(this.options.hideCursor===!0&&this.terminal.cursor(!1),this.options.linewrap===!1&&this.terminal.lineWrapping(!1),this.timer=setTimeout(this.update.bind(this),this.schedulingRate)),this.isActive=!0,o.start(e,r,n),this.emit("start")),o}remove(e){let r=this.bars.indexOf(e);return r<0?!1:(this.bars.splice(r,1),this.update(),this.terminal.newline(),this.terminal.clearBottom(),!0)}update(){if(this.timer&&(clearTimeout(this.timer),this.timer=null),this.emit("update-pre"),this.terminal.cursorRelativeReset(),this.emit("redraw-pre"),this.loggingBuffer.length>0)for(this.terminal.clearLine();this.loggingBuffer.length>0;)this.terminal.write(this.loggingBuffer.shift(),!0);for(let e=0;e<this.bars.length;e++)e>0&&this.terminal.newline(),this.bars[e].render();this.emit("redraw-post"),this.options.noTTYOutput&&this.terminal.isTTY()===!1&&(this.terminal.newline(),this.terminal.newline()),this.timer=setTimeout(this.update.bind(this),this.schedulingRate),this.emit("update-post"),this.options.stopOnComplete&&!this.bars.find(e=>e.isActive)&&this.stop()}stop(){if(clearTimeout(this.timer),this.timer=null,this.sigintCallback&&(process.removeListener("SIGINT",this.sigintCallback),process.removeListener("SIGTERM",this.sigintCallback),this.sigintCallback=null),this.isActive=!1,this.options.hideCursor===!0&&this.terminal.cursor(!0),this.options.linewrap===!1&&this.terminal.lineWrapping(!0),this.terminal.cursorRelativeReset(),this.emit("stop-pre-clear"),this.options.clearOnComplete)this.terminal.clearBottom();else{for(let e=0;e<this.bars.length;e++)e>0&&this.terminal.newline(),this.bars[e].render(),this.bars[e].stop();this.terminal.newline()}this.emit("stop")}log(e){this.loggingBuffer.push(e)}}});var hSe=k((Alr,mSe)=>{h();mSe.exports={format:"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"=",barIncompleteChar:"-"}});var ISe=k((ulr,CSe)=>{h();CSe.exports={format:" {bar} {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"\u2588",barIncompleteChar:"\u2591"}});var BSe=k((glr,ESe)=>{h();ESe.exports={format:" \x1B[90m{bar}\x1B[0m {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"\u2588",barIncompleteChar:"\u2591"}});var QSe=k((dlr,ySe)=>{h();ySe.exports={format:" {bar}\u25A0 {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"\u25A0",barIncompleteChar:" "}});var wSe=k((mlr,DSe)=>{h();var iht=hSe(),oht=ISe(),sht=BSe(),aht=QSe();DSe.exports={legacy:iht,shades_classic:oht,shades_grey:sht,rect:aht}});var SSe=k((Clr,bSe)=>{h();var vSe=pSe(),Aht=fSe(),cht=wSe(),uht=Vj(),lht=Yj(),ght=qj(),pht=zj();bSe.exports={Bar:vSe,SingleBar:vSe,MultiBar:Aht,Presets:cht,Format:{Formatter:uht,BarFormat:ght,ValueFormat:lht,TimeFormat:pht}}});var MSe=k((Olr,TSe)=>{h();TSe.exports=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g});var MCt={};eA(MCt,{default:()=>TCt});module.exports=mn(MCt);h();h();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="3ab21597-4604-4a81-aeb6-ab3e1026895d",t._sentryDebugIdIdentifier="sentry-dbid-3ab21597-4604-4a81-aeb6-ab3e1026895d")}catch{}})();h();var sFe=require("../core/index.cjs"),aFe=require("../node/index.cjs"),AFe=require("../server/index.cjs"),cFe=Z(D6(),1);h();h();var Nx=require("fs/promises");hQ();bn();Bf();Er();var an=Z(Zr(),1),oh=require("node:path");Fs();Mo();nn();Qn();vp();var lit="https://cdn.builder.io",XIe=async(t,e)=>{console.log(""),lr((0,an.bgCyan)((0,an.bold)((0,an.white)(" figma migrate ")))+" "+(0,an.dim)(wt));let{builderPrivateKey:r,builderPublicKey:n}=await Br(t,e,{forceSpaceId:e.spaceId,builderPrivateKey:!0,builderPublicKey:!0});await Qt("figma publish started",{spaceId:n});let i=await Ug(t);if(i.length>0){await Qt("figma migrate with existing files",{spaceId:n}),G.warning(`${(0,an.yellow)("This repo already has figma mappings in:")}
2792
+ `),this.dy++}write(e,r=!1){this.linewrap===!0&&r===!1?this.stream.write(e.substr(0,this.getWidth())):this.stream.write(e)}lineWrapping(e){this.stream.isTTY&&(this.linewrap=e,e?this.stream.write("\x1B[?7h"):this.stream.write("\x1B[?7l"))}isTTY(){return this.stream.isTTY===!0}getWidth(){return this.stream.columns||(this.stream.isTTY?80:200)}};Zbe.exports=Hj});var eSe=k((_ur,$j)=>{"use strict";h();var Xbe=t=>Number.isNaN(t)?!1:t>=4352&&(t<=4447||t===9001||t===9002||11904<=t&&t<=12871&&t!==12351||12880<=t&&t<=19903||19968<=t&&t<=42182||43360<=t&&t<=43388||44032<=t&&t<=55203||63744<=t&&t<=64255||65040<=t&&t<=65049||65072<=t&&t<=65131||65281<=t&&t<=65376||65504<=t&&t<=65510||110592<=t&&t<=110593||127488<=t&&t<=127569||131072<=t&&t<=262141);$j.exports=Xbe;$j.exports.default=Xbe});var rSe=k((Uur,tSe)=>{"use strict";h();tSe.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var iSe=k((Our,jj)=>{"use strict";h();var Omt=k1(),Kmt=eSe(),Hmt=rSe(),nSe=t=>{if(typeof t!="string"||t.length===0||(t=Omt(t),t.length===0))return 0;t=t.replace(Hmt()," ");let e=0;for(let r=0;r<t.length;r++){let n=t.codePointAt(r);n<=31||n>=127&&n<=159||n>=768&&n<=879||(n>65535&&r++,e+=Kmt(n)?2:1)}return e};jj.exports=nSe;jj.exports.default=nSe});var Yj=k((Hur,oSe)=>{h();oSe.exports=function(e,r,n){if(r.autopadding!==!0)return e;function i(o,s){return(r.autopaddingChar+o).slice(-s)}return n==="percentage"?i(e,3):e}});var qj=k(($ur,sSe)=>{h();sSe.exports=function(e,r){let n=Math.round(e*r.barsize),i=r.barsize-n;return r.barCompleteString.substr(0,n)+r.barGlue+r.barIncompleteString.substr(0,i)}});var zj=k((Yur,aSe)=>{h();aSe.exports=function(e,r,n){function i(s){return n?n*Math.round(s/n):s}function o(s){return(r.autopaddingChar+s).slice(-2)}return e>3600?o(Math.floor(e/3600))+"h"+o(i(e%3600/60))+"m":e>60?o(Math.floor(e/60))+"m"+o(i(e%60))+"s":e>10?o(i(e))+"s":o(e)+"s"}});var Vj=k((zur,ASe)=>{h();var Jmt=iSe(),$mt=Yj(),jmt=qj(),Ymt=zj();ASe.exports=function(e,r,n){let i=e.format,o=e.formatTime||Ymt,s=e.formatValue||$mt,a=e.formatBar||jmt,A=Math.floor(r.progress*100)+"",c=r.stopTime||Date.now(),u=Math.round((c-r.startTime)/1e3),l=Object.assign({},n,{bar:a(r.progress,e),percentage:s(A,e,"percentage"),total:s(r.total,e,"total"),value:s(r.value,e,"value"),eta:s(r.eta,e,"eta"),eta_formatted:o(r.eta,e,5),duration:s(u,e,"duration"),duration_formatted:o(u,e,1)});i=i.replace(/\{(\w+)\}/g,function(p,f){return typeof l[f]<"u"?l[f]:p});let d=Math.max(0,r.maxWidth-Jmt(i)-2),g=Math.floor(d/2);switch(e.align){case"right":i=d>0?" ".repeat(d)+i:i;break;case"center":i=g>0?" ".repeat(g)+i:i;break;default:break}return i}});var ik=k((Wur,cSe)=>{h();function Pr(t,e){return typeof t>"u"||t===null?e:t}cSe.exports={parse:function(e,r){let n={},i=Object.assign({},r,e);return n.throttleTime=1e3/Pr(i.fps,10),n.stream=Pr(i.stream,process.stderr),n.terminal=Pr(i.terminal,null),n.clearOnComplete=Pr(i.clearOnComplete,!1),n.stopOnComplete=Pr(i.stopOnComplete,!1),n.barsize=Pr(i.barsize,40),n.align=Pr(i.align,"left"),n.hideCursor=Pr(i.hideCursor,!1),n.linewrap=Pr(i.linewrap,!1),n.barGlue=Pr(i.barGlue,""),n.barCompleteChar=Pr(i.barCompleteChar,"="),n.barIncompleteChar=Pr(i.barIncompleteChar,"-"),n.format=Pr(i.format,"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}"),n.formatTime=Pr(i.formatTime,null),n.formatValue=Pr(i.formatValue,null),n.formatBar=Pr(i.formatBar,null),n.etaBufferLength=Pr(i.etaBuffer,10),n.etaAsynchronousUpdate=Pr(i.etaAsynchronousUpdate,!1),n.progressCalculationRelative=Pr(i.progressCalculationRelative,!1),n.synchronousUpdate=Pr(i.synchronousUpdate,!0),n.noTTYOutput=Pr(i.noTTYOutput,!1),n.notTTYSchedule=Pr(i.notTTYSchedule,2e3),n.emptyOnZero=Pr(i.emptyOnZero,!1),n.forceRedraw=Pr(i.forceRedraw,!1),n.autopadding=Pr(i.autopadding,!1),n.gracefulExit=Pr(i.gracefulExit,!1),n},assignDerivedOptions:function(e){return e.barCompleteString=e.barCompleteChar.repeat(e.barsize+1),e.barIncompleteString=e.barIncompleteChar.repeat(e.barsize+1),e.autopaddingChar=e.autopadding?Pr(e.autopaddingChar," "):"",e}}});var Wj=k((elr,lSe)=>{h();var uSe=Wbe(),qmt=Jj(),zmt=Vj(),Vmt=ik(),Wmt=require("events");lSe.exports=class extends Wmt{constructor(e){super(),this.options=Vmt.assignDerivedOptions(e),this.terminal=this.options.terminal?this.options.terminal:new qmt(this.options.stream),this.value=0,this.startValue=0,this.total=100,this.lastDrawnString=null,this.startTime=null,this.stopTime=null,this.lastRedraw=Date.now(),this.eta=new uSe(this.options.etaBufferLength,0,0),this.payload={},this.isActive=!1,this.formatter=typeof this.options.format=="function"?this.options.format:zmt}render(e=!1){let r={progress:this.getProgress(),eta:this.eta.getTime(),startTime:this.startTime,stopTime:this.stopTime,total:this.total,value:this.value,maxWidth:this.terminal.getWidth()};this.options.etaAsynchronousUpdate&&this.updateETA();let n=this.formatter(this.options,r,this.payload);(e||this.options.forceRedraw||this.options.noTTYOutput&&!this.terminal.isTTY()||this.lastDrawnString!=n)&&(this.emit("redraw-pre"),this.terminal.cursorTo(0,null),this.terminal.write(n),this.terminal.clearRight(),this.lastDrawnString=n,this.lastRedraw=Date.now(),this.emit("redraw-post"))}start(e,r,n){this.value=r||0,this.total=typeof e<"u"&&e>=0?e:100,this.startValue=r||0,this.payload=n||{},this.startTime=Date.now(),this.stopTime=null,this.lastDrawnString="",this.eta=new uSe(this.options.etaBufferLength,this.startTime,this.value),this.isActive=!0,this.emit("start",e,r)}stop(){this.isActive=!1,this.stopTime=Date.now(),this.emit("stop",this.total,this.value)}update(e,r={}){typeof e=="number"&&(this.value=e,this.eta.update(Date.now(),e,this.total));let n=(typeof e=="object"?e:r)||{};this.emit("update",this.total,this.value);for(let i in n)this.payload[i]=n[i];this.value>=this.getTotal()&&this.options.stopOnComplete&&this.stop()}getProgress(){let e=this.value/this.total;return this.options.progressCalculationRelative&&(e=(this.value-this.startValue)/(this.total-this.startValue)),isNaN(e)&&(e=this.options&&this.options.emptyOnZero?0:1),e=Math.min(Math.max(e,0),1),e}increment(e=1,r={}){typeof e=="object"?this.update(this.value+1,e):this.update(this.value+e,r)}getTotal(){return this.total}setTotal(e){typeof e<"u"&&e>=0&&(this.total=e)}updateETA(){this.eta.update(Date.now(),this.value,this.total)}}});var pSe=k((nlr,gSe)=>{h();var Zmt=Wj(),Xmt=ik();gSe.exports=class extends Zmt{constructor(e,r){super(Xmt.parse(e,r)),this.timer=null,this.options.noTTYOutput&&this.terminal.isTTY()===!1&&(this.options.synchronousUpdate=!1),this.schedulingRate=this.terminal.isTTY()?this.options.throttleTime:this.options.notTTYSchedule,this.sigintCallback=null}render(){this.timer&&(clearTimeout(this.timer),this.timer=null),super.render(),this.options.noTTYOutput&&this.terminal.isTTY()===!1&&this.terminal.newline(),this.timer=setTimeout(this.render.bind(this),this.schedulingRate)}update(e,r){this.timer&&(super.update(e,r),this.options.synchronousUpdate&&this.lastRedraw+this.options.throttleTime*2<Date.now()&&this.render())}start(e,r,n){this.options.noTTYOutput===!1&&this.terminal.isTTY()===!1||(this.sigintCallback===null&&this.options.gracefulExit&&(this.sigintCallback=this.stop.bind(this),process.once("SIGINT",this.sigintCallback),process.once("SIGTERM",this.sigintCallback)),this.terminal.cursorSave(),this.options.hideCursor===!0&&this.terminal.cursor(!1),this.options.linewrap===!1&&this.terminal.lineWrapping(!1),super.start(e,r,n),this.render())}stop(){this.timer&&(this.sigintCallback&&(process.removeListener("SIGINT",this.sigintCallback),process.removeListener("SIGTERM",this.sigintCallback),this.sigintCallback=null),this.render(),super.stop(),clearTimeout(this.timer),this.timer=null,this.options.hideCursor===!0&&this.terminal.cursor(!0),this.options.linewrap===!1&&this.terminal.lineWrapping(!0),this.terminal.cursorRestore(),this.options.clearOnComplete?(this.terminal.cursorTo(0,null),this.terminal.clearLine()):this.terminal.newline())}}});var fSe=k((slr,dSe)=>{h();var eht=Jj(),tht=Wj(),rht=ik(),nht=require("events");dSe.exports=class extends nht{constructor(e,r){super(),this.bars=[],this.options=rht.parse(e,r),this.options.synchronousUpdate=!1,this.terminal=this.options.terminal?this.options.terminal:new eht(this.options.stream),this.timer=null,this.isActive=!1,this.schedulingRate=this.terminal.isTTY()?this.options.throttleTime:this.options.notTTYSchedule,this.loggingBuffer=[],this.sigintCallback=null}create(e,r,n,i={}){let o=new tht(Object.assign({},this.options,{terminal:this.terminal},i));return this.bars.push(o),this.options.noTTYOutput===!1&&this.terminal.isTTY()===!1||(this.sigintCallback===null&&this.options.gracefulExit&&(this.sigintCallback=this.stop.bind(this),process.once("SIGINT",this.sigintCallback),process.once("SIGTERM",this.sigintCallback)),this.isActive||(this.options.hideCursor===!0&&this.terminal.cursor(!1),this.options.linewrap===!1&&this.terminal.lineWrapping(!1),this.timer=setTimeout(this.update.bind(this),this.schedulingRate)),this.isActive=!0,o.start(e,r,n),this.emit("start")),o}remove(e){let r=this.bars.indexOf(e);return r<0?!1:(this.bars.splice(r,1),this.update(),this.terminal.newline(),this.terminal.clearBottom(),!0)}update(){if(this.timer&&(clearTimeout(this.timer),this.timer=null),this.emit("update-pre"),this.terminal.cursorRelativeReset(),this.emit("redraw-pre"),this.loggingBuffer.length>0)for(this.terminal.clearLine();this.loggingBuffer.length>0;)this.terminal.write(this.loggingBuffer.shift(),!0);for(let e=0;e<this.bars.length;e++)e>0&&this.terminal.newline(),this.bars[e].render();this.emit("redraw-post"),this.options.noTTYOutput&&this.terminal.isTTY()===!1&&(this.terminal.newline(),this.terminal.newline()),this.timer=setTimeout(this.update.bind(this),this.schedulingRate),this.emit("update-post"),this.options.stopOnComplete&&!this.bars.find(e=>e.isActive)&&this.stop()}stop(){if(clearTimeout(this.timer),this.timer=null,this.sigintCallback&&(process.removeListener("SIGINT",this.sigintCallback),process.removeListener("SIGTERM",this.sigintCallback),this.sigintCallback=null),this.isActive=!1,this.options.hideCursor===!0&&this.terminal.cursor(!0),this.options.linewrap===!1&&this.terminal.lineWrapping(!0),this.terminal.cursorRelativeReset(),this.emit("stop-pre-clear"),this.options.clearOnComplete)this.terminal.clearBottom();else{for(let e=0;e<this.bars.length;e++)e>0&&this.terminal.newline(),this.bars[e].render(),this.bars[e].stop();this.terminal.newline()}this.emit("stop")}log(e){this.loggingBuffer.push(e)}}});var hSe=k((Alr,mSe)=>{h();mSe.exports={format:"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"=",barIncompleteChar:"-"}});var ISe=k((ulr,CSe)=>{h();CSe.exports={format:" {bar} {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"\u2588",barIncompleteChar:"\u2591"}});var BSe=k((glr,ESe)=>{h();ESe.exports={format:" \x1B[90m{bar}\x1B[0m {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"\u2588",barIncompleteChar:"\u2591"}});var QSe=k((dlr,ySe)=>{h();ySe.exports={format:" {bar}\u25A0 {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"\u25A0",barIncompleteChar:" "}});var wSe=k((mlr,DSe)=>{h();var iht=hSe(),oht=ISe(),sht=BSe(),aht=QSe();DSe.exports={legacy:iht,shades_classic:oht,shades_grey:sht,rect:aht}});var SSe=k((Clr,bSe)=>{h();var vSe=pSe(),Aht=fSe(),cht=wSe(),uht=Vj(),lht=Yj(),ght=qj(),pht=zj();bSe.exports={Bar:vSe,SingleBar:vSe,MultiBar:Aht,Presets:cht,Format:{Formatter:uht,BarFormat:ght,ValueFormat:lht,TimeFormat:pht}}});var MSe=k((Olr,TSe)=>{h();TSe.exports=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g});var MCt={};eA(MCt,{default:()=>TCt});module.exports=mn(MCt);h();h();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="a4c3d4b1-2cd6-4702-ac46-1cb47163345f",t._sentryDebugIdIdentifier="sentry-dbid-a4c3d4b1-2cd6-4702-ac46-1cb47163345f")}catch{}})();h();var sFe=require("../core/index.cjs"),aFe=require("../node/index.cjs"),AFe=require("../server/index.cjs"),cFe=Z(D6(),1);h();h();var Nx=require("fs/promises");hQ();bn();Bf();Er();var an=Z(Zr(),1),oh=require("node:path");Fs();Mo();nn();Qn();vp();var lit="https://cdn.builder.io",XIe=async(t,e)=>{console.log(""),lr((0,an.bgCyan)((0,an.bold)((0,an.white)(" figma migrate ")))+" "+(0,an.dim)(wt));let{builderPrivateKey:r,builderPublicKey:n}=await Br(t,e,{forceSpaceId:e.spaceId,builderPrivateKey:!0,builderPublicKey:!0});await Qt("figma publish started",{spaceId:n});let i=await Ug(t);if(i.length>0){await Qt("figma migrate with existing files",{spaceId:n}),G.warning(`${(0,an.yellow)("This repo already has figma mappings in:")}
2793
2793
 
2794
2794
  ${i.map(c=>` - ${(0,oh.relative)(t.getAppRootDir(),c)}`).join(`
2795
2795
  `)}
@@ -4824,7 +4824,7 @@ The agent will investigate:
4824
4824
  - Breaking changes (API changes without migration)
4825
4825
 
4826
4826
  The agent uses Read, Grep, Glob, Bash, WebSearch, and WebFetch to explore code dynamically and reports
4827
- findings via the ReportIssue tool.`,Kft=["ReportIssue","Read","Grep","Glob","Bash","WebSearch","WebFetch"],Hft="sonnet",Pj={name:Gft,description:Oft,tools:Kft,systemPrompt:bbe,model:Hft,roundRobinModels:["sonnet","opa5.acs4","gemini"],needDevServer:!1,includeMemories:!1,needValidation:!1,resetAfterRun:!1};h();h();var Sbe=`You are a Senior QA Engineer at Builder.io. You review pull requests by coordinating parallel code-review agents, performing visual verification of UI changes, and reporting findings back to the team.
4827
+ findings via the ReportIssue tool.`,Kft=["ReportIssue","Read","Grep","Glob","Bash","WebSearch","WebFetch"],Hft="sonnet",Pj={name:Gft,description:Oft,tools:Kft,systemPrompt:bbe,model:Hft,roundRobinModels:["sonnet","opa5.acs4","gemini"],needDevServer:!1,includeMemories:!1,needValidation:!1,resetAfterRun:!1,inheritSessionModel:!0};h();h();var Sbe=`You are a Senior QA Engineer at Builder.io. You review pull requests by coordinating parallel code-review agents, performing visual verification of UI changes, and reporting findings back to the team.
4828
4828
 
4829
4829
  You use multiple parallel code-review agent calls with randomized file ordering to combat position bias. Determine focus areas once and pass identical focus areas to all agent calls \u2014 only the file ordering varies between calls.
4830
4830