dsh-edge 0.18.0-alpha.4 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -149,7 +149,7 @@ Known schemas:
149
149
  - `)}`,new Error(je)}let pt=`${l}/$ref`,Ke=ds(e,Re,n,r,i,s,o,pt,c);if(Ke.valid||he.push({instanceLocation:o,keyword:"$ref",keywordLocation:pt,error:"A subschema had errors."},...Ke.errors),n==="4"||n==="7")return{valid:he.length===0,errors:he}}if(Array.isArray(g)){let Me=g.length,Re=!1;for(let pt=0;pt<Me;pt++)if(d===g[pt]||g[pt]==="integer"&&d==="number"&&e%1===0&&e===e){Re=!0;break}Re||he.push({instanceLocation:o,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${d}" is invalid. Expected "${g.join('", "')}".`})}else g==="integer"?(d!=="number"||e%1||e!==e)&&he.push({instanceLocation:o,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${d}" is invalid. Expected "${g}".`}):g!==void 0&&d!==g&&he.push({instanceLocation:o,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${d}" is invalid. Expected "${g}".`});if(y!==void 0&&(d==="object"||d==="array"?Yy(e,y)||he.push({instanceLocation:o,keyword:"const",keywordLocation:`${l}/const`,error:`Instance does not match ${JSON.stringify(y)}.`}):e!==y&&he.push({instanceLocation:o,keyword:"const",keywordLocation:`${l}/const`,error:`Instance does not match ${JSON.stringify(y)}.`})),v!==void 0&&(d==="object"||d==="array"?v.some(Me=>Yy(e,Me))||he.push({instanceLocation:o,keyword:"enum",keywordLocation:`${l}/enum`,error:`Instance does not match any of ${JSON.stringify(v)}.`}):v.some(Me=>e===Me)||he.push({instanceLocation:o,keyword:"enum",keywordLocation:`${l}/enum`,error:`Instance does not match any of ${JSON.stringify(v)}.`})),b!==void 0){let Me=`${l}/not`;ds(e,b,n,r,i,s,o,Me).valid&&he.push({instanceLocation:o,keyword:"not",keywordLocation:Me,error:'Instance matched "not" schema.'})}let nt=[];if(S!==void 0){let Me=`${l}/anyOf`,Re=he.length,pt=!1;for(let Ke=0;Ke<S.length;Ke++){let je=S[Ke],ut=Object.create(c),Se=ds(e,je,n,r,i,f===!0?s:null,o,`${Me}/${Ke}`,ut);he.push(...Se.errors),pt=pt||Se.valid,Se.valid&&nt.push(ut)}pt?he.length=Re:he.splice(Re,0,{instanceLocation:o,keyword:"anyOf",keywordLocation:Me,error:"Instance does not match any subschemas."})}if(k!==void 0){let Me=`${l}/allOf`,Re=he.length,pt=!0;for(let Ke=0;Ke<k.length;Ke++){let je=k[Ke],ut=Object.create(c),Se=ds(e,je,n,r,i,f===!0?s:null,o,`${Me}/${Ke}`,ut);he.push(...Se.errors),pt=pt&&Se.valid,Se.valid&&nt.push(ut)}pt?he.length=Re:he.splice(Re,0,{instanceLocation:o,keyword:"allOf",keywordLocation:Me,error:"Instance does not match every subschema."})}if(E!==void 0){let Me=`${l}/oneOf`,Re=he.length,pt=E.filter((Ke,je)=>{let ut=Object.create(c),Se=ds(e,Ke,n,r,i,f===!0?s:null,o,`${Me}/${je}`,ut);return he.push(...Se.errors),Se.valid&&nt.push(ut),Se.valid}).length;pt===1?he.length=Re:he.splice(Re,0,{instanceLocation:o,keyword:"oneOf",keywordLocation:Me,error:`Instance does not match exactly one subschema (${pt} matches).`})}if((d==="object"||d==="array")&&Object.assign(c,...nt),T!==void 0){let Me=`${l}/if`;if(ds(e,T,n,r,i,s,o,Me,c).valid){if(I!==void 0){let pt=ds(e,I,n,r,i,s,o,`${l}/then`,c);pt.valid||he.push({instanceLocation:o,keyword:"if",keywordLocation:Me,error:'Instance does not match "then" schema.'},...pt.errors)}}else if(N!==void 0){let pt=ds(e,N,n,r,i,s,o,`${l}/else`,c);pt.valid||he.push({instanceLocation:o,keyword:"if",keywordLocation:Me,error:'Instance does not match "else" schema.'},...pt.errors)}}if(d==="object"){if(w!==void 0)for(let Ke of w)Ke in e||he.push({instanceLocation:o,keyword:"required",keywordLocation:`${l}/required`,error:`Instance does not have required property "${Ke}".`});let Me=Object.keys(e);if(A!==void 0&&Me.length<A&&he.push({instanceLocation:o,keyword:"minProperties",keywordLocation:`${l}/minProperties`,error:`Instance does not have at least ${A} properties.`}),W!==void 0&&Me.length>W&&he.push({instanceLocation:o,keyword:"maxProperties",keywordLocation:`${l}/maxProperties`,error:`Instance does not have at least ${W} properties.`}),te!==void 0){let Ke=`${l}/propertyNames`;for(let je in e){let ut=`${o}/${Dl(je)}`,Se=ds(je,te,n,r,i,s,ut,Ke);Se.valid||he.push({instanceLocation:o,keyword:"propertyNames",keywordLocation:Ke,error:`Property name "${je}" does not match schema.`},...Se.errors)}}if(G!==void 0){let Ke=`${l}/dependantRequired`;for(let je in G)if(je in e){let ut=G[je];for(let Se of ut)Se in e||he.push({instanceLocation:o,keyword:"dependentRequired",keywordLocation:Ke,error:`Instance has "${je}" but does not have "${Se}".`})}}if(U!==void 0)for(let Ke in U){let je=`${l}/dependentSchemas`;if(Ke in e){let ut=ds(e,U[Ke],n,r,i,s,o,`${je}/${Dl(Ke)}`,c);ut.valid||he.push({instanceLocation:o,keyword:"dependentSchemas",keywordLocation:je,error:`Instance has "${Ke}" but does not match dependant schema.`},...ut.errors)}}if(L!==void 0){let Ke=`${l}/dependencies`;for(let je in L)if(je in e){let ut=L[je];if(Array.isArray(ut))for(let Se of ut)Se in e||he.push({instanceLocation:o,keyword:"dependencies",keywordLocation:Ke,error:`Instance has "${je}" but does not have "${Se}".`});else{let Se=ds(e,ut,n,r,i,s,o,`${Ke}/${Dl(je)}`);Se.valid||he.push({instanceLocation:o,keyword:"dependencies",keywordLocation:Ke,error:`Instance has "${je}" but does not match dependant schema.`},...Se.errors)}}}let Re=Object.create(null),pt=!1;if(j!==void 0){let Ke=`${l}/properties`;for(let je in j){if(!(je in e))continue;let ut=`${o}/${Dl(je)}`,Se=ds(e[je],j[je],n,r,i,s,ut,`${Ke}/${Dl(je)}`);if(Se.valid)c[je]=Re[je]=!0;else if(pt=i,he.push({instanceLocation:o,keyword:"properties",keywordLocation:Ke,error:`Property "${je}" does not match schema.`},...Se.errors),pt)break}}if(!pt&&R!==void 0){let Ke=`${l}/patternProperties`;for(let je in R){let ut=new RegExp(je,"u"),Se=R[je];for(let yt in e){if(!ut.test(yt))continue;let Mt=`${o}/${Dl(yt)}`,st=ds(e[yt],Se,n,r,i,s,Mt,`${Ke}/${Dl(je)}`);st.valid?c[yt]=Re[yt]=!0:(pt=i,he.push({instanceLocation:o,keyword:"patternProperties",keywordLocation:Ke,error:`Property "${yt}" matches pattern "${je}" but does not match associated schema.`},...st.errors))}}}if(!pt&&H!==void 0){let Ke=`${l}/additionalProperties`;for(let je in e){if(Re[je])continue;let ut=`${o}/${Dl(je)}`,Se=ds(e[je],H,n,r,i,s,ut,Ke);Se.valid?c[je]=!0:(pt=i,he.push({instanceLocation:o,keyword:"additionalProperties",keywordLocation:Ke,error:`Property "${je}" does not match additional properties schema.`},...Se.errors))}}else if(!pt&&J!==void 0){let Ke=`${l}/unevaluatedProperties`;for(let je in e)if(!c[je]){let ut=`${o}/${Dl(je)}`,Se=ds(e[je],J,n,r,i,s,ut,Ke);Se.valid?c[je]=!0:he.push({instanceLocation:o,keyword:"unevaluatedProperties",keywordLocation:Ke,error:`Property "${je}" does not match unevaluated properties schema.`},...Se.errors)}}}else if(d==="array"){Te!==void 0&&e.length>Te&&he.push({instanceLocation:o,keyword:"maxItems",keywordLocation:`${l}/maxItems`,error:`Array has too many items (${e.length} > ${Te}).`}),qe!==void 0&&e.length<qe&&he.push({instanceLocation:o,keyword:"minItems",keywordLocation:`${l}/minItems`,error:`Array has too few items (${e.length} < ${qe}).`});let Me=e.length,Re=0,pt=!1;if(B!==void 0){let Ke=`${l}/prefixItems`,je=Math.min(B.length,Me);for(;Re<je;Re++){let ut=ds(e[Re],B[Re],n,r,i,s,`${o}/${Re}`,`${Ke}/${Re}`);if(c[Re]=!0,!ut.valid&&(pt=i,he.push({instanceLocation:o,keyword:"prefixItems",keywordLocation:Ke,error:"Items did not match schema."},...ut.errors),pt))break}}if(ce!==void 0){let Ke=`${l}/items`;if(Array.isArray(ce)){let je=Math.min(ce.length,Me);for(;Re<je;Re++){let ut=ds(e[Re],ce[Re],n,r,i,s,`${o}/${Re}`,`${Ke}/${Re}`);if(c[Re]=!0,!ut.valid&&(pt=i,he.push({instanceLocation:o,keyword:"items",keywordLocation:Ke,error:"Items did not match schema."},...ut.errors),pt))break}}else for(;Re<Me;Re++){let je=ds(e[Re],ce,n,r,i,s,`${o}/${Re}`,Ke);if(c[Re]=!0,!je.valid&&(pt=i,he.push({instanceLocation:o,keyword:"items",keywordLocation:Ke,error:"Items did not match schema."},...je.errors),pt))break}if(!pt&&fe!==void 0){let je=`${l}/additionalItems`;for(;Re<Me;Re++){let ut=ds(e[Re],fe,n,r,i,s,`${o}/${Re}`,je);c[Re]=!0,ut.valid||(pt=i,he.push({instanceLocation:o,keyword:"additionalItems",keywordLocation:je,error:"Items did not match additional items schema."},...ut.errors))}}}if(z!==void 0)if(Me===0&&Ce===void 0)he.push({instanceLocation:o,keyword:"contains",keywordLocation:`${l}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(Ce!==void 0&&Me<Ce)he.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${l}/minContains`,error:`Array has less items (${Me}) than minContains (${Ce}).`});else{let Ke=`${l}/contains`,je=he.length,ut=0;for(let Se=0;Se<Me;Se++){let yt=ds(e[Se],z,n,r,i,s,`${o}/${Se}`,Ke);yt.valid?(c[Se]=!0,ut++):he.push(...yt.errors)}ut>=(Ce||0)&&(he.length=je),Ce===void 0&&Xe===void 0&&ut===0?he.splice(je,0,{instanceLocation:o,keyword:"contains",keywordLocation:Ke,error:"Array does not contain item matching schema."}):Ce!==void 0&&ut<Ce?he.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${l}/minContains`,error:`Array must contain at least ${Ce} items matching schema. Only ${ut} items were found.`}):Xe!==void 0&&ut>Xe&&he.push({instanceLocation:o,keyword:"maxContains",keywordLocation:`${l}/maxContains`,error:`Array may contain at most ${Xe} items matching schema. ${ut} items were found.`})}if(!pt&&ue!==void 0){let Ke=`${l}/unevaluatedItems`;for(Re;Re<Me;Re++){if(c[Re])continue;let je=ds(e[Re],ue,n,r,i,s,`${o}/${Re}`,Ke);c[Re]=!0,je.valid||he.push({instanceLocation:o,keyword:"unevaluatedItems",keywordLocation:Ke,error:"Items did not match unevaluated items schema."},...je.errors)}}if(at)for(let Ke=0;Ke<Me;Ke++){let je=e[Ke],ut=typeof je=="object"&&je!==null;for(let Se=0;Se<Me;Se++){if(Ke===Se)continue;let yt=e[Se];(je===yt||ut&&(typeof yt=="object"&&yt!==null)&&Yy(je,yt))&&(he.push({instanceLocation:o,keyword:"uniqueItems",keywordLocation:`${l}/uniqueItems`,error:`Duplicate items at indexes ${Ke} and ${Se}.`}),Ke=Number.MAX_SAFE_INTEGER,Se=Number.MAX_SAFE_INTEGER)}}}else if(d==="number"){if(n==="4"?(ze!==void 0&&(me===!0&&e<=ze||e<ze)&&he.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${l}/minimum`,error:`${e} is less than ${me?"or equal to ":""} ${ze}.`}),xe!==void 0&&(xt===!0&&e>=xe||e>xe)&&he.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${l}/maximum`,error:`${e} is greater than ${xt?"or equal to ":""} ${xe}.`})):(ze!==void 0&&e<ze&&he.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${l}/minimum`,error:`${e} is less than ${ze}.`}),xe!==void 0&&e>xe&&he.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${l}/maximum`,error:`${e} is greater than ${xe}.`}),me!==void 0&&e<=me&&he.push({instanceLocation:o,keyword:"exclusiveMinimum",keywordLocation:`${l}/exclusiveMinimum`,error:`${e} is less than ${me}.`}),xt!==void 0&&e>=xt&&he.push({instanceLocation:o,keyword:"exclusiveMaximum",keywordLocation:`${l}/exclusiveMaximum`,error:`${e} is greater than or equal to ${xt}.`})),Qe!==void 0){let Me=e%Qe;Math.abs(0-Me)>=11920929e-14&&Math.abs(Qe-Me)>=11920929e-14&&he.push({instanceLocation:o,keyword:"multipleOf",keywordLocation:`${l}/multipleOf`,error:`${e} is not a multiple of ${Qe}.`})}}else if(d==="string"){let Me=lt===void 0&&Ae===void 0?0:Mpe(e);lt!==void 0&&Me<lt&&he.push({instanceLocation:o,keyword:"minLength",keywordLocation:`${l}/minLength`,error:`String is too short (${Me} < ${lt}).`}),Ae!==void 0&&Me>Ae&&he.push({instanceLocation:o,keyword:"maxLength",keywordLocation:`${l}/maxLength`,error:`String is too long (${Me} > ${Ae}).`}),ge!==void 0&&!new RegExp(ge,"u").test(e)&&he.push({instanceLocation:o,keyword:"pattern",keywordLocation:`${l}/pattern`,error:"String does not match pattern."}),O!==void 0&&Kj[O]&&!Kj[O](e)&&he.push({instanceLocation:o,keyword:"format",keywordLocation:`${l}/format`,error:`String does not match format "${O}".`})}return{valid:he.length===0,errors:he}}var Yj=re(()=>{Zj();lA();Jj();aA();Xj();a(ds,"validate")});var cA,Lpe=re(()=>{lA();Yj();cA=class{static{a(this,"Validator")}schema;draft;shortCircuit;lookup;constructor(t,n="2019-09",r=!0){this.schema=t,this.draft=n,this.shortCircuit=r,this.lookup=vp(t)}validate(t){return ds(t,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(t,n){n&&(t={...t,$id:n}),vp(t,this.lookup)}}});var Fpe=re(()=>{Zj();lA();Jj();aA();Dpe();Xj();Yj();Lpe()});var uA,jpe=re(()=>{Fpe();uA=class{static{a(this,"CfWorkerJsonSchemaValidator")}constructor(t){this.shortcircuit=t?.shortcircuit??!0,this.draft=t?.draft??"2020-12"}getValidator(t){let n=new cA(t,this.draft,this.shortcircuit);return r=>{let i=n.validate(r);return i.valid?{valid:!0,data:r,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:i.errors.map(s=>`${s.instanceLocation}: ${s.error}`).join("; ")}}}}});var Hs,dA=re(()=>{"use strict";Hs={probeTimeoutMs:3e4,callTimeoutMs:6e4,maxToolsPerServer:128,maxCatalogPages:10,maxCatalogBytes:131072,maxDescriptionLength:512,maxErrorMessageChars:300,maxPublicNameLength:64,maxInstructionsLength:1024,metaToolThreshold:20}});import{createHash as Rnt}from"node:crypto";function Ont(e){let t=e.replace(/[.*+?^${}()|[\]\\]/gu,n=>n==="*"?"\0":`\\${n}`);return new RegExp(`^${t.replaceAll("\0",".*")}$`)}function qpe(e,t,n){let r=t??"read_only";return r==="allow_all"?"allow":r==="approve_all"?"ask":n===!0?"allow":n===!1?"ask":$nt.some(i=>Ont(i).test(e))?"allow":"ask"}function vd(e){return e.replace(/Bearer\s+[^\s"']+/giu,"Bearer ***").replace(/(https?:\/\/[^\s"'?]+)\?[^\s"']*/giu,"$1?***").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/gu,"").slice(0,Hs.maxErrorMessageChars)}function Upe(e,t){let n=`mcp__${e}__${t}`,r=n.replace(/[^A-Za-z0-9_-]/gu,"_");if(r===n&&r.length<=Hs.maxPublicNameLength)return r;let i=Pnt(e,t),s=Hs.maxPublicNameLength-i.length-1;return`${r.slice(0,s)}_${i}`}function Pnt(e,t){return Rnt("sha256").update(`${e}\0${t}`).digest("hex").slice(0,12)}function zpe(e){if(!(e==null||typeof e!="object"))try{let t=JSON.parse(JSON.stringify(e));return bm(t),t}catch{return}}function Mnt(e){return Nnt.has(e)}function Bpe(e){return e.type!=="image"||e.data===void 0||e.mimeType===void 0||!Mnt(e.mimeType)||!Dnt.test(e.data)?void 0:{data:Uint8Array.from(atob(e.data),n=>n.charCodeAt(0)),mediaType:e.mimeType}}function Wpe(e){return e.some(t=>t.type==="image"&&t.data!==void 0)}function zw(e){if(e.isError)return[{type:"text",text:e.content.filter(i=>i.type==="text"&&typeof i.text=="string").map(i=>i.text).join(`
150
150
  `)||"MCP tool returned an error."}];let t=[],n=[];for(let r of e.content)if(r.type==="text"&&typeof r.text=="string")n.push(r.text);else if(r.type==="resource_link"&&r.uri!==void 0)n.push(`Resource: ${r.name??"unnamed"} (${r.uri})`);else if(r.type==="image"&&r.data!==void 0)n.push(`![image](data:${r.mimeType??"image/png"};base64,${r.data})`);else if(r.type==="image")n.push(`[image: ${r.mimeType??"unknown type"}]`);else if(r.type==="audio")n.push("[audio result unsupported on Cloudflare Workers]");else if(r.type==="resource"&&r.resource?.text!==void 0){let i=r.resource.uri??"embedded resource";n.push(`--- ${i} ---
151
151
  ${r.resource.text}`)}else r.type==="resource"?n.push("[embedded resource: binary content not displayed]"):n.push(`[unsupported MCP content type: ${r.type}]`);return n.length>0&&t.push({type:"text",text:n.join(`
