// @bun
import {
  SandboxManager,
  Select,
  addToExcludedCommands,
  init_sandbox_adapter,
  init_select,
  shouldAllowManagedSandboxDomainsOnly
} from "./chunk-4vz571bb.js";
import"./chunk-14p6wvsq.js";
import"./chunk-8hseq8b1.js";
import"./chunk-ddtxq6k5.js";
import"./chunk-28jd8qjx.js";
import"./chunk-djt39ze3.js";
import"./chunk-ptxteaeh.js";
import"./chunk-wd53a7m4.js";
import"./chunk-hms8ge0k.js";
import"./chunk-whpphypt.js";
import"./chunk-pht800m5.js";
import"./chunk-pjkqh1kq.js";
import"./chunk-9a9g5hbj.js";
import"./chunk-9hn8e6h1.js";
import"./chunk-rgyzsbs3.js";
import"./chunk-qn6me9n1.js";
import"./chunk-qd3r2s2n.js";
import"./chunk-djzd7tef.js";
import"./chunk-gyhnpbkx.js";
import"./chunk-71sdcaq6.js";
import"./chunk-60gf7p5s.js";
import"./chunk-sj3d0nqx.js";
import"./chunk-9pk9rk2w.js";
import"./chunk-javpza6a.js";
import"./chunk-6v7bre98.js";
import"./chunk-24kv69g3.js";
import"./chunk-fcqebw9m.js";
import"./chunk-dnfd3c9s.js";
import"./chunk-15ezj4ww.js";
import"./chunk-1h284c6e.js";
import"./chunk-582g9yce.js";
import {
  init_useKeybinding
} from "./chunk-y3ztgztb.js";
import"./chunk-4spgkgr3.js";
import"./chunk-n8kbhswc.js";
import"./chunk-60fkafk2.js";
import"./chunk-fgbkrbk3.js";
import"./chunk-ssw61jfd.js";
import"./chunk-093ej2sf.js";
import"./chunk-7tfdhkpy.js";
import"./chunk-nde5ym6a.js";
import"./chunk-k8wq4qsj.js";
import"./chunk-g7d3xx1p.js";
import"./chunk-3wrx2943.js";
import"./chunk-7p9kkh0f.js";
import"./chunk-qp8cgz66.js";
import"./chunk-1mg610h2.js";
import"./chunk-93hc149s.js";
import"./chunk-935nrvdb.js";
import"./chunk-8zz4z1q3.js";
import"./chunk-nnat9jw5.js";
import"./chunk-hqxp6b72.js";
import"./chunk-4jzkqgf1.js";
import"./chunk-33rd41ng.js";
import"./chunk-f257kqw9.js";
import"./chunk-w5hnghah.js";
import"./chunk-36twraxy.js";
import"./chunk-1bkvnj0y.js";
import"./chunk-akdpcc5p.js";
import {
  getSettingsFilePathForSource,
  getSettings_DEPRECATED,
  init_settings1 as init_settings
} from "./chunk-7rrkrej7.js";
import"./chunk-6r0bxrh6.js";
import"./chunk-d6500tvx.js";
import"./chunk-jg4bw4hp.js";
import"./chunk-epvbnq43.js";
import"./chunk-tn2sx7j6.js";
import"./chunk-6tzyv21c.js";
import"./chunk-8kf8h7xf.js";
import"./chunk-bgan4cpf.js";
import"./chunk-jmv7k0jn.js";
import {
  getPlatform,
  init_platform
} from "./chunk-ch4pgvwq.js";
import"./chunk-99jc4tcw.js";
import"./chunk-fghczfqt.js";
import"./chunk-vwenx8ke.js";
import"./chunk-f86mwfyd.js";
import"./chunk-v4ypszbb.js";
import"./chunk-bk6ck5c2.js";
import"./chunk-ym6j0wv1.js";
import"./chunk-hjmatcgt.js";
import"./chunk-6mdh70q0.js";
import"./chunk-ch92ycde.js";
import"./chunk-e4dsy4g1.js";
import"./chunk-326zehp8.js";
import"./chunk-kc67kt75.js";
import"./chunk-40t1d75v.js";
import"./chunk-nt5dmk8q.js";
import"./chunk-e3abfxpy.js";
import"./chunk-q44zc68f.js";
import"./chunk-fejeqe61.js";
import"./chunk-0gp4q8aq.js";
import"./chunk-hn4w9pkj.js";
import {
  Link,
  Pane,
  Tab,
  Tabs,
  ThemedBox_default,
  ThemedText,
  color,
  init_src,
  useKeybindings,
  useTabHeaderFocus,
  useTheme
} from "./chunk-0r6npc3t.js";
import {
  require_jsx_runtime
} from "./chunk-gxyx8b8w.js";
import"./chunk-j1mep9ck.js";
import"./chunk-6x35ffpx.js";
import"./chunk-1zbwhcbt.js";
import"./chunk-t0450ma3.js";
import"./chunk-0cqw3y8h.js";
import"./chunk-k1sw7km0.js";
import"./chunk-e3j7m7k2.js";
import"./chunk-sc9ycxra.js";
import"./chunk-hhta0nge.js";
import"./chunk-8wsj9fff.js";
import"./chunk-m28vg9w4.js";
import"./chunk-f8prtxs3.js";
import"./chunk-41a6f2kv.js";
import"./chunk-c1yc761e.js";
import"./chunk-c5g9shkw.js";
import"./chunk-byd20vdq.js";
import"./chunk-kb3758f7.js";
import {
  getCwdState,
  init_state
} from "./chunk-3j8w0rq8.js";
import"./chunk-tj0dzck2.js";
import"./chunk-aeysytks.js";
import"./chunk-ns1htxgd.js";
import"./chunk-ztqzmfx1.js";
import"./chunk-6k1rsk85.js";
import"./chunk-nxzx0ey9.js";
import"./chunk-yes1my80.js";
import"./chunk-pecy49yr.js";
import"./chunk-azbab59e.js";
import"./chunk-3nk9q8dr.js";
import {
  __esm,
  __toESM
} from "./chunk-hhsxm2yr.js";

