import{d as s,r as e,c as t,e as i}from"../../nitro/nitro.mjs";import{promises as o}from"fs";import r from"path";import"node:http";import"node:https";import"node:crypto";import"stream";import"events";import"http";import"crypto";import"buffer";import"zlib";import"https";import"net";import"tls";import"url";import"node:events";import"node:buffer";import"node:fs";import"node:path";import"chokidar";import"@anthropic-ai/claude-code";import"fs/promises";import"readline";import"node:url";const a=s(async s=>{try{const a=await e(s),{projectId:n,settings:p}=a;if(!n)throw t({statusCode:400,statusMessage:"Project ID required"});if(!p)throw t({statusCode:400,statusMessage:"Settings data required"});const d=await i(n),m=r.join(d,".claude"),c=r.join(m,"settings.json");try{await o.mkdir(m,{recursive:!0})}catch(s){if("EEXIST"!==s.code)throw s}const l={};if(p.env&&"object"==typeof p.env&&(l.env=p.env),"boolean"==typeof p.includeCoAuthoredBy&&(l.includeCoAuthoredBy=p.includeCoAuthoredBy),"number"==typeof p.cleanupPeriodDays&&p.cleanupPeriodDays>0&&(l.cleanupPeriodDays=p.cleanupPeriodDays),p.permissions&&"object"==typeof p.permissions){if(l.permissions={},"string"==typeof p.permissions.defaultMode){["default","acceptEdits","plan","bypassPermissions"].includes(p.permissions.defaultMode)&&(l.permissions.defaultMode=p.permissions.defaultMode)}Array.isArray(p.permissions.allow)&&(l.permissions.allow=p.permissions.allow.filter(s=>"string"==typeof s&&s.trim())),Array.isArray(p.permissions.deny)&&(l.permissions.deny=p.permissions.deny.filter(s=>"string"==typeof s&&s.trim())),Array.isArray(p.permissions.additionalDirectories)&&(l.permissions.additionalDirectories=p.permissions.additionalDirectories.filter(s=>"string"==typeof s&&s.trim()))}return await o.writeFile(c,JSON.stringify(l,null,2),"utf8"),{success:!0,message:"Settings saved successfully"}}catch(s){throw t({statusCode:s.statusCode||500,statusMessage:s.message||"Failed to save project settings"})}});export{a as default};
//# sourceMappingURL=project-settings.post.mjs.map