152
- `)}),t.length>0?t:[{type:"text",text:"(empty MCP result)"}]}var $nt,Nnt,Dnt,pA=re(()=>{"use strict";Eo();dA();$nt=["get_*","list_*","read_*","search_*","find_*","fetch_*","describe_*"];a(Ont,"globToRegExp");a(qpe,"evaluateMcpToolPolicy");a(vd,"scrubMcpErrorMessage");a(Upe,"publicToolName");a(Pnt,"hashSuffix");a(zpe,"supportedOutputSchema");Nnt=new Set(["image/png","image/jpeg"]),Dnt=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u;a(Mnt,"isImageMediaType");a(Bpe,"decodeImageBlock");a(Wpe,"containsImage");a(zw,"mapMcpResultToContentBlocks")});var Qj,Hpe=re(()=>{Qj={name:"dsh-edge",version:"0.18.0-alpha.4",description:"Your DeepSeek Harness, anywhere \u2014 deploy a persistent personal coding agent to Cloudflare Workers in one command",author:"pawaca",license:"MIT",type:"module",bin:{"dsh-edge":"scripts/cli.mjs"},files:["dist","worker","scripts/*.d.mts","scripts/*.mjs","wrangler.jsonc","README.md","README.zh.md","LICENSE","THIRD_PARTY_NOTICES.md"],repository:{type:"git",url:"git+https://github.com/pawaca/dsh-edge.git",directory:"apps/dsh-edge"},homepage:"https://github.com/pawaca/dsh-edge#readme",bugs:{url:"https://github.com/pawaca/dsh-edge/issues"},keywords:["deepseek","deepseek-harness","ai-agents","byok","cloudflare-workers","durable-objects","self-hosted"],engines:{node:">=22.14.0"},publishConfig:{access:"public"},dshEdge:{upstreamVersion:"0.1.5-rc.2"},scripts:{"bundle:direct":"pnpm run web:build && pnpm --dir standalone run build:worker:direct && node standalone/scripts/promote.mjs direct","bundle:isolated":"pnpm run web:build && pnpm --dir standalone run build:worker:isolated && node standalone/scripts/promote.mjs isolated","bundle:workers":"pnpm --dir standalone run build && pnpm --dir standalone run verify && node standalone/scripts/promote.mjs all",dev:"pnpm run bundle:direct && node scripts/dev.mjs direct","dev:isolated":"pnpm run bundle:isolated && node scripts/dev.mjs isolated","dev:container":"pnpm run bundle:isolated && node scripts/dev.mjs container","dsh-edge":"node scripts/cli.mjs","example:install":"node examples/install-keyless.mjs","install:cloudflare":"pnpm run bundle:workers && node scripts/cli.mjs install","legal:write":"node scripts/legal-files.mjs write","pack:verify":"node scripts/verify-packed.mjs",prepack:"node scripts/legal-files.mjs verify && pnpm run bundle:workers","web:build":"pnpm --dir standalone run build:web && node standalone/scripts/promote.mjs web",test:"vitest run --root ../.. --project edge-runtime","test:integration":"pnpm run bundle:workers && node tests/run-session-integration.mjs","test:container":"pnpm run bundle:isolated && node tests/container.integration.mjs","test:snapshot":"vitest run --root ../.. --config apps/dsh-edge/vitest.snapshot.config.ts",typecheck:"tsc --noEmit"},dependencies:{"@clack/prompts":"1.7.0","compare-versions":"6.1.1",execa:"^10.0.1","jsonc-parser":"^3.3.1",wrangler:"4.129.0"},devDependencies:{"@cfworker/json-schema":"^4.1.1","@cloudflare/computer":"0.3.1","@cloudflare/workers-types":"5.20260904.1","@deepseek-ai/cordis":"4.0.2","@deepseek-ai/dsh-agent":"0.1.5-rc.2","@deepseek-ai/dsh-agent-loop":"0.1.5-rc.2","@deepseek-ai/dsh-anonymous-user-id":"0.1.5-rc.2","@deepseek-ai/dsh-api-gateway":"0.1.5-rc.2","@deepseek-ai/dsh-api-remotes":"0.1.5-rc.2","@deepseek-ai/dsh-api-session-controller":"0.1.5-rc.2","@deepseek-ai/dsh-api-settings-controller":"0.1.5-rc.2","@deepseek-ai/dsh-api-workspace-controller":"0.1.5-rc.2","@deepseek-ai/dsh-api-workspace-files":"0.1.5-rc.2","@deepseek-ai/dsh-attachment":"0.1.5-rc.2","@deepseek-ai/dsh-brand":"0.1.5-rc.2","@deepseek-ai/dsh-client-store":"0.1.5-rc.2","@deepseek-ai/dsh-code-runtime":"0.1.5-rc.2","@deepseek-ai/dsh-commands":"0.1.5-rc.2","@deepseek-ai/dsh-compaction":"0.1.5-rc.2","@deepseek-ai/dsh-compaction-basic":"0.1.5-rc.2","@deepseek-ai/dsh-compaction-tool-result-pruner":"0.1.5-rc.2","@deepseek-ai/dsh-credentials":"0.1.5-rc.2","@deepseek-ai/dsh-file-reference":"0.1.5-rc.2","@deepseek-ai/dsh-fs":"0.1.5-rc.2","@deepseek-ai/dsh-goal":"0.1.5-rc.2","@deepseek-ai/dsh-goal-round-driver":"0.1.5-rc.2","@deepseek-ai/dsh-host-directory-picker":"0.1.5-rc.2","@deepseek-ai/dsh-host-plugin-inventory":"0.1.5-rc.2","@deepseek-ai/dsh-invariants":"0.1.5-rc.2","@deepseek-ai/dsh-jobs":"0.1.5-rc.2","@deepseek-ai/dsh-jobs-local":"0.1.5-rc.2","@deepseek-ai/dsh-launch-environment":"0.1.5-rc.2","@deepseek-ai/dsh-llm":"0.1.5-rc.2","@deepseek-ai/dsh-llm-deepseek":"0.1.5-rc.2","@deepseek-ai/dsh-message-feedback":"0.1.5-rc.2","@deepseek-ai/dsh-output-retention":"0.1.5-rc.2","@deepseek-ai/dsh-plan-mode":"0.1.5-rc.2","@deepseek-ai/dsh-sandbox":"0.1.5-rc.2","@deepseek-ai/dsh-schedule":"0.1.5-rc.2","@deepseek-ai/dsh-scope":"0.1.5-rc.2","@deepseek-ai/dsh-session":"0.1.5-rc.2","@deepseek-ai/dsh-session-format":"0.1.5-rc.2","@deepseek-ai/dsh-session-format-catalog":"0.1.5-rc.2","@deepseek-ai/dsh-session-format-v0-to-v1":"0.1.5-rc.2","@deepseek-ai/dsh-session-format-v1-to-v2":"0.1.5-rc.2","@deepseek-ai/dsh-session-format-v2-to-v3":"0.1.5-rc.2","@deepseek-ai/dsh-session-persistence":"0.1.5-rc.2","@deepseek-ai/dsh-session-projection":"0.1.5-rc.2","@deepseek-ai/dsh-session-projection-cache":"0.1.5-rc.2","@deepseek-ai/dsh-session-query":"0.1.5-rc.2","@deepseek-ai/dsh-session-reference":"0.1.5-rc.2","@deepseek-ai/dsh-session-title":"0.1.5-rc.2","@deepseek-ai/dsh-session-title-first-prompt-llm":"0.1.5-rc.2","@deepseek-ai/dsh-session-title-llm":"0.1.5-rc.2","@deepseek-ai/dsh-settings":"0.1.5-rc.2","@deepseek-ai/dsh-skill":"0.1.5-rc.2","@deepseek-ai/dsh-spill":"0.1.5-rc.2","@deepseek-ai/dsh-spill-policy":"0.1.5-rc.2","@deepseek-ai/dsh-storage":"0.1.5-rc.2","@deepseek-ai/dsh-storage-domain":"0.1.5-rc.2","@deepseek-ai/dsh-subagent":"0.1.5-rc.2","@deepseek-ai/dsh-subagent-in-process-driver":"0.1.5-rc.2","@deepseek-ai/dsh-subagent-spawn-in-process":"0.1.5-rc.2","@deepseek-ai/dsh-system-prompt":"0.1.5-rc.2","@deepseek-ai/dsh-timeout":"0.1.5-rc.2","@deepseek-ai/dsh-token-meter":"0.1.5-rc.2","@deepseek-ai/dsh-tool-ask-user":"0.1.5-rc.2","@deepseek-ai/dsh-tool-call-timeout-policy":"0.1.5-rc.2","@deepseek-ai/dsh-tool-fs":"0.1.5-rc.2","@deepseek-ai/dsh-tool-goal":"0.1.5-rc.2","@deepseek-ai/dsh-tool-jobs":"0.1.5-rc.2","@deepseek-ai/dsh-tool-skill":"0.1.5-rc.2","@deepseek-ai/dsh-tool-subagent":"0.1.5-rc.2","@deepseek-ai/dsh-tool-web":"0.1.5-rc.2","@deepseek-ai/dsh-tool-workflow":"0.1.5-rc.2","@deepseek-ai/dsh-tools":"0.1.5-rc.2","@deepseek-ai/dsh-typert-protocol":"0.1.5-rc.2","@deepseek-ai/dsh-typert-registry":"0.1.5-rc.2","@deepseek-ai/dsh-user-approval":"0.1.5-rc.2","@deepseek-ai/dsh-user-questions":"0.1.5-rc.2","@deepseek-ai/dsh-util-values":"0.1.5-rc.2","@deepseek-ai/dsh-web":"0.1.5-rc.2","@deepseek-ai/dsh-web-fetch-http":"0.1.5-rc.2","@deepseek-ai/dsh-web-search-deepseek":"0.1.5-rc.2","@deepseek-ai/dsh-workflow":"0.1.5-rc.2","@deepseek-ai/dsh-workspace":"0.1.5-rc.2","@deepseek-ai/schemastery":"3.18.2","@mixmark-io/domino":"2.2.0","@modelcontextprotocol/sdk":"1.30.0",acorn:"8.18.0","fast-png":"8.0.0","jpeg-js":"0.4.4","just-bash":"3.4.2",playwright:"^1.49.0",sucrase:"3.35.1",typescript:"^6.0.3",vitest:"^4.1.8",ws:"^8.21.0"}}});var Qy,Vpe,fA=re(()=>{"use strict";Hpe();Qy=Qj.version,Vpe=Qj.dshEdge.upstreamVersion});function Unt(e){let t=/^::ffff:(\d+\.\d+\.\d+\.\d+)$/iu.exec(e);if(t!==null)return t[1];let n=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/iu.exec(e);if(n!==null){let r=parseInt(n[1],16),i=parseInt(n[2],16);return`${String(r>>8)}.${String(r&255)}.${String(i>>8)}.${String(i&255)}`}}function znt(e){return/^\d+\.\d+\.\d+\.\d+$/u.test(e)||e.includes(":")}function xp(e){let t=new URL(e);if(t.protocol!=="http:"&&t.protocol!=="https:")throw new Error("MCP server URL must use http: or https: protocol.");let n=t.hostname.toLowerCase(),r=n.endsWith(".")?n.slice(0,-1):n,i=r.startsWith("[")&&r.endsWith("]")?r.slice(1,-1):r;if(!(i==="localhost"||i==="127.0.0.1"||i==="::1")){for(let s of Fnt)if(i.endsWith(s))throw new Error(`MCP server hostname "${i}" is blocked.`);if(znt(i)){let s=Unt(i),o=s??i;for(let l of jnt)if(l.test(o))throw new Error(`MCP server address "${i}" is a private IP and is blocked.`);if(s===void 0){for(let l of qnt)if(l.test(i))throw new Error(`MCP server address "${i}" is a private IP and is blocked.`)}}}}function Bnt(e){return e?.type==="bearer"&&e.token!==void 0?{Authorization:`Bearer ${e.token}`}:{}}async function Gpe(e,t,n){xp(e);let r=new oA(new URL(e),{requestInit:{headers:Bnt(t),signal:n},fetch:Gm}),i=new iA({name:"dsh-edge",version:Qy},{capabilities:{},jsonSchemaValidator:Wnt});return await i.connect(r),{client:i,close:a(async()=>{await i.close().catch(()=>{})},"close")}}async function Zpe(e,t,n){let r=AbortSignal.timeout(Hs.probeTimeoutMs),i;try{i=await Gpe(t,n,r)}catch(l){throw new Error(vd(l instanceof Error?l.message:String(l)))}let{client:s,close:o}=i;try{let l=[],c=new Set,u=new Set,d;for(let f=0;f<Hs.maxCatalogPages;f++){let g=await s.listTools(d===void 0?void 0:{cursor:d},{signal:r});for(let y of g.tools){if(l.length>=Hs.maxToolsPerServer)break;let v=Upe(e,y.name);if(c.has(v))throw new Error(`Server listed tool "${y.name}" more than once`);c.add(v);let w=y.annotations?.readOnlyHint,b=zpe(y.outputSchema);l.push({name:y.name,publicName:v,description:y.description??"",inputSchema:y.inputSchema??{type:"object"},...b!==void 0?{outputSchema:b}:{},...w!==void 0?{annotations:{readOnlyHint:w}}:{}})}if(l.length>=Hs.maxToolsPerServer||(d=g.nextCursor??void 0,d===void 0))break;if(u.has(d))throw new Error("Server repeated a tools/list continuation cursor");u.add(d)}let p=s.getServerVersion?.(),h=s.getInstructions?.();return{tools:l,serverInfo:p?{name:p.name,version:p.version}:void 0,instructions:typeof h=="string"&&h.length>0?h.slice(0,Hs.maxInstructionsLength):void 0}}finally{await o()}}async function hA(e,t,n,r,i,s){let o=s??Hs.callTimeoutMs,l=i?AbortSignal.any([i,AbortSignal.timeout(o)]):AbortSignal.timeout(o),c;try{c=await Gpe(e,r,l)}catch(u){throw new Error(vd(u instanceof Error?u.message:String(u)))}try{let u=await c.client.callTool({name:t,arguments:n},void 0,{signal:l});return{content:u.content??[],structuredContent:u.structuredContent,isError:u.isError===!0}}catch(u){throw new Error(vd(u instanceof Error?u.message:String(u)))}finally{await c.close()}}var Fnt,jnt,qnt,Wnt,Gm,Bw=re(()=>{"use strict";Yde();$pe();jpe();pA();dA();fA();Fnt=[".internal",".local",".localhost"],jnt=[/^127\./u,/^10\./u,/^172\.(1[6-9]|2\d|3[01])\./u,/^192\.168\./u,/^0\./u,/^169\.254\./u],qnt=[/^::1$/u,/^fc/iu,/^fd/iu,/^fe[89ab][0-9a-f]:/iu];a(Unt,"extractMappedIPv4");a(znt,"isIpAddress");a(xp,"assertSafeUrl");a(Bnt,"buildHeaders");Wnt=new uA,Gm=a(async(e,t)=>{let n=await globalThis.fetch(e,{...t,redirect:"manual"});if(n.status>=300&&n.status<400)throw new Error(`MCP server returned HTTP ${String(n.status)} redirect; redirects are blocked for security.`);return n},"noRedirectFetch");a(Gpe,"connectClient");a(Zpe,"probe");a(hA,"callTool")});import{Buffer as Hnt}from"node:buffer";function Knt(e){return e instanceof Error&&"code"in e&&typeof e.code=="string"&&Znt.has(e.code)}function Jpe(e){return e instanceof Error&&"code"in e&&typeof e.code=="string"&&Gnt.has(e.code)}function Xpe(e,t,n){let r=Hnt.from(e,"base64");if(e.length===0&&t==="reject"||r.toString("base64")!==e)throw new Wn(n==="INVALID_IMAGE_BASE64"?"Image upload is not canonical base64.":"File upload is not canonical base64.",n);return new Uint8Array(r)}function Jnt(e){return Xpe(e,"reject","INVALID_IMAGE_BASE64")}function Xnt(e){return{data:Jnt(e.data),mediaType:e.mediaType,...e.name===void 0?{}:{name:e.name}}}async function Ww(e,t){return e.saveImages(t.map(Xnt))}async function Ynt(e,t){return e.saveFile({data:Xpe(t.data,"accept","INVALID_FILE_BASE64"),...t.name===void 0?{}:{name:t.name}})}function Ype(e,t,n){let r=Math.min(1,Math.sqrt(n/(e*t)));if(r===1)return{width:e,height:t};if(e>=t){let o=Math.max(1,Math.floor(e*r)),l=Math.max(1,Math.round(o*t/e));for(;o*l>n&&o>1;)o-=1,l=Math.max(1,Math.round(o*t/e));return{width:o,height:l}}let i=Math.max(1,Math.floor(t*r)),s=Math.max(1,Math.round(i*e/t));for(;s*i>n&&i>1;)i-=1,s=Math.max(1,Math.round(i*e/t));return{width:s,height:i}}var Kpe,Vnt,Gnt,Znt,Wn,eq,bp=re(()=>{Xn();Kpe=["TOO_MANY_IMAGES","IMAGES_TOO_LARGE","UNSUPPORTED_IMAGE_TYPE","INVALID_IMAGE_BASE64","INVALID_IMAGE","IMAGE_TYPE_MISMATCH","IMAGE_TOO_LARGE","IMAGE_TOO_MANY_PIXELS","IMAGE_DIMENSION_TOO_LARGE"],Vnt=[...Kpe,"INVALID_FILE_BASE64","INVALID_ATTACHMENT_REF","ATTACHMENT_CORRUPT","ATTACHMENT_WRITE_FAILED","ATTACHMENT_NOT_FOUND","ATTACHMENT_READ_FAILED","ATTACHMENT_PROJECTION_UNSUPPORTED","ATTACHMENT_FILES_UNSUPPORTED"],Gnt=new Set(Kpe),Znt=new Set(Vnt),Wn=class extends Error{static{a(this,"AttachmentError")}code;constructor(e,t,n){super(e,n),this.name="AttachmentError",this.code=t}};a(Knt,"isAttachmentError");a(Jpe,"isImageAdmissionError");a(Xpe,"decodeCanonicalBase64");a(Jnt,"decodeBase64");a(Xnt,"saveInput");a(Ww,"admitEncodedImages");a(Ynt,"admitEncodedFile");a(Ype,"requestImageDimensions");eq=class extends It{static{a(this,"AttachmentStore")}constructor(e){super(e,"attachments")}validateImageBatch(e){let{maxImagesPerMessage:t,maxMessageImageBytes:n,mediaTypes:r}=this.imageLimits;if(e.length>t)throw new Wn("Image batch exceeds the configured image-count limit.","TOO_MANY_IMAGES");if(e.reduce((i,s)=>i+s.data.byteLength,0)>n)throw new Wn("Image batch exceeds the configured aggregate image-byte limit.","IMAGES_TOO_LARGE");for(let i of e)if(!r.includes(i.mediaType))throw new Wn(`Image type ${i.mediaType} is not accepted by this deployment.`,"UNSUPPORTED_IMAGE_TYPE")}async saveImages(e){this.validateImageBatch(e);for(let n of e)await this.validateImage(n);let t=[];for(let n of e)t.push(await this.saveImage(n));return t}async admitPromptContent(e){if(e.every(r=>r.type!=="image"))return e.map(r=>r.type==="text"?{type:"text",text:r.text}:{type:"file",attachment:r.attachment});let t=await Ww(this,e.filter(r=>r.type==="image")),n=0;return e.map(r=>r.type==="text"?{type:"text",text:r.text}:r.type==="file"?{type:"file",attachment:r.attachment}:{type:"image",attachment:t[n++]})}admitEncodedFile(e){return Ynt(this,e)}isAttachmentError(e){return Knt(e)}imageHostPath(e){}saveFile(e){return Promise.reject(new Wn("The mounted attachment provider cannot store verbatim files.","ATTACHMENT_FILES_UNSUPPORTED"))}saveFileStream(e){return Promise.reject(new Wn("The mounted attachment provider cannot stream verbatim files.","ATTACHMENT_FILES_UNSUPPORTED"))}async*readFileStream(e,t){t?.throwIfAborted(),await Promise.reject(new Wn("The mounted attachment provider cannot read verbatim files.","ATTACHMENT_FILES_UNSUPPORTED"))}fileHostPath(e){}readImageRequest(e,t,n){return n?.throwIfAborted(),Promise.reject(new Wn("The mounted attachment provider cannot derive model-request images.","ATTACHMENT_PROJECTION_UNSUPPORTED"))}}});var gA={};Pn(gA,{buildAuthorizationUrl:()=>art,discoverEndpoints:()=>srt,exchangeCode:()=>lrt,isTokenExpired:()=>urt,refreshToken:()=>crt,registerClient:()=>ort});function nfe(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),Array.from(t,n=>n.toString(16).padStart(2,"0")).join("").slice(0,e)}async function irt(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return btoa(String.fromCharCode(...new Uint8Array(n))).replace(/\+/gu,"-").replace(/\//gu,"_").replace(/=/gu,"")}async function srt(e){let t=AbortSignal.timeout(mA),n=new URL(e),r=n.pathname==="/"?"/.well-known/oauth-protected-resource":`/.well-known/oauth-protected-resource${n.pathname}`,i=new URL(r,n.origin);xp(i.href);let s=await Gm(i.href,{signal:t});if(!s.ok)throw new Error(`PRM discovery failed: HTTP ${s.status}`);let l=(await s.json()).authorization_servers?.[0];if(typeof l!="string")throw new Error("No authorization server in PRM");let c=new URL(l),u=c.pathname==="/"?"/.well-known/oauth-authorization-server":`/.well-known/oauth-authorization-server${c.pathname}`,d=new URL(u,c.origin);xp(d.href);let p=await Gm(d.href,{signal:t});if(!p.ok)throw new Error(`AS metadata failed: HTTP ${p.status}`);let h=await p.json();if(typeof h.authorization_endpoint!="string"||typeof h.token_endpoint!="string")throw new Error("Missing required endpoints in AS metadata");return{authorization:h.authorization_endpoint,token:h.token_endpoint,registration:h.registration_endpoint}}async function ort(e,t,n){let r=AbortSignal.timeout(mA);xp(e);let i=await Gm(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({client_name:n,redirect_uris:[t],grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none"}),signal:r});if(!i.ok)throw new Error(`DCR failed: HTTP ${i.status}`);let s=await i.json();if(typeof s.client_id!="string")throw new Error("DCR response missing client_id");return{clientId:s.client_id,clientSecret:s.client_secret}}async function art(e,t,n,r,i){let s=nfe(32),o=nfe(64),l=await irt(o),c=new URL(e.authorization);for(let[u,d]of Object.entries({response_type:"code",client_id:t.clientId,redirect_uri:n,state:s,code_challenge:l,code_challenge_method:"S256",resource:i}))c.searchParams.set(u,d);return{authorizationUrl:c.href,pendingFlow:{state:s,codeVerifier:o,redirectUri:n,serverName:r,serverUrl:i,stagedClient:t,createdAt:Date.now()}}}async function lrt(e,t,n,r,i,s){let o=AbortSignal.timeout(mA),l=new URLSearchParams({grant_type:"authorization_code",code:n,redirect_uri:i,client_id:t.clientId,code_verifier:r});s!==void 0&&l.set("resource",s),t.clientSecret!==void 0&&l.set("client_secret",t.clientSecret),xp(e);let c=await Gm(e,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:l.toString(),signal:o});if(!c.ok)throw new Error(`Token exchange failed: HTTP ${c.status}`);return rfe(await c.json())}async function crt(e,t,n,r){let i=AbortSignal.timeout(mA),s=new URLSearchParams({grant_type:"refresh_token",refresh_token:n,client_id:t.clientId});r!==void 0&&s.set("resource",r),t.clientSecret!==void 0&&s.set("client_secret",t.clientSecret),xp(e);let o=await Gm(e,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:s.toString(),signal:i});if(!o.ok)throw new Error(`Token refresh failed: HTTP ${o.status}`);return rfe(await o.json())}function rfe(e){let t=e;if(typeof t.access_token!="string")throw new Error("Missing access_token");let n=typeof t.expires_in=="number"?t.expires_in:void 0;return{accessToken:t.access_token,refreshToken:typeof t.refresh_token=="string"?t.refresh_token:void 0,expiresAt:n!==void 0?Date.now()+n*1e3:void 0,tokenType:typeof t.token_type=="string"?t.token_type:"Bearer",scope:typeof t.scope=="string"?t.scope:void 0}}function urt(e){return e.expiresAt===void 0?!1:Date.now()>e.expiresAt-12e4}var mA,yA=re(()=>{"use strict";Bw();mA=1e4;a(nfe,"randomString");a(irt,"sha256Base64Url");a(srt,"discoverEndpoints");a(ort,"registerClient");a(art,"buildAuthorizationUrl");a(lrt,"exchangeCode");a(crt,"refreshToken");a(rfe,"parseTokenResponse");a(urt,"isTokenExpired")});var Zn,dfe,xA=re(()=>{Xn();Ir();Zn=class extends Nr{static{a(this,"FsError")}code;constructor(e,t,n){super(e,t,n),this.code=t}},dfe=class extends It{static{a(this,"FileSystem")}constructor(e){super(e,"fs")}get sandboxMode(){}processPathFromHostPath(e){}}});function vq(e){return CA.test(e)}function RA(e){return e.invocation.modelInvocable}function t0(e){return e.invocation.userInvocable}function xq(e){let t=Hit(e);return[`<skill_content name="${Vit(e.name)}">`,"<skill_resources>",...t,"</skill_resources>","","<skill_instructions>",e.content,"</skill_instructions>","</skill_content>"].join(`
152
+ `)}),t.length>0?t:[{type:"text",text:"(empty MCP result)"}]}var $nt,Nnt,Dnt,pA=re(()=>{"use strict";Eo();dA();$nt=["get_*","list_*","read_*","search_*","find_*","fetch_*","describe_*"];a(Ont,"globToRegExp");a(qpe,"evaluateMcpToolPolicy");a(vd,"scrubMcpErrorMessage");a(Upe,"publicToolName");a(Pnt,"hashSuffix");a(zpe,"supportedOutputSchema");Nnt=new Set(["image/png","image/jpeg"]),Dnt=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u;a(Mnt,"isImageMediaType");a(Bpe,"decodeImageBlock");a(Wpe,"containsImage");a(zw,"mapMcpResultToContentBlocks")});var Qj,Hpe=re(()=>{Qj={name:"dsh-edge",version:"0.18.0",description:"Your DeepSeek Harness, anywhere \u2014 deploy a persistent personal coding agent to Cloudflare Workers in one command",author:"pawaca",license:"MIT",type:"module",bin:{"dsh-edge":"scripts/cli.mjs"},files:["dist","worker","scripts/*.d.mts","scripts/*.mjs","wrangler.jsonc","README.md","README.zh.md","LICENSE","THIRD_PARTY_NOTICES.md"],repository:{type:"git",url:"git+https://github.com/pawaca/dsh-edge.git",directory:"apps/dsh-edge"},homepage:"https://github.com/pawaca/dsh-edge#readme",bugs:{url:"https://github.com/pawaca/dsh-edge/issues"},keywords:["deepseek","deepseek-harness","ai-agents","byok","cloudflare-workers","durable-objects","self-hosted"],engines:{node:">=22.14.0"},publishConfig:{access:"public"},dshEdge:{upstreamVersion:"0.1.5-rc.2"},scripts:{"bundle:direct":"pnpm run web:build && pnpm --dir standalone run build:worker:direct && node standalone/scripts/promote.mjs direct","bundle:isolated":"pnpm run web:build && pnpm --dir standalone run build:worker:isolated && node standalone/scripts/promote.mjs isolated","bundle:workers":"pnpm --dir standalone run build && pnpm --dir standalone run verify && node standalone/scripts/promote.mjs all",dev:"pnpm run bundle:direct && node scripts/dev.mjs direct","dev:isolated":"pnpm run bundle:isolated && node scripts/dev.mjs isolated","dev:container":"pnpm run bundle:isolated && node scripts/dev.mjs container","dsh-edge":"node scripts/cli.mjs","example:install":"node examples/install-keyless.mjs","install:cloudflare":"pnpm run bundle:workers && node scripts/cli.mjs install","legal:write":"node scripts/legal-files.mjs write","pack:verify":"node scripts/verify-packed.mjs",prepack:"node scripts/legal-files.mjs verify && pnpm run bundle:workers","web:build":"pnpm --dir standalone run build:web && node standalone/scripts/promote.mjs web",test:"vitest run --root ../.. --project edge-runtime","test:integration":"pnpm run bundle:workers && node tests/run-session-integration.mjs","test:container":"pnpm run bundle:isolated && node tests/container.integration.mjs","test:snapshot":"vitest run --root ../.. --config apps/dsh-edge/vitest.snapshot.config.ts",typecheck:"tsc --noEmit"},dependencies:{"@clack/prompts":"1.7.0","compare-versions":"6.1.1",execa:"^10.0.1","jsonc-parser":"^3.3.1",wrangler:"4.129.0"},devDependencies:{"@cfworker/json-schema":"^4.1.1","@cloudflare/computer":"0.3.1","@cloudflare/workers-types":"5.20260904.1","@deepseek-ai/cordis":"4.0.2","@deepseek-ai/dsh-agent":"0.1.5-rc.2","@deepseek-ai/dsh-agent-loop":"0.1.5-rc.2","@deepseek-ai/dsh-anonymous-user-id":"0.1.5-rc.2","@deepseek-ai/dsh-api-gateway":"0.1.5-rc.2","@deepseek-ai/dsh-api-remotes":"0.1.5-rc.2","@deepseek-ai/dsh-api-session-controller":"0.1.5-rc.2","@deepseek-ai/dsh-api-settings-controller":"0.1.5-rc.2","@deepseek-ai/dsh-api-workspace-controller":"0.1.5-rc.2","@deepseek-ai/dsh-api-workspace-files":"0.1.5-rc.2","@deepseek-ai/dsh-attachment":"0.1.5-rc.2","@deepseek-ai/dsh-brand":"0.1.5-rc.2","@deepseek-ai/dsh-client-store":"0.1.5-rc.2","@deepseek-ai/dsh-code-runtime":"0.1.5-rc.2","@deepseek-ai/dsh-commands":"0.1.5-rc.2","@deepseek-ai/dsh-compaction":"0.1.5-rc.2","@deepseek-ai/dsh-compaction-basic":"0.1.5-rc.2","@deepseek-ai/dsh-compaction-tool-result-pruner":"0.1.5-rc.2","@deepseek-ai/dsh-credentials":"0.1.5-rc.2","@deepseek-ai/dsh-file-reference":"0.1.5-rc.2","@deepseek-ai/dsh-fs":"0.1.5-rc.2","@deepseek-ai/dsh-goal":"0.1.5-rc.2","@deepseek-ai/dsh-goal-round-driver":"0.1.5-rc.2","@deepseek-ai/dsh-host-directory-picker":"0.1.5-rc.2","@deepseek-ai/dsh-host-plugin-inventory":"0.1.5-rc.2","@deepseek-ai/dsh-invariants":"0.1.5-rc.2","@deepseek-ai/dsh-jobs":"0.1.5-rc.2","@deepseek-ai/dsh-jobs-local":"0.1.5-rc.2","@deepseek-ai/dsh-launch-environment":"0.1.5-rc.2","@deepseek-ai/dsh-llm":"0.1.5-rc.2","@deepseek-ai/dsh-llm-deepseek":"0.1.5-rc.2","@deepseek-ai/dsh-message-feedback":"0.1.5-rc.2","@deepseek-ai/dsh-output-retention":"0.1.5-rc.2","@deepseek-ai/dsh-plan-mode":"0.1.5-rc.2","@deepseek-ai/dsh-sandbox":"0.1.5-rc.2","@deepseek-ai/dsh-schedule":"0.1.5-rc.2","@deepseek-ai/dsh-scope":"0.1.5-rc.2","@deepseek-ai/dsh-session":"0.1.5-rc.2","@deepseek-ai/dsh-session-format":"0.1.5-rc.2","@deepseek-ai/dsh-session-format-catalog":"0.1.5-rc.2","@deepseek-ai/dsh-session-format-v0-to-v1":"0.1.5-rc.2","@deepseek-ai/dsh-session-format-v1-to-v2":"0.1.5-rc.2","@deepseek-ai/dsh-session-format-v2-to-v3":"0.1.5-rc.2","@deepseek-ai/dsh-session-persistence":"0.1.5-rc.2","@deepseek-ai/dsh-session-projection":"0.1.5-rc.2","@deepseek-ai/dsh-session-projection-cache":"0.1.5-rc.2","@deepseek-ai/dsh-session-query":"0.1.5-rc.2","@deepseek-ai/dsh-session-reference":"0.1.5-rc.2","@deepseek-ai/dsh-session-title":"0.1.5-rc.2","@deepseek-ai/dsh-session-title-first-prompt-llm":"0.1.5-rc.2","@deepseek-ai/dsh-session-title-llm":"0.1.5-rc.2","@deepseek-ai/dsh-settings":"0.1.5-rc.2","@deepseek-ai/dsh-skill":"0.1.5-rc.2","@deepseek-ai/dsh-spill":"0.1.5-rc.2","@deepseek-ai/dsh-spill-policy":"0.1.5-rc.2","@deepseek-ai/dsh-storage":"0.1.5-rc.2","@deepseek-ai/dsh-storage-domain":"0.1.5-rc.2","@deepseek-ai/dsh-subagent":"0.1.5-rc.2","@deepseek-ai/dsh-subagent-in-process-driver":"0.1.5-rc.2","@deepseek-ai/dsh-subagent-spawn-in-process":"0.1.5-rc.2","@deepseek-ai/dsh-system-prompt":"0.1.5-rc.2","@deepseek-ai/dsh-timeout":"0.1.5-rc.2","@deepseek-ai/dsh-token-meter":"0.1.5-rc.2","@deepseek-ai/dsh-tool-ask-user":"0.1.5-rc.2","@deepseek-ai/dsh-tool-call-timeout-policy":"0.1.5-rc.2","@deepseek-ai/dsh-tool-fs":"0.1.5-rc.2","@deepseek-ai/dsh-tool-goal":"0.1.5-rc.2","@deepseek-ai/dsh-tool-jobs":"0.1.5-rc.2","@deepseek-ai/dsh-tool-skill":"0.1.5-rc.2","@deepseek-ai/dsh-tool-subagent":"0.1.5-rc.2","@deepseek-ai/dsh-tool-web":"0.1.5-rc.2","@deepseek-ai/dsh-tool-workflow":"0.1.5-rc.2","@deepseek-ai/dsh-tools":"0.1.5-rc.2","@deepseek-ai/dsh-typert-protocol":"0.1.5-rc.2","@deepseek-ai/dsh-typert-registry":"0.1.5-rc.2","@deepseek-ai/dsh-user-approval":"0.1.5-rc.2","@deepseek-ai/dsh-user-questions":"0.1.5-rc.2","@deepseek-ai/dsh-util-values":"0.1.5-rc.2","@deepseek-ai/dsh-web":"0.1.5-rc.2","@deepseek-ai/dsh-web-fetch-http":"0.1.5-rc.2","@deepseek-ai/dsh-web-search-deepseek":"0.1.5-rc.2","@deepseek-ai/dsh-workflow":"0.1.5-rc.2","@deepseek-ai/dsh-workspace":"0.1.5-rc.2","@deepseek-ai/schemastery":"3.18.2","@mixmark-io/domino":"2.2.0","@modelcontextprotocol/sdk":"1.30.0",acorn:"8.18.0","fast-png":"8.0.0","jpeg-js":"0.4.4","just-bash":"3.4.2",playwright:"^1.49.0",sucrase:"3.35.1",typescript:"^6.0.3",vitest:"^4.1.8",ws:"^8.21.0"}}});var Qy,Vpe,fA=re(()=>{"use strict";Hpe();Qy=Qj.version,Vpe=Qj.dshEdge.upstreamVersion});function Unt(e){let t=/^::ffff:(\d+\.\d+\.\d+\.\d+)$/iu.exec(e);if(t!==null)return t[1];let n=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/iu.exec(e);if(n!==null){let r=parseInt(n[1],16),i=parseInt(n[2],16);return`${String(r>>8)}.${String(r&255)}.${String(i>>8)}.${String(i&255)}`}}function znt(e){return/^\d+\.\d+\.\d+\.\d+$/u.test(e)||e.includes(":")}function xp(e){let t=new URL(e);if(t.protocol!=="http:"&&t.protocol!=="https:")throw new Error("MCP server URL must use http: or https: protocol.");let n=t.hostname.toLowerCase(),r=n.endsWith(".")?n.slice(0,-1):n,i=r.startsWith("[")&&r.endsWith("]")?r.slice(1,-1):r;if(!(i==="localhost"||i==="127.0.0.1"||i==="::1")){for(let s of Fnt)if(i.endsWith(s))throw new Error(`MCP server hostname "${i}" is blocked.`);if(znt(i)){let s=Unt(i),o=s??i;for(let l of jnt)if(l.test(o))throw new Error(`MCP server address "${i}" is a private IP and is blocked.`);if(s===void 0){for(let l of qnt)if(l.test(i))throw new Error(`MCP server address "${i}" is a private IP and is blocked.`)}}}}function Bnt(e){return e?.type==="bearer"&&e.token!==void 0?{Authorization:`Bearer ${e.token}`}:{}}async function Gpe(e,t,n){xp(e);let r=new oA(new URL(e),{requestInit:{headers:Bnt(t),signal:n},fetch:Gm}),i=new iA({name:"dsh-edge",version:Qy},{capabilities:{},jsonSchemaValidator:Wnt});return await i.connect(r),{client:i,close:a(async()=>{await i.close().catch(()=>{})},"close")}}async function Zpe(e,t,n){let r=AbortSignal.timeout(Hs.probeTimeoutMs),i;try{i=await Gpe(t,n,r)}catch(l){throw new Error(vd(l instanceof Error?l.message:String(l)))}let{client:s,close:o}=i;try{let l=[],c=new Set,u=new Set,d;for(let f=0;f<Hs.maxCatalogPages;f++){let g=await s.listTools(d===void 0?void 0:{cursor:d},{signal:r});for(let y of g.tools){if(l.length>=Hs.maxToolsPerServer)break;let v=Upe(e,y.name);if(c.has(v))throw new Error(`Server listed tool "${y.name}" more than once`);c.add(v);let w=y.annotations?.readOnlyHint,b=zpe(y.outputSchema);l.push({name:y.name,publicName:v,description:y.description??"",inputSchema:y.inputSchema??{type:"object"},...b!==void 0?{outputSchema:b}:{},...w!==void 0?{annotations:{readOnlyHint:w}}:{}})}if(l.length>=Hs.maxToolsPerServer||(d=g.nextCursor??void 0,d===void 0))break;if(u.has(d))throw new Error("Server repeated a tools/list continuation cursor");u.add(d)}let p=s.getServerVersion?.(),h=s.getInstructions?.();return{tools:l,serverInfo:p?{name:p.name,version:p.version}:void 0,instructions:typeof h=="string"&&h.length>0?h.slice(0,Hs.maxInstructionsLength):void 0}}finally{await o()}}async function hA(e,t,n,r,i,s){let o=s??Hs.callTimeoutMs,l=i?AbortSignal.any([i,AbortSignal.timeout(o)]):AbortSignal.timeout(o),c;try{c=await Gpe(e,r,l)}catch(u){throw new Error(vd(u instanceof Error?u.message:String(u)))}try{let u=await c.client.callTool({name:t,arguments:n},void 0,{signal:l});return{content:u.content??[],structuredContent:u.structuredContent,isError:u.isError===!0}}catch(u){throw new Error(vd(u instanceof Error?u.message:String(u)))}finally{await c.close()}}var Fnt,jnt,qnt,Wnt,Gm,Bw=re(()=>{"use strict";Yde();$pe();jpe();pA();dA();fA();Fnt=[".internal",".local",".localhost"],jnt=[/^127\./u,/^10\./u,/^172\.(1[6-9]|2\d|3[01])\./u,/^192\.168\./u,/^0\./u,/^169\.254\./u],qnt=[/^::1$/u,/^fc/iu,/^fd/iu,/^fe[89ab][0-9a-f]:/iu];a(Unt,"extractMappedIPv4");a(znt,"isIpAddress");a(xp,"assertSafeUrl");a(Bnt,"buildHeaders");Wnt=new uA,Gm=a(async(e,t)=>{let n=await globalThis.fetch(e,{...t,redirect:"manual"});if(n.status>=300&&n.status<400)throw new Error(`MCP server returned HTTP ${String(n.status)} redirect; redirects are blocked for security.`);return n},"noRedirectFetch");a(Gpe,"connectClient");a(Zpe,"probe");a(hA,"callTool")});import{Buffer as Hnt}from"node:buffer";function Knt(e){return e instanceof Error&&"code"in e&&typeof e.code=="string"&&Znt.has(e.code)}function Jpe(e){return e instanceof Error&&"code"in e&&typeof e.code=="string"&&Gnt.has(e.code)}function Xpe(e,t,n){let r=Hnt.from(e,"base64");if(e.length===0&&t==="reject"||r.toString("base64")!==e)throw new Wn(n==="INVALID_IMAGE_BASE64"?"Image upload is not canonical base64.":"File upload is not canonical base64.",n);return new Uint8Array(r)}function Jnt(e){return Xpe(e,"reject","INVALID_IMAGE_BASE64")}function Xnt(e){return{data:Jnt(e.data),mediaType:e.mediaType,...e.name===void 0?{}:{name:e.name}}}async function Ww(e,t){return e.saveImages(t.map(Xnt))}async function Ynt(e,t){return e.saveFile({data:Xpe(t.data,"accept","INVALID_FILE_BASE64"),...t.name===void 0?{}:{name:t.name}})}function Ype(e,t,n){let r=Math.min(1,Math.sqrt(n/(e*t)));if(r===1)return{width:e,height:t};if(e>=t){let o=Math.max(1,Math.floor(e*r)),l=Math.max(1,Math.round(o*t/e));for(;o*l>n&&o>1;)o-=1,l=Math.max(1,Math.round(o*t/e));return{width:o,height:l}}let i=Math.max(1,Math.floor(t*r)),s=Math.max(1,Math.round(i*e/t));for(;s*i>n&&i>1;)i-=1,s=Math.max(1,Math.round(i*e/t));return{width:s,height:i}}var Kpe,Vnt,Gnt,Znt,Wn,eq,bp=re(()=>{Xn();Kpe=["TOO_MANY_IMAGES","IMAGES_TOO_LARGE","UNSUPPORTED_IMAGE_TYPE","INVALID_IMAGE_BASE64","INVALID_IMAGE","IMAGE_TYPE_MISMATCH","IMAGE_TOO_LARGE","IMAGE_TOO_MANY_PIXELS","IMAGE_DIMENSION_TOO_LARGE"],Vnt=[...Kpe,"INVALID_FILE_BASE64","INVALID_ATTACHMENT_REF","ATTACHMENT_CORRUPT","ATTACHMENT_WRITE_FAILED","ATTACHMENT_NOT_FOUND","ATTACHMENT_READ_FAILED","ATTACHMENT_PROJECTION_UNSUPPORTED","ATTACHMENT_FILES_UNSUPPORTED"],Gnt=new Set(Kpe),Znt=new Set(Vnt),Wn=class extends Error{static{a(this,"AttachmentError")}code;constructor(e,t,n){super(e,n),this.name="AttachmentError",this.code=t}};a(Knt,"isAttachmentError");a(Jpe,"isImageAdmissionError");a(Xpe,"decodeCanonicalBase64");a(Jnt,"decodeBase64");a(Xnt,"saveInput");a(Ww,"admitEncodedImages");a(Ynt,"admitEncodedFile");a(Ype,"requestImageDimensions");eq=class extends It{static{a(this,"AttachmentStore")}constructor(e){super(e,"attachments")}validateImageBatch(e){let{maxImagesPerMessage:t,maxMessageImageBytes:n,mediaTypes:r}=this.imageLimits;if(e.length>t)throw new Wn("Image batch exceeds the configured image-count limit.","TOO_MANY_IMAGES");if(e.reduce((i,s)=>i+s.data.byteLength,0)>n)throw new Wn("Image batch exceeds the configured aggregate image-byte limit.","IMAGES_TOO_LARGE");for(let i of e)if(!r.includes(i.mediaType))throw new Wn(`Image type ${i.mediaType} is not accepted by this deployment.`,"UNSUPPORTED_IMAGE_TYPE")}async saveImages(e){this.validateImageBatch(e);for(let n of e)await this.validateImage(n);let t=[];for(let n of e)t.push(await this.saveImage(n));return t}async admitPromptContent(e){if(e.every(r=>r.type!=="image"))return e.map(r=>r.type==="text"?{type:"text",text:r.text}:{type:"file",attachment:r.attachment});let t=await Ww(this,e.filter(r=>r.type==="image")),n=0;return e.map(r=>r.type==="text"?{type:"text",text:r.text}:r.type==="file"?{type:"file",attachment:r.attachment}:{type:"image",attachment:t[n++]})}admitEncodedFile(e){return Ynt(this,e)}isAttachmentError(e){return Knt(e)}imageHostPath(e){}saveFile(e){return Promise.reject(new Wn("The mounted attachment provider cannot store verbatim files.","ATTACHMENT_FILES_UNSUPPORTED"))}saveFileStream(e){return Promise.reject(new Wn("The mounted attachment provider cannot stream verbatim files.","ATTACHMENT_FILES_UNSUPPORTED"))}async*readFileStream(e,t){t?.throwIfAborted(),await Promise.reject(new Wn("The mounted attachment provider cannot read verbatim files.","ATTACHMENT_FILES_UNSUPPORTED"))}fileHostPath(e){}readImageRequest(e,t,n){return n?.throwIfAborted(),Promise.reject(new Wn("The mounted attachment provider cannot derive model-request images.","ATTACHMENT_PROJECTION_UNSUPPORTED"))}}});var gA={};Pn(gA,{buildAuthorizationUrl:()=>art,discoverEndpoints:()=>srt,exchangeCode:()=>lrt,isTokenExpired:()=>urt,refreshToken:()=>crt,registerClient:()=>ort});function nfe(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),Array.from(t,n=>n.toString(16).padStart(2,"0")).join("").slice(0,e)}async function irt(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return btoa(String.fromCharCode(...new Uint8Array(n))).replace(/\+/gu,"-").replace(/\//gu,"_").replace(/=/gu,"")}async function srt(e){let t=AbortSignal.timeout(mA),n=new URL(e),r=n.pathname==="/"?"/.well-known/oauth-protected-resource":`/.well-known/oauth-protected-resource${n.pathname}`,i=new URL(r,n.origin);xp(i.href);let s=await Gm(i.href,{signal:t});if(!s.ok)throw new Error(`PRM discovery failed: HTTP ${s.status}`);let l=(await s.json()).authorization_servers?.[0];if(typeof l!="string")throw new Error("No authorization server in PRM");let c=new URL(l),u=c.pathname==="/"?"/.well-known/oauth-authorization-server":`/.well-known/oauth-authorization-server${c.pathname}`,d=new URL(u,c.origin);xp(d.href);let p=await Gm(d.href,{signal:t});if(!p.ok)throw new Error(`AS metadata failed: HTTP ${p.status}`);let h=await p.json();if(typeof h.authorization_endpoint!="string"||typeof h.token_endpoint!="string")throw new Error("Missing required endpoints in AS metadata");return{authorization:h.authorization_endpoint,token:h.token_endpoint,registration:h.registration_endpoint}}async function ort(e,t,n){let r=AbortSignal.timeout(mA);xp(e);let i=await Gm(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({client_name:n,redirect_uris:[t],grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none"}),signal:r});if(!i.ok)throw new Error(`DCR failed: HTTP ${i.status}`);let s=await i.json();if(typeof s.client_id!="string")throw new Error("DCR response missing client_id");return{clientId:s.client_id,clientSecret:s.client_secret}}async function art(e,t,n,r,i){let s=nfe(32),o=nfe(64),l=await irt(o),c=new URL(e.authorization);for(let[u,d]of Object.entries({response_type:"code",client_id:t.clientId,redirect_uri:n,state:s,code_challenge:l,code_challenge_method:"S256",resource:i}))c.searchParams.set(u,d);return{authorizationUrl:c.href,pendingFlow:{state:s,codeVerifier:o,redirectUri:n,serverName:r,serverUrl:i,stagedClient:t,createdAt:Date.now()}}}async function lrt(e,t,n,r,i,s){let o=AbortSignal.timeout(mA),l=new URLSearchParams({grant_type:"authorization_code",code:n,redirect_uri:i,client_id:t.clientId,code_verifier:r});s!==void 0&&l.set("resource",s),t.clientSecret!==void 0&&l.set("client_secret",t.clientSecret),xp(e);let c=await Gm(e,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:l.toString(),signal:o});if(!c.ok)throw new Error(`Token exchange failed: HTTP ${c.status}`);return rfe(await c.json())}async function crt(e,t,n,r){let i=AbortSignal.timeout(mA),s=new URLSearchParams({grant_type:"refresh_token",refresh_token:n,client_id:t.clientId});r!==void 0&&s.set("resource",r),t.clientSecret!==void 0&&s.set("client_secret",t.clientSecret),xp(e);let o=await Gm(e,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:s.toString(),signal:i});if(!o.ok)throw new Error(`Token refresh failed: HTTP ${o.status}`);return rfe(await o.json())}function rfe(e){let t=e;if(typeof t.access_token!="string")throw new Error("Missing access_token");let n=typeof t.expires_in=="number"?t.expires_in:void 0;return{accessToken:t.access_token,refreshToken:typeof t.refresh_token=="string"?t.refresh_token:void 0,expiresAt:n!==void 0?Date.now()+n*1e3:void 0,tokenType:typeof t.token_type=="string"?t.token_type:"Bearer",scope:typeof t.scope=="string"?t.scope:void 0}}function urt(e){return e.expiresAt===void 0?!1:Date.now()>e.expiresAt-12e4}var mA,yA=re(()=>{"use strict";Bw();mA=1e4;a(nfe,"randomString");a(irt,"sha256Base64Url");a(srt,"discoverEndpoints");a(ort,"registerClient");a(art,"buildAuthorizationUrl");a(lrt,"exchangeCode");a(crt,"refreshToken");a(rfe,"parseTokenResponse");a(urt,"isTokenExpired")});var Zn,dfe,xA=re(()=>{Xn();Ir();Zn=class extends Nr{static{a(this,"FsError")}code;constructor(e,t,n){super(e,t,n),this.code=t}},dfe=class extends It{static{a(this,"FileSystem")}constructor(e){super(e,"fs")}get sandboxMode(){}processPathFromHostPath(e){}}});function vq(e){return CA.test(e)}function RA(e){return e.invocation.modelInvocable}function t0(e){return e.invocation.userInvocable}function xq(e){let t=Hit(e);return[`<skill_content name="${Vit(e.name)}">`,"<skill_resources>",...t,"</skill_resources>","","<skill_instructions>",e.content,"</skill_instructions>","</skill_content>"].join(`
153
153
  `)}function Hit(e){let t=e.resourceBase;if(t===void 0)return[`Resources for this skill are managed by provider "${e0(e.provider)}".`,"Load referenced resources only as needed."];switch(t.kind){case"directory":return[`Base directory for this skill: ${e0(t.path)}`,"Resolve relative paths mentioned by this skill against the base directory before using them. Load referenced resources only as needed."];case"url":return[`Base URL for this skill: ${e0(t.url)}`,"Resolve relative URLs mentioned by this skill against the base URL before using them. Load referenced resources only as needed."];case"opaque":return[`Resources for this skill: ${e0(t.description)}`,"Load referenced resources only as needed."];default:return wi(t,"SkillResourceBase.kind")}}function Vit(e){return e.replaceAll("&","&amp;").replaceAll('"',"&quot;").replaceAll("<","&lt;")}function e0(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function Zit(e,t){if(Array.isArray(e))return{candidates:e,complete:!0};if(e===null||typeof e!="object")throw Ffe(t);let n=e;if(!Array.isArray(n.candidates)||typeof n.complete!="boolean")throw Ffe(t);return n}function Ffe(e){return new TypeError(`skill provider "${e}" list() must return an array or { candidates, complete } observation`)}function Jit(e){return{name:e.name,description:e.description,...e.whenToUse!==void 0?{whenToUse:e.whenToUse}:{},invocation:e.invocation,source:e.source,provider:e.provider,...e.resourceBase!==void 0?{resourceBase:e.resourceBase}:{},rank:Wit,locator:e,...e.path!==void 0?{path:e.path}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}}function Xit(e,t){if(typeof e.name!="string")throw new TypeError(`skill provider "${t}" returned a non-string skill name`);if(!CA.test(e.name))throw new Error(`skill provider "${t}" returned invalid skill name "${e.name}"`);if(typeof e.description!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string description`);if(e.description.length===0)throw new Error(`skill provider "${t}" returned skill "${e.name}" without a description`);if(bq(e.invocation,`skill provider "${t}" returned skill "${e.name}"`),e.whenToUse!==void 0&&typeof e.whenToUse!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string whenToUse`);if(typeof e.source!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string source`);if(typeof e.rank!="number"||!Number.isFinite(e.rank))throw new Error(`skill provider "${t}" returned skill "${e.name}" with an invalid rank`);if(typeof e.provider!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string provider`);if(e.provider!==t)throw new Error(`skill provider "${t}" returned skill "${e.name}" for provider "${e.provider}"`);if(e.path!==void 0&&typeof e.path!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string path`)}function Yit(e){if(!CA.test(e.name))throw new Error(`invalid skill name "${e.name}"`);if(e.description.length===0)throw new Error(`skill "${e.name}" requires a description`);bq(e.invocation,`runtime skill "${e.name}"`)}function Qit(e){let t=e.name,n=e.description,r=e.whenToUse,i=e.invocation,s=e.source,o=e.provider,l=e.content,c=e.path;if(typeof t!="string")throw new TypeError("loaded skill name must be a string");if(!CA.test(t))throw new Error(`loaded skill has invalid name "${t}"`);if(typeof n!="string")throw new TypeError(`loaded skill "${t}" description must be a string`);if(n.length===0)throw new Error(`loaded skill "${t}" requires a description`);if(bq(i,`loaded skill "${t}"`),r!==void 0&&typeof r!="string")throw new TypeError(`loaded skill "${t}" whenToUse must be a string`);if(typeof s!="string")throw new TypeError(`loaded skill "${t}" source must be a string`);if(typeof o!="string")throw new TypeError(`loaded skill "${t}" provider must be a string`);if(typeof l!="string")throw new TypeError(`loaded skill "${t}" content must be a string`);if(c!==void 0&&typeof c!="string")throw new TypeError(`loaded skill "${t}" path must be a string`)}function est(e){let{name:t,description:n,whenToUse:r,invocation:i,source:s,provider:o,resourceBase:l}=e;return{name:t,description:n,...r!==void 0?{whenToUse:r}:{},invocation:i,source:s,provider:o,...l!==void 0?{resourceBase:l}:{}}}function bq(e,t){if(e===void 0)return;if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError(`${t} with a non-object invocation policy`);let n=e;if(typeof n.modelInvocable!="boolean")throw new TypeError(`${t} with a non-boolean invocation.modelInvocable`);if(typeof n.userInvocable!="boolean")throw new TypeError(`${t} with a non-boolean invocation.userInvocable`)}function tst(e,t){return zfe(e.name,t.name)}function zfe(e,t){return e<t?-1:e>t?1:0}function nst(e,t){return e.candidate.rank-t.candidate.rank||e.providerOrder-t.providerOrder||e.localOrder-t.localOrder}function rst(e,t,n=1){if(!Number.isInteger(t)||t<n)throw new Error(`skill: ${e} must be an integer greater than or equal to ${n}`)}function jfe(e,t){return t===void 0?e:(Zw(t),new Promise((n,r)=>{let i=a(()=>{t.removeEventListener("abort",s)},"cleanup"),s=a(()=>{i(),r(AA(t.reason))},"onAbort");t.addEventListener("abort",s,{once:!0}),e.then(o=>{i(),n(o)},o=>{i(),r(AA(o))})}))}function Zw(e){if(e?.aborted===!0)throw AA(e.reason)}function AA(e){try{if(e instanceof Error)return e}catch{}return new Error(IA(e))}function IA(e){try{return String(e)}catch{return"[unrenderable thrown value]"}}var CA,Lfe,Bit,TA,Wit,qfe,Git,Ufe,Kit,n0=re(()=>{Xn();us();tl();nr();CA=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,Lfe=128,Bit=2,TA="runtime",Wit=250,qfe=600;a(vq,"isSkillName");a(RA,"isModelInvocable");a(t0,"isUserInvocable");a(xq,"renderSkillContent");a(Hit,"renderResourceHint");a(Vit,"escapeAttr");a(e0,"escapeText");Git=class{static{a(this,"SkillLayer")}providers;runtime=new Map;constructor(e){this.providers=new ad(t=>new Error(e===void 0?`a skill provider named "${t}" is already registered`:`a skill provider named "${t}" is already registered in this scope`))}isEmpty(){return this.providers.isEmpty()&&this.runtime.size===0}},Ufe=class extends It{static{a(this,"SkillRegistry")}static Config=F.object({collectCacheMaxEntries:F.number().default(Lfe)});collectCacheMaxEntries;layers=new cd(e=>new Git(e),()=>{this.invalidateCache()});collectCache=new Map;revision=0;nextProviderOrder=0;scopeIds=new WeakMap;nextScopeId=1;constructor(e,t={}){super(e,"skills"),this.collectCacheMaxEntries=t.collectCacheMaxEntries??Lfe,rst("collectCacheMaxEntries",this.collectCacheMaxEntries)}registerProvider(e){let t=new AbortController,n,r,i={signal:t.signal,invalidate:a(()=>{let s=n;s!==void 0&&s.layer.providers.get(s.name)?.provider===r&&this.invalidateCache()},"invalidate")};try{r=e(i);let s=r.name;if(s===TA)throw new Error(`"${TA}" is reserved for runtime skill registrations`);let o=this.nextProviderOrder;return this.nextProviderOrder+=1,this.layers.effect(this.ctx,l=>{let c=l.providers.insert(s,{provider:r,order:o});return n={layer:l,name:s},()=>{n=void 0,c(),t.abort(new Error(`skill provider "${s}" disposed`))}},{label:"skills.registerProvider()"})}catch(s){throw t.abort(s),s}}register(e){Yit(e);let t=da(this.ctx),n=t===void 0?this.layers.global:this.layers.peek(t);if(n!==void 0&&n.runtime.has(e.name))return this.ctx.logger.warn(`runtime skill "${e.name}" ignored because it is already registered`),()=>{};let r={...e,invocation:e.invocation??{modelInvocable:!0,userInvocable:!0},provider:e.provider??TA};return this.layers.effect(this.ctx,i=>(i.runtime.set(r.name,r),()=>{i.runtime.delete(r.name)}),{label:"skills.register()"})}async list(e={}){return(await this.snapshot(e)).skills}async snapshot(e={}){let t=await this.collect(e);return{skills:[...t.entries.values()].map(n=>est(n.candidate)).sort(tst),complete:t.cacheable}}async get(e,t={}){if(!vq(e))return;let n=await this.collect(t);Zw(t.signal);let r=n.entries.get(e);if(r===void 0)return;let i=await jfe(r.provider.get(r.candidate,t),t.signal);if(i!==void 0){if(Qit(i),i.name!==r.candidate.name){this.invalidateEntry(r);return}return i}}async collect(e){Zw(e.signal);let t=1;for(;;){let n=this.revision,r=this.collectCacheKey(e.cwd,vb(e.scope),n),i=this.collectCache.get(r);if(i!==void 0)return{entries:i,cacheable:!0};let s=await this.collectFresh(e);if(Zw(e.signal),n!==this.revision){if(t<Bit){t+=1;continue}return{entries:s.entries,cacheable:!1}}if(s.cacheable&&(this.collectCache.set(r,s.entries),this.collectCache.size>this.collectCacheMaxEntries)){let o=this.collectCache.keys().next();this.collectCache.delete(o.value)}return s}}async collectFresh(e){let t=[this.layers.global,...this.layers.chainLayers(e.scope)],n=new Map,r=!0;for(let i of t){let s=await this.collectLayer(i,e);s.cacheable||(r=!1);for(let o of s.entries)n.set(o.candidate.name,o)}return{entries:n,cacheable:r}}async collectLayer(e,t){let n=await this.listLayerCandidates(e,t);n.entries.sort(nst);let r=new Set,i=[];for(let s of n.entries){let o=s.candidate;if(r.has(o.name)){this.ctx.logger.warn(`skill "${o.name}" from ${o.source} ignored because a higher-priority skill already exists`);continue}r.add(o.name),i.push(s)}return{entries:i,cacheable:n.cacheable}}async listLayerCandidates(e,t){Zw(t.signal);let n=[],r=!0,i=0;for(let s of[...e.runtime.values()].sort((o,l)=>zfe(o.name,l.name)))n.push({candidate:Jit(s),provider:Kit,providerOrder:-1,localOrder:i,layer:e}),i+=1;for(let{provider:s,order:o}of[...e.providers.values()]){let l=0,c;try{c=await jfe(s.list(t),t.signal)}catch(d){if(t.signal?.aborted===!0)throw AA(t.signal.reason);r=!1,this.ctx.logger.warn(`skill provider "${s.name}" skipped: ${IA(d)}`)}if(c===void 0)continue;let u=Zit(c,s.name);u.complete||(r=!1);for(let d of u.candidates)Xit(d,s.name),n.push({candidate:d,provider:s,providerOrder:o,localOrder:l,layer:e}),l+=1}return{entries:n,cacheable:r}}invalidateCache(){this.revision+=1,this.collectCache.clear(),this.notifyChange()}invalidateEntry(e){e.layer.providers.get(e.provider.name)?.provider===e.provider&&this.invalidateCache()}scopeId(e){let t=this.scopeIds.get(e);return t===void 0&&(t=this.nextScopeId,this.nextScopeId+=1,this.scopeIds.set(e,t)),t}collectCacheKey(e,t,n){return JSON.stringify({cwd:e,scopes:t.map(r=>this.scopeId(r)),revision:n})}notifyChange(){for(let e of this.ctx.events.dispatch("emit",["skills/change"]))try{let t=e();Promise.resolve(t).catch(n=>{this.ctx.logger.warn(`skills/change listener rejected: ${IA(n)}`)})}catch(t){this.ctx.logger.warn(`skills/change listener threw: ${IA(t)}`)}}};a(Zit,"normalizeProviderObservation");a(Ffe,"invalidProviderObservation");Kit={name:TA,list(){return Promise.resolve([])},get(e){return Promise.resolve(e.locator)}};a(Jit,"runtimeCandidate");a(Xit,"validateCandidate");a(Yit,"validateRuntimeSkill");a(Qit,"validateDefinition");a(est,"toSummary");a(bq,"validateInvocation");a(tst,"compareSkillSummary");a(zfe,"compareCodePoints");a(nst,"compareIndexedCandidates");a(rst,"assertPositiveInteger");a(jfe,"waitWithAbort");a(Zw,"throwIfAborted");a(AA,"toError");a(IA,"errorMessage")});var mu,i0=re(()=>{mu=class{static{a(this,"Deque")}buffer=new Array(16);head=0;count=0;get size(){return this.count}pushBack(e){this.ensureCapacity();let t=this.head+this.count;this.buffer[t<this.buffer.length?t:t-this.buffer.length]=e,this.count+=1}pushFront(e){this.ensureCapacity(),this.head=this.head===0?this.buffer.length-1:this.head-1,this.buffer[this.head]=e,this.count+=1}popFront(){if(this.count===0)return;let e=this.buffer[this.head];return this.buffer[this.head]=void 0,this.head+=1,this.head===this.buffer.length&&(this.head=0),this.count-=1,this.compact(),e}clear(){this.buffer=new Array(16),this.head=0,this.count=0}ensureCapacity(){this.count<this.buffer.length||this.resize(this.buffer.length*2)}compact(){if(this.count===0){this.head=0;return}this.buffer.length>16&&this.count<=this.buffer.length/4&&this.resize(Math.max(16,this.buffer.length/2))}resize(e){let t=new Array(e),n=this.head;for(let r=0;r<this.count;r+=1)t[r]=this.buffer[n],n+=1,n===this.buffer.length&&(n=0);this.buffer=t,this.head=0}}});var Sp,_he,Pq=re(()=>{Xn();Sp=class extends Error{static{a(this,"DirectoryPickerError")}code;path;constructor(e,t,n){super(n),this.code=e,this.path=t,this.name="DirectoryPickerError"}},_he=class extends It{static{a(this,"DirectoryPicker")}constructor(e){super(e,"directoryPicker")}}});var tge=de((phn,cC)=>{var ege=ege||function(e){return Buffer.from(e).toString("base64")};function Jlt(e){var t=this,n=Math.round,r=Math.floor,i=new Array(64),s=new Array(64),o=new Array(64),l=new Array(64),c,u,d,p,h=new Array(65535),f=new Array(65535),g=new Array(64),y=new Array(64),v=[],w=0,b=7,S=new Array(64),k=new Array(64),E=new Array(64),T=new Array(256),I=new Array(2048),N,O=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],j=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],R=[0,1,2,3,4,5,6,7,8,9,10,11],H=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],J=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],A=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],W=[0,1,2,3,4,5,6,7,8,9,10,11],te=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],G=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];function U(ee){for(var Oe=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],he=0;he<64;he++){var nt=r((Oe[he]*ee+50)/100);nt<1?nt=1:nt>255&&(nt=255),i[O[he]]=nt}for(var Me=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],Re=0;Re<64;Re++){var pt=r((Me[Re]*ee+50)/100);pt<1?pt=1:pt>255&&(pt=255),s[O[Re]]=pt}for(var Ke=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],je=0,ut=0;ut<8;ut++)for(var Se=0;Se<8;Se++)o[je]=1/(i[O[je]]*Ke[ut]*Ke[Se]*8),l[je]=1/(s[O[je]]*Ke[ut]*Ke[Se]*8),je++}a(U,"initQuantTables");function L(ee,Oe){for(var he=0,nt=0,Me=new Array,Re=1;Re<=16;Re++){for(var pt=1;pt<=ee[Re];pt++)Me[Oe[nt]]=[],Me[Oe[nt]][0]=he,Me[Oe[nt]][1]=Re,nt++,he++;he*=2}return Me}a(L,"computeHuffmanTbl");function B(){c=L(j,R),u=L(A,W),d=L(H,J),p=L(te,G)}a(B,"initHuffmanTbl");function ce(){for(var ee=1,Oe=2,he=1;he<=15;he++){for(var nt=ee;nt<Oe;nt++)f[32767+nt]=he,h[32767+nt]=[],h[32767+nt][1]=he,h[32767+nt][0]=nt;for(var Me=-(Oe-1);Me<=-ee;Me++)f[32767+Me]=he,h[32767+Me]=[],h[32767+Me][1]=he,h[32767+Me][0]=Oe-1+Me;ee<<=1,Oe<<=1}}a(ce,"initCategoryNumber");function fe(){for(var ee=0;ee<256;ee++)I[ee]=19595*ee,I[ee+256>>0]=38470*ee,I[ee+512>>0]=7471*ee+32768,I[ee+768>>0]=-11059*ee,I[ee+1024>>0]=-21709*ee,I[ee+1280>>0]=32768*ee+8421375,I[ee+1536>>0]=-27439*ee,I[ee+1792>>0]=-5329*ee}a(fe,"initRGBYUVTable");function ue(ee){for(var Oe=ee[0],he=ee[1]-1;he>=0;)Oe&1<<he&&(w|=1<<b),he--,b--,b<0&&(w==255?(z(255),z(0)):z(w),b=7,w=0)}a(ue,"writeBits");function z(ee){v.push(ee)}a(z,"writeByte");function Ce(ee){z(ee>>8&255),z(ee&255)}a(Ce,"writeWord");function Xe(ee,Oe){var he,nt,Me,Re,pt,Ke,je,ut,Se=0,yt,Mt=8,st=64;for(yt=0;yt<Mt;++yt){he=ee[Se],nt=ee[Se+1],Me=ee[Se+2],Re=ee[Se+3],pt=ee[Se+4],Ke=ee[Se+5],je=ee[Se+6],ut=ee[Se+7];var an=he+ut,Dt=he-ut,Rt=nt+je,ne=nt-je,_e=Me+Ke,Fe=Me-Ke,Ye=Re+pt,wt=Re-pt,Be=an+Ye,Jt=an-Ye,Gt=Rt+_e,ln=Rt-_e;ee[Se]=Be+Gt,ee[Se+4]=Be-Gt;var Tt=(ln+Jt)*.707106781;ee[Se+2]=Jt+Tt,ee[Se+6]=Jt-Tt,Be=wt+Fe,Gt=Fe+ne,ln=ne+Dt;var fr=(Be-ln)*.382683433,yr=.5411961*Be+fr,Li=1.306562965*ln+fr,ti=Gt*.707106781,Vn=Dt+ti,Fi=Dt-ti;ee[Se+5]=Fi+yr,ee[Se+3]=Fi-yr,ee[Se+1]=Vn+Li,ee[Se+7]=Vn-Li,Se+=8}for(Se=0,yt=0;yt<Mt;++yt){he=ee[Se],nt=ee[Se+8],Me=ee[Se+16],Re=ee[Se+24],pt=ee[Se+32],Ke=ee[Se+40],je=ee[Se+48],ut=ee[Se+56];var ls=he+ut,Es=he-ut,Ls=nt+je,$t=nt-je,Sn=Me+Ke,Fs=Me-Ke,Do=Re+pt,no=Re-pt,ro=ls+Do,po=ls-Do,Mo=Ls+Sn,sa=Ls-Sn;ee[Se]=ro+Mo,ee[Se+32]=ro-Mo;var Il=(sa+po)*.707106781;ee[Se+16]=po+Il,ee[Se+48]=po-Il,ro=no+Fs,Mo=Fs+$t,sa=$t+Es;var Wa=(ro-sa)*.382683433,Zc=.5411961*ro+Wa,Kc=1.306562965*sa+Wa,Jc=Mo*.707106781,Xc=Es+Jc,Xd=Es-Jc;ee[Se+40]=Xd+Zc,ee[Se+24]=Xd-Zc,ee[Se+8]=Xc+Kc,ee[Se+56]=Xc-Kc,Se++}var Wu;for(yt=0;yt<st;++yt)Wu=ee[yt]*Oe[yt],g[yt]=Wu>0?Wu+.5|0:Wu-.5|0;return g}a(Xe,"fDCTQuant");function qe(){Ce(65504),Ce(16),z(74),z(70),z(73),z(70),z(0),z(1),z(1),z(0),Ce(1),Ce(1),z(0),z(0)}a(qe,"writeAPP0");function Te(ee){if(ee){Ce(65505),ee[0]===69&&ee[1]===120&&ee[2]===105&&ee[3]===102?Ce(ee.length+2):(Ce(ee.length+5+2),z(69),z(120),z(105),z(102),z(0));for(var Oe=0;Oe<ee.length;Oe++)z(ee[Oe])}}a(Te,"writeAPP1");function at(ee,Oe){Ce(65472),Ce(17),z(8),Ce(Oe),Ce(ee),z(3),z(1),z(17),z(0),z(2),z(17),z(1),z(3),z(17),z(1)}a(at,"writeSOF0");function ze(){Ce(65499),Ce(132),z(0);for(var ee=0;ee<64;ee++)z(i[ee]);z(1);for(var Oe=0;Oe<64;Oe++)z(s[Oe])}a(ze,"writeDQT");function xe(){Ce(65476),Ce(418),z(0);for(var ee=0;ee<16;ee++)z(j[ee+1]);for(var Oe=0;Oe<=11;Oe++)z(R[Oe]);z(16);for(var he=0;he<16;he++)z(H[he+1]);for(var nt=0;nt<=161;nt++)z(J[nt]);z(1);for(var Me=0;Me<16;Me++)z(A[Me+1]);for(var Re=0;Re<=11;Re++)z(W[Re]);z(17);for(var pt=0;pt<16;pt++)z(te[pt+1]);for(var Ke=0;Ke<=161;Ke++)z(G[Ke])}a(xe,"writeDHT");function me(ee){typeof ee>"u"||ee.constructor!==Array||ee.forEach(Oe=>{if(typeof Oe=="string"){Ce(65534);var he=Oe.length;Ce(he+2);var nt;for(nt=0;nt<he;nt++)z(Oe.charCodeAt(nt))}})}a(me,"writeCOM");function xt(){Ce(65498),Ce(12),z(3),z(1),z(0),z(2),z(17),z(3),z(17),z(0),z(63),z(0)}a(xt,"writeSOS");function Qe(ee,Oe,he,nt,Me){for(var Re=Me[0],pt=Me[240],Ke,je=16,ut=63,Se=64,yt=Xe(ee,Oe),Mt=0;Mt<Se;++Mt)y[O[Mt]]=yt[Mt];var st=y[0]-he;he=y[0],st==0?ue(nt[0]):(Ke=32767+st,ue(nt[f[Ke]]),ue(h[Ke]));for(var an=63;an>0&&y[an]==0;an--);if(an==0)return ue(Re),he;for(var Dt=1,Rt;Dt<=an;){for(var ne=Dt;y[Dt]==0&&Dt<=an;++Dt);var _e=Dt-ne;if(_e>=je){Rt=_e>>4;for(var Fe=1;Fe<=Rt;++Fe)ue(pt);_e=_e&15}Ke=32767+y[Dt],ue(Me[(_e<<4)+f[Ke]]),ue(h[Ke]),Dt++}return an!=ut&&ue(Re),he}a(Qe,"processDU");function lt(){for(var ee=String.fromCharCode,Oe=0;Oe<256;Oe++)T[Oe]=ee(Oe)}a(lt,"initCharLookupTable"),this.encode=function(ee,Oe){var he=new Date().getTime();Oe&&Ae(Oe),v=new Array,w=0,b=7,Ce(65496),qe(),me(ee.comments),Te(ee.exifBuffer),ze(),at(ee.width,ee.height),xe(),xt();var nt=0,Me=0,Re=0;w=0,b=7,this.encode.displayName="_encode_";for(var pt=ee.data,Ke=ee.width,je=ee.height,ut=Ke*4,Se=Ke*3,yt,Mt=0,st,an,Dt,Rt,ne,_e,Fe,Ye;Mt<je;){for(yt=0;yt<ut;){for(Rt=ut*Mt+yt,ne=Rt,_e=-1,Fe=0,Ye=0;Ye<64;Ye++)Fe=Ye>>3,_e=(Ye&7)*4,ne=Rt+Fe*ut+_e,Mt+Fe>=je&&(ne-=ut*(Mt+1+Fe-je)),yt+_e>=ut&&(ne-=yt+_e-ut+4),st=pt[ne++],an=pt[ne++],Dt=pt[ne++],S[Ye]=(I[st]+I[an+256>>0]+I[Dt+512>>0]>>16)-128,k[Ye]=(I[st+768>>0]+I[an+1024>>0]+I[Dt+1280>>0]>>16)-128,E[Ye]=(I[st+1280>>0]+I[an+1536>>0]+I[Dt+1792>>0]>>16)-128;nt=Qe(S,o,nt,c,d),Me=Qe(k,l,Me,u,p),Re=Qe(E,l,Re,u,p),yt+=32}Mt+=8}if(b>=0){var wt=[];wt[1]=b+1,wt[0]=(1<<b+1)-1,ue(wt)}if(Ce(65497),typeof cC>"u")return new Uint8Array(v);return Buffer.from(v);var Be,Jt};function Ae(ee){if(ee<=0&&(ee=1),ee>100&&(ee=100),N!=ee){var Oe=0;ee<50?Oe=Math.floor(5e3/ee):Oe=Math.floor(200-ee*2),U(Oe),N=ee}}a(Ae,"setQuality");function ge(){var ee=new Date().getTime();e||(e=50),lt(),B(),ce(),fe(),Ae(e);var Oe=new Date().getTime()-ee}a(ge,"init"),ge()}a(Jlt,"JPEGEncoder");typeof cC<"u"?cC.exports=Qme:typeof window<"u"&&(window["jpeg-js"]=window["jpeg-js"]||{},window["jpeg-js"].encode=Qme);function Qme(e,t){typeof t>"u"&&(t=50);var n=new Jlt(t),r=n.encode(e,t);return{data:r,width:e.width,height:e.height}}a(Qme,"encode")});var rge=de((hhn,cU)=>{var lU=a((function(){"use strict";var t=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),n=4017,r=799,i=3406,s=2276,o=1567,l=3784,c=5793,u=2896;function d(){}a(d,"constructor");function p(b,S){for(var k=0,E=[],T,I,N=16;N>0&&!b[N-1];)N--;E.push({children:[],index:0});var O=E[0],j;for(T=0;T<N;T++){for(I=0;I<b[T];I++){for(O=E.pop(),O.children[O.index]=S[k];O.index>0;){if(E.length===0)throw new Error("Could not recreate Huffman Table");O=E.pop()}for(O.index++,E.push(O);E.length<=T;)E.push(j={children:[],index:0}),O.children[O.index]=j.children,O=j;k++}T+1<N&&(E.push(j={children:[],index:0}),O.children[O.index]=j.children,O=j)}return E[0].children}a(p,"buildHuffmanTable");function h(b,S,k,E,T,I,N,O,j,R){var H=k.precision,J=k.samplesPerLine,A=k.scanLines,W=k.mcusPerLine,te=k.progressive,G=k.maxH,U=k.maxV,L=S,B=0,ce=0;function fe(){if(ce>0)return ce--,B>>ce&1;if(B=b[S++],B==255){var Se=b[S++];if(Se)throw new Error("unexpected marker: "+(B<<8|Se).toString(16))}return ce=7,B>>>7}a(fe,"readBit");function ue(Se){for(var yt=Se,Mt;(Mt=fe())!==null;){if(yt=yt[Mt],typeof yt=="number")return yt;if(typeof yt!="object")throw new Error("invalid huffman sequence")}return null}a(ue,"decodeHuffman");function z(Se){for(var yt=0;Se>0;){var Mt=fe();if(Mt===null)return;yt=yt<<1|Mt,Se--}return yt}a(z,"receive");function Ce(Se){var yt=z(Se);return yt>=1<<Se-1?yt:yt+(-1<<Se)+1}a(Ce,"receiveAndExtend");function Xe(Se,yt){var Mt=ue(Se.huffmanTableDC),st=Mt===0?0:Ce(Mt);yt[0]=Se.pred+=st;for(var an=1;an<64;){var Dt=ue(Se.huffmanTableAC),Rt=Dt&15,ne=Dt>>4;if(Rt===0){if(ne<15)break;an+=16;continue}an+=ne;var _e=t[an];yt[_e]=Ce(Rt),an++}}a(Xe,"decodeBaseline");function qe(Se,yt){var Mt=ue(Se.huffmanTableDC),st=Mt===0?0:Ce(Mt)<<j;yt[0]=Se.pred+=st}a(qe,"decodeDCFirst");function Te(Se,yt){yt[0]|=fe()<<j}a(Te,"decodeDCSuccessive");var at=0;function ze(Se,yt){if(at>0){at--;return}for(var Mt=I,st=N;Mt<=st;){var an=ue(Se.huffmanTableAC),Dt=an&15,Rt=an>>4;if(Dt===0){if(Rt<15){at=z(Rt)+(1<<Rt)-1;break}Mt+=16;continue}Mt+=Rt;var ne=t[Mt];yt[ne]=Ce(Dt)*(1<<j),Mt++}}a(ze,"decodeACFirst");var xe=0,me;function xt(Se,yt){for(var Mt=I,st=N,an=0;Mt<=st;){var Dt=t[Mt],Rt=yt[Dt]<0?-1:1;switch(xe){case 0:var ne=ue(Se.huffmanTableAC),_e=ne&15,an=ne>>4;if(_e===0)an<15?(at=z(an)+(1<<an),xe=4):(an=16,xe=1);else{if(_e!==1)throw new Error("invalid ACn encoding");me=Ce(_e),xe=an?2:3}continue;case 1:case 2:yt[Dt]?yt[Dt]+=(fe()<<j)*Rt:(an--,an===0&&(xe=xe==2?3:0));break;case 3:yt[Dt]?yt[Dt]+=(fe()<<j)*Rt:(yt[Dt]=me<<j,xe=0);break;case 4:yt[Dt]&&(yt[Dt]+=(fe()<<j)*Rt);break}Mt++}xe===4&&(at--,at===0&&(xe=0))}a(xt,"decodeACSuccessive");function Qe(Se,yt,Mt,st,an){var Dt=Mt/W|0,Rt=Mt%W,ne=Dt*Se.v+st,_e=Rt*Se.h+an;Se.blocks[ne]===void 0&&R.tolerantDecoding||yt(Se,Se.blocks[ne][_e])}a(Qe,"decodeMcu");function lt(Se,yt,Mt){var st=Mt/Se.blocksPerLine|0,an=Mt%Se.blocksPerLine;Se.blocks[st]===void 0&&R.tolerantDecoding||yt(Se,Se.blocks[st][an])}a(lt,"decodeBlock");var Ae=E.length,ge,ee,Oe,he,nt,Me;te?I===0?Me=O===0?qe:Te:Me=O===0?ze:xt:Me=Xe;var Re=0,pt,Ke;Ae==1?Ke=E[0].blocksPerLine*E[0].blocksPerColumn:Ke=W*k.mcusPerColumn,T||(T=Ke);for(var je,ut;Re<Ke;){for(ee=0;ee<Ae;ee++)E[ee].pred=0;if(at=0,Ae==1)for(ge=E[0],nt=0;nt<T;nt++)lt(ge,Me,Re),Re++;else for(nt=0;nt<T;nt++){for(ee=0;ee<Ae;ee++)for(ge=E[ee],je=ge.h,ut=ge.v,Oe=0;Oe<ut;Oe++)for(he=0;he<je;he++)Qe(ge,Me,Re,Oe,he);if(Re++,Re===Ke)break}if(Re===Ke)do{if(b[S]===255&&b[S+1]!==0)break;S+=1}while(S<b.length-2);if(ce=0,pt=b[S]<<8|b[S+1],pt<65280)throw new Error("marker was not found");if(pt>=65488&&pt<=65495)S+=2;else break}return S-L}a(h,"decodeScan");function f(b,S){var k=[],E=S.blocksPerLine,T=S.blocksPerColumn,I=E<<3,N=new Int32Array(64),O=new Uint8Array(64);function j(L,B,ce){var fe=S.quantizationTable,ue,z,Ce,Xe,qe,Te,at,ze,xe,me=ce,xt;for(xt=0;xt<64;xt++)me[xt]=L[xt]*fe[xt];for(xt=0;xt<8;++xt){var Qe=8*xt;if(me[1+Qe]==0&&me[2+Qe]==0&&me[3+Qe]==0&&me[4+Qe]==0&&me[5+Qe]==0&&me[6+Qe]==0&&me[7+Qe]==0){xe=c*me[0+Qe]+512>>10,me[0+Qe]=xe,me[1+Qe]=xe,me[2+Qe]=xe,me[3+Qe]=xe,me[4+Qe]=xe,me[5+Qe]=xe,me[6+Qe]=xe,me[7+Qe]=xe;continue}ue=c*me[0+Qe]+128>>8,z=c*me[4+Qe]+128>>8,Ce=me[2+Qe],Xe=me[6+Qe],qe=u*(me[1+Qe]-me[7+Qe])+128>>8,ze=u*(me[1+Qe]+me[7+Qe])+128>>8,Te=me[3+Qe]<<4,at=me[5+Qe]<<4,xe=ue-z+1>>1,ue=ue+z+1>>1,z=xe,xe=Ce*l+Xe*o+128>>8,Ce=Ce*o-Xe*l+128>>8,Xe=xe,xe=qe-at+1>>1,qe=qe+at+1>>1,at=xe,xe=ze+Te+1>>1,Te=ze-Te+1>>1,ze=xe,xe=ue-Xe+1>>1,ue=ue+Xe+1>>1,Xe=xe,xe=z-Ce+1>>1,z=z+Ce+1>>1,Ce=xe,xe=qe*s+ze*i+2048>>12,qe=qe*i-ze*s+2048>>12,ze=xe,xe=Te*r+at*n+2048>>12,Te=Te*n-at*r+2048>>12,at=xe,me[0+Qe]=ue+ze,me[7+Qe]=ue-ze,me[1+Qe]=z+at,me[6+Qe]=z-at,me[2+Qe]=Ce+Te,me[5+Qe]=Ce-Te,me[3+Qe]=Xe+qe,me[4+Qe]=Xe-qe}for(xt=0;xt<8;++xt){var lt=xt;if(me[8+lt]==0&&me[16+lt]==0&&me[24+lt]==0&&me[32+lt]==0&&me[40+lt]==0&&me[48+lt]==0&&me[56+lt]==0){xe=c*ce[xt+0]+8192>>14,me[0+lt]=xe,me[8+lt]=xe,me[16+lt]=xe,me[24+lt]=xe,me[32+lt]=xe,me[40+lt]=xe,me[48+lt]=xe,me[56+lt]=xe;continue}ue=c*me[0+lt]+2048>>12,z=c*me[32+lt]+2048>>12,Ce=me[16+lt],Xe=me[48+lt],qe=u*(me[8+lt]-me[56+lt])+2048>>12,ze=u*(me[8+lt]+me[56+lt])+2048>>12,Te=me[24+lt],at=me[40+lt],xe=ue-z+1>>1,ue=ue+z+1>>1,z=xe,xe=Ce*l+Xe*o+2048>>12,Ce=Ce*o-Xe*l+2048>>12,Xe=xe,xe=qe-at+1>>1,qe=qe+at+1>>1,at=xe,xe=ze+Te+1>>1,Te=ze-Te+1>>1,ze=xe,xe=ue-Xe+1>>1,ue=ue+Xe+1>>1,Xe=xe,xe=z-Ce+1>>1,z=z+Ce+1>>1,Ce=xe,xe=qe*s+ze*i+2048>>12,qe=qe*i-ze*s+2048>>12,ze=xe,xe=Te*r+at*n+2048>>12,Te=Te*n-at*r+2048>>12,at=xe,me[0+lt]=ue+ze,me[56+lt]=ue-ze,me[8+lt]=z+at,me[48+lt]=z-at,me[16+lt]=Ce+Te,me[40+lt]=Ce-Te,me[24+lt]=Xe+qe,me[32+lt]=Xe-qe}for(xt=0;xt<64;++xt){var Ae=128+(me[xt]+8>>4);B[xt]=Ae<0?0:Ae>255?255:Ae}}a(j,"quantizeAndInverse"),w(I*T*8);for(var R,H,J=0;J<T;J++){var A=J<<3;for(R=0;R<8;R++)k.push(new Uint8Array(I));for(var W=0;W<E;W++){j(S.blocks[J][W],O,N);var te=0,G=W<<3;for(H=0;H<8;H++){var U=k[A+H];for(R=0;R<8;R++)U[G+R]=O[te++]}}}return k}a(f,"buildComponentData");function g(b){return b<0?0:b>255?255:b}a(g,"clampTo8bit"),d.prototype={load:a(function(S){var k=new XMLHttpRequest;k.open("GET",S,!0),k.responseType="arraybuffer",k.onload=(function(){var E=new Uint8Array(k.response||k.mozResponseArrayBuffer);this.parse(E),this.onload&&this.onload()}).bind(this),k.send(null)},"load"),parse:a(function(S){var k=this.opts.maxResolutionInMP*1e3*1e3,E=0,T=S.length;function I(){var ne=S[E]<<8|S[E+1];return E+=2,ne}a(I,"readUint16");function N(){var ne=I(),_e=S.subarray(E,E+ne-2);return E+=_e.length,_e}a(N,"readDataBlock");function O(ne){var _e=1,Fe=1,Ye,wt;for(wt in ne.components)ne.components.hasOwnProperty(wt)&&(Ye=ne.components[wt],_e<Ye.h&&(_e=Ye.h),Fe<Ye.v&&(Fe=Ye.v));var Be=Math.ceil(ne.samplesPerLine/8/_e),Jt=Math.ceil(ne.scanLines/8/Fe);for(wt in ne.components)if(ne.components.hasOwnProperty(wt)){Ye=ne.components[wt];var Gt=Math.ceil(Math.ceil(ne.samplesPerLine/8)*Ye.h/_e),ln=Math.ceil(Math.ceil(ne.scanLines/8)*Ye.v/Fe),Tt=Be*Ye.h,fr=Jt*Ye.v,yr=fr*Tt,Li=[];w(yr*256);for(var ti=0;ti<fr;ti++){for(var Vn=[],Fi=0;Fi<Tt;Fi++)Vn.push(new Int32Array(64));Li.push(Vn)}Ye.blocksPerLine=Gt,Ye.blocksPerColumn=ln,Ye.blocks=Li}ne.maxH=_e,ne.maxV=Fe,ne.mcusPerLine=Be,ne.mcusPerColumn=Jt}a(O,"prepareComponents");var j=null,R=null,H=null,J,A,W=[],te=[],G=[],U=[],L=I(),B=-1;if(this.comments=[],L!=65496)throw new Error("SOI not found");for(L=I();L!=65497;){var ce,fe,ue;switch(L){case 65280:break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var z=N();if(L===65534){var Ce=String.fromCharCode.apply(null,z);this.comments.push(Ce)}L===65504&&z[0]===74&&z[1]===70&&z[2]===73&&z[3]===70&&z[4]===0&&(j={version:{major:z[5],minor:z[6]},densityUnits:z[7],xDensity:z[8]<<8|z[9],yDensity:z[10]<<8|z[11],thumbWidth:z[12],thumbHeight:z[13],thumbData:z.subarray(14,14+3*z[12]*z[13])}),L===65505&&z[0]===69&&z[1]===120&&z[2]===105&&z[3]===102&&z[4]===0&&(this.exifBuffer=z.subarray(5,z.length)),L===65518&&z[0]===65&&z[1]===100&&z[2]===111&&z[3]===98&&z[4]===101&&z[5]===0&&(R={version:z[6],flags0:z[7]<<8|z[8],flags1:z[9]<<8|z[10],transformCode:z[11]});break;case 65499:for(var Xe=I(),qe=Xe+E-2;E<qe;){var Te=S[E++];w(256);var at=new Int32Array(64);if(Te>>4===0)for(fe=0;fe<64;fe++){var ze=t[fe];at[ze]=S[E++]}else if(Te>>4===1)for(fe=0;fe<64;fe++){var ze=t[fe];at[ze]=I()}else throw new Error("DQT: invalid table spec");W[Te&15]=at}break;case 65472:case 65473:case 65474:I(),J={},J.extended=L===65473,J.progressive=L===65474,J.precision=S[E++],J.scanLines=I(),J.samplesPerLine=I(),J.components={},J.componentsOrder=[];var xe=J.scanLines*J.samplesPerLine;if(xe>k){var me=Math.ceil((xe-k)/1e6);throw new Error(`maxResolutionInMP limit exceeded by ${me}MP`)}var xt=S[E++],Qe,lt=0,Ae=0;for(ce=0;ce<xt;ce++){Qe=S[E];var ge=S[E+1]>>4,ee=S[E+1]&15,Oe=S[E+2];if(ge<=0||ee<=0)throw new Error("Invalid sampling factor, expected values above 0");J.componentsOrder.push(Qe),J.components[Qe]={h:ge,v:ee,quantizationIdx:Oe},E+=3}O(J),te.push(J);break;case 65476:var he=I();for(ce=2;ce<he;){var nt=S[E++],Me=new Uint8Array(16),Re=0;for(fe=0;fe<16;fe++,E++)Re+=Me[fe]=S[E];w(16+Re);var pt=new Uint8Array(Re);for(fe=0;fe<Re;fe++,E++)pt[fe]=S[E];ce+=17+Re,(nt>>4===0?U:G)[nt&15]=p(Me,pt)}break;case 65501:I(),A=I();break;case 65500:I(),I();break;case 65498:var Ke=I(),je=S[E++],ut=[],Se;for(ce=0;ce<je;ce++){Se=J.components[S[E++]];var yt=S[E++];Se.huffmanTableDC=U[yt>>4],Se.huffmanTableAC=G[yt&15],ut.push(Se)}var Mt=S[E++],st=S[E++],an=S[E++],Dt=h(S,E,J,ut,A,Mt,st,an>>4,an&15,this.opts);E+=Dt;break;case 65535:S[E]!==255&&E--;break;default:if(S[E-3]==255&&S[E-2]>=192&&S[E-2]<=254){E-=3;break}else if(L===224||L==225){if(B!==-1)throw new Error(`first unknown JPEG marker at offset ${B.toString(16)}, second unknown JPEG marker ${L.toString(16)} at offset ${(E-1).toString(16)}`);B=E-1;let ne=I();if(S[E+ne-2]===255){E+=ne-2;break}}throw new Error("unknown JPEG marker "+L.toString(16))}L=I()}if(te.length!=1)throw new Error("only single frame JPEGs supported");for(var ce=0;ce<te.length;ce++){var Rt=te[ce].components;for(var fe in Rt)Rt[fe].quantizationTable=W[Rt[fe].quantizationIdx],delete Rt[fe].quantizationIdx}this.width=J.samplesPerLine,this.height=J.scanLines,this.jfif=j,this.adobe=R,this.components=[];for(var ce=0;ce<J.componentsOrder.length;ce++){var Se=J.components[J.componentsOrder[ce]];this.components.push({lines:f(J,Se),scaleX:Se.h/J.maxH,scaleY:Se.v/J.maxV})}},"parse"),getData:a(function(S,k){var E=this.width/S,T=this.height/k,I,N,O,j,R,H,J,A,W,te,G=0,U,L,B,ce,fe,ue,z,Ce,Xe,qe,Te,at=S*k*this.components.length;w(at);var ze=new Uint8Array(at);switch(this.components.length){case 1:for(I=this.components[0],te=0;te<k;te++)for(R=I.lines[0|te*I.scaleY*T],W=0;W<S;W++)U=R[0|W*I.scaleX*E],ze[G++]=U;break;case 2:for(I=this.components[0],N=this.components[1],te=0;te<k;te++)for(R=I.lines[0|te*I.scaleY*T],H=N.lines[0|te*N.scaleY*T],W=0;W<S;W++)U=R[0|W*I.scaleX*E],ze[G++]=U,U=H[0|W*N.scaleX*E],ze[G++]=U;break;case 3:for(Te=!0,this.adobe&&this.adobe.transformCode?Te=!0:typeof this.opts.colorTransform<"u"&&(Te=!!this.opts.colorTransform),I=this.components[0],N=this.components[1],O=this.components[2],te=0;te<k;te++)for(R=I.lines[0|te*I.scaleY*T],H=N.lines[0|te*N.scaleY*T],J=O.lines[0|te*O.scaleY*T],W=0;W<S;W++)Te?(U=R[0|W*I.scaleX*E],L=H[0|W*N.scaleX*E],B=J[0|W*O.scaleX*E],Ce=g(U+1.402*(B-128)),Xe=g(U-.3441363*(L-128)-.71413636*(B-128)),qe=g(U+1.772*(L-128))):(Ce=R[0|W*I.scaleX*E],Xe=H[0|W*N.scaleX*E],qe=J[0|W*O.scaleX*E]),ze[G++]=Ce,ze[G++]=Xe,ze[G++]=qe;break;case 4:if(!this.adobe)throw new Error("Unsupported color mode (4 components)");for(Te=!1,this.adobe&&this.adobe.transformCode?Te=!0:typeof this.opts.colorTransform<"u"&&(Te=!!this.opts.colorTransform),I=this.components[0],N=this.components[1],O=this.components[2],j=this.components[3],te=0;te<k;te++)for(R=I.lines[0|te*I.scaleY*T],H=N.lines[0|te*N.scaleY*T],J=O.lines[0|te*O.scaleY*T],A=j.lines[0|te*j.scaleY*T],W=0;W<S;W++)Te?(U=R[0|W*I.scaleX*E],L=H[0|W*N.scaleX*E],B=J[0|W*O.scaleX*E],ce=A[0|W*j.scaleX*E],fe=255-g(U+1.402*(B-128)),ue=255-g(U-.3441363*(L-128)-.71413636*(B-128)),z=255-g(U+1.772*(L-128))):(fe=R[0|W*I.scaleX*E],ue=H[0|W*N.scaleX*E],z=J[0|W*O.scaleX*E],ce=A[0|W*j.scaleX*E]),ze[G++]=255-fe,ze[G++]=255-ue,ze[G++]=255-z,ze[G++]=255-ce;break;default:throw new Error("Unsupported color mode")}return ze},"getData"),copyToImageData:a(function(S,k){var E=S.width,T=S.height,I=S.data,N=this.getData(E,T),O=0,j=0,R,H,J,A,W,te,G,U,L;switch(this.components.length){case 1:for(H=0;H<T;H++)for(R=0;R<E;R++)J=N[O++],I[j++]=J,I[j++]=J,I[j++]=J,k&&(I[j++]=255);break;case 3:for(H=0;H<T;H++)for(R=0;R<E;R++)G=N[O++],U=N[O++],L=N[O++],I[j++]=G,I[j++]=U,I[j++]=L,k&&(I[j++]=255);break;case 4:for(H=0;H<T;H++)for(R=0;R<E;R++)W=N[O++],te=N[O++],J=N[O++],A=N[O++],G=255-g(W*(1-A/255)+A),U=255-g(te*(1-A/255)+A),L=255-g(J*(1-A/255)+A),I[j++]=G,I[j++]=U,I[j++]=L,k&&(I[j++]=255);break;default:throw new Error("Unsupported color mode")}},"copyToImageData")};var y=0,v=0;function w(b=0){var S=y+b;if(S>v){var k=Math.ceil((S-v)/1024/1024);throw new Error(`maxMemoryUsageInMB limit exceeded by at least ${k}MB`)}y=S}return a(w,"requestMemoryAllocation"),d.resetMaxMemoryUsage=function(b){y=0,v=b},d.getBytesAllocated=function(){return y},d.requestMemoryAllocation=w,d}),"jpegImage")();typeof cU<"u"?cU.exports=nge:typeof window<"u"&&(window["jpeg-js"]=window["jpeg-js"]||{},window["jpeg-js"].decode=nge);function nge(e,t={}){var n={colorTransform:void 0,useTArray:!1,formatAsRGBA:!0,tolerantDecoding:!0,maxResolutionInMP:100,maxMemoryUsageInMB:512},r={...n,...t},i=new Uint8Array(e),s=new lU;s.opts=r,lU.resetMaxMemoryUsage(r.maxMemoryUsageInMB*1024*1024),s.parse(i);var o=r.formatAsRGBA?4:3,l=s.width*s.height*o;try{lU.requestMemoryAllocation(l);var c={width:s.width,height:s.height,exifBuffer:s.exifBuffer,data:r.useTArray?new Uint8Array(l):Buffer.alloc(l)};s.comments.length>0&&(c.comments=s.comments)}catch(u){throw u instanceof RangeError?new Error("Could not allocate enough memory for the image. Required: "+l):u instanceof ReferenceError&&u.message==="Buffer is not defined"?new Error("Buffer is not globally defined in this environment. Consider setting useTArray to true"):u}return s.copyToImageData(c,r.formatAsRGBA),c}a(nge,"decode")});var sge=de((ghn,ige)=>{var Xlt=tge(),Ylt=rge();ige.exports={encode:Xlt,decode:Ylt}});async function A1e(e,t,n){let r=n===void 0?void 0:{signal:n},i=await e.open(t,"read",r),s;try{s=await i.read(0,void 0,r)}catch(l){try{await i.close()}catch{}throw l}await i.close();let{events:o}=s;return{eventState:s.eventState,header:i.header,inheritedEventCount:i.inheritedEventCount,events:[...o,...xT(o)]}}function KU(e,t){if(e.id!==t.id||e.createdAt!==t.createdAt||e.cwd!==t.cwd||e.parentSession!==t.parentSession||e.isSeeded!==t.isSeeded||(e.delegationDepth??0)!==(t.delegationDepth??0))throw new Cr(`session source headers conflict for session "${e.id}"`,"SESSION_QUERY_SOURCE_CONFLICT")}function AC(e,t,n,r){try{r?.throwIfAborted();let i=n(t);return r?.throwIfAborted(),{sessionId:e,status:"fulfilled",value:i}}catch(i){return r?.aborted&&r.throwIfAborted(),{sessionId:e,status:"rejected",reason:i}}}function JU(e){return{header:e.header,events:e.snapshotEvents()}}function CC(e,t){return e.map(n=>t.get(n))}async function XU(e,t){try{return(await e.list(t===void 0?void 0:{signal:t})).map(n=>n.header)}catch(n){throw t?.aborted&&t.throwIfAborted(),new Cr(`session persistence listing failed: ${ez(n)}`,"SESSION_QUERY_PERSISTENCE_FAILED",{cause:n})}}async function S1e(e,t,n){try{return await A1e(e,t,n)}catch(r){throw n?.aborted&&n.throwIfAborted(),r instanceof Error&&r.name==="SessionPersistenceCorruptionError"?new Cr(`stored session "${t}" is corrupt: ${ez(r)}`,"SESSION_QUERY_CORRUPT_SESSION",{cause:r}):new Cr(`failed to read stored session "${t}": ${ez(r)}`,"SESSION_QUERY_PERSISTENCE_FAILED",{cause:r})}}function k1e(e){return{header:structuredClone(e.header),inheritedEventCount:e.inheritedEventCount,events:e.snapshotEvents().map(t=>structuredClone(t))}}function Jdt(e,t){return t.header.createdAt-e.header.createdAt||e.header.id.localeCompare(t.header.id)}function RC(e){return new Cr(`session "${e}" not found`,"SESSION_QUERY_SESSION_NOT_FOUND")}function ez(e){return e instanceof Error?e.message:"unknown error"}function bS(e){if(e?.aborted===!0)throw new Cr("session observation was aborted","SESSION_QUERY_ABORTED",{cause:e.reason})}function E1e(e,t){return _1e(t,"SessionPersistenceNotFoundError")?tz(e,t):_1e(t,"SessionPersistenceCorruptionError")?new Cr(`stored session "${e}" is corrupt: ${t.message}`,"SESSION_QUERY_CORRUPT_SESSION",{cause:t}):new Cr(`failed to observe session "${e}": ${nz(t)}`,"SESSION_QUERY_PERSISTENCE_FAILED",{cause:t})}function tz(e,t){return new Cr(`session "${e}" not found`,"SESSION_QUERY_SESSION_NOT_FOUND",t===void 0?void 0:{cause:t})}function nz(e){return e instanceof Error?e.message:"unknown error"}function _1e(e,t){return e instanceof Error&&e.name===t}function Ydt(e){switch(e.type){case"user/message":return YU(e.data.content);case"assistant/message":return YU(e.data.message.content);case"tool/call":return wS([e.data.name,e.data.arguments]);case"tool/result":return wS([YU(e.data.message.content),e.data.error?.name??"",e.data.error?.code??""]);case"todo/write":return wS(e.data.todos.flatMap(t=>[t.status,t.content]));case"turn/end":return Qdt(e.data.reason);case"turn/start":case"step/start":case"step/end":case"assistant/attempt":case"request/header":return"";default:return""}}function Qdt(e){switch(e.kind){case"error":return wS(["error",e.error.message]);case"aborted":return"aborted";case"max-tokens":case"interrupted":return e.kind;case"completed":return"";default:return""}}function YU(e){return wS(e.flatMap(C1e))}function C1e(e){switch(e.type){case"text":return[e.text];case"reasoning":return[];case"tool-call":return[e.name,e.arguments];case"tool-result":return e.content.flatMap(C1e);default:return[]}}function wS(e){return e.map(t=>t.trim()).filter(Boolean).join(`
154
154
  `)}function iz(e,t){let n=ept(t),r=[];for(let i of t){let s=Ydt(i);s.length!==0&&r.push({sessionId:e,seq:i.seq,type:i.type,time:i.time,surface:n.get(i.seq)??"log-only",text:s})}return r}function ept(e){let t;try{t=x9(e)}catch(r){throw new Cr(`invalid session surface: ${r instanceof Error?r.message:"unknown error"}`,"SESSION_QUERY_INVALID_SURFACE",{cause:r})}let n=new Map;for(let r of t.nodes)n.set(r,"current");for(let r of t.replacements)for(let i of r.shadowedSeqs)n.set(i,"shadowed");return n}function sz(e,t=[]){let n=t.map(npt);return e.filter(r=>n.every(i=>i(r)))}function NC(e,t=[]){let n=t.map(rpt);return e.filter(r=>n.every(i=>i(r)))}function oz(e){return R1e(e),e.map(t=>{switch(t.kind){case"id":return{kind:t.kind,values:OC(t.kind,t.values)};case"cwd":return{kind:t.kind,values:T1e(t.kind,t.values)};case"created-at":return $1e(t.kind,t);case"parent":return{kind:t.kind,values:T1e(t.kind,t.values)};case"availability":{let n=OC(t.kind,t.values);return LC(t.kind,n,["live","persisted"]),{kind:t.kind,values:n}}default:return MC(t)}})}function DC(e){return R1e(e),e.map(t=>{switch(t.kind){case"seq":case"time":return $1e(t.kind,t);case"type":return{kind:t.kind,values:OC(t.kind,t.values)};case"surface":{let n=OC(t.kind,t.values);return LC(t.kind,n,["current","shadowed","log-only"]),{kind:t.kind,values:n}}case"text":if(typeof t.text!="string")throw x0("text filter text must be a string");return{kind:t.kind,text:t.text};default:return MC(t)}})}function tpt(e){let t=e.trim();if(t.length===0)throw new Cr("session text filter must contain non-whitespace text","SESSION_QUERY_INVALID_FILTER");let n=t.split(/\s+/u).map(r=>r.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")).join("\\s+");return new RegExp(n,"iu")}function npt(e){switch(e.kind){case"id":return t=>e.values.includes(t.header.id);case"cwd":return t=>e.values.includes(t.header.cwd??null);case"created-at":{let t=PC(e.kind,e);return n=>rz(n.header.createdAt,t)}case"parent":return t=>e.values.includes(t.header.parentSession??null);case"availability":return LC(e.kind,e.values,["live","persisted"]),t=>e.values.some(n=>n==="live"?t.live:t.persisted);default:return MC(e)}}function rpt(e){switch(e.kind){case"seq":{let t=PC(e.kind,e);return n=>rz(n.seq,t)}case"time":{let t=PC(e.kind,e);return n=>rz(n.time,t)}case"type":return t=>e.values.includes(t.type);case"surface":return LC(e.kind,e.values,["current","shadowed","log-only"]),t=>e.values.includes(t.surface);case"text":{let t=tpt(e.text);return n=>t.test(n.text)}default:return MC(e)}}function OC(e,t){if(!O1e(t)||t.some(n=>typeof n!="string"))throw x0(`${e} filter values must be an array of strings`);return[...t]}function R1e(e){if(!Array.isArray(e))throw x0("filters must be an array")}function T1e(e,t){if(!O1e(t)||t.some(n=>n!==null&&typeof n!="string"))throw x0(`${e} filter values must be an array of strings or null`);return[...t]}function $1e(e,t){let n={kind:e,...t.from===void 0?{}:{from:t.from},...t.to===void 0?{}:{to:t.to}};return PC(e,n),n}function MC(e){let t=e.kind;throw x0(`unknown filter kind ${typeof t=="string"?`"${t}"`:"(missing)"}`)}function LC(e,t,n){for(let r of t)if(!n.includes(r))throw new Cr(`session ${e} filter contains unknown value "${r}"`,"SESSION_QUERY_INVALID_FILTER")}function PC(e,t){if(t.from!==void 0&&!Number.isFinite(t.from))throw QU(e,"from must be finite");if(t.to!==void 0&&!Number.isFinite(t.to))throw QU(e,"to must be finite");if(t.from!==void 0&&t.to!==void 0&&t.from>t.to)throw QU(e,"from must be less than or equal to to");return t}function rz(e,t){return(t.from===void 0||e>=t.from)&&(t.to===void 0||e<=t.to)}function QU(e,t){return x0(`${e} filter ${t}`)}function x0(e){return new Cr(`session ${e}`,"SESSION_QUERY_INVALID_FILTER")}function O1e(e){return Array.isArray(e)}function ipt(e,t){return az(e,t).records}function spt(e,t){return az(e,t).currentSeqs.map(n=>{let r=t[n];if(r===void 0||r.seq!==n||!If(r))throw new Cr(`invalid session surface: current node ${n} is not a surface event`,"SESSION_QUERY_INVALID_SURFACE");return wb(r)})}function opt(e,t,n){let r=t[n];if(r===void 0||r.seq!==n)throw new Cr(`session "${e}" has no event at seq ${n}`,"SESSION_QUERY_EVENT_NOT_FOUND");let i=az(e,t),s=[],o=i.replacedBy.get(n);for(;o!==void 0;)s.push(o),o=i.replacedBy.get(o);let l=[];for(let d of t)d.seq<=n||I1e(d).includes(n)&&l.push(d.seq);let c=i.records[n],u=i.replacedBy.get(n);return{target:c,...u===void 0?{}:{replacedBy:u},replacementChain:s,replacedEventSeqs:i.replacedEventSeqs.get(n)??[],sourceEventSeqs:[...I1e(r)],derivedEventSeqs:l}}function apt(e,t){let n=new Map(e.map(p=>[p.header.id,p])),r=n.get(t);if(r===void 0)throw new Cr(`session "${t}" not found`,"SESSION_QUERY_SESSION_NOT_FOUND");let i=[],s=new Set([t]),o,l=r.header.parentSession;for(;l!==void 0;){if(s.has(l))throw new Cr(`session lineage contains a cycle at "${l}"`,"SESSION_QUERY_INVALID_LINEAGE");s.add(l);let p=n.get(l);if(p===void 0){o=l;break}i.push(p),l=p.header.parentSession}let c=new Map;for(let p of e){let h=p.header.parentSession;if(h===void 0)continue;let f=c.get(h)??[];f.push(p),c.set(h,f)}for(let p of c.values())p.sort((h,f)=>h.header.createdAt-f.header.createdAt||h.header.id.localeCompare(f.header.id));let u=lpt(c,t),d={target:$C(r),ancestors:i.map($C),descendants:u};return o!==void 0?{...d,complete:!1,unresolvedParentId:o}:{...d,complete:!0,root:$C(i.at(-1)??r)}}function az(e,t){let n;try{n=x9(t)}catch(o){throw new Cr(`invalid session surface: ${o instanceof Error?o.message:"unknown error"}`,"SESSION_QUERY_INVALID_SURFACE",{cause:o})}let r=new Set(n.nodes),i=new Map,s=new Map;for(let o of n.replacements){let l=o.shadowedSeqs;s.set(o.seq,l);for(let c of l)i.set(c,o.seq)}return{records:t.map(o=>({sessionId:e,seq:o.seq,type:o.type,time:o.time,surface:r.has(o.seq)?"current":i.has(o.seq)?"shadowed":"log-only"})),replacedBy:i,replacedEventSeqs:s,currentSeqs:[...n.nodes]}}function I1e(e){return e.sourceEventSeqs??[]}function lpt(e,t){let n=[],r=[{sessionId:t,descendants:n}];for(;r.length>0;){let i=r.pop(),s=[];for(let o of e.get(i.sessionId)??[]){let l={session:$C(o),descendants:[]};s.push(l),i.descendants.push(l)}for(let o=s.length-1;o>=0;o-=1){let l=s[o];r.push({sessionId:l.session.header.id,descendants:l.descendants})}}return n}function $C(e){return{...e,header:structuredClone(e.header)}}var Cr,Kdt,Xdt,P1e,lz=re(()=>{Xn();ws();Nf();Ir();Cr=class extends Nr{static{a(this,"SessionQueryError")}constructor(e,t,n){super(e,t,n)}};a(A1e,"readColdSessionLog");a(KU,"assertSessionHeadersCompatible");Kdt=class{static{a(this,"SessionCorpus")}_ctx;_persistedReadConcurrency;_persistence;_optionalPersistenceFiber;constructor(e,t){this._ctx=e,this._persistedReadConcurrency=t,this._optionalPersistenceFiber=e.inject(["sessionPersistence"],n=>{let r=n.sessionPersistence;this._persistence=r,n.effect(()=>()=>{this._persistence===r&&(this._persistence=void 0)},"sessionQuery.persistenceBinding")}),e.effect(()=>()=>this._optionalPersistenceFiber.dispose(),"sessionQuery.optionalPersistence")}async listSessions(e){e?.throwIfAborted();let t=this._persistence,n=t===void 0?[]:await XU(t,e);e?.throwIfAborted();let r=new Map;for(let i of n)r.set(i.id,{header:structuredClone(i),live:!1,persisted:!0});for(let i of this._ctx.sessions.list()){let s=r.get(i.id);s!==void 0&&KU(i.header,s.header),r.set(i.id,{header:structuredClone(i.header),live:!0,persisted:s!==void 0})}return[...r.values()].sort(Jdt)}async load(e,t){t?.throwIfAborted();let n=this._ctx.sessions.get(e);if(n!==void 0){let c=k1e(n);return t?.throwIfAborted(),c}let r=this._persistence;if(r===void 0)throw RC(e);let i=(await XU(r,t)).find(c=>c.id===e);if(t?.throwIfAborted(),i===void 0)throw RC(e);let s=await S1e(r,e,t);t?.throwIfAborted();let o=this._ctx.sessions.get(e);if(o!==void 0){let c=k1e(o);return t?.throwIfAborted(),c}KU(s.header,i);let l={header:structuredClone(s.header),inheritedEventCount:s.inheritedEventCount,events:s.events.map(c=>structuredClone(c))};return t?.throwIfAborted(),l}async projectMany(e,t,n){let r=[...new Set(e)];n?.throwIfAborted();let i=new Map,s=[];for(let g of r){let y=this._ctx.sessions.get(g);y===void 0?s.push(g):i.set(g,AC(g,JU(y),t,n))}if(s.length===0)return CC(r,i);let o=this._persistence;if(o===void 0){for(let g of s)i.set(g,{sessionId:g,status:"rejected",reason:RC(g)});return CC(r,i)}let l;try{l=await XU(o,n),n?.throwIfAborted()}catch(g){n?.aborted&&n.throwIfAborted();for(let y of s)i.set(y,{sessionId:y,status:"rejected",reason:g});return CC(r,i)}let c=new Map(l.map(g=>[g.id,g])),u=a(async g=>{let y=c.get(g);if(y===void 0){let v=this._ctx.sessions.get(g);i.set(g,v===void 0?{sessionId:g,status:"rejected",reason:RC(g)}:AC(g,JU(v),t,n));return}try{n?.throwIfAborted();let v=await S1e(o,g,n);n?.throwIfAborted();let w=this._ctx.sessions.get(g);if(w!==void 0){i.set(g,AC(g,JU(w),t,n));return}KU(v.header,y),i.set(g,AC(g,{header:v.header,events:v.events},t,n))}catch(v){n?.aborted&&n.throwIfAborted(),i.set(g,{sessionId:g,status:"rejected",reason:v})}},"resolvePersisted"),d=0,p=a(async()=>{for(;;){n?.throwIfAborted();let g=d;if(g>=s.length)return;d+=1,await u(s[g])}},"worker"),h=Math.min(this._persistedReadConcurrency,s.length),f=await Promise.allSettled(Array.from({length:h},()=>p()));n?.aborted&&n.throwIfAborted();for(let g of f)if(g.status==="rejected")throw g.reason;return n?.throwIfAborted(),CC(r,i)}};a(AC,"projectSource");a(JU,"sourceLive");a(CC,"orderedResults");a(XU,"listPersisted");a(S1e,"inspectPersisted");a(k1e,"snapshotLive");a(Jdt,"compareSessions");a(RC,"notFound$1");a(ez,"errorMessage$1");Xdt=class{static{a(this,"SessionObservationReader")}ctx;cacheCapacity;cache=new Map;constructor(e,t=5){this.ctx=e,this.cacheCapacity=t}async read(e,t={}){let{signal:n,projectionMode:r="all"}=t;for(;;){bS(n);let i=this.ctx.sessions.get(e);if(i!==void 0)return this.live(i,r);let s=this.ctx.get("sessionPersistence");if(s===void 0)throw tz(e);let o=await this.statSource(s,e,n),l=this.ctx.sessions.get(e);if(l!==void 0)return this.live(l,r);let c=this.cachedEntry(s,e,o.revision);if(c===void 0){let d=await this.loadSource(s,e,n);bS(n);let p=this.ctx.sessions.get(e);if(p!==void 0)return this.live(p,r);let h=d.events,f;try{f=this.ctx.sessions.prepare(e,{seed:h,meta:structuredClone(d.header),inheritedEventCount:d.inheritedEventCount,eventState:d.eventState})}catch(g){if(this.ctx.sessions.get(e)!==void 0)continue;throw new Cr(`stored session "${e}" is corrupt: ${nz(g)}`,"SESSION_QUERY_CORRUPT_SESSION",{cause:g})}c={persistence:s,revision:o.revision,session:f,events:Object.freeze(h),refs:0},this.store(e,c)}let u;try{u=r==="none"?void 0:this.preparedProjections(c)}catch(d){throw new Cr(`failed to project session "${e}": ${nz(d)}`,"SESSION_QUERY_CORRUPT_SESSION",{cause:d})}return this.preparedLease(e,c,u)}}async statSource(e,t,n){let r;try{r=await e.stat(t,n===void 0?void 0:{signal:n})}catch(i){throw bS(n),E1e(t,i)}if(bS(n),r===void 0)throw tz(t);if(r.header.id!==t)throw new Cr(`session persistence returned "${r.header.id}" for "${t}"`,"SESSION_QUERY_SOURCE_CONFLICT");return r}async loadSource(e,t,n){try{return await A1e(e,t,n)}catch(r){throw bS(n),E1e(t,r)}}cachedEntry(e,t,n){let r=this.cache.get(t);if(!(r===void 0||r.persistence!==e||r.revision!==n))return this.cache.delete(t),this.cache.set(t,r),r}store(e,t){this.cache.delete(e),this.cache.set(e,t),this.evictPastCapacity(t)}evictPastCapacity(e){if(!(this.cache.size<=this.cacheCapacity)){for(let[t,n]of this.cache)if(!(n===e||n.refs>0)&&(this.cache.delete(t),this.cache.size<=this.cacheCapacity))return}}preparedLease(e,t,n){t.refs+=1;let r=a(()=>{let i=!1;return{source:"prepared",header:t.session.header,inheritedEventCount:t.session.inheritedEventCount,events:t.events,cursor:t.events.at(-1)?.seq??-1,revision:t.revision,...n===void 0?{}:{projections:n},retain:a(()=>{if(i)throw new Error(`session observation "${e}" is disposed`);return t.refs+=1,r()},"retain"),[Symbol.dispose]:()=>{i||(i=!0,t.refs-=1,t.refs===0&&this.evictPastCapacity())}}},"lease");return r()}live(e,t){let n=e.seq,r,i=t==="none"?void 0:this.ctx.get("sessionProjections")?.snapshot(e),s=a(()=>{let o=!1;return{source:"live",header:e.header,inheritedEventCount:e.inheritedEventCount,get events(){return r??=e.snapshotEvents(en(0),n),r},cursor:n===0?-1:Yt(n-1),...i===void 0?{}:{projections:i},retain:a(()=>{if(o)throw new Error(`session observation "${e.id}" is disposed`);return s()},"retain"),[Symbol.dispose]:()=>{o=!0}}},"lease");return s()}preparedProjections(e){let t=this.ctx.get("sessionProjections");if(t===void 0)return;let n=this.ctx.get("sessionProjectionCache");return n===void 0?t.hydrate(e.session,{},e.events,en(0)):n.hydratePrepared(e.session,e.events)}};a(bS,"throwIfObservationAborted");a(E1e,"mapPersistenceFailure");a(tz,"notFound");a(nz,"errorMessage");a(_1e,"hasErrorName");a(Ydt,"extractSessionEventText");a(Qdt,"turnEndText");a(YU,"contentText");a(C1e,"blockText");a(wS,"joinText");a(iz,"buildSessionEventSearchDocuments");a(ept,"classifySurface");a(sz,"filterSessionResults");a(NC,"filterSessionEventDocuments");a(oz,"materializeSessionResultFilters");a(DC,"materializeSessionEventResultFilters");a(tpt,"compileSessionTextFilter");a(npt,"sessionPredicate");a(rpt,"eventPredicate");a(OC,"copyStrings");a(R1e,"assertArray");a(T1e,"copyNullableStrings");a($1e,"copyRange");a(MC,"unknownFilter");a(LC,"assertAllowedValues");a(PC,"validateRange");a(rz,"matchesRange");a(QU,"invalidRange");a(x0,"invalidFilter");a(O1e,"isRuntimeArray");a(ipt,"eventRecords");a(spt,"currentSurfaceEvents");a(opt,"traceEvent");a(apt,"traceSession");a(az,"analyzeEventLog");a(I1e,"eventSources");a(lpt,"buildDescendants");a($C,"cloneRecord");P1e=class extends It{static{a(this,"SessionQueryEngine")}static inject=["sessions"];_readWindowMax;_corpus;_observations;constructor(e,t={}){if(super(e,"sessionQuery"),this._readWindowMax=t.readWindowMax??50,!Number.isInteger(this._readWindowMax)||this._readWindowMax<0)throw new Cr("session-query: readWindowMax must be a non-negative integer","SESSION_QUERY_INVALID_CONFIG");let n=t.persistedReadConcurrency??4;if(!Number.isSafeInteger(n)||n<1)throw new Cr("session-query: persistedReadConcurrency must be a positive safe integer","SESSION_QUERY_INVALID_CONFIG");let r=t.preparedSessionCacheSize??5;if(!Number.isSafeInteger(r)||r<1)throw new Cr("session-query: preparedSessionCacheSize must be a positive safe integer","SESSION_QUERY_INVALID_CONFIG");this._corpus=new Kdt(e,n),this._observations=new Xdt(e,r)}observeSession(e,t={}){return this._observations.read(e,t)}listSessions(e){return this._corpus.listSessions(e)}async readSession(e){let t=await this._corpus.load(e);return ym.create(e,t.events,t.header,t.inheritedEventCount),{session:structuredClone(t.header),inheritedEventCount:t.inheritedEventCount,events:t.events.map(wb)}}async filterSessions(e,t){let n=oz(e);return this._filterSessions(n,t)}async readTitle(e,t){return(await this.readTitleSnapshot(e,t)).title}async readTitleSnapshot(e,t){let n=(await this.readTitleSnapshots([e],t))[0];if(n.status==="rejected")throw n.reason;return n.value}async readTitleSnapshots(e,t){return this._corpus.projectMany(e,n=>{let r=Pf(n.events);return{session:structuredClone(n.header),...r===void 0?{}:{title:r}}},t)}async listEvents(e){return ipt(e,(await this._corpus.load(e)).events)}async filterEvents(e,t){let n=DC(t);return this._filterEvents(e,n)}async _filterSessions(e,t){return sz(await this._corpus.listSessions(t),e)}async _filterEvents(e,t){return NC(iz(e,(await this._corpus.load(e)).events),t)}async readSurface(e){let t=await this._corpus.load(e);return{session:structuredClone(t.header),inheritedEventCount:t.inheritedEventCount,capturedThroughSeq:t.events.at(-1)?.seq??null,events:spt(e,t.events)}}async traceSession(e,t){let n=await this._corpus.listSessions(t);return t?.throwIfAborted(),apt(n,e)}async traceEvent(e,t){let n=await this._corpus.load(e.sessionId,t);return t?.throwIfAborted(),{session:n.header,...opt(e.sessionId,n.events,e.seq)}}async readEvent(e,t){let n=this._readWindow("before",e.before),r=this._readWindow("after",e.after),i=e.sessionId,s=e.seq;return this._readEvent(i,s,n,r,t)}async _readEvent(e,t,n,r,i){let s=await this._corpus.load(e,i);i?.throwIfAborted();let o=s.events[t];if(o===void 0||o.seq!==t)throw new Cr(`session "${e}" has no event at seq ${t}`,"SESSION_QUERY_EVENT_NOT_FOUND");let l=Yt(Math.max(0,t-n)),c=Yt(Math.min(s.events.length-1,t+r)),u=wb(o),d=s.events.slice(l,c+1).map(p=>p===o?u:wb(p));return{session:structuredClone(s.header),inheritedEventCount:s.inheritedEventCount,target:u,events:d,startSeq:l,endSeq:c}}_readWindow(e,t){if(t===void 0)return 0;if(!Number.isInteger(t)||t<0||t>this._readWindowMax)throw new Cr(`${e} must be an integer between 0 and ${this._readWindowMax}`,"SESSION_QUERY_INVALID_WINDOW");return t}}});var b0=de((vgn,H1e)=>{"use strict";H1e.exports=og;og.CAPTURING_PHASE=1;og.AT_TARGET=2;og.BUBBLING_PHASE=3;function og(e,t){if(this.type="",this.target=null,this.currentTarget=null,this.eventPhase=og.AT_TARGET,this.bubbles=!1,this.cancelable=!1,this.isTrusted=!1,this.defaultPrevented=!1,this.timeStamp=Date.now(),this._propagationStopped=!1,this._immediatePropagationStopped=!1,this._initialized=!0,this._dispatching=!1,e&&(this.type=e),t)for(var n in t)this[n]=t[n]}a(og,"Event");og.prototype=Object.create(Object.prototype,{constructor:{value:og},stopPropagation:{value:a(function(){this._propagationStopped=!0},"stopPropagation")},stopImmediatePropagation:{value:a(function(){this._propagationStopped=!0,this._immediatePropagationStopped=!0},"stopImmediatePropagation")},preventDefault:{value:a(function(){this.cancelable&&(this.defaultPrevented=!0)},"preventDefault")},initEvent:{value:a(function(t,n,r){this._initialized=!0,!this._dispatching&&(this._propagationStopped=!1,this._immediatePropagationStopped=!1,this.defaultPrevented=!1,this.isTrusted=!1,this.target=null,this.type=t,this.bubbles=n,this.cancelable=r)},"initEvent")}})});var xz=de((bgn,G1e)=>{"use strict";var V1e=b0();G1e.exports=vz;function vz(){V1e.call(this),this.view=null,this.detail=0}a(vz,"UIEvent");vz.prototype=Object.create(V1e.prototype,{constructor:{value:vz},initUIEvent:{value:a(function(e,t,n,r,i){this.initEvent(e,t,n),this.view=r,this.detail=i},"value")}})});var wz=de((Sgn,K1e)=>{"use strict";var Z1e=xz();K1e.exports=bz;function bz(){Z1e.call(this),this.screenX=this.screenY=this.clientX=this.clientY=0,this.ctrlKey=this.altKey=this.shiftKey=this.metaKey=!1,this.button=0,this.buttons=1,this.relatedTarget=null}a(bz,"MouseEvent");bz.prototype=Object.create(Z1e.prototype,{constructor:{value:bz},initMouseEvent:{value:a(function(e,t,n,r,i,s,o,l,c,u,d,p,h,f,g){switch(this.initEvent(e,t,n,r,i),this.screenX=s,this.screenY=o,this.clientX=l,this.clientY=c,this.ctrlKey=u,this.altKey=d,this.shiftKey=p,this.metaKey=h,this.button=f,f){case 0:this.buttons=1;break;case 1:this.buttons=4;break;case 2:this.buttons=2;break;default:this.buttons=0;break}this.relatedTarget=g},"value")},getModifierState:{value:a(function(e){switch(e){case"Alt":return this.altKey;case"Control":return this.ctrlKey;case"Shift":return this.shiftKey;case"Meta":return this.metaKey;default:return!1}},"value")}})});var BC=de((Egn,X1e)=>{"use strict";X1e.exports=zC;var Cpt=1,Rpt=3,$pt=4,Opt=5,Ppt=7,Npt=8,Dpt=9,Mpt=11,Lpt=12,Fpt=13,jpt=14,qpt=15,Upt=17,zpt=18,Bpt=19,Wpt=20,Hpt=21,Vpt=22,Gpt=23,Zpt=24,Kpt=25,Jpt=[null,"INDEX_SIZE_ERR",null,"HIERARCHY_REQUEST_ERR","WRONG_DOCUMENT_ERR","INVALID_CHARACTER_ERR",null,"NO_MODIFICATION_ALLOWED_ERR","NOT_FOUND_ERR","NOT_SUPPORTED_ERR","INUSE_ATTRIBUTE_ERR","INVALID_STATE_ERR","SYNTAX_ERR","INVALID_MODIFICATION_ERR","NAMESPACE_ERR","INVALID_ACCESS_ERR",null,"TYPE_MISMATCH_ERR","SECURITY_ERR","NETWORK_ERR","ABORT_ERR","URL_MISMATCH_ERR","QUOTA_EXCEEDED_ERR","TIMEOUT_ERR","INVALID_NODE_TYPE_ERR","DATA_CLONE_ERR"],Xpt=[null,"INDEX_SIZE_ERR (1): the index is not in the allowed range",null,"HIERARCHY_REQUEST_ERR (3): the operation would yield an incorrect nodes model","WRONG_DOCUMENT_ERR (4): the object is in the wrong Document, a call to importNode is required","INVALID_CHARACTER_ERR (5): the string contains invalid characters",null,"NO_MODIFICATION_ALLOWED_ERR (7): the object can not be modified","NOT_FOUND_ERR (8): the object can not be found here","NOT_SUPPORTED_ERR (9): this operation is not supported","INUSE_ATTRIBUTE_ERR (10): setAttributeNode called on owned Attribute","INVALID_STATE_ERR (11): the object is in an invalid state","SYNTAX_ERR (12): the string did not match the expected pattern","INVALID_MODIFICATION_ERR (13): the object can not be modified in this way","NAMESPACE_ERR (14): the operation is not allowed by Namespaces in XML","INVALID_ACCESS_ERR (15): the object does not support the operation or argument",null,"TYPE_MISMATCH_ERR (17): the type of the object does not match the expected type","SECURITY_ERR (18): the operation is insecure","NETWORK_ERR (19): a network error occurred","ABORT_ERR (20): the user aborted an operation","URL_MISMATCH_ERR (21): the given URL does not match another URL","QUOTA_EXCEEDED_ERR (22): the quota has been exceeded","TIMEOUT_ERR (23): a timeout occurred","INVALID_NODE_TYPE_ERR (24): the supplied node is invalid or has an invalid ancestor for this operation","DATA_CLONE_ERR (25): the object can not be cloned."],J1e={INDEX_SIZE_ERR:Cpt,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:Rpt,WRONG_DOCUMENT_ERR:$pt,INVALID_CHARACTER_ERR:Opt,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:Ppt,NOT_FOUND_ERR:Npt,NOT_SUPPORTED_ERR:Dpt,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:Mpt,SYNTAX_ERR:Lpt,INVALID_MODIFICATION_ERR:Fpt,NAMESPACE_ERR:jpt,INVALID_ACCESS_ERR:qpt,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:Upt,SECURITY_ERR:zpt,NETWORK_ERR:Bpt,ABORT_ERR:Wpt,URL_MISMATCH_ERR:Hpt,QUOTA_EXCEEDED_ERR:Vpt,TIMEOUT_ERR:Gpt,INVALID_NODE_TYPE_ERR:Zpt,DATA_CLONE_ERR:Kpt};function zC(e){Error.call(this),Error.captureStackTrace(this,this.constructor),this.code=e,this.message=Xpt[e],this.name=Jpt[e]}a(zC,"DOMException");zC.prototype.__proto__=Error.prototype;for(UC in J1e)Sz={value:J1e[UC]},Object.defineProperty(zC,UC,Sz),Object.defineProperty(zC.prototype,UC,Sz);var Sz,UC});var WC=de(Y1e=>{Y1e.isApiWritable=!globalThis.__domino_frozen__});var Cs=de(ai=>{"use strict";var As=BC(),Vs=As,Ypt=WC().isApiWritable;ai.NAMESPACE={HTML:"http://www.w3.org/1999/xhtml",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/",MATHML:"http://www.w3.org/1998/Math/MathML",SVG:"http://www.w3.org/2000/svg",XLINK:"http://www.w3.org/1999/xlink"};ai.IndexSizeError=function(){throw new As(Vs.INDEX_SIZE_ERR)};ai.HierarchyRequestError=function(){throw new As(Vs.HIERARCHY_REQUEST_ERR)};ai.WrongDocumentError=function(){throw new As(Vs.WRONG_DOCUMENT_ERR)};ai.InvalidCharacterError=function(){throw new As(Vs.INVALID_CHARACTER_ERR)};ai.NoModificationAllowedError=function(){throw new As(Vs.NO_MODIFICATION_ALLOWED_ERR)};ai.NotFoundError=function(){throw new As(Vs.NOT_FOUND_ERR)};ai.NotSupportedError=function(){throw new As(Vs.NOT_SUPPORTED_ERR)};ai.InvalidStateError=function(){throw new As(Vs.INVALID_STATE_ERR)};ai.SyntaxError=function(){throw new As(Vs.SYNTAX_ERR)};ai.InvalidModificationError=function(){throw new As(Vs.INVALID_MODIFICATION_ERR)};ai.NamespaceError=function(){throw new As(Vs.NAMESPACE_ERR)};ai.InvalidAccessError=function(){throw new As(Vs.INVALID_ACCESS_ERR)};ai.TypeMismatchError=function(){throw new As(Vs.TYPE_MISMATCH_ERR)};ai.SecurityError=function(){throw new As(Vs.SECURITY_ERR)};ai.NetworkError=function(){throw new As(Vs.NETWORK_ERR)};ai.AbortError=function(){throw new As(Vs.ABORT_ERR)};ai.UrlMismatchError=function(){throw new As(Vs.URL_MISMATCH_ERR)};ai.QuotaExceededError=function(){throw new As(Vs.QUOTA_EXCEEDED_ERR)};ai.TimeoutError=function(){throw new As(Vs.TIMEOUT_ERR)};ai.InvalidNodeTypeError=function(){throw new As(Vs.INVALID_NODE_TYPE_ERR)};ai.DataCloneError=function(){throw new As(Vs.DATA_CLONE_ERR)};ai.nyi=function(){throw new Error("NotYetImplemented")};ai.shouldOverride=function(){throw new Error("Abstract function; should be overriding in subclass.")};ai.assert=function(e,t){if(!e)throw new Error("Assertion failed: "+(t||"")+`
155
155
  `+new Error().stack)};ai.expose=function(e,t){for(var n in e)Object.defineProperty(t.prototype,n,{value:e[n],writable:Ypt})};ai.merge=function(e,t){for(var n in t)e[n]=t[n]};ai.documentOrder=function(e,t){return 3-(e.compareDocumentPosition(t)&6)};ai.toASCIILowerCase=function(e){return e.replace(/[A-Z]+/g,function(t){return t.toLowerCase()})};ai.toASCIIUpperCase=function(e){return e.replace(/[a-z]+/g,function(t){return t.toUpperCase()})}});var kz=de((Agn,eye)=>{"use strict";var ag=b0(),Qpt=wz(),eft=Cs();eye.exports=Q1e;function Q1e(){}a(Q1e,"EventTarget");Q1e.prototype={addEventListener:a(function(t,n,r){if(n){r===void 0&&(r=!1),this._listeners||(this._listeners=Object.create(null)),this._listeners[t]||(this._listeners[t]=[]);for(var i=this._listeners[t],s=0,o=i.length;s<o;s++){var l=i[s];if(l.listener===n&&l.capture===r)return}var c={listener:n,capture:r};typeof n=="function"&&(c.f=n),i.push(c)}},"addEventListener"),removeEventListener:a(function(t,n,r){if(r===void 0&&(r=!1),this._listeners){var i=this._listeners[t];if(i)for(var s=0,o=i.length;s<o;s++){var l=i[s];if(l.listener===n&&l.capture===r){i.length===1?this._listeners[t]=void 0:i.splice(s,1);return}}}},"removeEventListener"),dispatchEvent:a(function(t){return this._dispatchEvent(t,!1)},"dispatchEvent"),_dispatchEvent:a(function(t,n){typeof n!="boolean"&&(n=!1);function r(u,d){var p=d.type,h=d.eventPhase;if(d.currentTarget=u,h!==ag.CAPTURING_PHASE&&u._handlers&&u._handlers[p]){var f=u._handlers[p],g;if(typeof f=="function")g=f.call(d.currentTarget,d);else{var y=f.handleEvent;if(typeof y!="function")throw new TypeError("handleEvent property of event handler object isnot a function.");g=y.call(f,d)}d.type==="mouseover"?g===!0&&d.preventDefault():g===!1&&d.preventDefault()}var v=u._listeners&&u._listeners[p];if(v){v=v.slice();for(var w=0,b=v.length;w<b;w++){if(d._immediatePropagationStopped)return;var S=v[w];if(!(h===ag.CAPTURING_PHASE&&!S.capture||h===ag.BUBBLING_PHASE&&S.capture))if(S.f)S.f.call(d.currentTarget,d);else{var k=S.listener.handleEvent;if(typeof k!="function")throw new TypeError("handleEvent property of event listener object is not a function.");k.call(S.listener,d)}}}}a(r,"invoke"),(!t._initialized||t._dispatching)&&eft.InvalidStateError(),t.isTrusted=n,t._dispatching=!0,t.target=this;for(var i=[],s=this.parentNode;s;s=s.parentNode)i.push(s);t.eventPhase=ag.CAPTURING_PHASE;for(var o=i.length-1;o>=0&&(r(i[o],t),!t._propagationStopped);o--);if(t._propagationStopped||(t.eventPhase=ag.AT_TARGET,r(this,t)),t.bubbles&&!t._propagationStopped){t.eventPhase=ag.BUBBLING_PHASE;for(var l=0,c=i.length;l<c&&(r(i[l],t),!t._propagationStopped);l++);}if(t._dispatching=!1,t.eventPhase=ag.AT_TARGET,t.currentTarget=null,n&&!t.defaultPrevented&&t instanceof Qpt)switch(t.type){case"mousedown":this._armed={x:t.clientX,y:t.clientY,t:t.timeStamp};break;case"mouseout":case"mouseover":this._armed=null;break;case"mouseup":this._isClick(t)&&this._doClick(t),this._armed=null;break}return!t.defaultPrevented},"_dispatchEvent"),_isClick:a(function(e){return this._armed!==null&&e.type==="mouseup"&&e.isTrusted&&e.button===0&&e.timeStamp-this._armed.t<1e3&&Math.abs(e.clientX-this._armed.x)<10&&Math.abs(e.clientY-this._armed.Y)<10},"_isClick"),_doClick:a(function(e){if(!this._click_in_progress){this._click_in_progress=!0;for(var t=this;t&&!t._post_click_activation_steps;)t=t.parentNode;t&&t._pre_click_activation_steps&&t._pre_click_activation_steps();var n=this.ownerDocument.createEvent("MouseEvent");n.initMouseEvent("click",!0,!0,this.ownerDocument.defaultView,1,e.screenX,e.screenY,e.clientX,e.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,null);var r=this._dispatchEvent(n,!0);t&&(r?t._post_click_activation_steps&&t._post_click_activation_steps(n):t._cancelled_activation_steps&&t._cancelled_activation_steps())}},"_doClick"),_setEventHandler:a(function(t,n){this._handlers||(this._handlers=Object.create(null)),this._handlers[t]=n},"_setEventHandler"),_getEventHandler:a(function(t){return this._handlers&&this._handlers[t]||null},"_getEventHandler")}});var Ez=de((Rgn,tye)=>{"use strict";var _p=Cs(),kc=tye.exports={valid:a(function(e){return _p.assert(e,"list falsy"),_p.assert(e._previousSibling,"previous falsy"),_p.assert(e._nextSibling,"next falsy"),!0},"valid"),insertBefore:a(function(e,t){_p.assert(kc.valid(e)&&kc.valid(t));var n=e,r=e._previousSibling,i=t,s=t._previousSibling;n._previousSibling=s,r._nextSibling=i,s._nextSibling=n,i._previousSibling=r,_p.assert(kc.valid(e)&&kc.valid(t))},"insertBefore"),replace:a(function(e,t){_p.assert(kc.valid(e)&&(t===null||kc.valid(t))),t!==null&&kc.insertBefore(t,e),kc.remove(e),_p.assert(kc.valid(e)&&(t===null||kc.valid(t)))},"replace"),remove:a(function(e){_p.assert(kc.valid(e));var t=e._previousSibling;if(t!==e){var n=e._nextSibling;t._nextSibling=n,n._previousSibling=t,e._previousSibling=e._nextSibling=e,_p.assert(kc.valid(e))}},"remove")}});var _z=de((Ogn,cye)=>{"use strict";cye.exports={serializeOne:aft,\u0275escapeMatchingClosingTag:oye,\u0275escapeClosingCommentTag:aye,\u0275escapeProcessingInstructionContent:lye};var sye=Cs(),lg=sye.NAMESPACE,nye={STYLE:!0,SCRIPT:!0,XMP:!0,IFRAME:!0,NOEMBED:!0,NOFRAMES:!0,PLAINTEXT:!0},tft={area:!0,base:!0,basefont:!0,bgsound:!0,br:!0,col:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},nft={},rye=/[&<>\u00A0]/g,iye=/[&"<>\u00A0]/g;function rft(e){return rye.test(e)?e.replace(rye,t=>{switch(t){case"&":return"&amp;";case"<":return"&lt;";case">":return"&gt;";case"\xA0":return"&nbsp;"}}):e}a(rft,"escape");function ift(e){return iye.test(e)?e.replace(iye,t=>{switch(t){case"<":return"&lt;";case">":return"&gt;";case"&":return"&amp;";case'"':return"&quot;";case"\xA0":return"&nbsp;"}}):e}a(ift,"escapeAttr");function sft(e){var t=e.namespaceURI;return t?t===lg.XML?"xml:"+e.localName:t===lg.XLINK?"xlink:"+e.localName:t===lg.XMLNS?e.localName==="xmlns"?"xmlns":"xmlns:"+e.localName:e.name:e.localName}a(sft,"attrname");function oye(e,t){let n="</"+t;if(!e.toLowerCase().includes(n))return e;let r=[...e],i=e.matchAll(new RegExp(n,"ig"));for(let s of i)r[s.index]="&lt;";return r.join("")}a(oye,"escapeMatchingClosingTag");var oft=/--!?>/;function aye(e){return oft.test(e)?e.replace(/(--\!?)>/g,"$1&gt;"):e}a(aye,"escapeClosingCommentTag");function lye(e){return e.includes(">")?e.replaceAll(">","&gt;"):e}a(lye,"escapeProcessingInstructionContent");function aft(e,t){var n="";switch(e.nodeType){case 1:var r=e.namespaceURI,i=r===lg.HTML,s=i||r===lg.SVG||r===lg.MATHML?e.localName:e.tagName;n+="<"+s;for(var o=0,l=e._numattrs;o<l;o++){var c=e._attr(o);n+=" "+sft(c),c.value!==void 0&&(n+='="'+ift(c.value)+'"')}if(n+=">",!(i&&tft[s])){var u=e.serialize();nye[s.toUpperCase()]&&(u=oye(u,s)),i&&nft[s]&&u.charAt(0)===`
@@ -4993,7 +4993,7 @@ The web search request used endpoint ${JSON.stringify(e)}. Search endpoint confi
4993
4993
  button, .button { display: inline-block; box-sizing: border-box; margin-top: 1rem; padding: .75rem 1rem; border: 0; border-radius: .6rem; background: #5a87ff; color: #071022; font: inherit; font-weight: 750; text-decoration: none; cursor: pointer; }
4994
4994
  .secondary { background: #29314b; color: #edf2ff; }
4995
4995
  .error { padding: .75rem; border-radius: .5rem; background: #461d2b; color: #ffd6df; }
4996
- `}a(pTe,"pageStyles");fA();var DG="enabled",MG=Object.freeze({id:"direct",capabilities:Object.freeze(["bash"]),plan:"free",shell:"just-bash-direct",probe:a(e=>e.LOADER===void 0?"available":"needs-binding","probe")}),Rk=Object.freeze({id:"dynamic-worker",capabilities:Object.freeze(["bash","coding"]),plan:"paid",shell:"just-bash-isolated",probe:a(e=>e.LOADER===void 0?"needs-binding":"available","probe")}),LG=Object.freeze({id:"container",capabilities:Object.freeze(["container"]),plan:"paid",shell:"linux-container",probe:a(e=>e.DSH_EDGE_CONTAINER_RUNTIME===DG?"available":"needs-binding","probe")}),B6t=Object.freeze([LG,Rk,MG]);function FG(e,t=B6t){return t.filter(n=>n.probe(e)==="available")}a(FG,"availableEdgeRuntimeProviders");function jG(e){let t=a(r=>e.find(i=>i.capabilities.includes(r)),"first"),n=t("bash");if(n===void 0)throw new Error("No available runtime provider serves the bash layer.");return{bash:n.id,container:t("container")?.id??null}}a(jG,"resolveEdgeRuntimeSelection");function h$(e){let t=FG(e),{bash:n,container:r}=jG(t);return t.find(i=>i.id===(r??n)).shell}a(h$,"resolveEdgeRuntimeShell");function W6t(){return"dsh-edge@0.18.0-alpha.4/direct"}a(W6t,"resolveEdgeDeploymentId");function $k(e){return{baseURL:pz(e.DEEPSEEK_BASE_URL),maxTokens:mz(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:rg(e.DEEPSEEK_MODEL),reasoningEffort:fz(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:A6(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:hz(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:Eh(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}a($k,"resolveEdgeDeploymentConfig");function H6t(e){return typeof e.DEEPSEEK_API_KEY=="string"&&e.DEEPSEEK_API_KEY.trim().length>0}a(H6t,"edgeDeploymentApiKeyConfigured");function V6t(e){let t=pz(e),n=new URL(t);return n.search.length===0&&n.hash.length===0?t:(n.search="",n.hash="",n.href)}a(V6t,"projectedEdgeBaseURL");function qG(e,t){return{shell:h$(e),storage:"durable-object-sqlite-vfs",attachmentStorage:t??(e.DSH_EDGE_ATTACHMENTS===void 0?"temporary-do":"private-r2"),deploymentId:W6t(),apiKeyConfigured:H6t(e),baseURL:V6t(e.DEEPSEEK_BASE_URL),maxTokens:mz(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:rg(e.DEEPSEEK_MODEL),reasoningEffort:fz(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:A6(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:hz(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:Eh(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}a(qG,"resolveEdgeDeploymentProfile");function m$(e){$k(e);let t=qG(e);return{ok:!0,service:"dsh-edge",storage:t.storage,attachmentStorage:t.attachmentStorage,shell:t.shell,agent:"upstream-react-loop-agent",access:"single-owner-cookie",deploymentId:t.deploymentId,...e.CF_VERSION_METADATA===void 0?{}:{workerVersionId:e.CF_VERSION_METADATA.id},version:Qy,upstreamVersion:Vpe,status:"ready"}}a(m$,"resolveEdgeDeploymentHealth");import{AsyncLocalStorage as lzt}from"node:async_hooks";import{RpcTarget as G6t}from"cloudflare:workers";function Z6t(e){let{intervalMs:t,ping:n,onFailure:r}=e,i=!1,s=setInterval(()=>{i||n().catch(o=>{i||(i=!0,clearInterval(s),r(o instanceof Error?o:new Error(String(o))))})},t);return()=>{i||(i=!0,clearInterval(s))}}a(Z6t,"startHeartbeat");async function K6t(e,t){let n=AbortSignal.timeout(t.timeoutMs),r=await e.fetchPort(t.port,`http://container${t.path}`,{method:"HEAD",signal:n});if(r.body?.cancel(),!r.ok)throw new Error(`computerd health returned ${r.status}`)}a(K6t,"probeComputerdHealth");var J6t="computer.internal",X6t="/health",UG="/api",Y6t=8080,Q6t=3e4,eRt=2e4,tRt=1,nRt=2e3,rRt=250,iRt=2e3;function sRt(e,t){if(t===void 0||e===null)return!1;let n=e.indexOf(" ");if(n===-1||e.slice(0,n).toLowerCase()!=="bearer")return!1;let r=e.slice(n+1).trim();if(r.length!==t.length)return!1;let i=0;for(let s=0;s<t.length;s+=1)i|=r.charCodeAt(s)^t.charCodeAt(s);return i===0}a(sRt,"bearerMatches");var y$=class{static{a(this,"CloudflareContainerBackend")}type="cloudflare-container";id;#e;#t;#r;#n;#i;#s;#a;#l;constructor(e){this.id=e.id??"container-shell",this.#t=e.egress??{mode:"none"},this.#r=this.#t.mode==="http-gateway"?crypto.randomUUID():void 0,this.#e={container:e.container,workspace:e.workspace,containerEnv:e.containerEnv,egressHost:e.egressHost??J6t,containerPort:e.containerPort??Y6t,connectTimeoutMs:e.connectTimeoutMs??Q6t,heartbeatIntervalMs:e.heartbeatIntervalMs??eRt,restartAttempts:e.restartAttempts??tRt,healthProbeTimeoutMs:e.healthProbeTimeoutMs??nRt,healthRetryInitialDelayMs:e.healthRetryInitialDelayMs??rRt,healthRetryMaxDelayMs:e.healthRetryMaxDelayMs??iRt}}async connect(){if(this.#l)return this.#l;let e=Date.now()+this.#e.connectTimeoutMs,t=await(await this.#e.container()).getWorkspaceContainer(),n=await t.exitInfo().catch(()=>null),r={PORT:String(this.#e.containerPort),MOUNT_POINT:"/workspace",...this.#e.containerEnv},i,s;try{({runtimeId:i,clientSecret:s}=await t.start({env:r,enableInternet:this.#t.mode==="direct"}))}catch(p){throw new Ra(this.#d("start",{attempt:1,maxAttempts:this.#e.restartAttempts+1,restarts:0,lastError:p,priorExit:n}),{cause:p})}try{await t.interceptOutboundHttp(this.#e.egressHost,this.#e.workspace),this.#t.mode==="http-gateway"&&this.#r!==void 0&&await t.interceptAllOutboundHttp(this.#e.workspace,this.#r)}catch(p){throw new Ra(this.#d("egress",{attempt:1,maxAttempts:this.#e.restartAttempts+1,restarts:0,lastError:p,priorExit:n}),{cause:p})}this.#n=s,this.#u(),i=await this.#p(t,r,e,n,i),await this.#f(t,e),await this.#v(t,e,s);let o=await this.#h(e),l=H4(o),c,u=new Promise(p=>{let h=!1,f=a(()=>{h||(h=!0,c?.(),p(),this.#l=void 0)},"onClose");o.addEventListener("close",f,{once:!0}),o.addEventListener("error",f,{once:!0}),l.onRpcBroken(f)});this.#e.heartbeatIntervalMs>0&&(c=Z6t({intervalMs:this.#e.heartbeatIntervalMs,ping:a(()=>l.sync.watermarks(),"ping"),onFailure:a(()=>{try{o.close()}catch{}},"onFailure")}));let d={rpc:l,runtimeId:i,closed:u,close:a(async()=>{c?.();try{l[Symbol.dispose]?.()}catch{}try{o.close()}catch{}this.#l=void 0},"close")};return this.#l=d,d}async handleFetch(e){if(this.#t.mode==="http-gateway"&&this.#r!==void 0&&e.headers.get("x-workspace-egress-token")===this.#r){let i=new Headers(e.headers),s=i.get(ix),o;try{o=new URL(s??"")}catch{return new Response("invalid egress URL",{status:400})}if(o.protocol!=="http:"&&o.protocol!=="https:")return new Response("invalid egress URL",{status:400});i.delete(VE),i.delete(ix);let l=new Request(e,{headers:i});return this.#t.gateway.fetch(new Request(o,l))}if(new URL(e.url).pathname!==UG)return new Response("not found",{status:404});if(e.headers.get("upgrade")!=="websocket")return new Response(`${UG} requires a websocket upgrade`,{status:400});if(!sRt(e.headers.get("authorization"),this.#n))return new Response("unauthorized",{status:401,headers:{"www-authenticate":"Bearer"}});let t=new WebSocketPair,[n,r]=[t[0],t[1]];if(r.accept(),this.#s)this.#s(r);else return r.close(1011,"no pending connect"),new Response("no pending connect",{status:409});return new Response(null,{status:101,webSocket:n})}#u(){this.#i=new Promise((e,t)=>{this.#s=e,this.#a=t}),this.#i.catch(()=>{})}#o(){this.#i=void 0,this.#s=void 0,this.#a=void 0}async#p(e,t,n,r,i){let s=this.#e.restartAttempts+1,o=Math.max(0,n-Date.now()),l=Math.max(250,Math.floor(o/s)),c=0,u=0,d,p=i;for(;c<s;){c++;let h=Math.min(n,Date.now()+l);if(await this.#m(e,h).then(()=>!0,f=>(d=f,!1)))return p;if(c<s)try{({runtimeId:p}=await e.restart({env:t,enableInternet:this.#t.mode==="direct"})),u++}catch(f){throw this.#a?.(f),this.#o(),new Ra(this.#d("restart",{attempt:c,maxAttempts:s,restarts:u,lastError:f}),{cause:f})}}throw this.#a?.(new Error("computerd never became healthy")),this.#o(),new Ra(this.#d("health",{attempt:c,maxAttempts:s,restarts:u,lastError:d,priorExit:r}),d instanceof Error?{cause:d}:void 0)}async#m(e,t){let n=this.#e.healthRetryInitialDelayMs,r;for(;Date.now()<t;)try{await K6t(e,{port:this.#e.containerPort,path:"/health",timeoutMs:Math.min(this.#e.healthProbeTimeoutMs,Math.max(50,t-Date.now()))});return}catch(i){r=i;let s=t-Date.now();if(s<=0)break;await oRt(Math.min(n,s)),n=Math.min(n*2,this.#e.healthRetryMaxDelayMs)}throw r??new Error("computerd health probe timed out")}#d(e,t){let n=t.priorExit?` priorExit=${JSON.stringify(t.priorExit.reason)}`:"";return`CloudflareContainerBackend(${this.id}): connect failed at stage=${e} port=${this.#e.containerPort} attempt=${t.attempt}/${t.maxAttempts} restarts=${t.restarts} timeoutMs=${this.#e.connectTimeoutMs}${n} lastError=${fTe(t.lastError)}`}async#f(e,t){let n;try{let r=await e.fetchPort(this.#e.containerPort,"http://container/api",{signal:AbortSignal.timeout(Math.min(this.#e.healthProbeTimeoutMs,Math.max(50,t-Date.now())))});n=r.status,await r.text().catch(()=>"")}catch{return}if(n!==401)throw this.#a?.(new Error("container is not enforcing RPC_CLIENT_SECRET")),this.#o(),new Ra(`CloudflareContainerBackend(${this.id}) [stage=auth]: container served an unauthenticated request to /api with ${n}, so this workspace would run without authorization. A container or image predating RPC_CLIENT_SECRET has to be recycled.`)}async#v(e,t,n){let r=Math.max(0,t-Date.now()),i;try{i=await e.fetchPort(this.#e.containerPort,"http://container/connect",{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${n}`},body:JSON.stringify({base:`http://${this.#e.egressHost}`,health:X6t,api:UG,healthTimeoutMs:r})})}catch(s){throw this.#a?.(s),this.#o(),new Ra(`CloudflareContainerBackend(${this.id}) [stage=connect]: POST /connect failed: ${fTe(s)}`,{cause:s})}if(!i.ok){let s=await i.text().catch(()=>""),o=new Error(`/connect ${i.status}`);throw this.#a?.(o),this.#o(),new Ra(`CloudflareContainerBackend(${this.id}) [stage=connect]: POST /connect returned ${i.status}: ${s}`,{cause:o})}}async#h(e){let t=this.#i;if(!t)throw new Error("CloudflareContainerBackend: upgrade promise missing");let n=Math.max(0,e-Date.now()),r;try{return await Promise.race([t,new Promise((i,s)=>{r=setTimeout(()=>s(new Ra(`CloudflareContainerBackend(${this.id}) [stage=ws]: /api upgrade did not arrive within ${this.#e.connectTimeoutMs}ms`)),n)})])}finally{r&&clearTimeout(r),this.#o()}}};function oRt(e){return new Promise(t=>setTimeout(t,e))}a(oRt,"sleep");function fTe(e){return e instanceof Error?e.message:String(e)}a(fTe,"describeError");var hTe="computer:container-client-secret",aRt=16;function lRt(){let e=crypto.getRandomValues(new Uint8Array(aRt));return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}a(lRt,"generate");var cRt=class{static{a(this,"ContainerClientSecret")}storage;constructor(e){this.storage=e}async ensure(){let e=await this.storage.get(hTe);if(typeof e=="string"&&e.length>0)return e;let t=lRt();return await this.storage.put(hTe,t),t}},mTe="computer:container-launch-record";async function gTe(e){return{enableInternet:e.enableInternet,envDigest:await dRt(e.env)}}a(gTe,"launchRecordFor");function uRt(e,t){return e.enableInternet===t.enableInternet&&e.envDigest===t.envDigest}a(uRt,"sameLaunch");async function dRt(e){let t=Object.keys(e).sort().map(r=>`${r.length}:${r}=${e[r]?.length??0}:${e[r]??""}`).join(";"),n=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(n),r=>r.toString(16).padStart(2,"0")).join("")}a(dRt,"digestEnv");var pRt=class{static{a(this,"CurrentContainerLaunchRecord")}storage;constructor(e){this.storage=e}async get(){return await this.storage.get(mTe)??null}async set(e){await this.storage.put(mTe,e)}},yTe=new WeakMap;function WG(e){let t=yTe.get(e);return t===void 0&&(t={exit:null,currentGeneration:0,expectedExitGeneration:null,currentMonitorSettled:null},yTe.set(e,t)),t}a(WG,"getContainerLifecycle");function g$(e){return WG(e).exit}a(g$,"containerExitInfo");function vTe(e){return e===void 0?"exited normally":e instanceof Error?e.message:String(e)}a(vTe,"formatExitReason");function xTe(e,t,n){let r=WG(e);r.currentGeneration+=1;let i=r.currentGeneration;r.exit=null,r.currentMonitorSettled=t.monitor().then(()=>bTe(r,i,void 0,n),s=>bTe(r,i,s,n))}a(xTe,"installContainerMonitor");async function zG(e,t){let n=WG(e);n.expectedExitGeneration=n.currentGeneration;let r=n.currentMonitorSettled;await t.destroy(),r&&await r}a(zG,"destroyContainerExpectingExit");async function bTe(e,t,n,r){if(t!==e.currentGeneration)return;let i=e.expectedExitGeneration===t;i&&(e.expectedExitGeneration=null);let s=vTe(n),o=Date.now();e.exit={reason:s,exitedAt:o},i?console.info({message:"workspace.container.exited",reason:s,exitedAt:o,expected:!0}):console.warn({message:"workspace.container.exited",reason:s,exitedAt:o,expected:!1});try{await r?.()}catch(l){console.error({message:"workspace.container.exit_cleanup_failed",reason:vTe(l),exitedAt:Date.now()})}}a(bTe,"recordExit");var BG="computer:container-runtime-identity",fRt=class{static{a(this,"CurrentContainerRuntimeIdentity")}storage;constructor(e){this.storage=e}async get(){return await this.storage.get(BG)??null}async markStarted(){let e={id:crypto.randomUUID()};return await this.storage.put(BG,e),e}async clear(e){(await this.get())?.id===e.id&&await this.storage.delete(BG)}},hRt=class extends G6t{static{a(this,"WorkspaceContainerAPI")}#e;#t;#r;#n;#i;constructor(e){if(super(),!e.container)throw new Error("WorkspaceContainerAPI: DO is not container-enabled (check wrangler.jsonc)");this.#e=e.container,this.#t=e,this.#r=new fRt(e.storage),this.#n=new cRt(e.storage),this.#i=new pRt(e.storage)}async start(e){let t=g$(this.#t),n=await this.#n.ensure(),r=await gTe(e);if(t!==null){try{await zG(this.#t,this.#e)}catch{}return this.#s(e,n,r,"launched")}if(!this.#e.running)return this.#s(e,n,r,"launched");let i=await this.#i.get();if(i===null||!uRt(i,r)){console.warn({message:i===null?"container was started outside WorkspaceContainerAPI; relaunching so the requested environment applies":"running container was launched with a different spec; relaunching",component:"workspace-container",requested:r,actual:i});try{await zG(this.#t,this.#e)}catch{}return this.#s(e,n,r,"relaunched")}let s=await this.#r.get()??await this.#r.markStarted();return xTe(this.#t,this.#e,()=>this.#r.clear(s)),{runtimeId:s.id,clientSecret:n,outcome:"adopted"}}async restart(e){try{await zG(this.#t,this.#e)}catch{}let t=await this.#n.ensure();return this.#s(e,t,await gTe(e),"launched")}async setInactivityTimeout(e){await this.#e.setInactivityTimeout(e)}async#s(e,t,n,r){let i=await this.#r.markStarted();try{this.#e.start({enableInternet:e.enableInternet,env:{...e.env,RPC_CLIENT_SECRET:t}})}catch(s){throw await this.#r.clear(i),s}return await this.#i.set(n),xTe(this.#t,this.#e,()=>this.#r.clear(i)),{runtimeId:i.id,clientSecret:t,outcome:r}}async status(){return{running:this.#e.running,exit:g$(this.#t)}}async exitInfo(){return g$(this.#t)}async interceptAllOutboundHttp(e,t){let n=this.#t.exports.WorkspaceProxy({props:{...e,egressToken:t}});await Promise.all([this.#e.interceptAllOutboundHttp(n),this.#e.interceptOutboundHttps("*",n)])}async interceptOutboundHttp(e,t){let n=this.#t.exports;await this.#e.interceptOutboundHttp(e,n.WorkspaceProxy({props:t}))}fetchPort(e,t,n){let r=g$(this.#t);if(r!==null)throw new Ra(`container exited: ${r.reason}`);return this.#e.getTcpPort(e).fetch(t,n)}port(e){return this.#e.getTcpPort(e)}};function wTe(e){class t extends e{static{a(this,"WithWorkspaceContainer")}getWorkspaceContainer(){return new hRt(this.ctx)}}return t}a(wTe,"withWorkspaceContainer");var mRt={session:"sessions",skill:"skills",agentPreset:"agentPresets",subagent:"subagents",goal:"goals",event:"events",download:"downloads"};function kTe(e,t){let n=t.indexOf("."),r=t.indexOf("/"),i=n>=0?n:r;if(i<0)return;let s=t.slice(0,i),o=t.slice(i+1),l=mRt[s]??s,c=e[l];if(c===void 0)return;let u=c[o];return typeof u=="function"?u:void 0}a(kTe,"resolve");function gRt(e,t){return Response.json({type:"server-response",rpcId:e,result:{ok:!1,error:t}})}a(gRt,"errorResponse");async function HG(e,t,n,r,i){let s=kTe(e,t);if(s!==void 0)return await s({rpcId:n,payload:r},i)}a(HG,"callEdgeApi");async function ETe(e,t){let r=new URL(t.url).pathname;if(t.method!=="POST"||!r.startsWith("/api/"))return new Response("not found",{status:404});if(r==="/api/respond")return Response.json({accepted:!1,reason:"not-pending"});let i=r.slice(5);if(kTe(e,i)===void 0)return new Response("not found",{status:404});let s;try{s=await t.json()}catch{return new Response("body is not JSON",{status:400})}let o=typeof s.rpcId=="string"?s.rpcId:"invalid-request",l=s.payload??{};try{let c=await HG(e,i,o,l,t.signal);return c===void 0?new Response("not found",{status:404}):Response.json({type:"server-response",rpcId:c.rpcId,result:c.result})}catch(c){return gRt(o,{code:"internal",message:String(c),details:{}})}}a(ETe,"dispatchEdgeApi");Ir();ws();Nf();import{DurableObject as czt}from"cloudflare:workers";var v$=class{constructor(t,n=Date.now,r=2){this.sleepAfterMs=t;this.now=n;this.maxConcurrent=r}sleepAfterMs;now;maxConcurrent;static{a(this,"ContainerActivity")}inFlight=0;lastActivity;stopping;waiters=[];async admit(t){let n=this.now();for(;this.stopping!==void 0||this.inFlight>=this.maxConcurrent;){if(t?.throwIfAborted(),this.stopping!==void 0){await yRt(this.stopping,t);continue}await new Promise((r,i)=>{let s=a(()=>{t?.removeEventListener("abort",o),r()},"wake"),o=a(()=>{let l=this.waiters.indexOf(s);l!==-1&&this.waiters.splice(l,1),i(t.reason)},"abort");this.waiters.push(s),t?.addEventListener("abort",o,{once:!0})})}return t?.aborted===!0&&(this.waiters.shift()?.(),t.throwIfAborted()),{release:this.begin(),queuedMs:this.now()-n}}begin(){this.inFlight+=1,this.lastActivity=this.now();let t=!1;return()=>{t||(t=!0,this.inFlight-=1,this.lastActivity=this.now(),this.waiters.shift()?.())}}async stopIfIdle(t){return this.idle()?await this.stop(t):"busy"}async stopNow(t){return this.inFlight===0?await this.stop(t):"busy"}snapshot(){return{runningCommands:this.inFlight,lastActivityAt:this.lastActivity??null}}async stop(t){if(this.stopping!==void 0)return"busy";let n="stopped",r=t().catch(i=>{n="failed",this.lastActivity=this.now(),console.error("dsh-edge container stop failed.",i)});this.stopping=r;try{await r}finally{this.stopping=void 0}return n}deadline(){return this.inFlight>0?this.now()+this.sleepAfterMs():this.lastActivity===void 0?this.now():this.lastActivity+this.sleepAfterMs()}idle(){return this.inFlight===0&&(this.lastActivity===void 0||this.now()>=this.lastActivity+this.sleepAfterMs())}};function yRt(e,t){return t===void 0?e:new Promise((n,r)=>{let i=a(()=>r(t.reason),"abort");t.addEventListener("abort",i,{once:!0}),e.then(n,r).finally(()=>t.removeEventListener("abort",i))})}a(yRt,"untilAborted");import{WorkerEntrypoint as xTn}from"cloudflare:workers";var p1=Al(_Te());var VG=a((e,t,n)=>{let r=e instanceof RegExp?TTe(e,n):e,i=t instanceof RegExp?TTe(t,n):t,s=r!==null&&i!=null&&vRt(r,i,n);return s&&{start:s[0],end:s[1],pre:n.slice(0,s[0]),body:n.slice(s[0]+r.length,s[1]),post:n.slice(s[1]+i.length)}},"balanced"),TTe=a((e,t)=>{let n=t.match(e);return n?n[0]:null},"maybeMatch"),vRt=a((e,t,n)=>{let r,i,s,o,l,c=n.indexOf(e),u=n.indexOf(t,c+1),d=c;if(c>=0&&u>0){if(e===t)return[c,u];for(r=[],s=n.length;d>=0&&!l;){if(d===c)r.push(d),c=n.indexOf(e,d+1);else if(r.length===1){let p=r.pop();p!==void 0&&(l=[p,u])}else i=r.pop(),i!==void 0&&i<s&&(s=i,o=u),u=n.indexOf(t,d+1);d=c<u&&c>=0?c:u}r.length&&o!==void 0&&(l=[s,o])}return l},"range");var ITe="\0SLASH"+Math.random()+"\0",ATe="\0OPEN"+Math.random()+"\0",KG="\0CLOSE"+Math.random()+"\0",CTe="\0COMMA"+Math.random()+"\0",RTe="\0PERIOD"+Math.random()+"\0",xRt=new RegExp(ITe,"g"),bRt=new RegExp(ATe,"g"),wRt=new RegExp(KG,"g"),SRt=new RegExp(CTe,"g"),kRt=new RegExp(RTe,"g"),ERt=/\\\\/g,_Rt=/\\{/g,TRt=/\\}/g,IRt=/\\,/g,ARt=/\\\./g,CRt=1e5,RRt=4e6;function GG(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}a(GG,"numeric");function $Rt(e){return e.replace(ERt,ITe).replace(_Rt,ATe).replace(TRt,KG).replace(IRt,CTe).replace(ARt,RTe)}a($Rt,"escapeBraces");function ORt(e){return e.replace(xRt,"\\").replace(bRt,"{").replace(wRt,"}").replace(SRt,",").replace(kRt,".")}a(ORt,"unescapeBraces");function $Te(e){if(!e)return[""];let t=[],n=VG("{","}",e);if(!n)return e.split(",");let{pre:r,body:i,post:s}=n,o=r.split(",");o[o.length-1]+="{"+i+"}";let l=$Te(s);return s.length&&(o[o.length-1]+=l.shift(),o.push.apply(o,l)),t.push.apply(t,o),t}a($Te,"parseCommaParts");function OTe(e,t={}){if(!e)return[];let{max:n=CRt,maxLength:r=RRt}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),ZG($Rt(e),n,r,!0).map(ORt)}a(OTe,"expand");function PRt(e){return"{"+e+"}"}a(PRt,"embrace");function NRt(e){return/^-?0\d/.test(e)}a(NRt,"isPadded");function DRt(e,t){return e<=t}a(DRt,"lte");function MRt(e,t){return e>=t}a(MRt,"gte");function Ok(e,t,n,r,i,s){let o=[],l=0;for(let c=0;c<e.length;c++)for(let u=0;u<n.length;u++){if(o.length>=r)return o;let d=e[c]+t+n[u];if(!(s&&!d)){if(l+d.length>i)return o;o.push(d),l+=d.length}}return o}a(Ok,"combine");function LRt(e,t,n,r){let i=e.split(/\.\./),s=[];if(i[0]===void 0||i[1]===void 0)return s;let o=GG(i[0]),l=GG(i[1]),c=Math.max(i[0].length,i[1].length),u=i.length===3&&i[2]!==void 0?Math.max(Math.abs(GG(i[2])),1):1,d=DRt;l<o&&(u*=-1,d=MRt);let h=i.some(NRt),f=0;for(let g=o;d(g,l)&&s.length<n;g+=u){let y;if(t)y=String.fromCharCode(g),y==="\\"&&(y="");else if(y=String(g),h){let v=c-y.length;if(v>0){let w=new Array(v+1).join("0");g<0?y="-"+w+y.slice(1):y=w+y}}if(f+y.length>r)break;s.push(y),f+=y.length}return s}a(LRt,"expandSequence");function ZG(e,t,n,r){let i=[""],s=!1,o=!0;for(;;){let l=VG("{","}",e);if(!l)return Ok(i,e,[""],t,n,s);let c=l.pre;if(/\$$/.test(c)){if(i=Ok(i,c+"{"+l.body+"}",[""],t,n,s&&!l.post.length),o=!1,!l.post.length)break;e=l.post;continue}let u=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(l.body),d=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(l.body),p=u||d,h=l.body.indexOf(",")>=0;if(!p&&!h){if(l.post.match(/,(?!,).*\}/)){e=l.pre+"{"+l.body+KG+l.post,r=!0;continue}return Ok(i,c+"{"+l.body+"}"+l.post,[""],t,n,s)}o&&(s=r&&!p,o=!1);let f;if(p)f=LRt(l.body,d,t,n);else{let g=$Te(l.body);if(g.length===1&&g[0]!==void 0&&(g=ZG(g[0],t,n,!1).map(PRt),g.length===1)){if(i=Ok(i,c+g[0],[""],t,n,s&&!l.post.length),!l.post.length)break;e=l.post;continue}let y=s&&!l.post.length&&!c;for(let w=0;y&&w<i.length;w++)i[w]&&(y=!1);f=[];let v=0;e:for(let w=0;w<g.length;w++){let b=ZG(g[w],t,n,!1);for(let S=0;S<b.length;S++){let k=b[S];if(!(y&&!k)){if(f.length>=t||v+k.length>n)break e;f.push(k),v+=k.length}}}}if(i=Ok(i,c,f,t,n,s&&!l.post.length),!l.post.length)break;e=l.post}return i}a(ZG,"expand_");var Pk=a(e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")},"assertValidPattern");var FRt={"[: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]},Nk=a(e=>e.replace(/[[\]\\-]/g,"\\$&"),"braceEscape"),jRt=a(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regexpEscape"),PTe=a(e=>e.join(""),"rangesToString"),NTe=a((e,t)=>{let n=t;if(e.charAt(n)!=="[")throw new Error("not in a brace expression");let r=[],i=[],s=n+1,o=!1,l=!1,c=!1,u=!1,d=n,p="";e:for(;s<e.length;){let y=e.charAt(s);if((y==="!"||y==="^")&&s===n+1){u=!0,s++;continue}if(y==="]"&&o&&!c){d=s+1;break}if(o=!0,y==="\\"&&!c){c=!0,s++;continue}if(y==="["&&!c){for(let[v,[w,b,S]]of Object.entries(FRt))if(e.startsWith(v,s)){if(p)return["$.",!1,e.length-n,!0];s+=v.length,S?i.push(w):r.push(w),l=l||b;continue e}}if(c=!1,p){y>p?r.push(Nk(p)+"-"+Nk(y)):y===p&&r.push(Nk(y)),p="",s++;continue}if(e.startsWith("-]",s+1)){r.push(Nk(y+"-")),s+=2;continue}if(e.startsWith("-",s+1)){p=y,s+=2;continue}r.push(Nk(y)),s++}if(d<s)return["",!1,0,!1];if(!r.length&&!i.length)return["$.",!1,e.length-n,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!u){let y=r[0].length===2?r[0].slice(-1):r[0];return[jRt(y),!1,d-n,!1]}let h="["+(u?"^":"")+PTe(r)+"]",f="["+(u?"":"^")+PTe(i)+"]";return[r.length&&i.length?"("+h+"|"+f+")":r.length?h:f,l,d-n,!0]},"parseClass");var Ih=a((e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!0}={})=>n?t?e.replace(/\[([^/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?e.replace(/\[([^/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1"),"unescape");var gl,qRt=new Set(["!","?","+","*","@"]),JG=a(e=>qRt.has(e),"isExtglobType"),DTe=a(e=>JG(e.type),"isExtglobAST"),URt=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),zRt=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),BRt=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),MTe=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),WRt="(?!(?:^|/)\\.\\.?(?:$|/))",b$="(?!\\.)",HRt=new Set(["[","."]),VRt=new Set(["..","."]),GRt=new Set("().*{}+?[]^$\\!"),ZRt=a(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),XG="[^/]",LTe=XG+"*?",FTe=XG+"+?",KRt=0,Dg=class{static{a(this,"AST")}type;#e;#t;#r=!1;#n=[];#i;#s;#a;#l=!1;#u;#o;#p=!1;id=++KRt;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#n.length,parts:this.#n}}constructor(t,n,r={}){this.type=t,t&&(this.#t=!0),this.#i=n,this.#e=this.#i?this.#i.#e:this,this.#u=this.#e===this?r:this.#e.#u,this.#a=this.#e===this?[]:this.#e.#a,t==="!"&&!this.#e.#l&&this.#a.push(this),this.#s=this.#i?this.#i.#n.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let t of this.#n)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#o!==void 0?this.#o:this.type?this.#o=this.type+"("+this.#n.map(t=>String(t)).join("|")+")":this.#o=this.#n.map(t=>String(t)).join("")}#m(){if(this!==this.#e)throw new Error("should only call on root");if(this.#l)return this;this.toString(),this.#l=!0;let t;for(;t=this.#a.pop();){if(t.type!=="!")continue;let n=t,r=n.#i;for(;r;){for(let i=n.#s+1;!r.type&&i<r.#n.length;i++)for(let s of t.#n){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(r.#n[i])}n=r,r=n.#i}}return this}push(...t){for(let n of t)if(n!==""){if(typeof n!="string"&&!(n instanceof gl&&n.#i===this))throw new Error("invalid part: "+n);this.#n.push(n)}}toJSON(){let t=this.type===null?this.#n.slice().map(n=>typeof n=="string"?n:n.toJSON()):[this.type,...this.#n.map(n=>n.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#l&&this.#i?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#s===0)return!0;let t=this.#i;for(let n=0;n<this.#s;n++){let r=t.#n[n];if(!(r instanceof gl&&r.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let t=this.#i?this.#i.#n.length:0;return this.#s===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let n=new gl(this.type,t);for(let r of this.#n)n.copyIn(r);return n}static#d(t,n,r,i,s){let o=i.maxExtglobRecursion??2,l=!1,c=!1,u=-1,d=!1;if(n.type===null){let y=r,v="";for(;y<t.length;){let w=t.charAt(y++);if(l||w==="\\"){l=!l,v+=w;continue}if(c){y===u+1?(w==="^"||w==="!")&&(d=!0):w==="]"&&!(y===u+2&&d)&&(c=!1),v+=w;continue}else if(w==="["){c=!0,u=y,d=!1,v+=w;continue}if(!i.noext&&JG(w)&&t.charAt(y)==="("&&s<=o){n.push(v),v="";let S=new gl(w,n);y=gl.#d(t,S,y,i,s+1),n.push(S);continue}v+=w}return n.push(v),y}let p=r+1,h=new gl(null,n),f=[],g="";for(;p<t.length;){let y=t.charAt(p++);if(l||y==="\\"){l=!l,g+=y;continue}if(c){p===u+1?(y==="^"||y==="!")&&(d=!0):y==="]"&&!(p===u+2&&d)&&(c=!1),g+=y;continue}else if(y==="["){c=!0,u=p,d=!1,g+=y;continue}if(!i.noext&&JG(y)&&t.charAt(p)==="("&&(s<=o||n&&n.#h(y))){let w=n&&n.#h(y)?0:1;h.push(g),g="";let b=new gl(y,h);h.push(b),p=gl.#d(t,b,p,i,s+w);continue}if(y==="|"){h.push(g),g="",f.push(h),h=new gl(null,n);continue}if(y===")")return g===""&&n.#n.length===0&&(n.#p=!0),h.push(g),g="",n.push(...f,h),p;g+=y}return n.type=null,n.#t=void 0,n.#n=[t.substring(r-1)],p}#f(t){return this.#v(t,zRt)}#v(t,n=URt){if(!t||typeof t!="object"||t.type!==null||t.#n.length!==1||this.type===null)return!1;let r=t.#n[0];return!r||typeof r!="object"||r.type===null?!1:this.#h(r.type,n)}#h(t,n=BRt){return!!n.get(this.type)?.includes(t)}#O(t,n){let r=t.#n[0],i=new gl(null,r,this.options);i.#n.push(""),r.push(i),this.#x(t,n)}#x(t,n){let r=t.#n[0];this.#n.splice(n,1,...r.#n);for(let i of r.#n)typeof i=="object"&&(i.#i=this);this.#o=void 0}#E(t){return!!MTe.get(this.type)?.has(t)}#_(t){if(!t||typeof t!="object"||t.type!==null||t.#n.length!==1||this.type===null||this.#n.length!==1)return!1;let n=t.#n[0];return!n||typeof n!="object"||n.type===null?!1:this.#E(n.type)}#T(t){let n=MTe.get(this.type),r=t.#n[0],i=n?.get(r.type);if(!i)return!1;this.#n=r.#n;for(let s of this.#n)typeof s=="object"&&(s.#i=this);this.type=i,this.#o=void 0,this.#p=!1}static fromGlob(t,n={}){let r=new gl(null,void 0,n);return gl.#d(t,r,0,n,0),r}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[n,r,i,s]=this.toRegExpSource();if(!(i||this.#t||this.#u.nocase&&!this.#u.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return r;let l=(this.#u.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${n}$`,l),{_src:n,_glob:t})}get options(){return this.#u}toRegExpSource(t){let n=t??!!this.#u.dot;if(this.#e===this&&(this.#c(),this.#m()),!DTe(this)){let c=this.isStart()&&this.isEnd()&&!this.#n.some(f=>typeof f!="string"),u=this.#n.map(f=>{let[g,y,v,w]=typeof f=="string"?gl.#b(f,this.#t,c):f.toRegExpSource(t);return this.#t=this.#t||v,this.#r=this.#r||w,g}).join(""),d="";if(this.isStart()&&typeof this.#n[0]=="string"&&!(this.#n.length===1&&VRt.has(this.#n[0]))){let g=HRt,y=n&&g.has(u.charAt(0))||u.startsWith("\\.")&&g.has(u.charAt(2))||u.startsWith("\\.\\.")&&g.has(u.charAt(4)),v=!n&&!t&&g.has(u.charAt(0));d=y?WRt:v?b$:""}let p="";return this.isEnd()&&this.#e.#l&&this.#i?.type==="!"&&(p="(?:$|\\/)"),[d+u+p,Ih(u),this.#t=!!this.#t,this.#r]}let r=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#g(n);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let c=this.toString(),u=this;return u.#n=[c],u.type=null,u.#t=void 0,[c,Ih(this.toString()),!1,!1]}let o=!r||t||n||!b$?"":this.#g(!0);o===s&&(o=""),o&&(s=`(?:${s})(?:${o})*?`);let l="";if(this.type==="!"&&this.#p)l=(this.isStart()&&!n?b$:"")+FTe;else{let c=this.type==="!"?"))"+(this.isStart()&&!n&&!t?b$:"")+LTe+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;l=i+s+c}return[l,Ih(s),this.#t=!!this.#t,this.#r]}#c(){if(DTe(this)){let t=0,n=!1;do{n=!0;for(let r=0;r<this.#n.length;r++){let i=this.#n[r];typeof i=="object"&&(i.#c(),this.#v(i)?(n=!1,this.#x(i,r)):this.#f(i)?(n=!1,this.#O(i,r)):this.#_(i)&&(n=!1,this.#T(i)))}}while(!n&&++t<10)}else for(let t of this.#n)typeof t=="object"&&t.#c();this.#o=void 0}#g(t){return this.#n.map(n=>{if(typeof n=="string")throw new Error("string type in extglob ast??");let[r,i,s,o]=n.toRegExpSource(t);return this.#r=this.#r||o,r}).filter(n=>!(this.isStart()&&this.isEnd())||!!n).join("|")}static#b(t,n,r=!1){let i=!1,s="",o=!1,l=!1;for(let c=0;c<t.length;c++){let u=t.charAt(c);if(i){i=!1,s+=(GRt.has(u)?"\\":"")+u;continue}if(u==="*"){if(l)continue;l=!0,s+=r&&/^[*]+$/.test(t)?FTe:LTe,n=!0;continue}else l=!1;if(u==="\\"){c===t.length-1?s+="\\\\":i=!0;continue}if(u==="["){let[d,p,h,f]=NTe(t,c);if(h){s+=d,o=o||p,c+=h-1,n=n||f;continue}}if(u==="?"){s+=XG,n=!0;continue}s+=ZRt(u)}return[s,Ih(t),!!n,o]}};gl=Dg;var YG=a((e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!1}={})=>n?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&"),"escape");var $o=a((e,t,n={})=>(Pk(t),!n.nocomment&&t.charAt(0)==="#"?!1:new ov(t,n).match(e)),"minimatch"),JRt=/^\*+([^+@!?*[(]*)$/,XRt=a(e=>t=>!t.startsWith(".")&&t.endsWith(e),"starDotExtTest"),YRt=a(e=>t=>t.endsWith(e),"starDotExtTestDot"),QRt=a(e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),"starDotExtTestNocase"),e$t=a(e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),"starDotExtTestNocaseDot"),t$t=/^\*+\.\*+$/,n$t=a(e=>!e.startsWith(".")&&e.includes("."),"starDotStarTest"),r$t=a(e=>e!=="."&&e!==".."&&e.includes("."),"starDotStarTestDot"),i$t=/^\.\*+$/,s$t=a(e=>e!=="."&&e!==".."&&e.startsWith("."),"dotStarTest"),o$t=/^\*+$/,a$t=a(e=>e.length!==0&&!e.startsWith("."),"starTest"),l$t=a(e=>e.length!==0&&e!=="."&&e!=="..","starTestDot"),c$t=/^\?+([^+@!?*[(]*)?$/,u$t=a(([e,t=""])=>{let n=UTe([e]);return t?(t=t.toLowerCase(),r=>n(r)&&r.toLowerCase().endsWith(t)):n},"qmarksTestNocase"),d$t=a(([e,t=""])=>{let n=zTe([e]);return t?(t=t.toLowerCase(),r=>n(r)&&r.toLowerCase().endsWith(t)):n},"qmarksTestNocaseDot"),p$t=a(([e,t=""])=>{let n=zTe([e]);return t?r=>n(r)&&r.endsWith(t):n},"qmarksTestDot"),f$t=a(([e,t=""])=>{let n=UTe([e]);return t?r=>n(r)&&r.endsWith(t):n},"qmarksTest"),UTe=a(([e])=>{let t=e.length;return n=>n.length===t&&!n.startsWith(".")},"qmarksTestNoExt"),zTe=a(([e])=>{let t=e.length;return n=>n.length===t&&n!=="."&&n!==".."},"qmarksTestNoExtDot"),BTe=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",jTe={win32:{sep:"\\"},posix:{sep:"/"}},h$t=BTe==="win32"?jTe.win32.sep:jTe.posix.sep;$o.sep=h$t;var _a=Symbol("globstar **");$o.GLOBSTAR=_a;var m$t="[^/]",g$t=m$t+"*?",y$t="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",v$t="(?:(?!(?:\\/|^)\\.).)*?",x$t=a((e,t={})=>n=>$o(n,e,t),"filter");$o.filter=x$t;var $c=a((e,t={})=>Object.assign({},e,t),"ext"),b$t=a(e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return $o;let t=$o;return Object.assign(a((r,i,s={})=>t(r,i,$c(e,s)),"m"),{Minimatch:class extends t.Minimatch{static{a(this,"Minimatch")}constructor(i,s={}){super(i,$c(e,s))}static defaults(i){return t.defaults($c(e,i)).Minimatch}},AST:class extends t.AST{static{a(this,"AST")}constructor(i,s,o={}){super(i,s,$c(e,o))}static fromGlob(i,s={}){return t.AST.fromGlob(i,$c(e,s))}},unescape:a((r,i={})=>t.unescape(r,$c(e,i)),"unescape"),escape:a((r,i={})=>t.escape(r,$c(e,i)),"escape"),filter:a((r,i={})=>t.filter(r,$c(e,i)),"filter"),defaults:a(r=>t.defaults($c(e,r)),"defaults"),makeRe:a((r,i={})=>t.makeRe(r,$c(e,i)),"makeRe"),braceExpand:a((r,i={})=>t.braceExpand(r,$c(e,i)),"braceExpand"),match:a((r,i,s={})=>t.match(r,i,$c(e,s)),"match"),sep:t.sep,GLOBSTAR:_a})},"defaults");$o.defaults=b$t;var WTe=a((e,t={})=>(Pk(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:OTe(e,{max:t.braceExpandMax})),"braceExpand");$o.braceExpand=WTe;var w$t=a((e,t={})=>new ov(e,t).makeRe(),"makeRe");$o.makeRe=w$t;var S$t=a((e,t,n={})=>{let r=new ov(t,n);return e=e.filter(i=>r.match(i)),r.options.nonull&&!e.length&&e.push(t),e},"match");$o.match=S$t;var qTe=/[?*]|[+@!]\(.*?\)|\[|\]/,k$t=a(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),ov=class{static{a(this,"Minimatch")}options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,n={}){Pk(t),n=n||{},this.options=n,this.maxGlobstarRecursion=n.maxGlobstarRecursion??200,this.pattern=t,this.platform=n.platform||BTe,this.isWindows=this.platform==="win32";let r="allowWindowsEscape";this.windowsPathsNoEscape=!!n.windowsPathsNoEscape||n[r]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!n.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!n.nonegate,this.comment=!1,this.empty=!1,this.partial=!!n.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=n.windowsNoMagicRoot!==void 0?n.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let n of t)if(typeof n!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,n=this.options;if(!n.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],n.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let r=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(r),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,o,l)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=s[0]===""&&s[1]===""&&(s[2]==="?"||!qTe.test(s[2]))&&!qTe.test(s[3]),u=/^[a-z]:/i.test(s[0]);if(c)return[...s.slice(0,4),...s.slice(4).map(d=>this.parse(d))];if(u)return[s[0],...s.slice(1).map(d=>this.parse(d))]}return s.map(c=>this.parse(c))});if(this.debug(this.pattern,i),this.set=i.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let o=this.set[s];o[0]===""&&o[1]===""&&this.globParts[s][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let r of t)for(let i=0;i<r.length;i++)r[i]==="**"&&(r[i]="*");let{optimizationLevel:n=1}=this.options;return n>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):n>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(n=>{let r=-1;for(;(r=n.indexOf("**",r+1))!==-1;){let i=r;for(;n[i+1]==="**";)i++;i!==r&&n.splice(r,i-r)}return n})}levelOneOptimize(t){return t.map(n=>(n=n.reduce((r,i)=>{let s=r[r.length-1];return i==="**"&&s==="**"?r:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(r.pop(),r):(r.push(i),r)},[]),n.length===0?[""]:n))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let n=!1;do{if(n=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let s=t[i];i===1&&s===""&&t[0]===""||(s==="."||s==="")&&(n=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(n=!0,t.pop())}let r=0;for(;(r=t.indexOf("..",r+1))!==-1;){let i=t[r-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(n=!0,t.splice(r-1,2),r-=2)}}while(n);return t.length===0?[""]:t}firstPhasePreProcess(t){let n=!1;do{n=!1;for(let r of t){let i=-1;for(;(i=r.indexOf("**",i+1))!==-1;){let o=i;for(;r[o+1]==="**";)o++;o>i&&r.splice(i+1,o-i);let l=r[i+1],c=r[i+2],u=r[i+3];if(l!==".."||!c||c==="."||c===".."||!u||u==="."||u==="..")continue;n=!0,r.splice(i,1);let d=r.slice(0);d[i]="**",t.push(d),i--}if(!this.preserveMultipleSlashes){for(let o=1;o<r.length-1;o++){let l=r[o];o===1&&l===""&&r[0]===""||(l==="."||l==="")&&(n=!0,r.splice(o,1),o--)}r[0]==="."&&r.length===2&&(r[1]==="."||r[1]==="")&&(n=!0,r.pop())}let s=0;for(;(s=r.indexOf("..",s+1))!==-1;){let o=r[s-1];if(o&&o!=="."&&o!==".."&&o!=="**"){n=!0;let c=s===1&&r[s+1]==="**"?["."]:[];r.splice(s-1,2,...c),r.length===0&&r.push(""),s-=2}}}}while(n);return t}secondPhasePreProcess(t){for(let n=0;n<t.length-1;n++)for(let r=n+1;r<t.length;r++){let i=this.partsMatch(t[n],t[r],!this.preserveMultipleSlashes);if(i){t[n]=[],t[r]=i;break}}return t.filter(n=>n.length)}partsMatch(t,n,r=!1){let i=0,s=0,o=[],l="";for(;i<t.length&&s<n.length;)if(t[i]===n[s])o.push(l==="b"?n[s]:t[i]),i++,s++;else if(r&&t[i]==="**"&&n[s]===t[i+1])o.push(t[i]),i++;else if(r&&n[s]==="**"&&t[i]===n[s+1])o.push(n[s]),s++;else if(t[i]==="*"&&n[s]&&(this.options.dot||!n[s].startsWith("."))&&n[s]!=="**"){if(l==="b")return!1;l="a",o.push(t[i]),i++,s++}else if(n[s]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(l==="a")return!1;l="b",o.push(n[s]),i++,s++}else return!1;return t.length===n.length&&o}parseNegate(){if(this.nonegate)return;let t=this.pattern,n=!1,r=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)n=!n,r++;r&&(this.pattern=t.slice(r)),this.negate=n}matchOne(t,n,r=!1){let i=0,s=0;if(this.isWindows){let l=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),c=!l&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),u=typeof n[0]=="string"&&/^[a-z]:$/i.test(n[0]),d=!u&&n[0]===""&&n[1]===""&&n[2]==="?"&&typeof n[3]=="string"&&/^[a-z]:$/i.test(n[3]),p=c?3:l?0:void 0,h=d?3:u?0:void 0;if(typeof p=="number"&&typeof h=="number"){let[f,g]=[t[p],n[h]];f.toLowerCase()===g.toLowerCase()&&(n[h]=f,s=h,i=p)}}let{optimizationLevel:o=1}=this.options;return o>=2&&(t=this.levelTwoFileOptimize(t)),n.includes(_a)?this.#e(t,n,r,i,s):this.#r(t,n,r,i,s)}#e(t,n,r,i,s){let o=n.indexOf(_a,s),l=n.lastIndexOf(_a),[c,u,d]=r?[n.slice(s,o),n.slice(o+1),[]]:[n.slice(s,o),n.slice(o+1,l),n.slice(l+1)];if(c.length){let b=t.slice(i,i+c.length);if(!this.#r(b,c,r,0,0))return!1;i+=c.length,s+=c.length}let p=0;if(d.length){if(d.length+i>t.length)return!1;let b=t.length-d.length;if(this.#r(t,d,r,b,0))p=d.length;else{if(t[t.length-1]!==""||i+d.length===t.length||(b--,!this.#r(t,d,r,b,0)))return!1;p=d.length+1}}if(!u.length){let b=!!p;for(let S=i;S<t.length-p;S++){let k=String(t[S]);if(b=!0,k==="."||k===".."||!this.options.dot&&k.startsWith("."))return!1}return r||b}let h=[[[],0]],f=h[0],g=0,y=[0];for(let b of u)b===_a?(y.push(g),f=[[],0],h.push(f)):(f[0].push(b),g++);let v=h.length-1,w=t.length-p;for(let b of h)b[1]=w-(y[v--]+b[0].length);return!!this.#t(t,h,i,0,r,0,!!p)}#t(t,n,r,i,s,o,l){let c=n[i];if(!c){for(let p=r;p<t.length;p++){l=!0;let h=t[p];if(h==="."||h===".."||!this.options.dot&&h.startsWith("."))return!1}return l}let[u,d]=c;for(;r<=d;){if(this.#r(t.slice(0,r+u.length),u,s,r,0)&&o<this.maxGlobstarRecursion){let f=this.#t(t,n,r+u.length,i+1,s,o+1,l);if(f!==!1)return f}let h=t[r];if(h==="."||h===".."||!this.options.dot&&h.startsWith("."))return!1;r++}return s||null}#r(t,n,r,i,s){let o,l,c,u;for(o=i,l=s,u=t.length,c=n.length;o<u&&l<c;o++,l++){this.debug("matchOne loop");let d=n[l],p=t[o];if(this.debug(n,d,p),d===!1||d===_a)return!1;let h;if(typeof d=="string"?(h=p===d,this.debug("string match",d,p,h)):(h=d.test(p),this.debug("pattern match",d,p,h)),!h)return!1}if(o===u&&l===c)return!0;if(o===u)return r;if(l===c)return o===u-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return WTe(this.pattern,this.options)}parse(t){Pk(t);let n=this.options;if(t==="**")return _a;if(t==="")return"";let r,i=null;(r=t.match(o$t))?i=n.dot?l$t:a$t:(r=t.match(JRt))?i=(n.nocase?n.dot?e$t:QRt:n.dot?YRt:XRt)(r[1]):(r=t.match(c$t))?i=(n.nocase?n.dot?d$t:u$t:n.dot?p$t:f$t)(r):(r=t.match(t$t))?i=n.dot?r$t:n$t:(r=t.match(i$t))&&(i=s$t);let s=Dg.fromGlob(t,this.options).toMMPattern();return i&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:i}),s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let n=this.options,r=n.noglobstar?g$t:n.dot?y$t:v$t,i=new Set(n.nocase?["i"]:[]),s=t.map(c=>{let u=c.map(p=>{if(p instanceof RegExp)for(let h of p.flags.split(""))i.add(h);return typeof p=="string"?k$t(p):p===_a?_a:p._src});u.forEach((p,h)=>{let f=u[h+1],g=u[h-1];p!==_a||g===_a||(g===void 0?f!==void 0&&f!==_a?u[h+1]="(?:\\/|"+r+"\\/)?"+f:u[h]=r:f===void 0?u[h-1]=g+"(?:\\/|\\/"+r+")?":f!==_a&&(u[h-1]=g+"(?:\\/|\\/"+r+"\\/)"+f,u[h+1]=_a))});let d=u.filter(p=>p!==_a);if(this.partial&&d.length>=1){let p=[];for(let h=1;h<=d.length;h++)p.push(d.slice(0,h).join("/"));return"(?:"+p.join("|")+")"}return d.join("/")}).join("|"),[o,l]=t.length>1?["(?:",")"]:["",""];s="^"+o+s+l+"$",this.partial&&(s="^(?:\\/|"+o+s.slice(1,-1)+l+")$"),this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,n=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&n)return!0;let r=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let s=this.set;this.debug(this.pattern,"set",s);let o=i[i.length-1];if(!o)for(let l=i.length-2;!o&&l>=0;l--)o=i[l];for(let l of s){let c=i;if(r.matchBase&&l.length===1&&(c=[o]),this.matchOne(c,l,n))return r.flipNegate?!0:!this.negate}return r.flipNegate?!1:this.negate}static defaults(t){return $o.defaults(t).Minimatch}};$o.AST=Dg;$o.Minimatch=ov;$o.escape=YG;$o.unescape=Ih;import{gunzipSync as A4t}from"node:zlib";var Dk=class{static{a(this,"Diff")}diff(t,n,r={}){let i;typeof r=="function"?(i=r,r={}):"callback"in r&&(i=r.callback);let s=this.castInput(t,r),o=this.castInput(n,r),l=this.removeEmpty(this.tokenize(s,r)),c=this.removeEmpty(this.tokenize(o,r));return this.diffWithOptionsObj(l,c,r,i)}diffWithOptionsObj(t,n,r,i){var s;let o=a(b=>{if(b=this.postProcess(b,r),i){setTimeout(function(){i(b)},0);return}else return b},"done"),l=n.length,c=t.length,u=1,d=l+c;r.maxEditLength!=null&&(d=Math.min(d,r.maxEditLength));let p=(s=r.timeout)!==null&&s!==void 0?s:1/0,h=Date.now()+p,f=[{oldPos:-1,lastComponent:void 0}],g=this.extractCommon(f[0],n,t,0,r);if(f[0].oldPos+1>=c&&g+1>=l)return o(this.buildValues(f[0].lastComponent,n,t));let y=-1/0,v=1/0,w=a(()=>{for(let b=Math.max(y,-u);b<=Math.min(v,u);b+=2){let S,k=f[b-1],E=f[b+1];k&&(f[b-1]=void 0);let T=!1;if(E){let N=E.oldPos-b;T=E&&0<=N&&N<l}let I=k&&k.oldPos+1<c;if(!T&&!I){f[b]=void 0;continue}if(!I||T&&k.oldPos<E.oldPos?S=this.addToPath(E,!0,!1,0,r):S=this.addToPath(k,!1,!0,1,r),g=this.extractCommon(S,n,t,b,r),S.oldPos+1>=c&&g+1>=l)return o(this.buildValues(S.lastComponent,n,t))||!0;f[b]=S,S.oldPos+1>=c&&(v=Math.min(v,b-1)),g+1>=l&&(y=Math.max(y,b+1))}u++},"execEditLength");if(i)a(function b(){setTimeout(function(){if(u>d||Date.now()>h)return i(void 0);w()||b()},0)},"exec")();else for(;u<=d&&Date.now()<=h;){let b=w();if(b)return b}}addToPath(t,n,r,i,s){let o=t.lastComponent;return o&&!s.oneChangePerToken&&o.added===n&&o.removed===r?{oldPos:t.oldPos+i,lastComponent:{count:o.count+1,added:n,removed:r,previousComponent:o.previousComponent}}:{oldPos:t.oldPos+i,lastComponent:{count:1,added:n,removed:r,previousComponent:o}}}extractCommon(t,n,r,i,s){let o=n.length,l=r.length,c=t.oldPos,u=c-i,d=0;for(;u+1<o&&c+1<l&&this.equals(r[c+1],n[u+1],s);)u++,c++,d++,s.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return d&&!s.oneChangePerToken&&(t.lastComponent={count:d,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=c,u}equals(t,n,r){return r.comparator?r.comparator(t,n):t===n||!!r.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){let n=[];for(let r=0;r<t.length;r++)t[r]&&n.push(t[r]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,r){let i=[],s;for(;t;)i.push(t),s=t.previousComponent,delete t.previousComponent,t=s;i.reverse();let o=i.length,l=0,c=0,u=0;for(;l<o;l++){let d=i[l];if(d.removed)d.value=this.join(r.slice(u,u+d.count)),u+=d.count;else{if(!d.added&&this.useLongestToken){let p=n.slice(c,c+d.count);p=p.map(function(h,f){let g=r[u+f];return g.length>h.length?g:h}),d.value=this.join(p)}else d.value=this.join(n.slice(c,c+d.count));c+=d.count,d.added||(u+=d.count)}}return i}};var QG=class extends Dk{static{a(this,"LineDiff")}constructor(){super(...arguments),this.tokenize=_$t}equals(t,n,r){return r.ignoreWhitespace?((!r.newlineIsToken||!t.includes(`
4996
+ `}a(pTe,"pageStyles");fA();var DG="enabled",MG=Object.freeze({id:"direct",capabilities:Object.freeze(["bash"]),plan:"free",shell:"just-bash-direct",probe:a(e=>e.LOADER===void 0?"available":"needs-binding","probe")}),Rk=Object.freeze({id:"dynamic-worker",capabilities:Object.freeze(["bash","coding"]),plan:"paid",shell:"just-bash-isolated",probe:a(e=>e.LOADER===void 0?"needs-binding":"available","probe")}),LG=Object.freeze({id:"container",capabilities:Object.freeze(["container"]),plan:"paid",shell:"linux-container",probe:a(e=>e.DSH_EDGE_CONTAINER_RUNTIME===DG?"available":"needs-binding","probe")}),B6t=Object.freeze([LG,Rk,MG]);function FG(e,t=B6t){return t.filter(n=>n.probe(e)==="available")}a(FG,"availableEdgeRuntimeProviders");function jG(e){let t=a(r=>e.find(i=>i.capabilities.includes(r)),"first"),n=t("bash");if(n===void 0)throw new Error("No available runtime provider serves the bash layer.");return{bash:n.id,container:t("container")?.id??null}}a(jG,"resolveEdgeRuntimeSelection");function h$(e){let t=FG(e),{bash:n,container:r}=jG(t);return t.find(i=>i.id===(r??n)).shell}a(h$,"resolveEdgeRuntimeShell");function W6t(){return"dsh-edge@0.18.0/direct"}a(W6t,"resolveEdgeDeploymentId");function $k(e){return{baseURL:pz(e.DEEPSEEK_BASE_URL),maxTokens:mz(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:rg(e.DEEPSEEK_MODEL),reasoningEffort:fz(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:A6(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:hz(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:Eh(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}a($k,"resolveEdgeDeploymentConfig");function H6t(e){return typeof e.DEEPSEEK_API_KEY=="string"&&e.DEEPSEEK_API_KEY.trim().length>0}a(H6t,"edgeDeploymentApiKeyConfigured");function V6t(e){let t=pz(e),n=new URL(t);return n.search.length===0&&n.hash.length===0?t:(n.search="",n.hash="",n.href)}a(V6t,"projectedEdgeBaseURL");function qG(e,t){return{shell:h$(e),storage:"durable-object-sqlite-vfs",attachmentStorage:t??(e.DSH_EDGE_ATTACHMENTS===void 0?"temporary-do":"private-r2"),deploymentId:W6t(),apiKeyConfigured:H6t(e),baseURL:V6t(e.DEEPSEEK_BASE_URL),maxTokens:mz(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:rg(e.DEEPSEEK_MODEL),reasoningEffort:fz(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:A6(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:hz(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:Eh(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}a(qG,"resolveEdgeDeploymentProfile");function m$(e){$k(e);let t=qG(e);return{ok:!0,service:"dsh-edge",storage:t.storage,attachmentStorage:t.attachmentStorage,shell:t.shell,agent:"upstream-react-loop-agent",access:"single-owner-cookie",deploymentId:t.deploymentId,...e.CF_VERSION_METADATA===void 0?{}:{workerVersionId:e.CF_VERSION_METADATA.id},version:Qy,upstreamVersion:Vpe,status:"ready"}}a(m$,"resolveEdgeDeploymentHealth");import{AsyncLocalStorage as lzt}from"node:async_hooks";import{RpcTarget as G6t}from"cloudflare:workers";function Z6t(e){let{intervalMs:t,ping:n,onFailure:r}=e,i=!1,s=setInterval(()=>{i||n().catch(o=>{i||(i=!0,clearInterval(s),r(o instanceof Error?o:new Error(String(o))))})},t);return()=>{i||(i=!0,clearInterval(s))}}a(Z6t,"startHeartbeat");async function K6t(e,t){let n=AbortSignal.timeout(t.timeoutMs),r=await e.fetchPort(t.port,`http://container${t.path}`,{method:"HEAD",signal:n});if(r.body?.cancel(),!r.ok)throw new Error(`computerd health returned ${r.status}`)}a(K6t,"probeComputerdHealth");var J6t="computer.internal",X6t="/health",UG="/api",Y6t=8080,Q6t=3e4,eRt=2e4,tRt=1,nRt=2e3,rRt=250,iRt=2e3;function sRt(e,t){if(t===void 0||e===null)return!1;let n=e.indexOf(" ");if(n===-1||e.slice(0,n).toLowerCase()!=="bearer")return!1;let r=e.slice(n+1).trim();if(r.length!==t.length)return!1;let i=0;for(let s=0;s<t.length;s+=1)i|=r.charCodeAt(s)^t.charCodeAt(s);return i===0}a(sRt,"bearerMatches");var y$=class{static{a(this,"CloudflareContainerBackend")}type="cloudflare-container";id;#e;#t;#r;#n;#i;#s;#a;#l;constructor(e){this.id=e.id??"container-shell",this.#t=e.egress??{mode:"none"},this.#r=this.#t.mode==="http-gateway"?crypto.randomUUID():void 0,this.#e={container:e.container,workspace:e.workspace,containerEnv:e.containerEnv,egressHost:e.egressHost??J6t,containerPort:e.containerPort??Y6t,connectTimeoutMs:e.connectTimeoutMs??Q6t,heartbeatIntervalMs:e.heartbeatIntervalMs??eRt,restartAttempts:e.restartAttempts??tRt,healthProbeTimeoutMs:e.healthProbeTimeoutMs??nRt,healthRetryInitialDelayMs:e.healthRetryInitialDelayMs??rRt,healthRetryMaxDelayMs:e.healthRetryMaxDelayMs??iRt}}async connect(){if(this.#l)return this.#l;let e=Date.now()+this.#e.connectTimeoutMs,t=await(await this.#e.container()).getWorkspaceContainer(),n=await t.exitInfo().catch(()=>null),r={PORT:String(this.#e.containerPort),MOUNT_POINT:"/workspace",...this.#e.containerEnv},i,s;try{({runtimeId:i,clientSecret:s}=await t.start({env:r,enableInternet:this.#t.mode==="direct"}))}catch(p){throw new Ra(this.#d("start",{attempt:1,maxAttempts:this.#e.restartAttempts+1,restarts:0,lastError:p,priorExit:n}),{cause:p})}try{await t.interceptOutboundHttp(this.#e.egressHost,this.#e.workspace),this.#t.mode==="http-gateway"&&this.#r!==void 0&&await t.interceptAllOutboundHttp(this.#e.workspace,this.#r)}catch(p){throw new Ra(this.#d("egress",{attempt:1,maxAttempts:this.#e.restartAttempts+1,restarts:0,lastError:p,priorExit:n}),{cause:p})}this.#n=s,this.#u(),i=await this.#p(t,r,e,n,i),await this.#f(t,e),await this.#v(t,e,s);let o=await this.#h(e),l=H4(o),c,u=new Promise(p=>{let h=!1,f=a(()=>{h||(h=!0,c?.(),p(),this.#l=void 0)},"onClose");o.addEventListener("close",f,{once:!0}),o.addEventListener("error",f,{once:!0}),l.onRpcBroken(f)});this.#e.heartbeatIntervalMs>0&&(c=Z6t({intervalMs:this.#e.heartbeatIntervalMs,ping:a(()=>l.sync.watermarks(),"ping"),onFailure:a(()=>{try{o.close()}catch{}},"onFailure")}));let d={rpc:l,runtimeId:i,closed:u,close:a(async()=>{c?.();try{l[Symbol.dispose]?.()}catch{}try{o.close()}catch{}this.#l=void 0},"close")};return this.#l=d,d}async handleFetch(e){if(this.#t.mode==="http-gateway"&&this.#r!==void 0&&e.headers.get("x-workspace-egress-token")===this.#r){let i=new Headers(e.headers),s=i.get(ix),o;try{o=new URL(s??"")}catch{return new Response("invalid egress URL",{status:400})}if(o.protocol!=="http:"&&o.protocol!=="https:")return new Response("invalid egress URL",{status:400});i.delete(VE),i.delete(ix);let l=new Request(e,{headers:i});return this.#t.gateway.fetch(new Request(o,l))}if(new URL(e.url).pathname!==UG)return new Response("not found",{status:404});if(e.headers.get("upgrade")!=="websocket")return new Response(`${UG} requires a websocket upgrade`,{status:400});if(!sRt(e.headers.get("authorization"),this.#n))return new Response("unauthorized",{status:401,headers:{"www-authenticate":"Bearer"}});let t=new WebSocketPair,[n,r]=[t[0],t[1]];if(r.accept(),this.#s)this.#s(r);else return r.close(1011,"no pending connect"),new Response("no pending connect",{status:409});return new Response(null,{status:101,webSocket:n})}#u(){this.#i=new Promise((e,t)=>{this.#s=e,this.#a=t}),this.#i.catch(()=>{})}#o(){this.#i=void 0,this.#s=void 0,this.#a=void 0}async#p(e,t,n,r,i){let s=this.#e.restartAttempts+1,o=Math.max(0,n-Date.now()),l=Math.max(250,Math.floor(o/s)),c=0,u=0,d,p=i;for(;c<s;){c++;let h=Math.min(n,Date.now()+l);if(await this.#m(e,h).then(()=>!0,f=>(d=f,!1)))return p;if(c<s)try{({runtimeId:p}=await e.restart({env:t,enableInternet:this.#t.mode==="direct"})),u++}catch(f){throw this.#a?.(f),this.#o(),new Ra(this.#d("restart",{attempt:c,maxAttempts:s,restarts:u,lastError:f}),{cause:f})}}throw this.#a?.(new Error("computerd never became healthy")),this.#o(),new Ra(this.#d("health",{attempt:c,maxAttempts:s,restarts:u,lastError:d,priorExit:r}),d instanceof Error?{cause:d}:void 0)}async#m(e,t){let n=this.#e.healthRetryInitialDelayMs,r;for(;Date.now()<t;)try{await K6t(e,{port:this.#e.containerPort,path:"/health",timeoutMs:Math.min(this.#e.healthProbeTimeoutMs,Math.max(50,t-Date.now()))});return}catch(i){r=i;let s=t-Date.now();if(s<=0)break;await oRt(Math.min(n,s)),n=Math.min(n*2,this.#e.healthRetryMaxDelayMs)}throw r??new Error("computerd health probe timed out")}#d(e,t){let n=t.priorExit?` priorExit=${JSON.stringify(t.priorExit.reason)}`:"";return`CloudflareContainerBackend(${this.id}): connect failed at stage=${e} port=${this.#e.containerPort} attempt=${t.attempt}/${t.maxAttempts} restarts=${t.restarts} timeoutMs=${this.#e.connectTimeoutMs}${n} lastError=${fTe(t.lastError)}`}async#f(e,t){let n;try{let r=await e.fetchPort(this.#e.containerPort,"http://container/api",{signal:AbortSignal.timeout(Math.min(this.#e.healthProbeTimeoutMs,Math.max(50,t-Date.now())))});n=r.status,await r.text().catch(()=>"")}catch{return}if(n!==401)throw this.#a?.(new Error("container is not enforcing RPC_CLIENT_SECRET")),this.#o(),new Ra(`CloudflareContainerBackend(${this.id}) [stage=auth]: container served an unauthenticated request to /api with ${n}, so this workspace would run without authorization. A container or image predating RPC_CLIENT_SECRET has to be recycled.`)}async#v(e,t,n){let r=Math.max(0,t-Date.now()),i;try{i=await e.fetchPort(this.#e.containerPort,"http://container/connect",{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${n}`},body:JSON.stringify({base:`http://${this.#e.egressHost}`,health:X6t,api:UG,healthTimeoutMs:r})})}catch(s){throw this.#a?.(s),this.#o(),new Ra(`CloudflareContainerBackend(${this.id}) [stage=connect]: POST /connect failed: ${fTe(s)}`,{cause:s})}if(!i.ok){let s=await i.text().catch(()=>""),o=new Error(`/connect ${i.status}`);throw this.#a?.(o),this.#o(),new Ra(`CloudflareContainerBackend(${this.id}) [stage=connect]: POST /connect returned ${i.status}: ${s}`,{cause:o})}}async#h(e){let t=this.#i;if(!t)throw new Error("CloudflareContainerBackend: upgrade promise missing");let n=Math.max(0,e-Date.now()),r;try{return await Promise.race([t,new Promise((i,s)=>{r=setTimeout(()=>s(new Ra(`CloudflareContainerBackend(${this.id}) [stage=ws]: /api upgrade did not arrive within ${this.#e.connectTimeoutMs}ms`)),n)})])}finally{r&&clearTimeout(r),this.#o()}}};function oRt(e){return new Promise(t=>setTimeout(t,e))}a(oRt,"sleep");function fTe(e){return e instanceof Error?e.message:String(e)}a(fTe,"describeError");var hTe="computer:container-client-secret",aRt=16;function lRt(){let e=crypto.getRandomValues(new Uint8Array(aRt));return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}a(lRt,"generate");var cRt=class{static{a(this,"ContainerClientSecret")}storage;constructor(e){this.storage=e}async ensure(){let e=await this.storage.get(hTe);if(typeof e=="string"&&e.length>0)return e;let t=lRt();return await this.storage.put(hTe,t),t}},mTe="computer:container-launch-record";async function gTe(e){return{enableInternet:e.enableInternet,envDigest:await dRt(e.env)}}a(gTe,"launchRecordFor");function uRt(e,t){return e.enableInternet===t.enableInternet&&e.envDigest===t.envDigest}a(uRt,"sameLaunch");async function dRt(e){let t=Object.keys(e).sort().map(r=>`${r.length}:${r}=${e[r]?.length??0}:${e[r]??""}`).join(";"),n=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(n),r=>r.toString(16).padStart(2,"0")).join("")}a(dRt,"digestEnv");var pRt=class{static{a(this,"CurrentContainerLaunchRecord")}storage;constructor(e){this.storage=e}async get(){return await this.storage.get(mTe)??null}async set(e){await this.storage.put(mTe,e)}},yTe=new WeakMap;function WG(e){let t=yTe.get(e);return t===void 0&&(t={exit:null,currentGeneration:0,expectedExitGeneration:null,currentMonitorSettled:null},yTe.set(e,t)),t}a(WG,"getContainerLifecycle");function g$(e){return WG(e).exit}a(g$,"containerExitInfo");function vTe(e){return e===void 0?"exited normally":e instanceof Error?e.message:String(e)}a(vTe,"formatExitReason");function xTe(e,t,n){let r=WG(e);r.currentGeneration+=1;let i=r.currentGeneration;r.exit=null,r.currentMonitorSettled=t.monitor().then(()=>bTe(r,i,void 0,n),s=>bTe(r,i,s,n))}a(xTe,"installContainerMonitor");async function zG(e,t){let n=WG(e);n.expectedExitGeneration=n.currentGeneration;let r=n.currentMonitorSettled;await t.destroy(),r&&await r}a(zG,"destroyContainerExpectingExit");async function bTe(e,t,n,r){if(t!==e.currentGeneration)return;let i=e.expectedExitGeneration===t;i&&(e.expectedExitGeneration=null);let s=vTe(n),o=Date.now();e.exit={reason:s,exitedAt:o},i?console.info({message:"workspace.container.exited",reason:s,exitedAt:o,expected:!0}):console.warn({message:"workspace.container.exited",reason:s,exitedAt:o,expected:!1});try{await r?.()}catch(l){console.error({message:"workspace.container.exit_cleanup_failed",reason:vTe(l),exitedAt:Date.now()})}}a(bTe,"recordExit");var BG="computer:container-runtime-identity",fRt=class{static{a(this,"CurrentContainerRuntimeIdentity")}storage;constructor(e){this.storage=e}async get(){return await this.storage.get(BG)??null}async markStarted(){let e={id:crypto.randomUUID()};return await this.storage.put(BG,e),e}async clear(e){(await this.get())?.id===e.id&&await this.storage.delete(BG)}},hRt=class extends G6t{static{a(this,"WorkspaceContainerAPI")}#e;#t;#r;#n;#i;constructor(e){if(super(),!e.container)throw new Error("WorkspaceContainerAPI: DO is not container-enabled (check wrangler.jsonc)");this.#e=e.container,this.#t=e,this.#r=new fRt(e.storage),this.#n=new cRt(e.storage),this.#i=new pRt(e.storage)}async start(e){let t=g$(this.#t),n=await this.#n.ensure(),r=await gTe(e);if(t!==null){try{await zG(this.#t,this.#e)}catch{}return this.#s(e,n,r,"launched")}if(!this.#e.running)return this.#s(e,n,r,"launched");let i=await this.#i.get();if(i===null||!uRt(i,r)){console.warn({message:i===null?"container was started outside WorkspaceContainerAPI; relaunching so the requested environment applies":"running container was launched with a different spec; relaunching",component:"workspace-container",requested:r,actual:i});try{await zG(this.#t,this.#e)}catch{}return this.#s(e,n,r,"relaunched")}let s=await this.#r.get()??await this.#r.markStarted();return xTe(this.#t,this.#e,()=>this.#r.clear(s)),{runtimeId:s.id,clientSecret:n,outcome:"adopted"}}async restart(e){try{await zG(this.#t,this.#e)}catch{}let t=await this.#n.ensure();return this.#s(e,t,await gTe(e),"launched")}async setInactivityTimeout(e){await this.#e.setInactivityTimeout(e)}async#s(e,t,n,r){let i=await this.#r.markStarted();try{this.#e.start({enableInternet:e.enableInternet,env:{...e.env,RPC_CLIENT_SECRET:t}})}catch(s){throw await this.#r.clear(i),s}return await this.#i.set(n),xTe(this.#t,this.#e,()=>this.#r.clear(i)),{runtimeId:i.id,clientSecret:t,outcome:r}}async status(){return{running:this.#e.running,exit:g$(this.#t)}}async exitInfo(){return g$(this.#t)}async interceptAllOutboundHttp(e,t){let n=this.#t.exports.WorkspaceProxy({props:{...e,egressToken:t}});await Promise.all([this.#e.interceptAllOutboundHttp(n),this.#e.interceptOutboundHttps("*",n)])}async interceptOutboundHttp(e,t){let n=this.#t.exports;await this.#e.interceptOutboundHttp(e,n.WorkspaceProxy({props:t}))}fetchPort(e,t,n){let r=g$(this.#t);if(r!==null)throw new Ra(`container exited: ${r.reason}`);return this.#e.getTcpPort(e).fetch(t,n)}port(e){return this.#e.getTcpPort(e)}};function wTe(e){class t extends e{static{a(this,"WithWorkspaceContainer")}getWorkspaceContainer(){return new hRt(this.ctx)}}return t}a(wTe,"withWorkspaceContainer");var mRt={session:"sessions",skill:"skills",agentPreset:"agentPresets",subagent:"subagents",goal:"goals",event:"events",download:"downloads"};function kTe(e,t){let n=t.indexOf("."),r=t.indexOf("/"),i=n>=0?n:r;if(i<0)return;let s=t.slice(0,i),o=t.slice(i+1),l=mRt[s]??s,c=e[l];if(c===void 0)return;let u=c[o];return typeof u=="function"?u:void 0}a(kTe,"resolve");function gRt(e,t){return Response.json({type:"server-response",rpcId:e,result:{ok:!1,error:t}})}a(gRt,"errorResponse");async function HG(e,t,n,r,i){let s=kTe(e,t);if(s!==void 0)return await s({rpcId:n,payload:r},i)}a(HG,"callEdgeApi");async function ETe(e,t){let r=new URL(t.url).pathname;if(t.method!=="POST"||!r.startsWith("/api/"))return new Response("not found",{status:404});if(r==="/api/respond")return Response.json({accepted:!1,reason:"not-pending"});let i=r.slice(5);if(kTe(e,i)===void 0)return new Response("not found",{status:404});let s;try{s=await t.json()}catch{return new Response("body is not JSON",{status:400})}let o=typeof s.rpcId=="string"?s.rpcId:"invalid-request",l=s.payload??{};try{let c=await HG(e,i,o,l,t.signal);return c===void 0?new Response("not found",{status:404}):Response.json({type:"server-response",rpcId:c.rpcId,result:c.result})}catch(c){return gRt(o,{code:"internal",message:String(c),details:{}})}}a(ETe,"dispatchEdgeApi");Ir();ws();Nf();import{DurableObject as czt}from"cloudflare:workers";var v$=class{constructor(t,n=Date.now,r=2){this.sleepAfterMs=t;this.now=n;this.maxConcurrent=r}sleepAfterMs;now;maxConcurrent;static{a(this,"ContainerActivity")}inFlight=0;lastActivity;stopping;waiters=[];async admit(t){let n=this.now();for(;this.stopping!==void 0||this.inFlight>=this.maxConcurrent;){if(t?.throwIfAborted(),this.stopping!==void 0){await yRt(this.stopping,t);continue}await new Promise((r,i)=>{let s=a(()=>{t?.removeEventListener("abort",o),r()},"wake"),o=a(()=>{let l=this.waiters.indexOf(s);l!==-1&&this.waiters.splice(l,1),i(t.reason)},"abort");this.waiters.push(s),t?.addEventListener("abort",o,{once:!0})})}return t?.aborted===!0&&(this.waiters.shift()?.(),t.throwIfAborted()),{release:this.begin(),queuedMs:this.now()-n}}begin(){this.inFlight+=1,this.lastActivity=this.now();let t=!1;return()=>{t||(t=!0,this.inFlight-=1,this.lastActivity=this.now(),this.waiters.shift()?.())}}async stopIfIdle(t){return this.idle()?await this.stop(t):"busy"}async stopNow(t){return this.inFlight===0?await this.stop(t):"busy"}snapshot(){return{runningCommands:this.inFlight,lastActivityAt:this.lastActivity??null}}async stop(t){if(this.stopping!==void 0)return"busy";let n="stopped",r=t().catch(i=>{n="failed",this.lastActivity=this.now(),console.error("dsh-edge container stop failed.",i)});this.stopping=r;try{await r}finally{this.stopping=void 0}return n}deadline(){return this.inFlight>0?this.now()+this.sleepAfterMs():this.lastActivity===void 0?this.now():this.lastActivity+this.sleepAfterMs()}idle(){return this.inFlight===0&&(this.lastActivity===void 0||this.now()>=this.lastActivity+this.sleepAfterMs())}};function yRt(e,t){return t===void 0?e:new Promise((n,r)=>{let i=a(()=>r(t.reason),"abort");t.addEventListener("abort",i,{once:!0}),e.then(n,r).finally(()=>t.removeEventListener("abort",i))})}a(yRt,"untilAborted");import{WorkerEntrypoint as xTn}from"cloudflare:workers";var p1=Al(_Te());var VG=a((e,t,n)=>{let r=e instanceof RegExp?TTe(e,n):e,i=t instanceof RegExp?TTe(t,n):t,s=r!==null&&i!=null&&vRt(r,i,n);return s&&{start:s[0],end:s[1],pre:n.slice(0,s[0]),body:n.slice(s[0]+r.length,s[1]),post:n.slice(s[1]+i.length)}},"balanced"),TTe=a((e,t)=>{let n=t.match(e);return n?n[0]:null},"maybeMatch"),vRt=a((e,t,n)=>{let r,i,s,o,l,c=n.indexOf(e),u=n.indexOf(t,c+1),d=c;if(c>=0&&u>0){if(e===t)return[c,u];for(r=[],s=n.length;d>=0&&!l;){if(d===c)r.push(d),c=n.indexOf(e,d+1);else if(r.length===1){let p=r.pop();p!==void 0&&(l=[p,u])}else i=r.pop(),i!==void 0&&i<s&&(s=i,o=u),u=n.indexOf(t,d+1);d=c<u&&c>=0?c:u}r.length&&o!==void 0&&(l=[s,o])}return l},"range");var ITe="\0SLASH"+Math.random()+"\0",ATe="\0OPEN"+Math.random()+"\0",KG="\0CLOSE"+Math.random()+"\0",CTe="\0COMMA"+Math.random()+"\0",RTe="\0PERIOD"+Math.random()+"\0",xRt=new RegExp(ITe,"g"),bRt=new RegExp(ATe,"g"),wRt=new RegExp(KG,"g"),SRt=new RegExp(CTe,"g"),kRt=new RegExp(RTe,"g"),ERt=/\\\\/g,_Rt=/\\{/g,TRt=/\\}/g,IRt=/\\,/g,ARt=/\\\./g,CRt=1e5,RRt=4e6;function GG(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}a(GG,"numeric");function $Rt(e){return e.replace(ERt,ITe).replace(_Rt,ATe).replace(TRt,KG).replace(IRt,CTe).replace(ARt,RTe)}a($Rt,"escapeBraces");function ORt(e){return e.replace(xRt,"\\").replace(bRt,"{").replace(wRt,"}").replace(SRt,",").replace(kRt,".")}a(ORt,"unescapeBraces");function $Te(e){if(!e)return[""];let t=[],n=VG("{","}",e);if(!n)return e.split(",");let{pre:r,body:i,post:s}=n,o=r.split(",");o[o.length-1]+="{"+i+"}";let l=$Te(s);return s.length&&(o[o.length-1]+=l.shift(),o.push.apply(o,l)),t.push.apply(t,o),t}a($Te,"parseCommaParts");function OTe(e,t={}){if(!e)return[];let{max:n=CRt,maxLength:r=RRt}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),ZG($Rt(e),n,r,!0).map(ORt)}a(OTe,"expand");function PRt(e){return"{"+e+"}"}a(PRt,"embrace");function NRt(e){return/^-?0\d/.test(e)}a(NRt,"isPadded");function DRt(e,t){return e<=t}a(DRt,"lte");function MRt(e,t){return e>=t}a(MRt,"gte");function Ok(e,t,n,r,i,s){let o=[],l=0;for(let c=0;c<e.length;c++)for(let u=0;u<n.length;u++){if(o.length>=r)return o;let d=e[c]+t+n[u];if(!(s&&!d)){if(l+d.length>i)return o;o.push(d),l+=d.length}}return o}a(Ok,"combine");function LRt(e,t,n,r){let i=e.split(/\.\./),s=[];if(i[0]===void 0||i[1]===void 0)return s;let o=GG(i[0]),l=GG(i[1]),c=Math.max(i[0].length,i[1].length),u=i.length===3&&i[2]!==void 0?Math.max(Math.abs(GG(i[2])),1):1,d=DRt;l<o&&(u*=-1,d=MRt);let h=i.some(NRt),f=0;for(let g=o;d(g,l)&&s.length<n;g+=u){let y;if(t)y=String.fromCharCode(g),y==="\\"&&(y="");else if(y=String(g),h){let v=c-y.length;if(v>0){let w=new Array(v+1).join("0");g<0?y="-"+w+y.slice(1):y=w+y}}if(f+y.length>r)break;s.push(y),f+=y.length}return s}a(LRt,"expandSequence");function ZG(e,t,n,r){let i=[""],s=!1,o=!0;for(;;){let l=VG("{","}",e);if(!l)return Ok(i,e,[""],t,n,s);let c=l.pre;if(/\$$/.test(c)){if(i=Ok(i,c+"{"+l.body+"}",[""],t,n,s&&!l.post.length),o=!1,!l.post.length)break;e=l.post;continue}let u=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(l.body),d=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(l.body),p=u||d,h=l.body.indexOf(",")>=0;if(!p&&!h){if(l.post.match(/,(?!,).*\}/)){e=l.pre+"{"+l.body+KG+l.post,r=!0;continue}return Ok(i,c+"{"+l.body+"}"+l.post,[""],t,n,s)}o&&(s=r&&!p,o=!1);let f;if(p)f=LRt(l.body,d,t,n);else{let g=$Te(l.body);if(g.length===1&&g[0]!==void 0&&(g=ZG(g[0],t,n,!1).map(PRt),g.length===1)){if(i=Ok(i,c+g[0],[""],t,n,s&&!l.post.length),!l.post.length)break;e=l.post;continue}let y=s&&!l.post.length&&!c;for(let w=0;y&&w<i.length;w++)i[w]&&(y=!1);f=[];let v=0;e:for(let w=0;w<g.length;w++){let b=ZG(g[w],t,n,!1);for(let S=0;S<b.length;S++){let k=b[S];if(!(y&&!k)){if(f.length>=t||v+k.length>n)break e;f.push(k),v+=k.length}}}}if(i=Ok(i,c,f,t,n,s&&!l.post.length),!l.post.length)break;e=l.post}return i}a(ZG,"expand_");var Pk=a(e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")},"assertValidPattern");var FRt={"[: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]},Nk=a(e=>e.replace(/[[\]\\-]/g,"\\$&"),"braceEscape"),jRt=a(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regexpEscape"),PTe=a(e=>e.join(""),"rangesToString"),NTe=a((e,t)=>{let n=t;if(e.charAt(n)!=="[")throw new Error("not in a brace expression");let r=[],i=[],s=n+1,o=!1,l=!1,c=!1,u=!1,d=n,p="";e:for(;s<e.length;){let y=e.charAt(s);if((y==="!"||y==="^")&&s===n+1){u=!0,s++;continue}if(y==="]"&&o&&!c){d=s+1;break}if(o=!0,y==="\\"&&!c){c=!0,s++;continue}if(y==="["&&!c){for(let[v,[w,b,S]]of Object.entries(FRt))if(e.startsWith(v,s)){if(p)return["$.",!1,e.length-n,!0];s+=v.length,S?i.push(w):r.push(w),l=l||b;continue e}}if(c=!1,p){y>p?r.push(Nk(p)+"-"+Nk(y)):y===p&&r.push(Nk(y)),p="",s++;continue}if(e.startsWith("-]",s+1)){r.push(Nk(y+"-")),s+=2;continue}if(e.startsWith("-",s+1)){p=y,s+=2;continue}r.push(Nk(y)),s++}if(d<s)return["",!1,0,!1];if(!r.length&&!i.length)return["$.",!1,e.length-n,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!u){let y=r[0].length===2?r[0].slice(-1):r[0];return[jRt(y),!1,d-n,!1]}let h="["+(u?"^":"")+PTe(r)+"]",f="["+(u?"":"^")+PTe(i)+"]";return[r.length&&i.length?"("+h+"|"+f+")":r.length?h:f,l,d-n,!0]},"parseClass");var Ih=a((e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!0}={})=>n?t?e.replace(/\[([^/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?e.replace(/\[([^/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1"),"unescape");var gl,qRt=new Set(["!","?","+","*","@"]),JG=a(e=>qRt.has(e),"isExtglobType"),DTe=a(e=>JG(e.type),"isExtglobAST"),URt=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),zRt=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),BRt=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),MTe=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),WRt="(?!(?:^|/)\\.\\.?(?:$|/))",b$="(?!\\.)",HRt=new Set(["[","."]),VRt=new Set(["..","."]),GRt=new Set("().*{}+?[]^$\\!"),ZRt=a(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),XG="[^/]",LTe=XG+"*?",FTe=XG+"+?",KRt=0,Dg=class{static{a(this,"AST")}type;#e;#t;#r=!1;#n=[];#i;#s;#a;#l=!1;#u;#o;#p=!1;id=++KRt;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#n.length,parts:this.#n}}constructor(t,n,r={}){this.type=t,t&&(this.#t=!0),this.#i=n,this.#e=this.#i?this.#i.#e:this,this.#u=this.#e===this?r:this.#e.#u,this.#a=this.#e===this?[]:this.#e.#a,t==="!"&&!this.#e.#l&&this.#a.push(this),this.#s=this.#i?this.#i.#n.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let t of this.#n)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#o!==void 0?this.#o:this.type?this.#o=this.type+"("+this.#n.map(t=>String(t)).join("|")+")":this.#o=this.#n.map(t=>String(t)).join("")}#m(){if(this!==this.#e)throw new Error("should only call on root");if(this.#l)return this;this.toString(),this.#l=!0;let t;for(;t=this.#a.pop();){if(t.type!=="!")continue;let n=t,r=n.#i;for(;r;){for(let i=n.#s+1;!r.type&&i<r.#n.length;i++)for(let s of t.#n){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(r.#n[i])}n=r,r=n.#i}}return this}push(...t){for(let n of t)if(n!==""){if(typeof n!="string"&&!(n instanceof gl&&n.#i===this))throw new Error("invalid part: "+n);this.#n.push(n)}}toJSON(){let t=this.type===null?this.#n.slice().map(n=>typeof n=="string"?n:n.toJSON()):[this.type,...this.#n.map(n=>n.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#l&&this.#i?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#s===0)return!0;let t=this.#i;for(let n=0;n<this.#s;n++){let r=t.#n[n];if(!(r instanceof gl&&r.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let t=this.#i?this.#i.#n.length:0;return this.#s===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let n=new gl(this.type,t);for(let r of this.#n)n.copyIn(r);return n}static#d(t,n,r,i,s){let o=i.maxExtglobRecursion??2,l=!1,c=!1,u=-1,d=!1;if(n.type===null){let y=r,v="";for(;y<t.length;){let w=t.charAt(y++);if(l||w==="\\"){l=!l,v+=w;continue}if(c){y===u+1?(w==="^"||w==="!")&&(d=!0):w==="]"&&!(y===u+2&&d)&&(c=!1),v+=w;continue}else if(w==="["){c=!0,u=y,d=!1,v+=w;continue}if(!i.noext&&JG(w)&&t.charAt(y)==="("&&s<=o){n.push(v),v="";let S=new gl(w,n);y=gl.#d(t,S,y,i,s+1),n.push(S);continue}v+=w}return n.push(v),y}let p=r+1,h=new gl(null,n),f=[],g="";for(;p<t.length;){let y=t.charAt(p++);if(l||y==="\\"){l=!l,g+=y;continue}if(c){p===u+1?(y==="^"||y==="!")&&(d=!0):y==="]"&&!(p===u+2&&d)&&(c=!1),g+=y;continue}else if(y==="["){c=!0,u=p,d=!1,g+=y;continue}if(!i.noext&&JG(y)&&t.charAt(p)==="("&&(s<=o||n&&n.#h(y))){let w=n&&n.#h(y)?0:1;h.push(g),g="";let b=new gl(y,h);h.push(b),p=gl.#d(t,b,p,i,s+w);continue}if(y==="|"){h.push(g),g="",f.push(h),h=new gl(null,n);continue}if(y===")")return g===""&&n.#n.length===0&&(n.#p=!0),h.push(g),g="",n.push(...f,h),p;g+=y}return n.type=null,n.#t=void 0,n.#n=[t.substring(r-1)],p}#f(t){return this.#v(t,zRt)}#v(t,n=URt){if(!t||typeof t!="object"||t.type!==null||t.#n.length!==1||this.type===null)return!1;let r=t.#n[0];return!r||typeof r!="object"||r.type===null?!1:this.#h(r.type,n)}#h(t,n=BRt){return!!n.get(this.type)?.includes(t)}#O(t,n){let r=t.#n[0],i=new gl(null,r,this.options);i.#n.push(""),r.push(i),this.#x(t,n)}#x(t,n){let r=t.#n[0];this.#n.splice(n,1,...r.#n);for(let i of r.#n)typeof i=="object"&&(i.#i=this);this.#o=void 0}#E(t){return!!MTe.get(this.type)?.has(t)}#_(t){if(!t||typeof t!="object"||t.type!==null||t.#n.length!==1||this.type===null||this.#n.length!==1)return!1;let n=t.#n[0];return!n||typeof n!="object"||n.type===null?!1:this.#E(n.type)}#T(t){let n=MTe.get(this.type),r=t.#n[0],i=n?.get(r.type);if(!i)return!1;this.#n=r.#n;for(let s of this.#n)typeof s=="object"&&(s.#i=this);this.type=i,this.#o=void 0,this.#p=!1}static fromGlob(t,n={}){let r=new gl(null,void 0,n);return gl.#d(t,r,0,n,0),r}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[n,r,i,s]=this.toRegExpSource();if(!(i||this.#t||this.#u.nocase&&!this.#u.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return r;let l=(this.#u.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${n}$`,l),{_src:n,_glob:t})}get options(){return this.#u}toRegExpSource(t){let n=t??!!this.#u.dot;if(this.#e===this&&(this.#c(),this.#m()),!DTe(this)){let c=this.isStart()&&this.isEnd()&&!this.#n.some(f=>typeof f!="string"),u=this.#n.map(f=>{let[g,y,v,w]=typeof f=="string"?gl.#b(f,this.#t,c):f.toRegExpSource(t);return this.#t=this.#t||v,this.#r=this.#r||w,g}).join(""),d="";if(this.isStart()&&typeof this.#n[0]=="string"&&!(this.#n.length===1&&VRt.has(this.#n[0]))){let g=HRt,y=n&&g.has(u.charAt(0))||u.startsWith("\\.")&&g.has(u.charAt(2))||u.startsWith("\\.\\.")&&g.has(u.charAt(4)),v=!n&&!t&&g.has(u.charAt(0));d=y?WRt:v?b$:""}let p="";return this.isEnd()&&this.#e.#l&&this.#i?.type==="!"&&(p="(?:$|\\/)"),[d+u+p,Ih(u),this.#t=!!this.#t,this.#r]}let r=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#g(n);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let c=this.toString(),u=this;return u.#n=[c],u.type=null,u.#t=void 0,[c,Ih(this.toString()),!1,!1]}let o=!r||t||n||!b$?"":this.#g(!0);o===s&&(o=""),o&&(s=`(?:${s})(?:${o})*?`);let l="";if(this.type==="!"&&this.#p)l=(this.isStart()&&!n?b$:"")+FTe;else{let c=this.type==="!"?"))"+(this.isStart()&&!n&&!t?b$:"")+LTe+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;l=i+s+c}return[l,Ih(s),this.#t=!!this.#t,this.#r]}#c(){if(DTe(this)){let t=0,n=!1;do{n=!0;for(let r=0;r<this.#n.length;r++){let i=this.#n[r];typeof i=="object"&&(i.#c(),this.#v(i)?(n=!1,this.#x(i,r)):this.#f(i)?(n=!1,this.#O(i,r)):this.#_(i)&&(n=!1,this.#T(i)))}}while(!n&&++t<10)}else for(let t of this.#n)typeof t=="object"&&t.#c();this.#o=void 0}#g(t){return this.#n.map(n=>{if(typeof n=="string")throw new Error("string type in extglob ast??");let[r,i,s,o]=n.toRegExpSource(t);return this.#r=this.#r||o,r}).filter(n=>!(this.isStart()&&this.isEnd())||!!n).join("|")}static#b(t,n,r=!1){let i=!1,s="",o=!1,l=!1;for(let c=0;c<t.length;c++){let u=t.charAt(c);if(i){i=!1,s+=(GRt.has(u)?"\\":"")+u;continue}if(u==="*"){if(l)continue;l=!0,s+=r&&/^[*]+$/.test(t)?FTe:LTe,n=!0;continue}else l=!1;if(u==="\\"){c===t.length-1?s+="\\\\":i=!0;continue}if(u==="["){let[d,p,h,f]=NTe(t,c);if(h){s+=d,o=o||p,c+=h-1,n=n||f;continue}}if(u==="?"){s+=XG,n=!0;continue}s+=ZRt(u)}return[s,Ih(t),!!n,o]}};gl=Dg;var YG=a((e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!1}={})=>n?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&"),"escape");var $o=a((e,t,n={})=>(Pk(t),!n.nocomment&&t.charAt(0)==="#"?!1:new ov(t,n).match(e)),"minimatch"),JRt=/^\*+([^+@!?*[(]*)$/,XRt=a(e=>t=>!t.startsWith(".")&&t.endsWith(e),"starDotExtTest"),YRt=a(e=>t=>t.endsWith(e),"starDotExtTestDot"),QRt=a(e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),"starDotExtTestNocase"),e$t=a(e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),"starDotExtTestNocaseDot"),t$t=/^\*+\.\*+$/,n$t=a(e=>!e.startsWith(".")&&e.includes("."),"starDotStarTest"),r$t=a(e=>e!=="."&&e!==".."&&e.includes("."),"starDotStarTestDot"),i$t=/^\.\*+$/,s$t=a(e=>e!=="."&&e!==".."&&e.startsWith("."),"dotStarTest"),o$t=/^\*+$/,a$t=a(e=>e.length!==0&&!e.startsWith("."),"starTest"),l$t=a(e=>e.length!==0&&e!=="."&&e!=="..","starTestDot"),c$t=/^\?+([^+@!?*[(]*)?$/,u$t=a(([e,t=""])=>{let n=UTe([e]);return t?(t=t.toLowerCase(),r=>n(r)&&r.toLowerCase().endsWith(t)):n},"qmarksTestNocase"),d$t=a(([e,t=""])=>{let n=zTe([e]);return t?(t=t.toLowerCase(),r=>n(r)&&r.toLowerCase().endsWith(t)):n},"qmarksTestNocaseDot"),p$t=a(([e,t=""])=>{let n=zTe([e]);return t?r=>n(r)&&r.endsWith(t):n},"qmarksTestDot"),f$t=a(([e,t=""])=>{let n=UTe([e]);return t?r=>n(r)&&r.endsWith(t):n},"qmarksTest"),UTe=a(([e])=>{let t=e.length;return n=>n.length===t&&!n.startsWith(".")},"qmarksTestNoExt"),zTe=a(([e])=>{let t=e.length;return n=>n.length===t&&n!=="."&&n!==".."},"qmarksTestNoExtDot"),BTe=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",jTe={win32:{sep:"\\"},posix:{sep:"/"}},h$t=BTe==="win32"?jTe.win32.sep:jTe.posix.sep;$o.sep=h$t;var _a=Symbol("globstar **");$o.GLOBSTAR=_a;var m$t="[^/]",g$t=m$t+"*?",y$t="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",v$t="(?:(?!(?:\\/|^)\\.).)*?",x$t=a((e,t={})=>n=>$o(n,e,t),"filter");$o.filter=x$t;var $c=a((e,t={})=>Object.assign({},e,t),"ext"),b$t=a(e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return $o;let t=$o;return Object.assign(a((r,i,s={})=>t(r,i,$c(e,s)),"m"),{Minimatch:class extends t.Minimatch{static{a(this,"Minimatch")}constructor(i,s={}){super(i,$c(e,s))}static defaults(i){return t.defaults($c(e,i)).Minimatch}},AST:class extends t.AST{static{a(this,"AST")}constructor(i,s,o={}){super(i,s,$c(e,o))}static fromGlob(i,s={}){return t.AST.fromGlob(i,$c(e,s))}},unescape:a((r,i={})=>t.unescape(r,$c(e,i)),"unescape"),escape:a((r,i={})=>t.escape(r,$c(e,i)),"escape"),filter:a((r,i={})=>t.filter(r,$c(e,i)),"filter"),defaults:a(r=>t.defaults($c(e,r)),"defaults"),makeRe:a((r,i={})=>t.makeRe(r,$c(e,i)),"makeRe"),braceExpand:a((r,i={})=>t.braceExpand(r,$c(e,i)),"braceExpand"),match:a((r,i,s={})=>t.match(r,i,$c(e,s)),"match"),sep:t.sep,GLOBSTAR:_a})},"defaults");$o.defaults=b$t;var WTe=a((e,t={})=>(Pk(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:OTe(e,{max:t.braceExpandMax})),"braceExpand");$o.braceExpand=WTe;var w$t=a((e,t={})=>new ov(e,t).makeRe(),"makeRe");$o.makeRe=w$t;var S$t=a((e,t,n={})=>{let r=new ov(t,n);return e=e.filter(i=>r.match(i)),r.options.nonull&&!e.length&&e.push(t),e},"match");$o.match=S$t;var qTe=/[?*]|[+@!]\(.*?\)|\[|\]/,k$t=a(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),ov=class{static{a(this,"Minimatch")}options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,n={}){Pk(t),n=n||{},this.options=n,this.maxGlobstarRecursion=n.maxGlobstarRecursion??200,this.pattern=t,this.platform=n.platform||BTe,this.isWindows=this.platform==="win32";let r="allowWindowsEscape";this.windowsPathsNoEscape=!!n.windowsPathsNoEscape||n[r]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!n.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!n.nonegate,this.comment=!1,this.empty=!1,this.partial=!!n.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=n.windowsNoMagicRoot!==void 0?n.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let n of t)if(typeof n!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,n=this.options;if(!n.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],n.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let r=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(r),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,o,l)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=s[0]===""&&s[1]===""&&(s[2]==="?"||!qTe.test(s[2]))&&!qTe.test(s[3]),u=/^[a-z]:/i.test(s[0]);if(c)return[...s.slice(0,4),...s.slice(4).map(d=>this.parse(d))];if(u)return[s[0],...s.slice(1).map(d=>this.parse(d))]}return s.map(c=>this.parse(c))});if(this.debug(this.pattern,i),this.set=i.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let o=this.set[s];o[0]===""&&o[1]===""&&this.globParts[s][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let r of t)for(let i=0;i<r.length;i++)r[i]==="**"&&(r[i]="*");let{optimizationLevel:n=1}=this.options;return n>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):n>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(n=>{let r=-1;for(;(r=n.indexOf("**",r+1))!==-1;){let i=r;for(;n[i+1]==="**";)i++;i!==r&&n.splice(r,i-r)}return n})}levelOneOptimize(t){return t.map(n=>(n=n.reduce((r,i)=>{let s=r[r.length-1];return i==="**"&&s==="**"?r:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(r.pop(),r):(r.push(i),r)},[]),n.length===0?[""]:n))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let n=!1;do{if(n=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let s=t[i];i===1&&s===""&&t[0]===""||(s==="."||s==="")&&(n=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(n=!0,t.pop())}let r=0;for(;(r=t.indexOf("..",r+1))!==-1;){let i=t[r-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(n=!0,t.splice(r-1,2),r-=2)}}while(n);return t.length===0?[""]:t}firstPhasePreProcess(t){let n=!1;do{n=!1;for(let r of t){let i=-1;for(;(i=r.indexOf("**",i+1))!==-1;){let o=i;for(;r[o+1]==="**";)o++;o>i&&r.splice(i+1,o-i);let l=r[i+1],c=r[i+2],u=r[i+3];if(l!==".."||!c||c==="."||c===".."||!u||u==="."||u==="..")continue;n=!0,r.splice(i,1);let d=r.slice(0);d[i]="**",t.push(d),i--}if(!this.preserveMultipleSlashes){for(let o=1;o<r.length-1;o++){let l=r[o];o===1&&l===""&&r[0]===""||(l==="."||l==="")&&(n=!0,r.splice(o,1),o--)}r[0]==="."&&r.length===2&&(r[1]==="."||r[1]==="")&&(n=!0,r.pop())}let s=0;for(;(s=r.indexOf("..",s+1))!==-1;){let o=r[s-1];if(o&&o!=="."&&o!==".."&&o!=="**"){n=!0;let c=s===1&&r[s+1]==="**"?["."]:[];r.splice(s-1,2,...c),r.length===0&&r.push(""),s-=2}}}}while(n);return t}secondPhasePreProcess(t){for(let n=0;n<t.length-1;n++)for(let r=n+1;r<t.length;r++){let i=this.partsMatch(t[n],t[r],!this.preserveMultipleSlashes);if(i){t[n]=[],t[r]=i;break}}return t.filter(n=>n.length)}partsMatch(t,n,r=!1){let i=0,s=0,o=[],l="";for(;i<t.length&&s<n.length;)if(t[i]===n[s])o.push(l==="b"?n[s]:t[i]),i++,s++;else if(r&&t[i]==="**"&&n[s]===t[i+1])o.push(t[i]),i++;else if(r&&n[s]==="**"&&t[i]===n[s+1])o.push(n[s]),s++;else if(t[i]==="*"&&n[s]&&(this.options.dot||!n[s].startsWith("."))&&n[s]!=="**"){if(l==="b")return!1;l="a",o.push(t[i]),i++,s++}else if(n[s]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(l==="a")return!1;l="b",o.push(n[s]),i++,s++}else return!1;return t.length===n.length&&o}parseNegate(){if(this.nonegate)return;let t=this.pattern,n=!1,r=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)n=!n,r++;r&&(this.pattern=t.slice(r)),this.negate=n}matchOne(t,n,r=!1){let i=0,s=0;if(this.isWindows){let l=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),c=!l&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),u=typeof n[0]=="string"&&/^[a-z]:$/i.test(n[0]),d=!u&&n[0]===""&&n[1]===""&&n[2]==="?"&&typeof n[3]=="string"&&/^[a-z]:$/i.test(n[3]),p=c?3:l?0:void 0,h=d?3:u?0:void 0;if(typeof p=="number"&&typeof h=="number"){let[f,g]=[t[p],n[h]];f.toLowerCase()===g.toLowerCase()&&(n[h]=f,s=h,i=p)}}let{optimizationLevel:o=1}=this.options;return o>=2&&(t=this.levelTwoFileOptimize(t)),n.includes(_a)?this.#e(t,n,r,i,s):this.#r(t,n,r,i,s)}#e(t,n,r,i,s){let o=n.indexOf(_a,s),l=n.lastIndexOf(_a),[c,u,d]=r?[n.slice(s,o),n.slice(o+1),[]]:[n.slice(s,o),n.slice(o+1,l),n.slice(l+1)];if(c.length){let b=t.slice(i,i+c.length);if(!this.#r(b,c,r,0,0))return!1;i+=c.length,s+=c.length}let p=0;if(d.length){if(d.length+i>t.length)return!1;let b=t.length-d.length;if(this.#r(t,d,r,b,0))p=d.length;else{if(t[t.length-1]!==""||i+d.length===t.length||(b--,!this.#r(t,d,r,b,0)))return!1;p=d.length+1}}if(!u.length){let b=!!p;for(let S=i;S<t.length-p;S++){let k=String(t[S]);if(b=!0,k==="."||k===".."||!this.options.dot&&k.startsWith("."))return!1}return r||b}let h=[[[],0]],f=h[0],g=0,y=[0];for(let b of u)b===_a?(y.push(g),f=[[],0],h.push(f)):(f[0].push(b),g++);let v=h.length-1,w=t.length-p;for(let b of h)b[1]=w-(y[v--]+b[0].length);return!!this.#t(t,h,i,0,r,0,!!p)}#t(t,n,r,i,s,o,l){let c=n[i];if(!c){for(let p=r;p<t.length;p++){l=!0;let h=t[p];if(h==="."||h===".."||!this.options.dot&&h.startsWith("."))return!1}return l}let[u,d]=c;for(;r<=d;){if(this.#r(t.slice(0,r+u.length),u,s,r,0)&&o<this.maxGlobstarRecursion){let f=this.#t(t,n,r+u.length,i+1,s,o+1,l);if(f!==!1)return f}let h=t[r];if(h==="."||h===".."||!this.options.dot&&h.startsWith("."))return!1;r++}return s||null}#r(t,n,r,i,s){let o,l,c,u;for(o=i,l=s,u=t.length,c=n.length;o<u&&l<c;o++,l++){this.debug("matchOne loop");let d=n[l],p=t[o];if(this.debug(n,d,p),d===!1||d===_a)return!1;let h;if(typeof d=="string"?(h=p===d,this.debug("string match",d,p,h)):(h=d.test(p),this.debug("pattern match",d,p,h)),!h)return!1}if(o===u&&l===c)return!0;if(o===u)return r;if(l===c)return o===u-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return WTe(this.pattern,this.options)}parse(t){Pk(t);let n=this.options;if(t==="**")return _a;if(t==="")return"";let r,i=null;(r=t.match(o$t))?i=n.dot?l$t:a$t:(r=t.match(JRt))?i=(n.nocase?n.dot?e$t:QRt:n.dot?YRt:XRt)(r[1]):(r=t.match(c$t))?i=(n.nocase?n.dot?d$t:u$t:n.dot?p$t:f$t)(r):(r=t.match(t$t))?i=n.dot?r$t:n$t:(r=t.match(i$t))&&(i=s$t);let s=Dg.fromGlob(t,this.options).toMMPattern();return i&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:i}),s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let n=this.options,r=n.noglobstar?g$t:n.dot?y$t:v$t,i=new Set(n.nocase?["i"]:[]),s=t.map(c=>{let u=c.map(p=>{if(p instanceof RegExp)for(let h of p.flags.split(""))i.add(h);return typeof p=="string"?k$t(p):p===_a?_a:p._src});u.forEach((p,h)=>{let f=u[h+1],g=u[h-1];p!==_a||g===_a||(g===void 0?f!==void 0&&f!==_a?u[h+1]="(?:\\/|"+r+"\\/)?"+f:u[h]=r:f===void 0?u[h-1]=g+"(?:\\/|\\/"+r+")?":f!==_a&&(u[h-1]=g+"(?:\\/|\\/"+r+"\\/)"+f,u[h+1]=_a))});let d=u.filter(p=>p!==_a);if(this.partial&&d.length>=1){let p=[];for(let h=1;h<=d.length;h++)p.push(d.slice(0,h).join("/"));return"(?:"+p.join("|")+")"}return d.join("/")}).join("|"),[o,l]=t.length>1?["(?:",")"]:["",""];s="^"+o+s+l+"$",this.partial&&(s="^(?:\\/|"+o+s.slice(1,-1)+l+")$"),this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,n=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&n)return!0;let r=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let s=this.set;this.debug(this.pattern,"set",s);let o=i[i.length-1];if(!o)for(let l=i.length-2;!o&&l>=0;l--)o=i[l];for(let l of s){let c=i;if(r.matchBase&&l.length===1&&(c=[o]),this.matchOne(c,l,n))return r.flipNegate?!0:!this.negate}return r.flipNegate?!1:this.negate}static defaults(t){return $o.defaults(t).Minimatch}};$o.AST=Dg;$o.Minimatch=ov;$o.escape=YG;$o.unescape=Ih;import{gunzipSync as A4t}from"node:zlib";var Dk=class{static{a(this,"Diff")}diff(t,n,r={}){let i;typeof r=="function"?(i=r,r={}):"callback"in r&&(i=r.callback);let s=this.castInput(t,r),o=this.castInput(n,r),l=this.removeEmpty(this.tokenize(s,r)),c=this.removeEmpty(this.tokenize(o,r));return this.diffWithOptionsObj(l,c,r,i)}diffWithOptionsObj(t,n,r,i){var s;let o=a(b=>{if(b=this.postProcess(b,r),i){setTimeout(function(){i(b)},0);return}else return b},"done"),l=n.length,c=t.length,u=1,d=l+c;r.maxEditLength!=null&&(d=Math.min(d,r.maxEditLength));let p=(s=r.timeout)!==null&&s!==void 0?s:1/0,h=Date.now()+p,f=[{oldPos:-1,lastComponent:void 0}],g=this.extractCommon(f[0],n,t,0,r);if(f[0].oldPos+1>=c&&g+1>=l)return o(this.buildValues(f[0].lastComponent,n,t));let y=-1/0,v=1/0,w=a(()=>{for(let b=Math.max(y,-u);b<=Math.min(v,u);b+=2){let S,k=f[b-1],E=f[b+1];k&&(f[b-1]=void 0);let T=!1;if(E){let N=E.oldPos-b;T=E&&0<=N&&N<l}let I=k&&k.oldPos+1<c;if(!T&&!I){f[b]=void 0;continue}if(!I||T&&k.oldPos<E.oldPos?S=this.addToPath(E,!0,!1,0,r):S=this.addToPath(k,!1,!0,1,r),g=this.extractCommon(S,n,t,b,r),S.oldPos+1>=c&&g+1>=l)return o(this.buildValues(S.lastComponent,n,t))||!0;f[b]=S,S.oldPos+1>=c&&(v=Math.min(v,b-1)),g+1>=l&&(y=Math.max(y,b+1))}u++},"execEditLength");if(i)a(function b(){setTimeout(function(){if(u>d||Date.now()>h)return i(void 0);w()||b()},0)},"exec")();else for(;u<=d&&Date.now()<=h;){let b=w();if(b)return b}}addToPath(t,n,r,i,s){let o=t.lastComponent;return o&&!s.oneChangePerToken&&o.added===n&&o.removed===r?{oldPos:t.oldPos+i,lastComponent:{count:o.count+1,added:n,removed:r,previousComponent:o.previousComponent}}:{oldPos:t.oldPos+i,lastComponent:{count:1,added:n,removed:r,previousComponent:o}}}extractCommon(t,n,r,i,s){let o=n.length,l=r.length,c=t.oldPos,u=c-i,d=0;for(;u+1<o&&c+1<l&&this.equals(r[c+1],n[u+1],s);)u++,c++,d++,s.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return d&&!s.oneChangePerToken&&(t.lastComponent={count:d,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=c,u}equals(t,n,r){return r.comparator?r.comparator(t,n):t===n||!!r.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){let n=[];for(let r=0;r<t.length;r++)t[r]&&n.push(t[r]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,r){let i=[],s;for(;t;)i.push(t),s=t.previousComponent,delete t.previousComponent,t=s;i.reverse();let o=i.length,l=0,c=0,u=0;for(;l<o;l++){let d=i[l];if(d.removed)d.value=this.join(r.slice(u,u+d.count)),u+=d.count;else{if(!d.added&&this.useLongestToken){let p=n.slice(c,c+d.count);p=p.map(function(h,f){let g=r[u+f];return g.length>h.length?g:h}),d.value=this.join(p)}else d.value=this.join(n.slice(c,c+d.count));c+=d.count,d.added||(u+=d.count)}}return i}};var QG=class extends Dk{static{a(this,"LineDiff")}constructor(){super(...arguments),this.tokenize=_$t}equals(t,n,r){return r.ignoreWhitespace?((!r.newlineIsToken||!t.includes(`
4997
4997
  `))&&(t=t.trim()),(!r.newlineIsToken||!n.includes(`
4998
4998
  `))&&(n=n.trim())):r.ignoreNewlineAtEof&&!r.newlineIsToken&&(t.endsWith(`
4999
4999
  `)&&(t=t.slice(0,-1)),n.endsWith(`