// src/components/sandbox/SandboxConfigTab.tsx
function SandboxConfigTab() {
  const isEnabled = SandboxManager.isSandboxingEnabled();
  const depCheck = SandboxManager.checkDependencies();
  const warningsNote = depCheck.warnings.length > 0 ? /* @__PURE__ */ jsx_runtime.jsx(ThemedBox_default, {
    marginTop: 1,
    flexDirection: "column",
    children: depCheck.warnings.map((w, i) => /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
      dimColor: true,
      children: w
    }, i))
  }) : null;
  if (!isEnabled) {
    return /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
      flexDirection: "column",
      paddingY: 1,
      children: [
        /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          color: "subtle",
          children: "Sandbox is not enabled"
        }),
        warningsNote
      ]
    });
  }
  const fsReadConfig = SandboxManager.getFsReadConfig();
  const fsWriteConfig = SandboxManager.getFsWriteConfig();
  const networkConfig = SandboxManager.getNetworkRestrictionConfig();
  const allowUnixSockets = SandboxManager.getAllowUnixSockets();
  const excludedCommands = SandboxManager.getExcludedCommands();
  const globPatternWarnings = SandboxManager.getLinuxGlobPatternWarnings();
  return /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
    flexDirection: "column",
    paddingY: 1,
    children: [
      /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
        flexDirection: "column",
        children: [
          /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
            bold: true,
            color: "permission",
            children: "Excluded Commands:"
          }),
          /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
            dimColor: true,
            children: excludedCommands.length > 0 ? excludedCommands.join(", ") : "None"
          })
        ]
      }),
      fsReadConfig.denyOnly.length > 0 && /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
        marginTop: 1,
        flexDirection: "column",
        children: [
          /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
            bold: true,
            color: "permission",
            children: "Filesystem Read Restrictions:"
          }),
          /* @__PURE__ */ jsx_runtime.jsxs(ThemedText, {
            dimColor: true,
            children: [
              "Denied: ",
              fsReadConfig.denyOnly.join(", ")
            ]
          }),
          fsReadConfig.allowWithinDeny && fsReadConfig.allowWithinDeny.length > 0 && /* @__PURE__ */ jsx_runtime.jsxs(ThemedText, {
            dimColor: true,
            children: [
              "Allowed within denied: ",
              fsReadConfig.allowWithinDeny.join(", ")
            ]
          })
        ]
      }),
      fsWriteConfig.allowOnly.length > 0 && /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
        marginTop: 1,
        flexDirection: "column",
        children: [
          /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
            bold: true,
            color: "permission",
            children: "Filesystem Write Restrictions:"
          }),
          /* @__PURE__ */ jsx_runtime.jsxs(ThemedText, {
            dimColor: true,
            children: [
              "Allowed: ",
              fsWriteConfig.allowOnly.join(", ")
            ]
          }),
          fsWriteConfig.denyWithinAllow.length > 0 && /* @__PURE__ */ jsx_runtime.jsxs(ThemedText, {
            dimColor: true,
            children: [
              "Denied within allowed: ",
              fsWriteConfig.denyWithinAllow.join(", ")
            ]
          })
        ]
      }),
      (networkConfig.allowedHosts && networkConfig.allowedHosts.length > 0 || networkConfig.deniedHosts && networkConfig.deniedHosts.length > 0) && /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
        marginTop: 1,
        flexDirection: "column",
        children: [
          /* @__PURE__ */ jsx_runtime.jsxs(ThemedText, {
            bold: true,
            color: "permission",
            children: [
              "Network Restrictions",
              shouldAllowManagedSandboxDomainsOnly() ? " (Managed)" : "",
              ":"
            ]
          }),
          networkConfig.allowedHosts && networkConfig.allowedHosts.length > 0 && /* @__PURE__ */ jsx_runtime.jsxs(ThemedText, {
            dimColor: true,
            children: [
              "Allowed: ",
              networkConfig.allowedHosts.join(", ")
            ]
          }),
          networkConfig.deniedHosts && networkConfig.deniedHosts.length > 0 && /* @__PURE__ */ jsx_runtime.jsxs(ThemedText, {
            dimColor: true,
            children: [
              "Denied: ",
              networkConfig.deniedHosts.join(", ")
            ]
          })
        ]
      }),
      allowUnixSockets && allowUnixSockets.length > 0 && /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
        marginTop: 1,
        flexDirection: "column",
        children: [
          /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
            bold: true,
            color: "permission",
            children: "Allowed Unix Sockets:"
          }),
          /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
            dimColor: true,
            children: allowUnixSockets.join(", ")
          })
        ]
      }),
      globPatternWarnings.length > 0 && /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
        marginTop: 1,
        flexDirection: "column",
        children: [
          /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
            bold: true,
            color: "warning",
            children: "\u26A0 Warning: Glob patterns not fully supported on Linux"
          }),
          /* @__PURE__ */ jsx_runtime.jsxs(ThemedText, {
            dimColor: true,
            children: [
              "The following patterns will be ignored: ",
              globPatternWarnings.slice(0, 3).join(", "),
              globPatternWarnings.length > 3 && ` (${globPatternWarnings.length - 3} more)`
            ]
          })
        ]
      }),
      warningsNote
    ]
  });
}
var jsx_runtime;
var init_SandboxConfigTab = __esm(() => {
  init_src();
  init_sandbox_adapter();
  jsx_runtime = __toESM(require_jsx_runtime(), 1);
});

// src/components/sandbox/SandboxDependenciesTab.tsx
function SandboxDependenciesTab({ depCheck }) {
  const platform = getPlatform();
  const isMac = platform === "macos";
  const rgMissing = depCheck.errors.some((e) => e.includes("ripgrep"));
  const bwrapMissing = depCheck.errors.some((e) => e.includes("bwrap"));
  const socatMissing = depCheck.errors.some((e) => e.includes("socat"));
  const seccompMissing = depCheck.warnings.length > 0;
  const otherErrors = depCheck.errors.filter((e) => !e.includes("ripgrep") && !e.includes("bwrap") && !e.includes("socat"));
  const rgInstallHint = isMac ? "brew install ripgrep" : "apt install ripgrep";
  return /* @__PURE__ */ jsx_runtime2.jsxs(ThemedBox_default, {
    flexDirection: "column",
    paddingY: 1,
    gap: 1,
    children: [
      isMac && /* @__PURE__ */ jsx_runtime2.jsx(ThemedBox_default, {
        flexDirection: "column",
        children: /* @__PURE__ */ jsx_runtime2.jsxs(ThemedText, {
          children: [
            "seatbelt: ",
            /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
              color: "success",
              children: "built-in (macOS)"
            })
          ]
        })
      }),
      /* @__PURE__ */ jsx_runtime2.jsxs(ThemedBox_default, {
        flexDirection: "column",
        children: [
          /* @__PURE__ */ jsx_runtime2.jsxs(ThemedText, {
            children: [
              "ripgrep (rg): ",
              rgMissing ? /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
                color: "error",
                children: "not found"
              }) : /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
                color: "success",
                children: "found"
              })
            ]
          }),
          rgMissing && /* @__PURE__ */ jsx_runtime2.jsxs(ThemedText, {
            dimColor: true,
            children: [
              "  ",
              "\xB7 ",
              rgInstallHint
            ]
          })
        ]
      }),
      !isMac && /* @__PURE__ */ jsx_runtime2.jsxs(jsx_runtime2.Fragment, {
        children: [
          /* @__PURE__ */ jsx_runtime2.jsxs(ThemedBox_default, {
            flexDirection: "column",
            children: [
              /* @__PURE__ */ jsx_runtime2.jsxs(ThemedText, {
                children: [
                  "bubblewrap (bwrap):",
                  " ",
                  bwrapMissing ? /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
                    color: "error",
                    children: "not installed"
                  }) : /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
                    color: "success",
                    children: "installed"
                  })
                ]
              }),
              bwrapMissing && /* @__PURE__ */ jsx_runtime2.jsxs(ThemedText, {
                dimColor: true,
                children: [
                  "  ",
                  "\xB7 apt install bubblewrap"
                ]
              })
            ]
          }),
          /* @__PURE__ */ jsx_runtime2.jsxs(ThemedBox_default, {
            flexDirection: "column",
            children: [
              /* @__PURE__ */ jsx_runtime2.jsxs(ThemedText, {
                children: [
                  "socat: ",
                  socatMissing ? /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
                    color: "error",
                    children: "not installed"
                  }) : /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
                    color: "success",
                    children: "installed"
                  })
                ]
              }),
              socatMissing && /* @__PURE__ */ jsx_runtime2.jsxs(ThemedText, {
                dimColor: true,
                children: [
                  "  ",
                  "\xB7 apt install socat"
                ]
              })
            ]
          }),
          /* @__PURE__ */ jsx_runtime2.jsxs(ThemedBox_default, {
            flexDirection: "column",
            children: [
              /* @__PURE__ */ jsx_runtime2.jsxs(ThemedText, {
                children: [
                  "seccomp filter:",
                  " ",
                  seccompMissing ? /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
                    color: "warning",
                    children: "not installed"
                  }) : /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
                    color: "success",
                    children: "installed"
                  }),
                  seccompMissing && /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
                    dimColor: true,
                    children: " (required to block unix domain sockets)"
                  })
                ]
              }),
              seccompMissing && /* @__PURE__ */ jsx_runtime2.jsxs(ThemedBox_default, {
                flexDirection: "column",
                children: [
                  /* @__PURE__ */ jsx_runtime2.jsxs(ThemedText, {
                    dimColor: true,
                    children: [
                      "  ",
                      "\xB7 npm install -g @anthropic-ai/sandbox-runtime"
                    ]
                  }),
                  /* @__PURE__ */ jsx_runtime2.jsxs(ThemedText, {
                    dimColor: true,
                    children: [
                      "  ",
                      "\xB7 or copy vendor/seccomp/* from sandbox-runtime and set"
                    ]
                  }),
                  /* @__PURE__ */ jsx_runtime2.jsxs(ThemedText, {
                    dimColor: true,
                    children: [
                      "    ",
                      "sandbox.seccomp.bpfPath and applyPath in settings.json"
                    ]
                  })
                ]
              })
            ]
          })
        ]
      }),
      otherErrors.map((err) => /* @__PURE__ */ jsx_runtime2.jsx(ThemedText, {
        color: "error",
        children: err
      }, err))
    ]
  });
}
var jsx_runtime2;
var init_SandboxDependenciesTab = __esm(() => {
  init_src();
  init_platform();
  jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
});

// src/components/sandbox/SandboxOverridesTab.tsx
function SandboxOverridesTab({ onComplete }) {
  const isEnabled = SandboxManager.isSandboxingEnabled();
  const isLocked = SandboxManager.areSandboxSettingsLockedByPolicy();
  const currentAllowUnsandboxed = SandboxManager.areUnsandboxedCommandsAllowed();
  if (!isEnabled) {
    return /* @__PURE__ */ jsx_runtime3.jsx(ThemedBox_default, {
      flexDirection: "column",
      paddingY: 1,
      children: /* @__PURE__ */ jsx_runtime3.jsx(ThemedText, {
        color: "subtle",
        children: "Sandbox is not enabled. Enable sandbox to configure override settings."
      })
    });
  }
  if (isLocked) {
    return /* @__PURE__ */ jsx_runtime3.jsxs(ThemedBox_default, {
      flexDirection: "column",
      paddingY: 1,
      children: [
        /* @__PURE__ */ jsx_runtime3.jsx(ThemedText, {
          color: "subtle",
          children: "Override settings are managed by a higher-priority configuration and cannot be changed locally."
        }),
        /* @__PURE__ */ jsx_runtime3.jsx(ThemedBox_default, {
          marginTop: 1,
          children: /* @__PURE__ */ jsx_runtime3.jsxs(ThemedText, {
            dimColor: true,
            children: [
              "Current setting: ",
              currentAllowUnsandboxed ? "Allow unsandboxed fallback" : "Strict sandbox mode"
            ]
          })
        })
      ]
    });
  }
  return /* @__PURE__ */ jsx_runtime3.jsx(OverridesSelect, {
    onComplete,
    currentMode: currentAllowUnsandboxed ? "open" : "closed"
  });
}
function OverridesSelect({ onComplete, currentMode }) {
  const [theme] = useTheme();
  const { headerFocused, focusHeader } = useTabHeaderFocus();
  const currentIndicator = color("success", theme)(`(current)`);
  const options = [
    {
      label: currentMode === "open" ? `Allow unsandboxed fallback ${currentIndicator}` : "Allow unsandboxed fallback",
      value: "open"
    },
    {
      label: currentMode === "closed" ? `Strict sandbox mode ${currentIndicator}` : "Strict sandbox mode",
      value: "closed"
    }
  ];
  async function handleSelect(value) {
    const mode = value;
    await SandboxManager.setSandboxSettings({
      allowUnsandboxedCommands: mode === "open"
    });
    const message = mode === "open" ? "\u2713 Unsandboxed fallback allowed - commands can run outside sandbox when necessary" : "\u2713 Strict sandbox mode - all commands must run in sandbox or be excluded via the `excludedCommands` option";
    onComplete(message);
  }
  return /* @__PURE__ */ jsx_runtime3.jsxs(ThemedBox_default, {
    flexDirection: "column",
    paddingY: 1,
    children: [
      /* @__PURE__ */ jsx_runtime3.jsx(ThemedBox_default, {
        marginBottom: 1,
        children: /* @__PURE__ */ jsx_runtime3.jsx(ThemedText, {
          bold: true,
          children: "Configure Overrides:"
        })
      }),
      /* @__PURE__ */ jsx_runtime3.jsx(Select, {
        options,
        onChange: handleSelect,
        onCancel: () => onComplete(undefined, { display: "skip" }),
        onUpFromFirstItem: focusHeader,
        isDisabled: headerFocused
      }),
      /* @__PURE__ */ jsx_runtime3.jsxs(ThemedBox_default, {
        flexDirection: "column",
        marginTop: 1,
        gap: 1,
        children: [
          /* @__PURE__ */ jsx_runtime3.jsxs(ThemedText, {
            dimColor: true,
            children: [
              /* @__PURE__ */ jsx_runtime3.jsx(ThemedText, {
                bold: true,
                dimColor: true,
                children: "Allow unsandboxed fallback:"
              }),
              " ",
              "When a command fails due to sandbox restrictions, Claude can retry with dangerouslyDisableSandbox to run outside the sandbox (falling back to default permissions)."
            ]
          }),
          /* @__PURE__ */ jsx_runtime3.jsxs(ThemedText, {
            dimColor: true,
            children: [
              /* @__PURE__ */ jsx_runtime3.jsx(ThemedText, {
                bold: true,
                dimColor: true,
                children: "Strict sandbox mode:"
              }),
              " ",
              "All bash commands invoked by the model must run in the sandbox unless they are explicitly listed in excludedCommands."
            ]
          }),
          /* @__PURE__ */ jsx_runtime3.jsxs(ThemedText, {
            dimColor: true,
            children: [
              "Learn more:",
              " ",
              /* @__PURE__ */ jsx_runtime3.jsx(Link, {
                url: "https://code.claude.com/docs/en/sandboxing#configure-sandboxing",
                children: "code.claude.com/docs/en/sandboxing#configure-sandboxing"
              })
            ]
          })
        ]
      })
    ]
  });
}
var jsx_runtime3;
var init_SandboxOverridesTab = __esm(() => {
  init_src();
  init_sandbox_adapter();
  init_select();
  jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
});

// src/components/sandbox/SandboxSettings.tsx
function SandboxSettings({ onComplete, depCheck }) {
  const [theme] = useTheme();
  const currentEnabled = SandboxManager.isSandboxingEnabled();
  const currentAutoAllow = SandboxManager.isAutoAllowBashIfSandboxedEnabled();
  const hasWarnings = depCheck.warnings.length > 0;
  const settings = getSettings_DEPRECATED();
  const allowAllUnixSockets = settings.sandbox?.network?.allowAllUnixSockets;
  const showSocketWarning = hasWarnings && !allowAllUnixSockets;
  const getCurrentMode = () => {
    if (!currentEnabled)
      return "disabled";
    if (currentAutoAllow)
      return "auto-allow";
    return "regular";
  };
  const currentMode = getCurrentMode();
  const currentIndicator = color("success", theme)(`(current)`);
  const options = [
    {
      label: currentMode === "auto-allow" ? `Sandbox BashTool, with auto-allow ${currentIndicator}` : "Sandbox BashTool, with auto-allow",
      value: "auto-allow"
    },
    {
      label: currentMode === "regular" ? `Sandbox BashTool, with regular permissions ${currentIndicator}` : "Sandbox BashTool, with regular permissions",
      value: "regular"
    },
    {
      label: currentMode === "disabled" ? `No Sandbox ${currentIndicator}` : "No Sandbox",
      value: "disabled"
    }
  ];
  async function handleSelect(value) {
    const mode = value;
    switch (mode) {
      case "auto-allow":
        await SandboxManager.setSandboxSettings({
          enabled: true,
          autoAllowBashIfSandboxed: true
        });
        onComplete("\u2713 Sandbox enabled with auto-allow for bash commands");
        break;
      case "regular":
        await SandboxManager.setSandboxSettings({
          enabled: true,
          autoAllowBashIfSandboxed: false
        });
        onComplete("\u2713 Sandbox enabled with regular bash permissions");
        break;
      case "disabled":
        await SandboxManager.setSandboxSettings({
          enabled: false,
          autoAllowBashIfSandboxed: false
        });
        onComplete("\u25CB Sandbox disabled");
        break;
    }
  }
  useKeybindings({
    "confirm:no": () => onComplete(undefined, { display: "skip" })
  }, { context: "Settings" });
  const modeTab = /* @__PURE__ */ jsx_runtime4.jsx(Tab, {
    title: "Mode",
    children: /* @__PURE__ */ jsx_runtime4.jsx(SandboxModeTab, {
      showSocketWarning,
      options,
      onSelect: handleSelect,
      onComplete
    })
  }, "mode");
  const overridesTab = /* @__PURE__ */ jsx_runtime4.jsx(Tab, {
    title: "Overrides",
    children: /* @__PURE__ */ jsx_runtime4.jsx(SandboxOverridesTab, {
      onComplete
    })
  }, "overrides");
  const configTab = /* @__PURE__ */ jsx_runtime4.jsx(Tab, {
    title: "Config",
    children: /* @__PURE__ */ jsx_runtime4.jsx(SandboxConfigTab, {})
  }, "config");
  const hasErrors = depCheck.errors.length > 0;
  const tabs = hasErrors ? [
    /* @__PURE__ */ jsx_runtime4.jsx(Tab, {
      title: "Dependencies",
      children: /* @__PURE__ */ jsx_runtime4.jsx(SandboxDependenciesTab, {
        depCheck
      })
    }, "dependencies")
  ] : [
    modeTab,
    ...hasWarnings ? [
      /* @__PURE__ */ jsx_runtime4.jsx(Tab, {
        title: "Dependencies",
        children: /* @__PURE__ */ jsx_runtime4.jsx(SandboxDependenciesTab, {
          depCheck
        })
      }, "dependencies")
    ] : [],
    overridesTab,
    configTab
  ];
  return /* @__PURE__ */ jsx_runtime4.jsx(Pane, {
    color: "permission",
    children: /* @__PURE__ */ jsx_runtime4.jsx(Tabs, {
      title: "Sandbox:",
      color: "permission",
      defaultTab: "Mode",
      children: tabs
    })
  });
}
function SandboxModeTab({
  showSocketWarning,
  options,
  onSelect,
  onComplete
}) {
  const { headerFocused, focusHeader } = useTabHeaderFocus();
  return /* @__PURE__ */ jsx_runtime4.jsxs(ThemedBox_default, {
    flexDirection: "column",
    paddingY: 1,
    children: [
      showSocketWarning && /* @__PURE__ */ jsx_runtime4.jsx(ThemedBox_default, {
        marginBottom: 1,
        children: /* @__PURE__ */ jsx_runtime4.jsx(ThemedText, {
          color: "warning",
          children: "Cannot block unix domain sockets (see Dependencies tab)"
        })
      }),
      /* @__PURE__ */ jsx_runtime4.jsx(ThemedBox_default, {
        marginBottom: 1,
        children: /* @__PURE__ */ jsx_runtime4.jsx(ThemedText, {
          bold: true,
          children: "Configure Mode:"
        })
      }),
      /* @__PURE__ */ jsx_runtime4.jsx(Select, {
        options,
        onChange: onSelect,
        onCancel: () => onComplete(undefined, { display: "skip" }),
        onUpFromFirstItem: focusHeader,
        isDisabled: headerFocused
      }),
      /* @__PURE__ */ jsx_runtime4.jsxs(ThemedBox_default, {
        flexDirection: "column",
        marginTop: 1,
        gap: 1,
        children: [
          /* @__PURE__ */ jsx_runtime4.jsxs(ThemedText, {
            dimColor: true,
            children: [
              /* @__PURE__ */ jsx_runtime4.jsx(ThemedText, {
                bold: true,
                dimColor: true,
                children: "Auto-allow mode:"
              }),
              " ",
              "Commands will try to run in the sandbox automatically, and attempts to run outside of the sandbox fallback to regular permissions. Explicit ask/deny rules are always respected."
            ]
          }),
          /* @__PURE__ */ jsx_runtime4.jsxs(ThemedText, {
            dimColor: true,
            children: [
              "Learn more: ",
              /* @__PURE__ */ jsx_runtime4.jsx(Link, {
                url: "https://code.claude.com/docs/en/sandboxing",
                children: "code.claude.com/docs/en/sandboxing"
              })
            ]
          })
        ]
      })
    ]
  });
}
var jsx_runtime4;
var init_SandboxSettings = __esm(() => {
  init_src();
  init_useKeybinding();
  init_sandbox_adapter();
  init_settings();
  init_select();
  init_SandboxConfigTab();
  init_SandboxDependenciesTab();
  init_SandboxOverridesTab();
  jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
});

// src/commands/sandbox-toggle/sandbox-toggle.tsx
import { relative } from "path";
async function call(onDone, _context, args) {
  const settings = getSettings_DEPRECATED();
  const themeName = settings.theme || "light";
  const platform = getPlatform();
  if (!SandboxManager.isSupportedPlatform()) {
    const errorMessage = platform === "wsl" ? "Error: Sandboxing requires WSL2. WSL1 is not supported." : "Error: Sandboxing is currently only supported on macOS, Linux, and WSL2.";
    const message = color("error", themeName)(errorMessage);
    onDone(message);
    return null;
  }
  const depCheck = SandboxManager.checkDependencies();
  if (!SandboxManager.isPlatformInEnabledList()) {
    const message = color("error", themeName)(`Error: Sandboxing is disabled for this platform (${platform}) via the enabledPlatforms setting.`);
    onDone(message);
    return null;
  }
  if (SandboxManager.areSandboxSettingsLockedByPolicy()) {
    const message = color("error", themeName)("Error: Sandbox settings are overridden by a higher-priority configuration and cannot be changed locally.");
    onDone(message);
    return null;
  }
  const trimmedArgs = args?.trim() || "";
  if (!trimmedArgs) {
    return /* @__PURE__ */ jsx_runtime5.jsx(SandboxSettings, {
      onComplete: onDone,
      depCheck
    });
  }
  if (trimmedArgs) {
    const parts = trimmedArgs.split(" ");
    const subcommand = parts[0];
    if (subcommand === "exclude") {
      const commandPattern = trimmedArgs.slice("exclude ".length).trim();
      if (!commandPattern) {
        const message2 = color("error", themeName)('Error: Please provide a command pattern to exclude (e.g., /sandbox exclude "npm run test:*")');
        onDone(message2);
        return null;
      }
      const cleanPattern = commandPattern.replace(/^["']|["']$/g, "");
      addToExcludedCommands(cleanPattern);
      const localSettingsPath = getSettingsFilePathForSource("localSettings");
      const relativePath = localSettingsPath ? relative(getCwdState(), localSettingsPath) : ".claude/settings.local.json";
      const message = color("success", themeName)(`Added "${cleanPattern}" to excluded commands in ${relativePath}`);
      onDone(message);
      return null;
    } else {
      const message = color("error", themeName)(`Error: Unknown subcommand "${subcommand}". Available subcommand: exclude`);
      onDone(message);
      return null;
    }
  }
  return null;
}
var jsx_runtime5;
var init_sandbox_toggle = __esm(() => {
  init_state();
  init_SandboxSettings();
  init_src();
  init_platform();
  init_sandbox_adapter();
  init_settings();
  jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
});
init_sandbox_toggle();

export {
  call
};

//# debugId=7516D18D755EB72D64756E2164756E21
//# sourceMappingURL=chunk-m7rzafr5.js.map
