@tavlo-dsh/dsh-plugin-hooks 0.0.0-stage → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +29 -2
- package/cordis.patch.yml +4 -0
- package/icon.svg +5 -0
- package/index.js +793 -0
- package/lib/client.js +5 -0
- package/lib/client.js.LEGAL.txt +4 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +77 -4
- package/src/config-store.js +804 -0
- package/src/default-scripts.js +193 -0
- package/src/dsh-hook-bridge.js +999 -0
- package/src/event-hub.js +198 -0
- package/src/hook-catalog.js +359 -0
- package/src/notification-dispatcher.js +486 -0
- package/src/script-runner.js +671 -0
- package/src/sound-manager.js +403 -0
- package/src/system-notifier.js +549 -0
- package/src/third-party-providers.js +1137 -0
package/lib/client.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Generated by scripts/build-client.mjs. See client.js.LEGAL.txt for notices.
|
|
2
|
+
window.__ModuleLoader__.load({id:"@tavlo-dsh/dsh-plugin-hooks",factory(require){var module={exports:{}},exports=module.exports,__TAVLO_HOOKS_CSS__=`.tavlo-hooks-root{--th-bg: var(--dsw-alias-bg-layer-1, light-dark(#ffffff, #20232a));--th-bg-2: var(--dsw-alias-bg-layer-2, light-dark(#f6f8fb, #262a33));--th-bg-3: var(--dsw-alias-bg-layer-3, light-dark(#eef2f7, #1b1e25));--th-ink: var(--dsw-alias-label-primary, light-dark(#152032, #eef2f8));--th-muted: var(--dsw-alias-label-secondary, light-dark(#526277, #a8b4c7));--th-subtle: var(--dsw-alias-label-tertiary, light-dark(#6d7d92, #8693a7));--th-border: var(--dsw-alias-border-l2, light-dark(#e1e7ef, #353c49));--th-border-strong: var(--dsw-alias-border-l3, light-dark(#cbd5e1, #495264));--th-brand: var(--dsw-alias-brand-primary, light-dark(#2563eb, #60a5fa));--th-brand-fg: var(--dsw-alias-label-primary-foreground, #ffffff);--th-brand-soft: var(--dsw-alias-state-business-tertiary, light-dark(#ebf3ff, #1f3352));--th-success: var(--dsw-alias-state-success-primary, light-dark(#15803d, #4ade80));--th-success-soft: var(--dsw-alias-state-success-tertiary, light-dark(#eafaf0, #163324));--th-warn: var(--dsw-alias-state-warn-primary, light-dark(#b45309, #fbbf24));--th-warn-soft: var(--dsw-alias-state-warn-tertiary, light-dark(#fff7e6, #3b2d15));--th-error: var(--dsw-alias-state-error-primary, light-dark(#dc2626, #f87171));--th-error-soft: light-dark(#fef2f2, #3d1c22);--th-hover: var(--dsw-alias-interactive-bg-hover, light-dark(rgba(15, 23, 42, .045), rgba(255, 255, 255, .06)));--th-radius-sm: var(--dsw-radius-sm, 8px);--th-radius-md: var(--dsw-radius-md, 12px);--th-radius-lg: var(--dsw-radius-lg, 16px);color-scheme:light dark;container:tavlo-hooks / inline-size;display:grid;gap:14px;max-width:820px;color:var(--th-ink);font-size:13px;line-height:1.5;min-width:0}body[data-ds-dark-theme] .tavlo-hooks-root,body[data-ds-dark-theme] .tavlo-hooks-toast-stack,body[data-ds-dark-theme] .tavlo-hooks-modal-backdrop{color-scheme:dark}.tavlo-hooks-root *,.tavlo-hooks-root *:before,.tavlo-hooks-root *:after,.tavlo-hooks-toast-stack *,.tavlo-hooks-modal-backdrop *{box-sizing:border-box}.tavlo-hooks-root h2,.tavlo-hooks-root h3,.tavlo-hooks-root h4,.tavlo-hooks-root p{margin:0}.tavlo-hooks-page-header{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px;padding:2px 0 4px}.tavlo-hooks-page-title-wrap{display:flex;align-items:center;gap:12px;min-width:0}.tavlo-hooks-hero-badge{display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;border-radius:var(--th-radius-md);background:var(--th-brand-soft);color:var(--th-brand);flex:none}.tavlo-hooks-page-title{font-size:18px;font-weight:650;letter-spacing:-.015em;color:var(--th-ink)}.tavlo-hooks-page-subtitle{font-size:12.5px;color:var(--th-muted);margin-top:2px}.tavlo-hooks-page-meta{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.tavlo-hooks-stat-pills{display:flex;align-items:center;gap:6px}.tavlo-hooks-sections{display:grid;gap:14px;min-width:0}.tavlo-hooks-card{border:1px solid var(--th-border);border-radius:var(--th-radius-lg);background:var(--th-bg);overflow:hidden;min-width:0}.tavlo-hooks-card-header,.tavlo-hooks-card-header-bar{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;padding:14px 16px;background:var(--th-bg);border:0;color:inherit;font:inherit;text-align:left}.tavlo-hooks-card-header{cursor:pointer}.tavlo-hooks-card-header:hover{background:var(--th-hover)}.tavlo-hooks-card-header-bar{flex-wrap:wrap}.tavlo-hooks-card-header-btn{display:flex;align-items:center;gap:11px;flex:1 1 220px;min-width:0;padding:0;border:0;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer}.tavlo-hooks-card-header-left{display:flex;align-items:center;gap:11px;min-width:0}.tavlo-hooks-card-titles{min-width:0}.tavlo-hooks-card-titles h3{font-size:15px;font-weight:650;color:var(--th-ink)}.tavlo-hooks-card-titles p{font-size:12px;color:var(--th-muted);margin-top:2px}.tavlo-hooks-header-tools{display:flex;align-items:center;gap:6px;flex-wrap:wrap}.tavlo-hooks-chevron{display:inline-flex;color:var(--th-muted);flex:none}.tavlo-hooks-card-body{display:grid;gap:14px;padding:14px 16px 16px;border-top:1px solid var(--th-border)}.tavlo-hooks-setting-block{display:grid;gap:10px}.tavlo-hooks-row{display:flex;align-items:center;justify-content:space-between;gap:14px;flex-wrap:wrap}.tavlo-hooks-row-text{flex:1 1 240px;min-width:0}.tavlo-hooks-row-with-icon{display:flex;align-items:flex-start;gap:10px}.tavlo-hooks-row-title{font-size:13.5px;font-weight:600;color:var(--th-ink)}.tavlo-hooks-row-title-sm{font-size:13px;font-weight:550;color:var(--th-ink)}.tavlo-hooks-helper{font-size:12px;color:var(--th-muted);line-height:1.5;margin-top:2px}.tavlo-hooks-row-controls{display:flex;align-items:center;gap:8px;flex:none;flex-wrap:wrap}.tavlo-hooks-subpanel{display:grid;gap:10px;padding:10px 12px;border:1px solid var(--th-border);border-radius:var(--th-radius-md);background:var(--th-bg-2)}.tavlo-hooks-taskbar-controls{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:12px}.tavlo-hooks-inline-field{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.tavlo-hooks-divider{border:0;border-top:1px solid var(--th-border);margin:0}.tavlo-hooks-icon-chip{display:inline-flex;align-items:center;justify-content:center;width:30px;height:30px;border-radius:9px;background:var(--th-bg-3);color:var(--th-muted);flex:none}.tavlo-hooks-icon-chip.is-blue{background:var(--th-brand-soft);color:var(--th-brand)}.tavlo-hooks-title-with-pills{display:flex;align-items:center;gap:6px;flex-wrap:wrap}.tavlo-hooks-badge{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;border-radius:999px;font-size:11px;font-weight:600;line-height:1.4;white-space:nowrap}.tavlo-hooks-badge-muted{background:var(--th-bg-3);color:var(--th-muted)}.tavlo-hooks-badge-blue{background:var(--th-brand-soft);color:var(--th-brand)}.tavlo-hooks-badge-success{background:var(--th-success-soft);color:var(--th-success)}.tavlo-hooks-badge-warn{background:var(--th-warn-soft);color:var(--th-warn)}.tavlo-hooks-badge-error{background:var(--th-error-soft);color:var(--th-error)}.tavlo-hooks-badge-mono{background:var(--th-bg-3);color:var(--th-muted);font-family:ui-monospace,SFMono-Regular,Consolas,monospace}.tavlo-hooks-code-pill{display:inline-flex;align-items:center;padding:2px 7px;border-radius:6px;border:1px solid var(--th-border);background:var(--th-bg-2);color:var(--th-ink);font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:11.5px;word-break:break-all}.tavlo-hooks-count-pill{display:inline-flex;align-items:center;justify-content:center;min-width:18px;height:18px;padding:0 5px;border-radius:999px;background:var(--th-brand-soft);color:var(--th-brand);font-size:11px;font-weight:650}.tavlo-hooks-switch{position:relative;display:inline-flex;align-items:center;width:38px;height:22px;padding:2px;border:1px solid var(--th-border-strong);border-radius:999px;background:var(--th-bg-3);cursor:pointer;flex:none;transition:background-color .14s ease,border-color .14s ease}.tavlo-hooks-switch.is-compact{width:34px;height:20px}.tavlo-hooks-switch[data-checked=true]{background:var(--th-brand);border-color:var(--th-brand)}.tavlo-hooks-switch:disabled{opacity:.55;cursor:not-allowed}.tavlo-hooks-switch-thumb{width:16px;height:16px;border-radius:50%;background:#fff;box-shadow:0 1px 2px #00000038;transform:translate(0);transition:transform .14s ease}.tavlo-hooks-switch.is-compact .tavlo-hooks-switch-thumb{width:14px;height:14px}.tavlo-hooks-switch[data-checked=true] .tavlo-hooks-switch-thumb{transform:translate(16px)}.tavlo-hooks-switch.is-compact[data-checked=true] .tavlo-hooks-switch-thumb{transform:translate(14px)}.tavlo-hooks-btn{display:inline-flex;align-items:center;justify-content:center;gap:5px;min-height:32px;padding:5px 12px;border:1px solid var(--th-border-strong);border-radius:var(--th-radius-sm);background:var(--th-bg);color:var(--th-ink);font:inherit;font-size:12.5px;font-weight:550;cursor:pointer;white-space:nowrap}.tavlo-hooks-btn:hover:not(:disabled){background:var(--th-hover)}.tavlo-hooks-btn.is-active{background:var(--th-brand-soft);border-color:var(--th-brand);color:var(--th-brand)}.tavlo-hooks-btn-sm{min-height:29px;padding:4px 10px;font-size:12px}.tavlo-hooks-btn-xs{min-height:26px;padding:2px 8px;font-size:11.5px}.tavlo-hooks-btn-primary{background:var(--th-brand);border-color:var(--th-brand);color:var(--th-brand-fg)}.tavlo-hooks-btn-primary:hover:not(:disabled){background:color-mix(in srgb,var(--th-brand) 88%,#000)}.tavlo-hooks-btn:disabled{opacity:.52;cursor:not-allowed}.tavlo-hooks-icon-btn{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:1px solid transparent;border-radius:var(--th-radius-sm);background:transparent;color:var(--th-muted);cursor:pointer;flex:none}.tavlo-hooks-icon-btn:hover:not(:disabled){background:var(--th-hover);color:var(--th-ink)}.tavlo-hooks-icon-btn-danger:hover:not(:disabled){background:var(--th-error-soft);color:var(--th-error)}.tavlo-hooks-link-btn{border:0;padding:0;background:transparent;color:var(--th-brand);font:inherit;font-size:12px;font-weight:600;cursor:pointer;text-decoration:underline}.tavlo-hooks-segmented{display:inline-flex;padding:2px;border:1px solid var(--th-border);border-radius:var(--th-radius-sm);background:var(--th-bg);gap:2px}.tavlo-hooks-seg-btn{border:0;padding:4px 10px;border-radius:6px;background:transparent;color:var(--th-muted);font:inherit;font-size:12px;font-weight:500;cursor:pointer}.tavlo-hooks-seg-btn[data-active=true]{background:var(--th-brand-soft);color:var(--th-brand);font-weight:600}.tavlo-hooks-stepper{display:inline-flex;align-items:center;gap:4px}.tavlo-hooks-field{display:grid;gap:5px;min-width:0}.tavlo-hooks-field.is-full{grid-column:1 / -1}.tavlo-hooks-field-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px 12px}.tavlo-hooks-label{display:flex;align-items:center;gap:4px;font-size:12px;font-weight:550;color:var(--th-ink)}.tavlo-hooks-req{color:var(--th-error)}.tavlo-hooks-secret-preview{margin-left:auto;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:11px;color:var(--th-subtle)}.tavlo-hooks-input,.tavlo-hooks-select,.tavlo-hooks-textarea{width:100%;min-width:0;padding:6px 9px;border:1px solid var(--th-border-strong);border-radius:var(--th-radius-sm);background:var(--th-bg);color:var(--th-ink);font:inherit;font-size:12.5px}.tavlo-hooks-input-sm{width:100px}.tavlo-hooks-input-xs{width:64px;text-align:center}.tavlo-hooks-input-meta{width:170px;padding:4px 8px;font-size:12px}.tavlo-hooks-textarea{resize:vertical;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12px}.tavlo-hooks-secret-input-wrap{display:flex;align-items:center;gap:4px}.tavlo-hooks-input:focus,.tavlo-hooks-select:focus,.tavlo-hooks-textarea:focus,.tavlo-hooks-btn:focus-visible,.tavlo-hooks-switch:focus-visible,.tavlo-hooks-bell-btn:focus-visible{outline:2px solid var(--th-brand);outline-offset:1px}.tavlo-hooks-sound-meta{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.tavlo-hooks-perm-bar{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--th-muted)}.tavlo-hooks-banner{display:flex;align-items:center;gap:8px;padding:8px 11px;border-radius:var(--th-radius-sm);font-size:12px;line-height:1.45;border:1px solid var(--th-border)}.tavlo-hooks-banner-text{flex:1;min-width:0}.tavlo-hooks-banner.is-warn{background:var(--th-warn-soft);border-color:color-mix(in srgb,var(--th-warn) 35%,transparent);color:var(--th-warn)}.tavlo-hooks-banner.is-error{background:var(--th-error-soft);border-color:color-mix(in srgb,var(--th-error) 35%,transparent);color:var(--th-error)}.tavlo-hooks-banner.is-success{background:var(--th-success-soft);border-color:color-mix(in srgb,var(--th-success) 35%,transparent);color:var(--th-success)}.tavlo-hooks-banner.is-muted{background:var(--th-bg-2);color:var(--th-muted)}.tavlo-hooks-inline-result{padding:7px 10px;border-radius:var(--th-radius-sm);font-size:12px}.tavlo-hooks-inline-result.is-success{background:var(--th-success-soft);color:var(--th-success)}.tavlo-hooks-inline-result.is-error{background:var(--th-error-soft);color:var(--th-error)}.tavlo-hooks-loading-card,.tavlo-hooks-empty-box{padding:16px;border:1px dashed var(--th-border-strong);border-radius:var(--th-radius-md);color:var(--th-muted);font-size:12.5px;text-align:center}.tavlo-hooks-thirdparty{display:grid;gap:12px}.tavlo-hooks-sub-header{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}.tavlo-hooks-sub-title-group{display:flex;align-items:flex-start;gap:10px;min-width:0}.tavlo-hooks-sub-title{font-size:14px;font-weight:650;color:var(--th-ink)}.tavlo-hooks-add-bar{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.tavlo-hooks-add-select-wrap{display:flex;align-items:center;gap:8px;flex:1 1 200px;max-width:300px}.tavlo-hooks-platform-glyph{display:inline-flex;align-items:center;justify-content:center;font-weight:700;letter-spacing:-.02em;flex:none;user-select:none}.tavlo-hooks-target-list{display:grid;gap:8px}.tavlo-hooks-target-card{border:1px solid var(--th-border);border-radius:var(--th-radius-md);background:var(--th-bg-2);overflow:hidden}.tavlo-hooks-target-header{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 12px;flex-wrap:wrap}.tavlo-hooks-target-main{display:flex;align-items:center;gap:9px;min-width:0;flex:1 1 240px}.tavlo-hooks-target-title-wrap{min-width:0}.tavlo-hooks-target-title-row{display:flex;align-items:center;gap:6px;flex-wrap:wrap}.tavlo-hooks-target-name{font-weight:600;color:var(--th-ink)}.tavlo-hooks-target-events-summary{font-size:11.5px;color:var(--th-muted);margin-top:2px}.tavlo-hooks-target-actions{display:flex;align-items:center;gap:4px;flex:none}.tavlo-hooks-target-body{display:grid;gap:12px;padding:12px;border-top:1px solid var(--th-border);background:var(--th-bg)}.tavlo-hooks-events-checks{display:flex;flex-wrap:wrap;gap:6px}.tavlo-hooks-check-pill{display:inline-flex;align-items:center;gap:5px;padding:4px 9px;border:1px solid var(--th-border);border-radius:999px;background:var(--th-bg-2);font-size:12px;cursor:pointer;user-select:none}.tavlo-hooks-check-pill[data-checked=true]{border-color:var(--th-brand);background:var(--th-brand-soft);color:var(--th-brand);font-weight:550}.tavlo-hooks-check-pill input{margin:0;accent-color:var(--th-brand)}.tavlo-hooks-target-footer{display:flex;justify-content:flex-end;gap:8px}.tavlo-hooks-group{display:grid;gap:10px}.tavlo-hooks-group-header{display:flex;align-items:center;justify-content:space-between;width:100%;padding:6px 8px;border:0;border-radius:var(--th-radius-sm);background:var(--th-bg-2);color:var(--th-ink);font:inherit;font-weight:600;cursor:pointer}.tavlo-hooks-group-header:hover{background:var(--th-bg-3)}.tavlo-hooks-group-title{display:inline-flex;align-items:center;gap:6px}.tavlo-hooks-mount-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:10px}.tavlo-hooks-mount-card{display:grid;align-content:space-between;gap:8px;padding:11px 12px;border:1px solid var(--th-border);border-radius:var(--th-radius-md);background:var(--th-bg-2);cursor:pointer;transition:border-color .14s ease,background-color .14s ease}.tavlo-hooks-mount-card:hover{border-color:var(--th-border-strong)}.tavlo-hooks-mount-card[data-selected=true]{border-color:var(--th-brand);background:var(--th-brand-soft)}.tavlo-hooks-mount-card[data-enabled=false]{opacity:.78}.tavlo-hooks-mount-top{display:flex;align-items:center;justify-content:space-between;gap:8px}.tavlo-hooks-mount-title-wrap{display:flex;align-items:center;gap:6px;min-width:0}.tavlo-hooks-mount-name{font-weight:650;font-size:13px;color:var(--th-ink);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tavlo-hooks-mount-event-line{display:flex;flex-wrap:wrap;gap:4px}.tavlo-hooks-mount-desc{font-size:11.5px;color:var(--th-muted);line-height:1.45}.tavlo-hooks-mount-footer{display:flex;align-items:center;justify-content:space-between;gap:8px;padding-top:4px;border-top:1px solid var(--th-border)}.tavlo-hooks-mount-counts{font-size:11.5px;color:var(--th-muted)}.tavlo-hooks-mount-tools{display:flex;align-items:center;gap:5px}.tavlo-hooks-bell-btn{display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:7px;border:1px solid var(--th-border);background:var(--th-bg);cursor:pointer}.tavlo-hooks-bell-btn.is-on{color:var(--th-brand);border-color:color-mix(in srgb,var(--th-brand) 45%,transparent);background:var(--th-brand-soft)}.tavlo-hooks-bell-btn.is-off{color:var(--th-subtle)}.tavlo-hooks-drawer{display:grid;gap:12px;padding:13px;border:1px solid var(--th-brand);border-radius:var(--th-radius-md);background:var(--th-bg)}.tavlo-hooks-drawer-head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;flex-wrap:wrap}.tavlo-hooks-drawer-title{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:650}.tavlo-hooks-dsh-events{display:flex;flex-wrap:wrap;gap:4px;margin-top:5px}.tavlo-hooks-drawer-head-actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap}.tavlo-hooks-script-list{display:grid;gap:8px}.tavlo-hooks-script-row{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:9px 11px;border:1px solid var(--th-border);border-radius:var(--th-radius-sm);background:var(--th-bg-2);flex-wrap:wrap}.tavlo-hooks-script-main{display:flex;align-items:center;gap:10px;flex:1 1 260px;min-width:0}.tavlo-hooks-script-info{display:grid;gap:6px;min-width:0}.tavlo-hooks-script-name-line{display:flex;align-items:center;gap:6px;flex-wrap:wrap}.tavlo-hooks-script-name{font-weight:600}.tavlo-hooks-script-meta-inputs{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.tavlo-hooks-inline-meta{display:inline-flex;align-items:center;gap:6px;font-size:11.5px;color:var(--th-muted)}.tavlo-hooks-script-actions{display:flex;align-items:center;gap:5px;flex-wrap:wrap}.tavlo-hooks-output-pre{margin:6px 0 0;padding:7px 9px;border-radius:6px;background:var(--th-bg-3);color:var(--th-ink);font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:11px;white-space:pre-wrap;word-break:break-word;max-height:160px;overflow:auto}.tavlo-hooks-output-pre.is-stderr{color:var(--th-error)}.tavlo-hooks-logs-panel{display:grid;gap:10px;padding:12px 16px;border-top:1px solid var(--th-border);background:var(--th-bg-2)}.tavlo-hooks-logs-head{display:flex;align-items:center;justify-content:space-between;font-weight:600}.tavlo-hooks-logs-list{display:grid;gap:6px;max-height:240px;overflow-y:auto}.tavlo-hooks-log-item{padding:8px 10px;border:1px solid var(--th-border);border-radius:var(--th-radius-sm);background:var(--th-bg)}.tavlo-hooks-log-top{display:flex;align-items:center;gap:7px;flex-wrap:wrap}.tavlo-hooks-log-time{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:11px;color:var(--th-subtle)}.tavlo-hooks-log-script{font-weight:600}.tavlo-hooks-modal-backdrop{position:fixed;inset:0;z-index:1200;display:flex;align-items:center;justify-content:center;padding:20px;background:var(--dsw-alias-bg-mask-1, rgba(0, 0, 0, .45));backdrop-filter:blur(2px)}.tavlo-hooks-modal{width:min(740px,100%);max-height:82vh;display:grid;grid-template-rows:auto minmax(0,1fr);border:1px solid var(--dsw-alias-border-l2, #cbd5e1);border-radius:var(--dsw-radius-lg, 14px);background:var(--dsw-alias-bg-layer-1, light-dark(#ffffff, #1e222a));color:var(--dsw-alias-label-primary, light-dark(#152032, #eef2f8));box-shadow:var(--dsw-shadow-lv3, 0 18px 46px rgba(0, 0, 0, .28));overflow:hidden}.tavlo-hooks-modal-head{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:12px 16px;border-bottom:1px solid var(--dsw-alias-border-l2, #e2e8f0)}.tavlo-hooks-modal-head h4{margin:0;font-size:14px;font-weight:650}.tavlo-hooks-source-pre{margin:0;padding:14px 16px;overflow:auto;background:var(--dsw-alias-bg-layer-2, light-dark(#f8fafc, #14171d));font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12px;line-height:1.55;white-space:pre}.tavlo-hooks-toast-stack{position:fixed;right:18px;bottom:18px;z-index:1150;display:grid;gap:10px;width:min(360px,calc(100vw - 24px));pointer-events:none}.tavlo-hooks-toast-card{position:relative;display:grid;grid-template-columns:4px minmax(0,1fr);border:1px solid var(--dsw-alias-border-l2, light-dark(#dde4ee, #384150));border-radius:var(--dsw-radius-md, 12px);background:var(--dsw-alias-bg-layer-1, light-dark(#ffffff, #20242d));color:var(--dsw-alias-label-primary, light-dark(#152032, #f1f5f9));box-shadow:var(--dsw-shadow-lv2, 0 10px 28px rgba(0, 0, 0, .18));overflow:hidden;pointer-events:auto}.tavlo-hooks-toast-accent{background:var(--dsw-alias-brand-primary, #3b82f6)}.tavlo-hooks-toast-card[data-variant=approval] .tavlo-hooks-toast-accent{background:#f59e0b}.tavlo-hooks-toast-card[data-variant=attention] .tavlo-hooks-toast-accent{background:#3b82f6}.tavlo-hooks-toast-card[data-variant=success] .tavlo-hooks-toast-accent{background:#10b981}.tavlo-hooks-toast-card[data-variant=error] .tavlo-hooks-toast-accent{background:#ef4444}.tavlo-hooks-toast-body{display:grid;gap:4px;padding:10px 12px;min-width:0}.tavlo-hooks-toast-head{display:flex;align-items:center;justify-content:space-between;gap:8px}.tavlo-hooks-toast-eyebrow{display:flex;align-items:center;gap:5px;font-size:11px;font-weight:600;color:var(--dsw-alias-label-secondary, light-dark(#526277, #9fb0c7))}.tavlo-hooks-toast-point{padding:1px 5px;border-radius:4px;background:var(--dsw-alias-bg-layer-2, light-dark(#f1f5f9, #2c313d));font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:10.5px}.tavlo-hooks-toast-title{font-size:13.5px;font-weight:650;line-height:1.35}.tavlo-hooks-toast-source{font-size:11.5px;color:var(--dsw-alias-label-secondary, light-dark(#526277, #9fb0c7))}.tavlo-hooks-toast-summary{font-size:12.5px;color:var(--dsw-alias-label-secondary, light-dark(#3b4a5e, #cbd5e1));word-break:break-word}.tavlo-hooks-toast-actions{display:flex;justify-content:flex-end;margin-top:4px}@container tavlo-hooks (max-width: 520px){.tavlo-hooks-field-grid,.tavlo-hooks-mount-grid{grid-template-columns:minmax(0,1fr)}}@media(max-width:640px){.tavlo-hooks-field-grid,.tavlo-hooks-mount-grid{grid-template-columns:minmax(0,1fr)}.tavlo-hooks-toast-stack{right:12px;bottom:12px}}
|
|
3
|
+
`,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),index_exports={};__export(index_exports,{apply:()=>apply,inject:()=>inject}),module.exports=__toCommonJS(index_exports);function normalizeRpcResponse(raw){if(!raw||typeof raw!="object")return{ok:!1,error:{code:"hooks/malformed",message:"Malformed response"}};let obj=raw;return obj.type==="server-response"&&"result"in obj?normalizeRpcResponse(obj.result):typeof obj.ok=="boolean"?obj.ok?{ok:!0,value:"value"in obj?obj.value:obj}:{ok:!1,error:obj.error&&typeof obj.error=="object"?obj.error:{}}:"revision"in obj&&"config"in obj?{ok:!0,value:obj}:{ok:!0,value:obj}}function createClientId(){try{if(typeof window<"u"&&window.crypto?.randomUUID)return window.crypto.randomUUID();if(typeof window<"u"&&window.crypto?.getRandomValues){let bytes=window.crypto.getRandomValues(new Uint8Array(16));return Array.from(bytes,b=>b.toString(16).padStart(2,"0")).join("")}}catch{}return`client_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`}function createHooksApi(connection){let clientId=createClientId();async function call(operation,input={},timeoutMs=3e4){let controller=new AbortController,timer=setTimeout(()=>controller.abort(),timeoutMs);try{if(connection?.rpc?.call){let res=await connection.rpc.call("/api","tavlo-hooks/rpc",{operation,input},controller.signal);return normalizeRpcResponse(res)}let response=await window.fetch("api/tavlo-hooks/rpc",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify({operation,input}),signal:controller.signal}),json=await response.json().catch(()=>null);return!response.ok&&!json?{ok:!1,error:{code:`http/${response.status}`,message:`HTTP ${response.status}`}}:normalizeRpcResponse(json)}catch(error){return{ok:!1,error:{code:"hooks/network",message:error instanceof Error?error.message:String(error)}}}finally{clearTimeout(timer)}}async function uploadScript(params){let controller=new AbortController,timer=setTimeout(()=>controller.abort(),45e3);try{let qs=new URLSearchParams({mountPointId:params.mountPointId,filename:params.file.name});params.name&&qs.set("name",params.name),params.matcher!==void 0&&qs.set("matcher",params.matcher),params.timeoutSeconds!==void 0&&qs.set("timeoutSeconds",String(params.timeoutSeconds)),params.expectedRevision!==void 0&&qs.set("expectedRevision",String(params.expectedRevision));let response=await window.fetch(`api/tavlo-hooks/scripts/upload?${qs.toString()}`,{method:"POST",credentials:"same-origin",redirect:"error",headers:{"Content-Type":"application/octet-stream"},body:params.file,signal:controller.signal}),json=await response.json().catch(()=>null);return!response.ok&&!json?{ok:!1,error:{code:`http/${response.status}`,message:`HTTP ${response.status}`}}:normalizeRpcResponse(json)}catch(error){return{ok:!1,error:{code:"hooks/upload-failed",message:error instanceof Error?error.message:String(error)}}}finally{clearTimeout(timer)}}async function getScriptSource(mountPointId,scriptId){let controller=new AbortController,timer=setTimeout(()=>controller.abort(),2e4);try{let qs=new URLSearchParams({mountPointId,scriptId}),response=await window.fetch(`api/tavlo-hooks/scripts/source?${qs.toString()}`,{method:"GET",credentials:"same-origin",cache:"no-store",signal:controller.signal}),json=await response.json().catch(()=>null);return!response.ok&&!json?{ok:!1,error:{code:`http/${response.status}`,message:`HTTP ${response.status}`}}:normalizeRpcResponse(json)}catch(error){return{ok:!1,error:{code:"hooks/source-failed",message:error instanceof Error?error.message:String(error)}}}finally{clearTimeout(timer)}}async function uploadCustomSound(file,expectedRevision){let controller=new AbortController,timer=setTimeout(()=>controller.abort(),45e3);try{let qs=new URLSearchParams({filename:file.name});expectedRevision!==void 0&&qs.set("expectedRevision",String(expectedRevision));let response=await window.fetch(`api/tavlo-hooks/sound/upload?${qs.toString()}`,{method:"POST",credentials:"same-origin",redirect:"error",headers:{"Content-Type":"audio/wav"},body:file,signal:controller.signal}),json=await response.json().catch(()=>null);return!response.ok&&!json?{ok:!1,error:{code:`http/${response.status}`,message:`HTTP ${response.status}`}}:normalizeRpcResponse(json)}catch(error){return{ok:!1,error:{code:"hooks/sound-upload-failed",message:error instanceof Error?error.message:String(error)}}}finally{clearTimeout(timer)}}async function postClientState(payload){try{await window.fetch("api/tavlo-hooks/client-state",{method:"POST",credentials:"same-origin",cache:"no-store",keepalive:!0,headers:{"Content-Type":"application/json"},body:JSON.stringify(payload)})}catch{}}function subscribeEvents(handlers){let disposed=!1,suspended=!1,streamController,reconnectTimer,retryDelay=1e3;async function connect(){if(disposed||suspended||streamController)return;let startedAt=Date.now(),controller=new AbortController;streamController=controller;let reader,watchdog,resetWatchdog=()=>{watchdog&&clearTimeout(watchdog),watchdog=setTimeout(()=>controller.abort(),9e4)};resetWatchdog();try{let response=await window.fetch("api/tavlo-hooks/events",{method:"GET",credentials:"same-origin",cache:"no-store",headers:{accept:"text/event-stream"},signal:controller.signal});if(disposed||controller.signal.aborted){await response.body?.cancel().catch(()=>{});return}let contentType=response.headers.get("content-type")?.split(";",1)[0]?.trim().toLowerCase();if(!response.ok||contentType!=="text/event-stream"||!response.body)throw new Error("SSE stream unavailable");handlers.onStatus?.(!0),reader=response.body.getReader();let decoder=new TextDecoder,buffer="";for(;!disposed&&!controller.signal.aborted;){let{done,value}=await reader.read();if(done)throw new Error("SSE stream closed");if(disposed||controller.signal.aborted)break;if(resetWatchdog(),buffer+=decoder.decode(value,{stream:!0}),buffer.length>4*1024*1024)throw new Error("SSE buffer overflow");let match;for(;!disposed&&!controller.signal.aborted&&(match=/\r?\n\r?\n/.exec(buffer));){let frame=buffer.slice(0,match.index);buffer=buffer.slice(match.index+match[0].length);let eventName="message",dataLines=[];for(let line of frame.split(/\r?\n/))!line||line.startsWith(":")||(line.startsWith("event:")?eventName=line.slice(6).trim():line.startsWith("data:")&&dataLines.push(line.slice(5).replace(/^ /,"")));if(!dataLines.length)continue;let rawData=dataLines.join(`
|
|
4
|
+
`),parsed;try{parsed=JSON.parse(rawData)}catch{continue}eventName==="notification"?handlers.onNotification?.(parsed):eventName==="dismiss"?handlers.onDismiss?.(parsed):eventName==="logs"&&handlers.onLogs?.(parsed)}}}catch{disposed||handlers.onStatus?.(!1)}finally{watchdog&&clearTimeout(watchdog),controller.abort();try{await reader?.cancel()}catch{}try{reader?.releaseLock()}catch{}streamController===controller&&(streamController=void 0),!disposed&&!suspended&&(Date.now()-startedAt>=3e4&&(retryDelay=1e3),reconnectTimer=setTimeout(()=>{reconnectTimer=void 0,connect()},retryDelay),retryDelay=Math.min(retryDelay*2,15e3))}}let pause=()=>{suspended=!0,reconnectTimer&&clearTimeout(reconnectTimer),reconnectTimer=void 0,streamController?.abort()},resume=()=>{suspended=!1,reconnectTimer&&clearTimeout(reconnectTimer),reconnectTimer=void 0,!streamController&&!disposed&&connect()};return typeof window<"u"&&(window.addEventListener("pagehide",pause),window.addEventListener("pageshow",resume),window.addEventListener("online",resume)),connect(),()=>{disposed=!0,reconnectTimer&&clearTimeout(reconnectTimer),streamController?.abort(),typeof window<"u"&&(window.removeEventListener("pagehide",pause),window.removeEventListener("pageshow",resume),window.removeEventListener("online",resume))}}return{call,getState:()=>call("getState",{}),saveSettings:(patch,expectedRevision)=>call("saveSettings",{...patch,...expectedRevision!==void 0?{expectedRevision}:{}}),toggleMountPoint:(mountPointId,enabled,expectedRevision)=>call("toggleMountPoint",{mountPointId,enabled,...expectedRevision!==void 0?{expectedRevision}:{}}),toggleMountPointBell:(mountPointId,bellEnabled,expectedRevision)=>call("toggleMountPointBell",{mountPointId,bellEnabled,...expectedRevision!==void 0?{expectedRevision}:{}}),toggleScript:(mountPointId,scriptId,enabled,expectedRevision)=>call("toggleScript",{mountPointId,scriptId,enabled,...expectedRevision!==void 0?{expectedRevision}:{}}),updateScriptMeta:(mountPointId,scriptId,patch,expectedRevision)=>call("updateScriptMeta",{mountPointId,scriptId,...patch,...expectedRevision!==void 0?{expectedRevision}:{}}),deleteScript:(mountPointId,scriptId,expectedRevision)=>call("deleteScript",{mountPointId,scriptId,...expectedRevision!==void 0?{expectedRevision}:{}}),resetDefaultScripts:expectedRevision=>call("resetDefaultScripts",expectedRevision!==void 0?{expectedRevision}:{}),testMountPoint:mountPointId=>call("testMountPoint",{mountPointId},45e3),testScript:(mountPointId,scriptId)=>call("testScript",{mountPointId,scriptId},45e3),getExecutionLogs:()=>call("getExecutionLogs",{}),saveThirdPartyTarget:(target,expectedRevision)=>call("saveThirdPartyTarget",{target,...expectedRevision!==void 0?{expectedRevision}:{}}),toggleThirdPartyTarget:(targetId,enabled,expectedRevision)=>call("toggleThirdPartyTarget",{targetId,enabled,...expectedRevision!==void 0?{expectedRevision}:{}}),deleteThirdPartyTarget:(targetId,expectedRevision)=>call("deleteThirdPartyTarget",{targetId,...expectedRevision!==void 0?{expectedRevision}:{}}),testThirdPartyTarget:target=>call("testThirdPartyTarget",{target},45e3),clearCustomSound:expectedRevision=>call("clearCustomSound",expectedRevision!==void 0?{expectedRevision}:{}),testSystemNotification:()=>call("testSystemNotification",{}),testTaskbarFlash:overrides=>call("testTaskbarFlash",overrides??{}),uploadScript,getScriptSource,uploadCustomSound,getSoundPreviewUrl:()=>`api/tavlo-hooks/sound/current?ts=${Date.now()}`,postClientState,subscribeEvents,getClientId:()=>clientId}}function createLogBus(){let listeners=new Set;return{subscribe(listener){return listeners.add(listener),()=>{listeners.delete(listener)}},publish(logs){for(let listener of listeners)listener(logs)}}}var LOCALE_NS="tavlo-hooks",EN={nav:"Hook",pageTitle:"Hooks & Notifications",pageSubtitle:"Configure DSH lifecycle hooks, desktop/system alerts, and third-party notification targets.",loading:"Loading hook settings\u2026",retry:"Retry",reload:"Reload Latest State",saving:"Saving\u2026",saved:"Saved",conflictError:"Settings were modified elsewhere. Reload to sync before saving.",loadError:"Could not load hook settings.",actionError:"Operation failed. Please check inputs and try again.",refresh:"Refresh",notificationsTitle:"Hook Notifications",notificationsSubtitle:"Manage system notifications and third-party notification dispatch.",inAppTitle:"DSH In-App Notifications",inAppDesc:"Display stacked hook alert cards in the bottom-right corner of DSH.",inAppEnabled:"Enable in-app hook toasts",inAppAutoClose:"Auto-close notification toasts",inAppAutoCloseSeconds:"Auto-close duration (seconds)",inAppAutoCloseHint:"Range: 5\u20133600 seconds (default 60).",systemNotifyTitle:"System Notifications",systemNotifyHelper:"Filter system notification and taskbar alerts per Hook card below (gray bell = off, blue bell = on).",testBtn:"Test",testingBtn:"Testing\u2026",testSystemSent:"Test system notification sent.",testSystemFailed:"Failed to send test system notification.",browserPermissionHint:"Browser notifications are not granted yet.",browserPermissionGrant:"Enable Browser Permission",taskbarTitle:"Taskbar Attention",taskbarHelper:"Flash the Windows taskbar when the window is unfocused; toggled independently from system notifications.",taskbarModeLabel:"Attention Mode",taskbarModeFinite:"Flash N Times",taskbarModeUntilFocused:"Until Focused",taskbarFlashCountLabel:"Flash Count",testTaskbarSent:"Taskbar flash triggered.",testTaskbarFailed:"Failed to trigger taskbar flash.",soundTitle:"Custom Notification Sound",soundHelper:"Select a WAV file for hook system notifications; uses the OS default sound when unset.",soundFormatBadge:".wav only",soundChoose:"Choose Sound",soundUploading:"Uploading\u2026",soundClear:"Clear",soundPreview:"Preview",soundUnset:"Not Set",soundUnsetDesc:"No custom sound set; system default sound will be used.",soundSetDesc:"Using custom WAV notification sound.",soundInvalidFile:"Please select a valid .wav file under 20 MiB.",soundUploadFailed:"Failed to upload custom sound.",soundPreviewFailed:"Unable to play audio preview in this browser.",suppressFocusedTitle:"Suppress System Notifications When Focused",suppressFocusedHelper:"When enabled, only in-app hook toasts are shown while DSH is in active use; system notifications still trigger when unfocused or in background.",thirdPartyTitle:"Third-Party Hook Notifications",thirdPartyEnabled:"Enabled",thirdPartyPaused:"Paused",thirdPartyPrivacy:"DSH dispatches batched alerts asynchronously on hooks; sends only summary and event icon without prompts, terminal output, or absolute paths.",thirdPartyPausedBanner:"Third-party dispatch is currently paused. Enable the master switch above to resume sending.",thirdPartyAddBtn:"+ Add Target",thirdPartyCredNotice:"Credentials are stored in DSH local credential vault (~/.dsh/.credentials.yaml) and masked in UI; leave blank when editing to preserve existing values.",thirdPartyEmpty:'No third-party notification targets yet. Choose a platform above and click "+ Add Target".',targetNameLabel:"Target Name",targetNamePlaceholder:"e.g. My Phone Bark / Team Feishu",targetProviderLabel:"Platform",targetEventsLabel:"Subscribed Events",targetNoEvents:"No events selected",targetSaveBtn:"Save",targetCancelBtn:"Cancel",targetDeleteBtn:"Delete",targetExpand:"Configure",targetCollapse:"Collapse",targetSaved:"Target saved.",targetSaveFailed:"Failed to save target.",targetDeleted:"Target removed.",targetTestOk:"Delivered ({ms} ms)",targetTestFail:"Failed: {msg}",secretConfiguredPlaceholder:"Configured (leave blank to keep)",secretConfiguredHint:"Saved in credential vault",showSecret:"Show",hideSecret:"Hide",targetLimitReached:"Maximum of 20 targets reached.",targetUnsavedBadge:"Unsaved Draft",mountPointsTitle:"Hook Mount Points & Scripts",mountPointsSubtitle:"Configure DSH lifecycle hooks, independent notification bells, and custom automation scripts.",resetDefaultScripts:"Reset Default Scripts",resetDone:"Default scripts restored.",executionLogs:"Execution Logs",groupCore:"Core Notification Hooks",groupSessionTools:"Session & Tool Hooks",groupSubsystems:"Subsystem Hooks",mountCountSummary:"{enabled}/{total} active",scriptsSummary:"Default {defaults} \xB7 Custom {customs}",bellOnTip:"System & taskbar notifications ON for this hook (click to mute)",bellOffTip:"System & taskbar notifications OFF for this hook (click to enable)",expandScripts:"Scripts",collapseScripts:"Close",noScriptsInPoint:"No scripts attached to this mount point yet. Upload a custom script or test trigger directly.",scriptDefaultBadge:"Default",scriptCustomBadge:"Custom",matcherLabel:"Matcher (Regex)",matcherPlaceholder:"e.g. Bash|Write|Edit",timeoutLabel:"Timeout (s)",viewSource:"View Source",testRunScript:"Test Run",deleteScript:"Delete",uploadScript:"Upload Script",uploadingScript:"Uploading\u2026",testMountPoint:"Test Trigger Mount Point",testResultOk:"Triggered successfully ({ms} ms)",testResultSuppressed:"Suppressed by hook script ({ms} ms)",testResultFail:"Test failed: {msg}",scriptInvalidFile:"Supported extensions: .mjs, .js, .cjs, .ps1, .sh, .py, .cmd, .bat (max 512 KiB).",sourceModalTitle:"Script Source",copySource:"Copy",copiedSource:"Copied",closeBtn:"Close",logsTitle:"Recent Hook Executions",logsEmpty:"No script executions recorded yet.",logsSuppressed:"Suppressed",logsDryRun:"Test Run",logsExitCode:"Exit {code}",toastEyebrow:"DSH Hook",toastJumpSession:"Open Session",toastHandleAction:"Review",toastDismiss:"Dismiss",toastFromPrefix:"From: "},ZH={nav:"Hook",pageTitle:"Hook \u4E0E\u901A\u77E5\u8BBE\u7F6E",pageSubtitle:"\u7BA1\u7406 DSH \u539F\u751F\u751F\u547D\u5468\u671F Hook \u6302\u8F7D\u70B9\u3001\u7CFB\u7EDF\u901A\u77E5\u63D0\u9192\u4E0E\u7B2C\u4E09\u65B9\u901A\u77E5\u6D3E\u53D1\u3002",loading:"\u6B63\u5728\u52A0\u8F7D Hook \u8BBE\u7F6E\u2026",retry:"\u91CD\u8BD5",reload:"\u91CD\u65B0\u52A0\u8F7D\u6700\u65B0\u914D\u7F6E",saving:"\u6B63\u5728\u4FDD\u5B58\u2026",saved:"\u5DF2\u4FDD\u5B58",conflictError:"\u8BBE\u7F6E\u5DF2\u5728\u522B\u5904\u66F4\u65B0\uFF0C\u8BF7\u91CD\u65B0\u52A0\u8F7D\u540E\u518D\u4FDD\u5B58\u3002",loadError:"\u65E0\u6CD5\u52A0\u8F7D Hook \u8BBE\u7F6E\u3002",actionError:"\u64CD\u4F5C\u672A\u6210\u529F\uFF0C\u8BF7\u68C0\u67E5\u8F93\u5165\u540E\u91CD\u8BD5\u3002",refresh:"\u5237\u65B0",notificationsTitle:"Hook \u901A\u77E5",notificationsSubtitle:"\u7BA1\u7406\u7CFB\u7EDF\u901A\u77E5\u548C\u7B2C\u4E09\u65B9\u901A\u77E5\u6D3E\u53D1\u3002",inAppTitle:"DSH \u5185\u90E8\u901A\u77E5",inAppDesc:"\u5728 DSH \u7A97\u53E3\u53F3\u4E0B\u89D2\u5F39\u51FA\u5E94\u7528\u5185 Hook \u901A\u77E5\u5361\u7247\u3002",inAppEnabled:"\u542F\u7528\u5E94\u7528\u5185 Hook \u901A\u77E5\u5F39\u6846",inAppAutoClose:"\u81EA\u52A8\u5173\u95ED\u901A\u77E5\u5F39\u6846",inAppAutoCloseSeconds:"\u81EA\u52A8\u5173\u95ED\u65F6\u95F4\uFF08\u79D2\uFF09",inAppAutoCloseHint:"\u53EF\u914D\u7F6E 5\u20133600 \u79D2\uFF0C\u9ED8\u8BA4 60 \u79D2\u3002",systemNotifyTitle:"\u7CFB\u7EDF\u901A\u77E5",systemNotifyHelper:"\u6BCF\u4E2A Hook \u5361\u7247\u4E0B\u65B9\u53EF\u72EC\u7ACB\u7B5B\u9009\u7CFB\u7EDF\u901A\u77E5\u4E0E\u4EFB\u52A1\u680F\u63D0\u9192\u4E8B\u4EF6\uFF08\u7070\u8272\u94C3\u94DB=\u5173\u95ED\uFF0C\u84DD\u8272\u94C3\u94DB=\u5F00\u542F\uFF09",testBtn:"\u6D4B\u8BD5",testingBtn:"\u6D4B\u8BD5\u4E2D\u2026",testSystemSent:"\u5DF2\u53D1\u9001\u6D4B\u8BD5\u7CFB\u7EDF\u901A\u77E5\u3002",testSystemFailed:"\u6D4B\u8BD5\u7CFB\u7EDF\u901A\u77E5\u53D1\u9001\u5931\u8D25\u3002",browserPermissionHint:"\u5F53\u524D\u6D4F\u89C8\u5668\u5C1A\u672A\u6388\u4E88\u684C\u9762\u901A\u77E5\u6743\u9650\u3002",browserPermissionGrant:"\u8BF7\u6C42\u6D4F\u89C8\u5668\u901A\u77E5\u6743\u9650",taskbarTitle:"\u4EFB\u52A1\u680F\u63D0\u9192",taskbarHelper:"\u7A97\u53E3\u672A\u805A\u7126\u65F6\uFF0C\u901A\u8FC7 Windows \u4EFB\u52A1\u680F\u95EA\u70C1\u63D0\u9192\uFF1B\u4E0E\u7CFB\u7EDF\u901A\u77E5\u72EC\u7ACB\u5F00\u5173\u3002",taskbarModeLabel:"\u63D0\u9192\u65B9\u5F0F",taskbarModeFinite:"\u95EA\u70C1\u6307\u5B9A\u6B21\u6570",taskbarModeUntilFocused:"\u6301\u7EED\u5230\u7A97\u53E3\u805A\u7126",taskbarFlashCountLabel:"\u95EA\u70C1\u6B21\u6570",testTaskbarSent:"\u5DF2\u89E6\u53D1\u4EFB\u52A1\u680F\u95EA\u70C1\u6D4B\u8BD5\u3002",testTaskbarFailed:"\u4EFB\u52A1\u680F\u95EA\u70C1\u6D4B\u8BD5\u5931\u8D25\u3002",soundTitle:"\u81EA\u5B9A\u4E49\u901A\u77E5\u58F0\u97F3",soundHelper:"\u4E3A Hook \u7CFB\u7EDF\u901A\u77E5\u9009\u62E9 WAV \u58F0\u97F3\uFF1B\u672A\u8BBE\u7F6E\u65F6\u4F7F\u7528\u7CFB\u7EDF\u9ED8\u8BA4\u58F0\u97F3\u3002",soundFormatBadge:"\u4EC5\u652F\u6301 .wav \u683C\u5F0F",soundChoose:"\u9009\u62E9\u58F0\u97F3",soundUploading:"\u4E0A\u4F20\u4E2D\u2026",soundClear:"\u6E05\u9664",soundPreview:"\u8BD5\u542C",soundUnset:"\u672A\u8BBE\u7F6E",soundUnsetDesc:"\u672A\u8BBE\u7F6E\u81EA\u5B9A\u4E49\u58F0\u97F3\uFF0C\u5C06\u4F7F\u7528\u7CFB\u7EDF\u9ED8\u8BA4\u58F0\u97F3\u3002",soundSetDesc:"\u5DF2\u542F\u7528\u81EA\u5B9A\u4E49 WAV \u901A\u77E5\u58F0\u97F3\u3002",soundInvalidFile:"\u8BF7\u9009\u62E9\u6709\u6548\u7684 .wav \u6587\u4EF6\uFF08\u4E0D\u8D85\u8FC7 20 MiB\uFF09\u3002",soundUploadFailed:"\u81EA\u5B9A\u4E49\u58F0\u97F3\u4E0A\u4F20\u5931\u8D25\u3002",soundPreviewFailed:"\u5F53\u524D\u6D4F\u89C8\u5668\u65E0\u6CD5\u64AD\u653E\u8BD5\u542C\u97F3\u9891\u3002",suppressFocusedTitle:"\u7A97\u53E3\u805A\u7126\u65F6\u4E0D\u53D1\u9001\u7CFB\u7EDF\u901A\u77E5",suppressFocusedHelper:"\u5F00\u542F\u540E\uFF0CDSH \u6B63\u5728\u4F7F\u7528\u65F6\u53EA\u663E\u793A\u5E94\u7528\u5185 Hook \u901A\u77E5\uFF1B\u5207\u5230\u5176\u4ED6\u5E94\u7528\u6216\u540E\u53F0\u65F6\u4ECD\u6309\u7CFB\u7EDF\u901A\u77E5\u8BBE\u7F6E\u63D0\u9192\u3002",thirdPartyTitle:"\u4E09\u65B9 Hook \u901A\u77E5",thirdPartyEnabled:"\u5DF2\u542F\u7528",thirdPartyPaused:"\u5DF2\u6682\u505C",thirdPartyPrivacy:"DSH \u6536\u5230 Hook \u540E\u5F02\u6B65\u6279\u91CF\u901A\u77E5\u5916\u90E8\u5E73\u53F0\uFF1B\u53EA\u53D1\u9001\u6458\u8981\u548C\u4E8B\u4EF6\u56FE\u6807\uFF0C\u4E0D\u53D1\u9001 Prompt\u3001\u7EC8\u7AEF\u8F93\u51FA\u6216\u7EDD\u5BF9\u8DEF\u5F84\u3002",thirdPartyPausedBanner:"\u4E09\u65B9 Hook \u901A\u77E5\u5F53\u524D\u5DF2\u6682\u505C\uFF0C\u6253\u5F00\u4E0A\u65B9\u603B\u5F00\u5173\u5373\u53EF\u6062\u590D\u6D3E\u53D1\u3002",thirdPartyAddBtn:"+ \u65B0\u589E\u901A\u77E5\u76EE\u6807",thirdPartyCredNotice:"\u51ED\u8BC1\u4FDD\u5B58\u5728 DSH \u672C\u5730\u51ED\u8BC1\u5E93\uFF08~/.dsh/.credentials.yaml\uFF09\uFF0C\u754C\u9762\u906E\u7F69\u663E\u793A\uFF1B\u7F16\u8F91\u7559\u7A7A\u8868\u793A\u4FDD\u7559\u5DF2\u4FDD\u5B58\u51ED\u8BC1\u3002",thirdPartyEmpty:"\u6682\u65E0\u4E09\u65B9\u901A\u77E5\u76EE\u6807\u3002\u5728\u4E0A\u65B9\u9009\u62E9\u5E73\u53F0\u5E76\u70B9\u51FB\u300C+ \u65B0\u589E\u901A\u77E5\u76EE\u6807\u300D\u5F00\u59CB\u914D\u7F6E\u3002",targetNameLabel:"\u76EE\u6807\u540D\u79F0",targetNamePlaceholder:"\u4F8B\u5982\uFF1A\u6211\u7684\u624B\u673A Bark / \u7814\u53D1\u7FA4\u98DE\u4E66",targetProviderLabel:"\u901A\u77E5\u5E73\u53F0",targetEventsLabel:"\u8BA2\u9605\u4E8B\u4EF6",targetNoEvents:"\u672A\u8BA2\u9605\u4EFB\u4F55\u4E8B\u4EF6",targetSaveBtn:"\u4FDD\u5B58",targetCancelBtn:"\u53D6\u6D88",targetDeleteBtn:"\u5220\u9664",targetExpand:"\u5C55\u5F00\u914D\u7F6E",targetCollapse:"\u6536\u8D77",targetSaved:"\u901A\u77E5\u76EE\u6807\u5DF2\u4FDD\u5B58\u3002",targetSaveFailed:"\u4FDD\u5B58\u901A\u77E5\u76EE\u6807\u5931\u8D25\u3002",targetDeleted:"\u5DF2\u5220\u9664\u901A\u77E5\u76EE\u6807\u3002",targetTestOk:"\u53D1\u9001\u6210\u529F ({ms} ms)",targetTestFail:"\u5931\u8D25\uFF1A{msg}",secretConfiguredPlaceholder:"\u5DF2\u914D\u7F6E\uFF08\u7559\u7A7A\u4FDD\u7559\u539F\u503C\uFF09",secretConfiguredHint:"\u5DF2\u4FDD\u5B58\u5728\u672C\u5730\u51ED\u8BC1\u5E93",showSecret:"\u663E\u793A",hideSecret:"\u9690\u85CF",targetLimitReached:"\u6700\u591A\u652F\u6301 20 \u4E2A\u4E09\u65B9\u901A\u77E5\u76EE\u6807\u3002",targetUnsavedBadge:"\u672A\u4FDD\u5B58",mountPointsTitle:"Hook \u6302\u8F7D\u70B9\u4E0E\u811A\u672C",mountPointsSubtitle:"\u7BA1\u7406 DSH \u539F\u751F Hook \u6302\u8F7D\u70B9\u3001\u72EC\u7ACB\u7CFB\u7EDF\u901A\u77E5\u5F00\u5173\u4EE5\u53CA\u81EA\u5B9A\u4E49\u6269\u5C55\u811A\u672C\u3002",resetDefaultScripts:"\u91CD\u7F6E\u9ED8\u8BA4\u811A\u672C",resetDone:"\u9ED8\u8BA4\u811A\u672C\u5DF2\u91CD\u7F6E\u6062\u590D\u3002",executionLogs:"\u6267\u884C\u65E5\u5FD7",groupCore:"\u6838\u5FC3\u901A\u77E5 Hook",groupSessionTools:"\u4F1A\u8BDD\u4E0E\u5DE5\u5177 Hook",groupSubsystems:"\u5B50\u7CFB\u7EDF Hook",mountCountSummary:"\u5DF2\u5F00\u542F {enabled}/{total}",scriptsSummary:"\u9ED8\u8BA4 {defaults} \xB7 \u81EA\u5B9A\u4E49 {customs}",bellOnTip:"\u6B64\u6302\u8F7D\u70B9\u5DF2\u5F00\u542F\u7CFB\u7EDF\u901A\u77E5\u4E0E\u4EFB\u52A1\u680F\u63D0\u9192\uFF08\u70B9\u51FB\u9759\u97F3\uFF09",bellOffTip:"\u6B64\u6302\u8F7D\u70B9\u5DF2\u5173\u95ED\u7CFB\u7EDF\u901A\u77E5\u4E0E\u4EFB\u52A1\u680F\u63D0\u9192\uFF08\u70B9\u51FB\u5F00\u542F\uFF09",expandScripts:"\u7BA1\u7406\u811A\u672C",collapseScripts:"\u6536\u8D77",noScriptsInPoint:"\u8BE5\u6302\u8F7D\u70B9\u6682\u65E0\u811A\u672C\u3002\u53EF\u76F4\u63A5\u4E0A\u4F20\u81EA\u5B9A\u4E49\u811A\u672C\u6216\u70B9\u51FB\u6D4B\u8BD5\u89E6\u53D1\u901A\u77E5\u3002",scriptDefaultBadge:"\u9ED8\u8BA4",scriptCustomBadge:"\u81EA\u5B9A\u4E49",matcherLabel:"\u5DE5\u5177\u5339\u914D\u5668 (\u6B63\u5219)",matcherPlaceholder:"\u4F8B\u5982\uFF1ABash|Write|Edit",timeoutLabel:"\u8D85\u65F6 (\u79D2)",viewSource:"\u67E5\u770B\u6E90\u7801",testRunScript:"\u6D4B\u8BD5\u8FD0\u884C",deleteScript:"\u5220\u9664",uploadScript:"\u4E0A\u4F20\u811A\u672C",uploadingScript:"\u4E0A\u4F20\u4E2D\u2026",testMountPoint:"\u6D4B\u8BD5\u89E6\u53D1\u6B64\u6302\u8F7D\u70B9",testResultOk:"\u5DF2\u6210\u529F\u89E6\u53D1 ({ms} ms)",testResultSuppressed:"\u5DF2\u88AB\u811A\u672C\u6291\u5236\u901A\u77E5 ({ms} ms)",testResultFail:"\u6D4B\u8BD5\u6267\u884C\u5931\u8D25\uFF1A{msg}",scriptInvalidFile:"\u4EC5\u652F\u6301 .mjs, .js, .cjs, .ps1, .sh, .py, .cmd, .bat\uFF08\u6700\u5927 512 KiB\uFF09\u3002",sourceModalTitle:"\u811A\u672C\u6E90\u7801",copySource:"\u590D\u5236",copiedSource:"\u5DF2\u590D\u5236",closeBtn:"\u5173\u95ED",logsTitle:"\u6700\u8FD1\u811A\u672C\u6267\u884C\u65E5\u5FD7",logsEmpty:"\u6682\u65E0\u811A\u672C\u6267\u884C\u8BB0\u5F55\u3002",logsSuppressed:"\u5DF2\u6291\u5236",logsDryRun:"\u6D4B\u8BD5\u8FD0\u884C",logsExitCode:"\u9000\u51FA\u7801 {code}",toastEyebrow:"DSH Hook",toastJumpSession:"\u67E5\u770B\u4F1A\u8BDD",toastHandleAction:"\u53BB\u5904\u7406",toastDismiss:"\u5173\u95ED",toastFromPrefix:"\u6765\u81EA\uFF1A"};function formatMessage(template,params){return params?template.replace(/\{(\w+)\}/g,(_,k)=>Object.prototype.hasOwnProperty.call(params,k)?String(params[k]):`{${k}}`):template}function detectIsZh(t){return t("nav")==="Hook"&&t("notificationsTitle")==="Hook \u901A\u77E5"}var import_react4=require("react"),import_jsx_runtime=require("react/jsx-runtime");function Svg({size=16,className,style,children}){return(0,import_jsx_runtime.jsx)("svg",{width:size,height:size,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",className,style:{flexShrink:0,display:"inline-block",...style},children})}function WebhookIcon({size=16,className,style}){return(0,import_jsx_runtime.jsxs)(Svg,{size,className,style,children:[(0,import_jsx_runtime.jsx)("path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2"}),(0,import_jsx_runtime.jsx)("path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06"}),(0,import_jsx_runtime.jsx)("path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8"})]})}function BellIcon({size=16,className,style}){return(0,import_jsx_runtime.jsxs)(Svg,{size,className,style,children:[(0,import_jsx_runtime.jsx)("path",{d:"M10.268 21a2 2 0 0 0 3.464 0"}),(0,import_jsx_runtime.jsx)("path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"})]})}function BellOffIcon({size=16,className,style}){return(0,import_jsx_runtime.jsxs)(Svg,{size,className,style,children:[(0,import_jsx_runtime.jsx)("path",{d:"M10.268 21a2 2 0 0 0 3.464 0"}),(0,import_jsx_runtime.jsx)("path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742"}),(0,import_jsx_runtime.jsx)("path",{d:"m2 2 20 20"}),(0,import_jsx_runtime.jsx)("path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05"})]})}function Volume2Icon({size=16,className,style}){return(0,import_jsx_runtime.jsxs)(Svg,{size,className,style,children:[(0,import_jsx_runtime.jsx)("path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"}),(0,import_jsx_runtime.jsx)("path",{d:"M16 9a5 5 0 0 1 0 6"}),(0,import_jsx_runtime.jsx)("path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728"})]})}function PlayIcon({size=14,className,style}){return(0,import_jsx_runtime.jsx)(Svg,{size,className,style,children:(0,import_jsx_runtime.jsx)("polygon",{points:"6 3 20 12 6 21 6 3"})})}function TrashIcon({size=15,className,style}){return(0,import_jsx_runtime.jsxs)(Svg,{size,className,style,children:[(0,import_jsx_runtime.jsx)("path",{d:"M3 6h18"}),(0,import_jsx_runtime.jsx)("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),(0,import_jsx_runtime.jsx)("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})}function UploadIcon({size=15,className,style}){return(0,import_jsx_runtime.jsxs)(Svg,{size,className,style,children:[(0,import_jsx_runtime.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,import_jsx_runtime.jsx)("polyline",{points:"17 8 12 3 7 8"}),(0,import_jsx_runtime.jsx)("line",{x1:"12",x2:"12",y1:"3",y2:"15"})]})}function FileCodeIcon({size=15,className,style}){return(0,import_jsx_runtime.jsxs)(Svg,{size,className,style,children:[(0,import_jsx_runtime.jsx)("path",{d:"M10 12.5 8 15l2 2.5"}),(0,import_jsx_runtime.jsx)("path",{d:"m14 12.5 2 2.5-2 2.5"}),(0,import_jsx_runtime.jsx)("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),(0,import_jsx_runtime.jsx)("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z"})]})}function RotateCcwIcon({size=15,className,style}){return(0,import_jsx_runtime.jsxs)(Svg,{size,className,style,children:[(0,import_jsx_runtime.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,import_jsx_runtime.jsx)("path",{d:"M3 3v5h5"})]})}function TerminalIcon({size=15,className,style}){return(0,import_jsx_runtime.jsxs)(Svg,{size,className,style,children:[(0,import_jsx_runtime.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,import_jsx_runtime.jsx)("line",{x1:"12",x2:"20",y1:"19",y2:"19"})]})}function ChevronDownIcon({size=16,className,style}){return(0,import_jsx_runtime.jsx)(Svg,{size,className,style,children:(0,import_jsx_runtime.jsx)("path",{d:"m6 9 6 6 6-6"})})}function ChevronRightIcon({size=16,className,style}){return(0,import_jsx_runtime.jsx)(Svg,{size,className,style,children:(0,import_jsx_runtime.jsx)("path",{d:"m9 18 6-6-6-6"})})}function PlusIcon({size=15,className,style}){return(0,import_jsx_runtime.jsxs)(Svg,{size,className,style,children:[(0,import_jsx_runtime.jsx)("path",{d:"M5 12h14"}),(0,import_jsx_runtime.jsx)("path",{d:"M12 5v14"})]})}function EyeIcon({size=15,className,style}){return(0,import_jsx_runtime.jsxs)(Svg,{size,className,style,children:[(0,import_jsx_runtime.jsx)("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),(0,import_jsx_runtime.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}function EyeOffIcon({size=15,className,style}){return(0,import_jsx_runtime.jsxs)(Svg,{size,className,style,children:[(0,import_jsx_runtime.jsx)("path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"}),(0,import_jsx_runtime.jsx)("path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}),(0,import_jsx_runtime.jsx)("path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"}),(0,import_jsx_runtime.jsx)("path",{d:"m2 2 20 20"})]})}function CheckIcon({size=14,className,style}){return(0,import_jsx_runtime.jsx)(Svg,{size,className,style,children:(0,import_jsx_runtime.jsx)("path",{d:"M20 6 9 17l-5-5"})})}function AlertTriangleIcon({size=15,className,style}){return(0,import_jsx_runtime.jsxs)(Svg,{size,className,style,children:[(0,import_jsx_runtime.jsx)("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),(0,import_jsx_runtime.jsx)("path",{d:"M12 9v4"}),(0,import_jsx_runtime.jsx)("path",{d:"M12 17h.01"})]})}function XIcon({size=15,className,style}){return(0,import_jsx_runtime.jsxs)(Svg,{size,className,style,children:[(0,import_jsx_runtime.jsx)("path",{d:"M18 6 6 18"}),(0,import_jsx_runtime.jsx)("path",{d:"m6 6 12 12"})]})}function RefreshCwIcon({size=14,className,style}){return(0,import_jsx_runtime.jsxs)(Svg,{size,className,style,children:[(0,import_jsx_runtime.jsx)("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),(0,import_jsx_runtime.jsx)("path",{d:"M21 3v5h-5"}),(0,import_jsx_runtime.jsx)("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),(0,import_jsx_runtime.jsx)("path",{d:"M8 16H3v5"})]})}function MonitorIcon({size=15,className,style}){return(0,import_jsx_runtime.jsxs)(Svg,{size,className,style,children:[(0,import_jsx_runtime.jsx)("rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}),(0,import_jsx_runtime.jsx)("line",{x1:"8",x2:"16",y1:"21",y2:"21"}),(0,import_jsx_runtime.jsx)("line",{x1:"12",x2:"12",y1:"17",y2:"21"})]})}function SendIcon({size=14,className,style}){return(0,import_jsx_runtime.jsxs)(Svg,{size,className,style,children:[(0,import_jsx_runtime.jsx)("path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z"}),(0,import_jsx_runtime.jsx)("path",{d:"m21.854 2.147-10.94 10.939"})]})}function CopyIcon({size=14,className,style}){return(0,import_jsx_runtime.jsxs)(Svg,{size,className,style,children:[(0,import_jsx_runtime.jsx)("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),(0,import_jsx_runtime.jsx)("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})}function ToggleSwitch({checked,onChange,label,disabled=!1,title,compact=!1}){return(0,import_jsx_runtime.jsx)("button",{type:"button",role:"switch","aria-checked":checked,"aria-label":label,title:title??label,disabled,className:`tavlo-hooks-switch${compact?" is-compact":""}`,"data-checked":checked?"true":"false",onClick:e=>{e.stopPropagation(),disabled||onChange(!checked)},children:(0,import_jsx_runtime.jsx)("span",{className:"tavlo-hooks-switch-thumb","aria-hidden":"true"})})}var PROVIDER_COLORS={bark:{bg:"#ef4444",fg:"#fff",label:"BK"},dingtalk:{bg:"#0089ff",fg:"#fff",label:"\u9489"},feishu:{bg:"#00d6b9",fg:"#063b36",label:"\u98DE"},telegram:{bg:"#26a5e4",fg:"#fff",label:"TG"},wecom:{bg:"#2b7de9",fg:"#fff",label:"\u4F01"},pushplus:{bg:"#10b981",fg:"#fff",label:"P+"},wxpusher:{bg:"#07c160",fg:"#fff",label:"Wx"},serverchan:{bg:"#f59e0b",fg:"#fff",label:"\u9171"},ntfy:{bg:"#317f6f",fg:"#fff",label:"nt"},gotify:{bg:"#6366f1",fg:"#fff",label:"Go"},custom:{bg:"#64748b",fg:"#fff",label:"{}"}};function PlatformIcon({provider,size=18}){let palette=PROVIDER_COLORS[provider]??PROVIDER_COLORS.custom;return(0,import_jsx_runtime.jsx)("span",{"aria-hidden":"true",className:"tavlo-hooks-platform-glyph",style:{width:size,height:size,borderRadius:Math.max(4,Math.round(size*.28)),background:palette.bg,color:palette.fg,fontSize:Math.max(9,Math.round(size*.52))},children:palette.label})}var import_react=require("react"),import_react_dom=require("react-dom"),NOTIFICATION_CATEGORIES=["PermissionRequest","Notification","Stop","StopFailure","SessionStart","UserPromptSubmit"],FALLBACK_CATEGORY_META={PermissionRequest:{icon:"\u{1F6E1}\uFE0F",labelZh:"\u5F85\u5BA1\u6279",labelEn:"Pending Approval",variant:"approval",defaultSelected:!0},Notification:{icon:"\u{1F514}",labelZh:"\u9700\u8981\u5173\u6CE8",labelEn:"Needs Attention",variant:"attention",defaultSelected:!0},Stop:{icon:"\u2705",labelZh:"\u4EFB\u52A1\u5B8C\u6210",labelEn:"Task Completed",variant:"success",defaultSelected:!0},StopFailure:{icon:"\u274C",labelZh:"\u4EFB\u52A1\u5931\u8D25",labelEn:"Task Failed",variant:"error",defaultSelected:!0},SessionStart:{icon:"\u{1F680}",labelZh:"\u4F1A\u8BDD\u542F\u52A8",labelEn:"Session Started",variant:"info",defaultSelected:!1},UserPromptSubmit:{icon:"\u2328\uFE0F",labelZh:"\u8FD0\u884C\u4E2D",labelEn:"Running",variant:"info",defaultSelected:!1}},FALLBACK_MOUNT_POINTS=[{id:"approval.request",group:"core",nameZh:"\u5F85\u5BA1\u6279\u6743\u9650\u8BF7\u6C42",nameEn:"Approval Request",descZh:"\u5DE5\u5177\u6267\u884C\u9700\u8981\u7528\u6237\u5BA1\u6279\u786E\u8BA4\u65F6\u89E6\u53D1\u3002",descEn:"Fires when a tool call awaits user approval.",dshEvents:["approval/request","session:approval/asked"],category:"PermissionRequest",defaultEnabled:!0,defaultBell:!0,defaultScriptIds:["notify-approval"]},{id:"user.question",group:"core",nameZh:"\u7B49\u5F85\u7528\u6237\u56DE\u7B54",nameEn:"User Question",descZh:"Agent \u53D1\u8D77\u63D0\u95EE\u6216\u8BF7\u6C42\u8BA1\u5212\u786E\u8BA4\u65F6\u89E6\u53D1\u3002",descEn:"Fires when the agent asks a question or requests plan review.",dshEvents:["user-questions/request"],category:"Notification",defaultEnabled:!0,defaultBell:!0,defaultScriptIds:["notify-attention"]},{id:"turn.completed",group:"core",nameZh:"\u56DE\u5408\u5B8C\u6210",nameEn:"Turn Completed",descZh:"\u4E3B\u4F1A\u8BDD Agent \u56DE\u5408\u771F\u6B63\u5B8C\u6210\u5E76\u8FDB\u5165\u7B49\u5F85\u7528\u6237\u72B6\u6001\u65F6\u89E6\u53D1\uFF08\u81EA\u52A8\u6392\u9664\u5B50 Agent\u3001Goal \u4E2D\u95F4\u8F6E\u6B21\u4E0E\u961F\u5217\u7EED\u8DD1\uFF09\u3002",descEn:"Fires when a main-session agent turn finishes and enters idle (excludes subagents, intermediate Goal rounds, and queued continuations).",dshEvents:["session:turn/end[completed]"],category:"Stop",defaultEnabled:!0,defaultBell:!0,defaultScriptIds:["notify-task-done"]},{id:"turn.failed",group:"core",nameZh:"\u6267\u884C\u5931\u8D25",nameEn:"Turn Failed",descZh:"\u56DE\u5408\u6216\u4EE3\u7406\u5FAA\u73AF\u53D1\u751F\u9519\u8BEF\u65F6\u89E6\u53D1\u3002",descEn:"Fires when a turn or agent loop fails.",dshEvents:["session:turn/end[error]","agent/error","agent-loop/config-start-failed"],category:"StopFailure",defaultEnabled:!0,defaultBell:!0,defaultScriptIds:["notify-task-failed"]},{id:"turn.attention",group:"core",nameZh:"\u56DE\u5408\u4E2D\u65AD / \u963B\u585E",nameEn:"Turn Needs Attention",descZh:"\u56DE\u5408\u88AB\u963B\u585E\u3001\u8FBE\u5230\u4E0A\u9650\u3001\u4E2D\u6B62\u6216\u4E2D\u65AD\u65F6\u89E6\u53D1\u3002",descEn:"Fires when a turn stops due to block, max tokens, abort, or interrupt.",dshEvents:["session:turn/end[blocked|max-tokens|aborted|interrupted]"],category:"Notification",defaultEnabled:!0,defaultBell:!0,defaultScriptIds:["notify-attention"]},{id:"session.start",group:"session_tools",nameZh:"\u4F1A\u8BDD\u542F\u52A8",nameEn:"Session Start",descZh:"\u65B0\u4F1A\u8BDD\u6216 Agent \u5B9E\u4F8B\u521B\u5EFA\u65F6\u89E6\u53D1\u3002",descEn:"Fires when a session or agent is created.",dshEvents:["agent/created","session/created"],category:"SessionStart",defaultEnabled:!1,defaultBell:!1,defaultScriptIds:["notify-session-start"]},{id:"turn.start",group:"session_tools",nameZh:"\u65B0\u56DE\u5408\u5F00\u59CB",nameEn:"Turn Start",descZh:"\u63D0\u4EA4\u7528\u6237\u8F93\u5165\u5E76\u5F00\u59CB\u65B0\u4E00\u8F6E\u6267\u884C\u65F6\u89E6\u53D1\u3002",descEn:"Fires when a new turn starts.",dshEvents:["session:turn/start"],category:"UserPromptSubmit",defaultEnabled:!1,defaultBell:!1,defaultScriptIds:[]},{id:"session.end",group:"session_tools",nameZh:"\u4F1A\u8BDD\u7ED3\u675F",nameEn:"Session End",descZh:"\u4F1A\u8BDD\u6216 Agent \u91CA\u653E\u9500\u6BC1\u65F6\u89E6\u53D1\u3002",descEn:"Fires when a session or agent is disposed.",dshEvents:["session/disposed","agent/disposed"],category:"SessionStart",defaultEnabled:!1,defaultBell:!1,defaultScriptIds:[]},{id:"tool.pre",group:"session_tools",nameZh:"\u5DE5\u5177\u8C03\u7528\u524D",nameEn:"Pre Tool Execute",descZh:"\u5DE5\u5177\u6267\u884C\u524D\u89C2\u5BDF\uFF08\u53EF\u6309\u5DE5\u5177\u540D\u79F0\u6B63\u5219\u5339\u914D\uFF09\u3002",descEn:"Observes tool invocations before execution (supports matcher).",dshEvents:["tools/pre-execute"],category:"UserPromptSubmit",defaultEnabled:!1,defaultBell:!1,supportsMatcher:!0,defaultScriptIds:[]},{id:"tool.post",group:"session_tools",nameZh:"\u5DE5\u5177\u8C03\u7528\u6210\u529F",nameEn:"Post Tool Execute",descZh:"\u5DE5\u5177\u8C03\u7528\u6210\u529F\u8FD4\u56DE\u7ED3\u679C\u540E\u89E6\u53D1\uFF08\u652F\u6301\u5BA1\u8BA1\u793A\u4F8B\u811A\u672C\uFF09\u3002",descEn:"Fires after a tool succeeds (supports matcher and audit log script).",dshEvents:["tools/result[ok]"],category:"UserPromptSubmit",defaultEnabled:!1,defaultBell:!1,supportsMatcher:!0,defaultScriptIds:["audit-log-example"]},{id:"tool.failure",group:"session_tools",nameZh:"\u5DE5\u5177\u8C03\u7528\u5931\u8D25",nameEn:"Tool Failure",descZh:"\u5DE5\u5177\u8C03\u7528\u8FD4\u56DE\u9519\u8BEF\u65F6\u89E6\u53D1\uFF08\u53EF\u6309\u5DE5\u5177\u540D\u79F0\u5339\u914D\uFF09\u3002",descEn:"Fires when a tool execution returns an error (supports matcher).",dshEvents:["tools/result[error]"],category:"StopFailure",defaultEnabled:!1,defaultBell:!1,supportsMatcher:!0,defaultScriptIds:[]},{id:"subagent.start",group:"subsystems",nameZh:"\u5B50 Agent \u542F\u52A8",nameEn:"Subagent Start",descZh:"\u5B50 Agent \u5F00\u59CB\u8FD0\u884C\u65F6\u89E6\u53D1\u3002",descEn:"Fires when a subagent starts.",dshEvents:["subagent/start"],category:"UserPromptSubmit",defaultEnabled:!1,defaultBell:!1,defaultScriptIds:[]},{id:"subagent.end",group:"subsystems",nameZh:"\u5B50 Agent \u5B8C\u6210",nameEn:"Subagent End",descZh:"\u5B50 Agent \u8FD0\u884C\u7ED3\u675F\u65F6\u89E6\u53D1\u3002",descEn:"Fires when a subagent finishes.",dshEvents:["subagent/end"],category:"Stop",defaultEnabled:!1,defaultBell:!1,defaultScriptIds:["notify-subagent-end"]},{id:"job.settled",group:"subsystems",nameZh:"\u540E\u53F0\u4EFB\u52A1\u7ED3\u675F",nameEn:"Background Job Settled",descZh:"\u4EC5\u5728\u771F\u6B63\u5F02\u6B65\u7684\u540E\u53F0\u4EFB\u52A1\uFF08\u4E0D\u542B\u666E\u901A\u524D\u53F0\u547D\u4EE4\uFF09\u5B8C\u6210\u3001\u88AB\u7EC8\u6B62\u6216\u5931\u8D25\u65F6\u89E6\u53D1\u3002",descEn:"Fires only when an unawaited background job completes, is killed, or fails (excludes foreground shell commands).",dshEvents:["jobs:settled[background]"],category:"Stop",defaultEnabled:!1,defaultBell:!1,defaultScriptIds:["notify-job-settled"]},{id:"workflow.start",group:"subsystems",nameZh:"\u5DE5\u4F5C\u6D41\u5F00\u59CB",nameEn:"Workflow Start",descZh:"Python \u7F16\u6392\u5DE5\u4F5C\u6D41\u5F00\u59CB\u6267\u884C\u65F6\u89E6\u53D1\u3002",descEn:"Fires when a workflow starts.",dshEvents:["workflow/start"],category:"UserPromptSubmit",defaultEnabled:!1,defaultBell:!1,defaultScriptIds:[]},{id:"workflow.end",group:"subsystems",nameZh:"\u5DE5\u4F5C\u6D41\u7ED3\u675F",nameEn:"Workflow End",descZh:"\u5DE5\u4F5C\u6D41\u5B8C\u6210\u65F6\u89E6\u53D1\u3002",descEn:"Fires when a workflow ends.",dshEvents:["workflow/end"],category:"Stop",defaultEnabled:!1,defaultBell:!1,defaultScriptIds:[]},{id:"compaction.end",group:"subsystems",nameZh:"\u4E0A\u4E0B\u6587\u538B\u7F29\u5B8C\u6210",nameEn:"Compaction End",descZh:"\u4F1A\u8BDD\u4E0A\u4E0B\u6587\u538B\u7F29\u6574\u7406\u5B8C\u6210\u65F6\u89E6\u53D1\u3002",descEn:"Fires when context compaction finishes.",dshEvents:["session:compaction/end"],category:"Notification",defaultEnabled:!1,defaultBell:!1,defaultScriptIds:[]},{id:"goal.changed",group:"subsystems",nameZh:"\u76EE\u6807\u72B6\u6001\u53D8\u66F4",nameEn:"Goal Changed",descZh:"\u957F\u671F\u76EE\u6807\u6216\u6FC0\u6D3B\u72B6\u6001\u53D1\u751F\u53D8\u5316\u65F6\u89E6\u53D1\u3002",descEn:"Fires when a goal or its activation status changes.",dshEvents:["goal/changed","goal/activation-changed"],category:"Notification",defaultEnabled:!1,defaultBell:!1,defaultScriptIds:[]},{id:"account.attention",group:"subsystems",nameZh:"\u8D26\u53F7\u4E0E\u767B\u5F55\u63D0\u9192",nameEn:"Account Attention",descZh:"\u8D26\u53F7\u4F1A\u8BDD\u8FC7\u671F\u6216\u6A21\u578B\u9700\u8981\u91CD\u65B0\u767B\u5F55\u65F6\u89E6\u53D1\u3002",descEn:"Fires when account session expires or model sign-in is required.",dshEvents:["deepseek-account/session-expired","model-sign-in-required"],category:"Notification",defaultEnabled:!0,defaultBell:!0,defaultScriptIds:["notify-attention"]}],FALLBACK_PROVIDERS=[{id:"bark",labelZh:"Bark",labelEn:"Bark",fields:[{key:"serverUrl",labelZh:"\u670D\u52A1\u5668\u5730\u5740",labelEn:"Server URL",kind:"text",defaultValue:"https://api.day.app",placeholder:"https://api.day.app"},{key:"deviceKey",labelZh:"Device Key",labelEn:"Device Key",kind:"secret",required:!0},{key:"group",labelZh:"\u5206\u7EC4 (\u53EF\u9009)",labelEn:"Group (optional)",kind:"text"},{key:"sound",labelZh:"\u63D0\u793A\u97F3 (\u53EF\u9009)",labelEn:"Sound (optional)",kind:"text"},{key:"level",labelZh:"\u4E2D\u65AD\u7EA7\u522B",labelEn:"Level",kind:"select",options:[{value:"",labelZh:"\u9ED8\u8BA4",labelEn:"Default"},{value:"active",labelZh:"active"},{value:"timeSensitive",labelZh:"timeSensitive"},{value:"passive",labelZh:"passive"},{value:"critical",labelZh:"critical"}]},{key:"basicUsername",labelZh:"Basic \u7528\u6237\u540D (\u53EF\u9009)",labelEn:"Basic Username",kind:"text"},{key:"basicPassword",labelZh:"Basic \u5BC6\u7801 (\u53EF\u9009)",labelEn:"Basic Password",kind:"secret"}]},{id:"dingtalk",labelZh:"\u9489\u9489\u673A\u5668\u4EBA",labelEn:"DingTalk",fields:[{key:"webhookUrl",labelZh:"Webhook URL",labelEn:"Webhook URL",kind:"secret",required:!0},{key:"secret",labelZh:"\u52A0\u7B7E\u5BC6\u94A5 (\u53EF\u9009)",labelEn:"Signing Secret (optional)",kind:"secret"}]},{id:"feishu",labelZh:"\u98DE\u4E66\u673A\u5668\u4EBA",labelEn:"Feishu / Lark",fields:[{key:"webhookUrl",labelZh:"Webhook URL",labelEn:"Webhook URL",kind:"secret",required:!0},{key:"secret",labelZh:"\u7B7E\u540D\u5BC6\u94A5 (\u53EF\u9009)",labelEn:"Signing Secret (optional)",kind:"secret"}]},{id:"telegram",labelZh:"Telegram",labelEn:"Telegram",fields:[{key:"botToken",labelZh:"Bot Token",labelEn:"Bot Token",kind:"secret",required:!0},{key:"chatId",labelZh:"Chat ID",labelEn:"Chat ID",kind:"text",required:!0},{key:"messageThreadId",labelZh:"Thread ID (\u53EF\u9009)",labelEn:"Thread ID (optional)",kind:"number"}]},{id:"wecom",labelZh:"\u4F01\u4E1A\u5FAE\u4FE1",labelEn:"WeCom",fields:[{key:"webhookUrl",labelZh:"Webhook URL",labelEn:"Webhook URL",kind:"secret",required:!0}]},{id:"pushplus",labelZh:"PushPlus",labelEn:"PushPlus",fields:[{key:"token",labelZh:"Token",labelEn:"Token",kind:"secret",required:!0},{key:"template",labelZh:"\u6A21\u677F",labelEn:"Template",kind:"text",defaultValue:"txt"},{key:"channel",labelZh:"\u53D1\u9001\u6E20\u9053 (\u53EF\u9009)",labelEn:"Channel (optional)",kind:"text"},{key:"topic",labelZh:"\u7FA4\u7EC4\u7F16\u7801 (\u53EF\u9009)",labelEn:"Topic (optional)",kind:"text"},{key:"webhook",labelZh:"Webhook \u7F16\u7801 (\u53EF\u9009)",labelEn:"Webhook (optional)",kind:"text"}]},{id:"wxpusher",labelZh:"WxPusher",labelEn:"WxPusher",fields:[{key:"spt",labelZh:"SPT (\u63A8\u8350)",labelEn:"SPT (recommended)",kind:"secret"},{key:"appToken",labelZh:"App Token (\u65E0 SPT \u65F6\u5FC5\u586B)",labelEn:"App Token (if no SPT)",kind:"secret"},{key:"uids",labelZh:"UID \u5217\u8868 (\u9017\u53F7\u5206\u9694)",labelEn:"UIDs (CSV)",kind:"csv"},{key:"topicIds",labelZh:"Topic ID \u5217\u8868 (\u9017\u53F7\u5206\u9694)",labelEn:"Topic IDs (CSV)",kind:"numberCsv"}]},{id:"serverchan",labelZh:"Server \u9171",labelEn:"ServerChan",fields:[{key:"sendKey",labelZh:"SendKey",labelEn:"SendKey",kind:"secret",required:!0}]},{id:"ntfy",labelZh:"ntfy",labelEn:"ntfy",fields:[{key:"serverUrl",labelZh:"\u670D\u52A1\u5668\u5730\u5740",labelEn:"Server URL",kind:"text",defaultValue:"https://ntfy.sh"},{key:"topic",labelZh:"Topic",labelEn:"Topic",kind:"secret",required:!0},{key:"authType",labelZh:"\u8BA4\u8BC1\u65B9\u5F0F",labelEn:"Auth Type",kind:"select",defaultValue:"none",options:[{value:"none",labelZh:"\u65E0\u8BA4\u8BC1",labelEn:"None"},{value:"bearer",labelZh:"Bearer Token",labelEn:"Bearer Token"},{value:"basic",labelZh:"Basic Auth",labelEn:"Basic Auth"}]},{key:"authToken",labelZh:"Bearer Token",labelEn:"Bearer Token",kind:"secret"},{key:"basicUsername",labelZh:"Basic \u7528\u6237\u540D",labelEn:"Basic Username",kind:"text"},{key:"basicPassword",labelZh:"Basic \u5BC6\u7801",labelEn:"Basic Password",kind:"secret"},{key:"priority",labelZh:"\u4F18\u5148\u7EA7 (1-5)",labelEn:"Priority (1-5)",kind:"text"},{key:"tags",labelZh:"\u6807\u7B7E (\u9017\u53F7\u5206\u9694)",labelEn:"Tags (CSV)",kind:"text"}]},{id:"gotify",labelZh:"Gotify",labelEn:"Gotify",fields:[{key:"serverUrl",labelZh:"\u670D\u52A1\u5668\u5730\u5740",labelEn:"Server URL",kind:"text",required:!0,placeholder:"https://gotify.example.com"},{key:"appToken",labelZh:"App Token",labelEn:"App Token",kind:"secret",required:!0},{key:"priority",labelZh:"\u4F18\u5148\u7EA7",labelEn:"Priority",kind:"number",defaultValue:5}]},{id:"custom",labelZh:"\u81EA\u5B9A\u4E49 HTTP",labelEn:"Custom HTTP",fields:[{key:"method",labelZh:"\u8BF7\u6C42\u65B9\u6CD5",labelEn:"Method",kind:"select",defaultValue:"POST",options:[{value:"POST",labelZh:"POST",labelEn:"POST"},{value:"GET",labelZh:"GET",labelEn:"GET"}]},{key:"url",labelZh:"\u8BF7\u6C42 URL",labelEn:"URL",kind:"secret",required:!0},{key:"bodyType",labelZh:"\u8BF7\u6C42\u4F53\u683C\u5F0F",labelEn:"Body Type",kind:"select",defaultValue:"json",options:[{value:"json",labelZh:"JSON",labelEn:"JSON"},{value:"form",labelZh:"Form (urlencoded)",labelEn:"Form"},{value:"text",labelZh:"\u7EAF\u6587\u672C",labelEn:"Plain Text"}]},{key:"query",labelZh:"Query \u53C2\u6570 (\u6BCF\u884C key=value)",labelEn:"Query Params (key=value lines)",kind:"kvLines"},{key:"headers",labelZh:"\u8BF7\u6C42\u5934 (\u6BCF\u884C key=value)",labelEn:"Headers (key=value lines)",kind:"kvLines"},{key:"jsonBody",labelZh:"JSON \u6A21\u677F",labelEn:"JSON Body Template",kind:"textarea",defaultValue:'{"title":"{{title}}","body":"{{body}}"}'},{key:"formBody",labelZh:"Form \u5B57\u6BB5 (\u6BCF\u884C key=value)",labelEn:"Form Body (key=value lines)",kind:"kvLines"},{key:"textBody",labelZh:"\u7EAF\u6587\u672C\u6A21\u677F",labelEn:"Text Body Template",kind:"textarea"}]}],import_jsx_runtime2=require("react/jsx-runtime"),MAX_SCRIPT_BYTES=512*1024,ALLOWED_SCRIPT_RE=/\.(mjs|js|cjs|ps1|sh|py|cmd|bat)$/i,GROUP_ORDER=["core","session_tools","subsystems"];function HookMountPointsSection({t,isZh,config,mountPoints,categories,logs:initialLogs,revision,busy,api,logBus,onApplyState,onError,onNotice}){let mountDefs=mountPoints&&mountPoints.length>0?mountPoints:FALLBACK_MOUNT_POINTS,categoryMap=categories??FALLBACK_CATEGORY_META,[sectionExpanded,setSectionExpanded]=(0,import_react.useState)(!0),[groupOpen,setGroupOpen]=(0,import_react.useState)({core:!0,session_tools:!0,subsystems:!1}),[selectedMountId,setSelectedMountId]=(0,import_react.useState)(null),[showLogs,setShowLogs]=(0,import_react.useState)(!1),[logs,setLogs]=(0,import_react.useState)(initialLogs??[]),[loadingLogs,setLoadingLogs]=(0,import_react.useState)(!1),[matcherDrafts,setMatcherDrafts]=(0,import_react.useState)({}),[timeoutDrafts,setTimeoutDrafts]=(0,import_react.useState)({}),[testRunResults,setTestRunResults]=(0,import_react.useState)({}),[uploadingMountId,setUploadingMountId]=(0,import_react.useState)(null),[testingId,setTestingId]=(0,import_react.useState)(null),[sourceModal,setSourceModal]=(0,import_react.useState)(null),[copiedSource,setCopiedSource]=(0,import_react.useState)(!1),uploadInputRef=(0,import_react.useRef)(null),uploadTargetMountRef=(0,import_react.useRef)(null);(0,import_react.useEffect)(()=>{initialLogs&&setLogs(initialLogs)},[initialLogs]),(0,import_react.useEffect)(()=>logBus.subscribe(nextLogs=>{setLogs(nextLogs)}),[logBus]),(0,import_react.useEffect)(()=>{if(!sourceModal)return;let onKeyDown=e=>{e.key==="Escape"&&(e.preventDefault(),setSourceModal(null))};return window.addEventListener("keydown",onKeyDown),()=>window.removeEventListener("keydown",onKeyDown)},[sourceModal]);let getMountState=def=>config.mountPoints?.[def.id]??{enabled:def.defaultEnabled,bellEnabled:def.defaultBell,scripts:[]},refreshLogs=async()=>{setLoadingLogs(!0);try{let res=await api.getExecutionLogs();res.ok&&setLogs(res.value.logs??[])}finally{setLoadingLogs(!1)}},handleToggleLogs=()=>{let next=!showLogs;setShowLogs(next),next&&refreshLogs()},handleResetDefaults=async()=>{onError(null);let res=await api.resetDefaultScripts(revision);res.ok?(onApplyState(res.value),onNotice(t("resetDone"))):onError(res.error?.message||t("actionError"))},handleToggleMount=async(mountId,next)=>{onError(null);let res=await api.toggleMountPoint(mountId,next,revision);res.ok?onApplyState(res.value):onError(res.error?.message||t("actionError"))},handleToggleBell=async(mountId,next)=>{onError(null);let res=await api.toggleMountPointBell(mountId,next,revision);res.ok?onApplyState(res.value):onError(res.error?.message||t("actionError"))},handleToggleScript=async(mountId,scriptId,next)=>{onError(null);let res=await api.toggleScript(mountId,scriptId,next,revision);res.ok?onApplyState(res.value):onError(res.error?.message||t("actionError"))},handleCommitScriptMeta=async(mountId,script,patch)=>{onError(null);let draftKey=`${mountId}:${script.id}`,res=await api.updateScriptMeta(mountId,script.id,patch,revision);res.ok?(setMatcherDrafts(prev=>{let next={...prev};return delete next[draftKey],next}),setTimeoutDrafts(prev=>{let next={...prev};return delete next[draftKey],next}),onApplyState(res.value)):onError(res.error?.message||t("actionError"))},handleDeleteScript=async(mountId,scriptId)=>{onError(null);let res=await api.deleteScript(mountId,scriptId,revision);res.ok?onApplyState(res.value):onError(res.error?.message||t("actionError"))},handleViewSource=async(mountId,scriptId)=>{onError(null);let res=await api.getScriptSource(mountId,scriptId);res.ok?(setCopiedSource(!1),setSourceModal(res.value)):onError(res.error?.message||t("actionError"))},handleTestScript=async(mountId,scriptId)=>{let key=`script:${mountId}:${scriptId}`;setTestingId(key);try{let res=await api.testScript(mountId,scriptId);if(res.ok){res.value.logs&&setLogs(res.value.logs);let ok=res.value.exitCode===0&&!res.value.error,text=res.value.suppressed?formatMessage(t("testResultSuppressed"),{ms:res.value.elapsedMs??0}):ok?formatMessage(t("testResultOk"),{ms:res.value.elapsedMs??0}):formatMessage(t("testResultFail"),{msg:res.value.error||`exit ${res.value.exitCode}`});setTestRunResults(prev=>({...prev,[mountId]:{ok,text,stdout:res.value.stdout,stderr:res.value.stderr}}))}else setTestRunResults(prev=>({...prev,[mountId]:{ok:!1,text:formatMessage(t("testResultFail"),{msg:res.error?.message||"Error"})}}))}finally{setTestingId(null)}},handleTestMountPoint=async mountId=>{let key=`mount:${mountId}`;setTestingId(key);try{let res=await api.testMountPoint(mountId);if(res.ok){res.value.logs&&setLogs(res.value.logs),res.value.state&&onApplyState(res.value.state);let text=res.value.suppressed?formatMessage(t("testResultSuppressed"),{ms:res.value.elapsedMs??0}):formatMessage(t("testResultOk"),{ms:res.value.elapsedMs??0});setTestRunResults(prev=>({...prev,[mountId]:{ok:!0,text}}))}else setTestRunResults(prev=>({...prev,[mountId]:{ok:!1,text:formatMessage(t("testResultFail"),{msg:res.error?.message||"Error"})}}))}finally{setTestingId(null)}},handleUploadFile=async file=>{let mountId=uploadTargetMountRef.current;if(!(!file||!mountId)){if(!ALLOWED_SCRIPT_RE.test(file.name)||file.size<=0||file.size>MAX_SCRIPT_BYTES){onError(t("scriptInvalidFile"));return}setUploadingMountId(mountId),onError(null);try{let res=await api.uploadScript({mountPointId:mountId,file,name:file.name,timeoutSeconds:10,expectedRevision:revision});res.ok?(onApplyState(res.value),onNotice(t("saved"))):onError(res.error?.message||t("actionError"))}finally{setUploadingMountId(null),uploadInputRef.current&&(uploadInputRef.current.value="")}}},groupTitle=group=>t(group==="core"?"groupCore":group==="session_tools"?"groupSessionTools":"groupSubsystems"),renderDrawer=def=>{let mpState=getMountState(def),testResult=testRunResults[def.id];return(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-drawer",children:[(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-drawer-head",children:[(0,import_jsx_runtime2.jsxs)("div",{children:[(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-drawer-title",children:[(0,import_jsx_runtime2.jsx)("span",{children:isZh?def.nameZh:def.nameEn}),(0,import_jsx_runtime2.jsx)("span",{className:"tavlo-hooks-badge tavlo-hooks-badge-mono",children:def.id})]}),(0,import_jsx_runtime2.jsx)("div",{className:"tavlo-hooks-dsh-events",children:def.dshEvents.map(ev=>(0,import_jsx_runtime2.jsx)("code",{className:"tavlo-hooks-code-pill",children:ev},ev))})]}),(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-drawer-head-actions",children:[(0,import_jsx_runtime2.jsxs)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-sm",disabled:busy||uploadingMountId===def.id,onClick:()=>{uploadTargetMountRef.current=def.id,uploadInputRef.current?.click()},children:[(0,import_jsx_runtime2.jsx)(UploadIcon,{size:13}),(0,import_jsx_runtime2.jsx)("span",{children:uploadingMountId===def.id?t("uploadingScript"):t("uploadScript")})]}),(0,import_jsx_runtime2.jsxs)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-primary tavlo-hooks-btn-sm",disabled:busy||testingId===`mount:${def.id}`,onClick:()=>{handleTestMountPoint(def.id)},children:[(0,import_jsx_runtime2.jsx)(PlayIcon,{size:12}),(0,import_jsx_runtime2.jsx)("span",{children:testingId===`mount:${def.id}`?t("testingBtn"):t("testMountPoint")})]})]})]}),(0,import_jsx_runtime2.jsx)("div",{className:"tavlo-hooks-script-list",children:mpState.scripts.length===0?(0,import_jsx_runtime2.jsx)("div",{className:"tavlo-hooks-empty-box",children:t("noScriptsInPoint")}):mpState.scripts.map(script=>{let draftKey=`${def.id}:${script.id}`,matcherVal=matcherDrafts[draftKey]??script.matcher??"",timeoutVal=timeoutDrafts[draftKey]??String(script.timeoutSeconds??10);return(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-script-row",children:[(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-script-main",children:[(0,import_jsx_runtime2.jsx)(ToggleSwitch,{checked:script.enabled,disabled:busy,label:script.name,compact:!0,onChange:next=>{handleToggleScript(def.id,script.id,next)}}),(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-script-info",children:[(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-script-name-line",children:[(0,import_jsx_runtime2.jsx)("span",{className:"tavlo-hooks-script-name",children:script.name}),(0,import_jsx_runtime2.jsx)("span",{className:`tavlo-hooks-badge ${script.kind==="default"?"tavlo-hooks-badge-blue":"tavlo-hooks-badge-muted"}`,children:script.kind==="default"?t("scriptDefaultBadge"):t("scriptCustomBadge")}),(0,import_jsx_runtime2.jsx)("code",{className:"tavlo-hooks-code-pill",children:script.filename})]}),(def.supportsMatcher||script.kind==="custom")&&(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-script-meta-inputs",children:[def.supportsMatcher&&(0,import_jsx_runtime2.jsxs)("label",{className:"tavlo-hooks-inline-meta",children:[(0,import_jsx_runtime2.jsx)("span",{children:t("matcherLabel")}),(0,import_jsx_runtime2.jsx)("input",{type:"text",className:"tavlo-hooks-input tavlo-hooks-input-meta",placeholder:t("matcherPlaceholder"),value:matcherVal,onChange:e=>{let v=e.currentTarget.value;setMatcherDrafts(prev=>({...prev,[draftKey]:v}))},onBlur:()=>{(matcherDrafts[draftKey]??script.matcher??"")!==(script.matcher??"")&&handleCommitScriptMeta(def.id,script,{matcher:matcherVal.trim()})}})]}),script.kind==="custom"&&(0,import_jsx_runtime2.jsxs)("label",{className:"tavlo-hooks-inline-meta",children:[(0,import_jsx_runtime2.jsx)("span",{children:t("timeoutLabel")}),(0,import_jsx_runtime2.jsx)("input",{type:"number",min:1,max:60,step:1,className:"tavlo-hooks-input tavlo-hooks-input-xs",value:timeoutVal,onChange:e=>{let v=e.currentTarget.value;setTimeoutDrafts(prev=>({...prev,[draftKey]:v}))},onBlur:()=>{let num=Math.min(60,Math.max(1,Math.round(Number(timeoutVal)||10)));setTimeoutDrafts(prev=>({...prev,[draftKey]:String(num)})),num!==(script.timeoutSeconds??10)&&handleCommitScriptMeta(def.id,script,{timeoutSeconds:num})}})]})]})]})]}),(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-script-actions",children:[(0,import_jsx_runtime2.jsxs)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-xs",onClick:()=>{handleViewSource(def.id,script.id)},children:[(0,import_jsx_runtime2.jsx)(FileCodeIcon,{size:13}),(0,import_jsx_runtime2.jsx)("span",{children:t("viewSource")})]}),(0,import_jsx_runtime2.jsxs)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-xs",disabled:busy||testingId===`script:${def.id}:${script.id}`,onClick:()=>{handleTestScript(def.id,script.id)},children:[(0,import_jsx_runtime2.jsx)(PlayIcon,{size:12}),(0,import_jsx_runtime2.jsx)("span",{children:testingId===`script:${def.id}:${script.id}`?t("testingBtn"):t("testRunScript")})]}),script.kind==="custom"&&(0,import_jsx_runtime2.jsx)("button",{type:"button",className:"tavlo-hooks-icon-btn tavlo-hooks-icon-btn-danger","aria-label":t("deleteScript"),title:t("deleteScript"),disabled:busy,onClick:()=>{handleDeleteScript(def.id,script.id)},children:(0,import_jsx_runtime2.jsx)(TrashIcon,{size:13})})]})]},script.id)})}),testResult&&(0,import_jsx_runtime2.jsxs)("div",{className:`tavlo-hooks-inline-result ${testResult.ok?"is-success":"is-error"}`,role:"status",children:[(0,import_jsx_runtime2.jsx)("div",{children:testResult.text}),testResult.stdout&&(0,import_jsx_runtime2.jsx)("pre",{className:"tavlo-hooks-output-pre",children:testResult.stdout}),testResult.stderr&&(0,import_jsx_runtime2.jsx)("pre",{className:"tavlo-hooks-output-pre is-stderr",children:testResult.stderr})]})]})};return(0,import_jsx_runtime2.jsxs)("section",{className:"tavlo-hooks-card",children:[(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-card-header-bar",children:[(0,import_jsx_runtime2.jsxs)("button",{type:"button",className:"tavlo-hooks-card-header-btn","aria-expanded":sectionExpanded,onClick:()=>setSectionExpanded(prev=>!prev),children:[(0,import_jsx_runtime2.jsx)("span",{className:"tavlo-hooks-icon-chip is-blue",children:(0,import_jsx_runtime2.jsx)(WebhookIcon,{size:17})}),(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-card-titles",children:[(0,import_jsx_runtime2.jsx)("h3",{children:t("mountPointsTitle")}),(0,import_jsx_runtime2.jsx)("p",{children:t("mountPointsSubtitle")})]})]}),(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-header-tools",children:[(0,import_jsx_runtime2.jsxs)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-sm",disabled:busy,onClick:()=>{handleResetDefaults()},children:[(0,import_jsx_runtime2.jsx)(RotateCcwIcon,{size:13}),(0,import_jsx_runtime2.jsx)("span",{children:t("resetDefaultScripts")})]}),(0,import_jsx_runtime2.jsxs)("button",{type:"button",className:`tavlo-hooks-btn tavlo-hooks-btn-sm${showLogs?" is-active":""}`,"aria-pressed":showLogs,onClick:handleToggleLogs,children:[(0,import_jsx_runtime2.jsx)(TerminalIcon,{size:13}),(0,import_jsx_runtime2.jsx)("span",{children:t("executionLogs")}),logs.length>0&&(0,import_jsx_runtime2.jsx)("span",{className:"tavlo-hooks-count-pill",children:logs.length})]}),(0,import_jsx_runtime2.jsx)("button",{type:"button",className:"tavlo-hooks-icon-btn","aria-label":t(sectionExpanded?"targetCollapse":"targetExpand"),onClick:()=>setSectionExpanded(prev=>!prev),children:sectionExpanded?(0,import_jsx_runtime2.jsx)(ChevronDownIcon,{size:17}):(0,import_jsx_runtime2.jsx)(ChevronRightIcon,{size:17})})]})]}),(0,import_jsx_runtime2.jsx)("input",{ref:uploadInputRef,type:"file",accept:".mjs,.js,.cjs,.ps1,.sh,.py,.cmd,.bat",hidden:!0,onChange:e=>{handleUploadFile(e.currentTarget.files?.[0])}}),showLogs&&(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-logs-panel",children:[(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-logs-head",children:[(0,import_jsx_runtime2.jsx)("span",{children:t("logsTitle")}),(0,import_jsx_runtime2.jsxs)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-xs",disabled:loadingLogs,onClick:()=>{refreshLogs()},children:[(0,import_jsx_runtime2.jsx)(RefreshCwIcon,{size:12}),(0,import_jsx_runtime2.jsx)("span",{children:t("refresh")})]})]}),logs.length===0?(0,import_jsx_runtime2.jsx)("div",{className:"tavlo-hooks-empty-box",children:t("logsEmpty")}):(0,import_jsx_runtime2.jsx)("div",{className:"tavlo-hooks-logs-list",children:logs.map(entry=>(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-log-item",children:[(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-log-top",children:[(0,import_jsx_runtime2.jsx)("span",{className:"tavlo-hooks-log-time",children:new Date(entry.timestamp).toLocaleTimeString()}),(0,import_jsx_runtime2.jsx)("code",{className:"tavlo-hooks-code-pill",children:entry.mountPointId}),(0,import_jsx_runtime2.jsx)("span",{className:"tavlo-hooks-log-script",children:entry.scriptName}),typeof entry.turn=="number"&&(0,import_jsx_runtime2.jsxs)("span",{className:"tavlo-hooks-badge tavlo-hooks-badge-muted",children:["T",entry.turn]}),entry.reason&&(0,import_jsx_runtime2.jsx)("span",{className:"tavlo-hooks-badge tavlo-hooks-badge-muted",children:entry.reason}),entry.sessionId&&(0,import_jsx_runtime2.jsx)("code",{className:"tavlo-hooks-code-pill",title:entry.sessionId,children:entry.sessionId.slice(-8)}),entry.dryRun&&(0,import_jsx_runtime2.jsx)("span",{className:"tavlo-hooks-badge tavlo-hooks-badge-blue",children:t("logsDryRun")}),entry.suppressed&&(0,import_jsx_runtime2.jsx)("span",{className:"tavlo-hooks-badge tavlo-hooks-badge-warn",children:t("logsSuppressed")}),(0,import_jsx_runtime2.jsx)("span",{className:`tavlo-hooks-badge ${entry.exitCode===0&&!entry.error?"tavlo-hooks-badge-success":"tavlo-hooks-badge-error"}`,children:formatMessage(t("logsExitCode"),{code:entry.exitCode??"err"})}),(0,import_jsx_runtime2.jsxs)("span",{className:"tavlo-hooks-helper",children:[entry.elapsedMs," ms"]})]}),(entry.error||entry.stdout||entry.stderr)&&(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-log-output",children:[entry.error&&(0,import_jsx_runtime2.jsx)("pre",{className:"tavlo-hooks-output-pre is-stderr",children:entry.error}),entry.stdout&&(0,import_jsx_runtime2.jsx)("pre",{className:"tavlo-hooks-output-pre",children:entry.stdout}),entry.stderr&&(0,import_jsx_runtime2.jsx)("pre",{className:"tavlo-hooks-output-pre is-stderr",children:entry.stderr})]})]},entry.id))})]}),sectionExpanded&&(0,import_jsx_runtime2.jsx)("div",{className:"tavlo-hooks-card-body",children:GROUP_ORDER.map(group=>{let defs=mountDefs.filter(item=>item.group===group);if(defs.length===0)return null;let isOpen=groupOpen[group],activeCount=defs.filter(item=>getMountState(item).enabled).length,selectedInGroup=defs.find(item=>item.id===selectedMountId);return(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-group",children:[(0,import_jsx_runtime2.jsxs)("button",{type:"button",className:"tavlo-hooks-group-header","aria-expanded":isOpen,onClick:()=>setGroupOpen(prev=>({...prev,[group]:!isOpen})),children:[(0,import_jsx_runtime2.jsxs)("span",{className:"tavlo-hooks-group-title",children:[isOpen?(0,import_jsx_runtime2.jsx)(ChevronDownIcon,{size:15}):(0,import_jsx_runtime2.jsx)(ChevronRightIcon,{size:15}),(0,import_jsx_runtime2.jsx)("span",{children:groupTitle(group)})]}),(0,import_jsx_runtime2.jsx)("span",{className:"tavlo-hooks-badge tavlo-hooks-badge-muted",children:formatMessage(t("mountCountSummary"),{enabled:activeCount,total:defs.length})})]}),isOpen&&(0,import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment,{children:[(0,import_jsx_runtime2.jsx)("div",{className:"tavlo-hooks-mount-grid",children:defs.map(def=>{let mpState=getMountState(def),catMeta=categoryMap[def.category]??FALLBACK_CATEGORY_META.Notification,defaultCount=mpState.scripts.filter(s=>s.kind==="default").length,customCount=mpState.scripts.filter(s=>s.kind==="custom").length,isSelected=selectedMountId===def.id;return(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-mount-card","data-selected":isSelected?"true":"false","data-enabled":mpState.enabled?"true":"false",onClick:()=>setSelectedMountId(isSelected?null:def.id),children:[(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-mount-top",children:[(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-mount-title-wrap",children:[(0,import_jsx_runtime2.jsx)("span",{"aria-hidden":"true",children:catMeta.icon}),(0,import_jsx_runtime2.jsx)("span",{className:"tavlo-hooks-mount-name",children:isZh?def.nameZh:def.nameEn})]}),(0,import_jsx_runtime2.jsx)(ToggleSwitch,{checked:mpState.enabled,disabled:busy,label:isZh?def.nameZh:def.nameEn,compact:!0,onChange:next=>{handleToggleMount(def.id,next)}})]}),(0,import_jsx_runtime2.jsx)("div",{className:"tavlo-hooks-mount-event-line",children:(0,import_jsx_runtime2.jsx)("code",{className:"tavlo-hooks-code-pill",children:def.dshEvents[0]})}),(0,import_jsx_runtime2.jsx)("p",{className:"tavlo-hooks-mount-desc",children:isZh?def.descZh:def.descEn}),(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-mount-footer",children:[(0,import_jsx_runtime2.jsx)("span",{className:"tavlo-hooks-mount-counts",children:formatMessage(t("scriptsSummary"),{defaults:defaultCount,customs:customCount})}),(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-mount-tools",children:[(0,import_jsx_runtime2.jsx)("button",{type:"button",className:`tavlo-hooks-bell-btn ${mpState.bellEnabled?"is-on":"is-off"}`,"aria-pressed":mpState.bellEnabled,"aria-label":mpState.bellEnabled?t("bellOnTip"):t("bellOffTip"),title:mpState.bellEnabled?t("bellOnTip"):t("bellOffTip"),disabled:busy,onClick:e=>{e.stopPropagation(),handleToggleBell(def.id,!mpState.bellEnabled)},children:mpState.bellEnabled?(0,import_jsx_runtime2.jsx)(BellIcon,{size:14}):(0,import_jsx_runtime2.jsx)(BellOffIcon,{size:14})}),(0,import_jsx_runtime2.jsxs)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-xs","aria-expanded":isSelected,onClick:e=>{e.stopPropagation(),setSelectedMountId(isSelected?null:def.id)},children:[(0,import_jsx_runtime2.jsx)("span",{children:t(isSelected?"collapseScripts":"expandScripts")}),isSelected?(0,import_jsx_runtime2.jsx)(ChevronDownIcon,{size:12}):(0,import_jsx_runtime2.jsx)(ChevronRightIcon,{size:12})]})]})]})]},def.id)})}),selectedInGroup&&renderDrawer(selectedInGroup)]})]},group)})}),sourceModal&&typeof document<"u"&&(0,import_react_dom.createPortal)((0,import_jsx_runtime2.jsx)("div",{className:"tavlo-hooks-modal-backdrop",role:"presentation",onClick:()=>setSourceModal(null),children:(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-modal",role:"dialog","aria-modal":"true","aria-label":t("sourceModalTitle"),onClick:e=>e.stopPropagation(),children:[(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-modal-head",children:[(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-title-with-pills",children:[(0,import_jsx_runtime2.jsx)("h4",{children:sourceModal.filename}),(0,import_jsx_runtime2.jsx)("span",{className:"tavlo-hooks-badge tavlo-hooks-badge-muted",children:sourceModal.kind==="default"?t("scriptDefaultBadge"):t("scriptCustomBadge")})]}),(0,import_jsx_runtime2.jsxs)("div",{className:"tavlo-hooks-row-controls",children:[(0,import_jsx_runtime2.jsxs)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-xs",onClick:()=>{navigator.clipboard?.writeText(sourceModal.content).then(()=>{setCopiedSource(!0),setTimeout(()=>setCopiedSource(!1),1800)})},children:[copiedSource?(0,import_jsx_runtime2.jsx)(CheckIcon,{size:13}):(0,import_jsx_runtime2.jsx)(CopyIcon,{size:13}),(0,import_jsx_runtime2.jsx)("span",{children:t(copiedSource?"copiedSource":"copySource")})]}),(0,import_jsx_runtime2.jsx)("button",{type:"button",className:"tavlo-hooks-icon-btn","aria-label":t("closeBtn"),onClick:()=>setSourceModal(null),children:(0,import_jsx_runtime2.jsx)(XIcon,{size:15})})]})]}),(0,import_jsx_runtime2.jsx)("pre",{className:"tavlo-hooks-source-pre",children:(0,import_jsx_runtime2.jsx)("code",{children:sourceModal.content})})]})}),document.body)]})}var import_react3=require("react"),import_react2=require("react"),import_jsx_runtime3=require("react/jsx-runtime"),MAX_TARGETS=20;function defaultEvents(){return{PermissionRequest:!0,Notification:!0,Stop:!0,StopFailure:!0,SessionStart:!1,UserPromptSubmit:!1}}function fieldValueToString(val){return val==null?"":Array.isArray(val)?val.length>0&&typeof val[0]=="object"&&val[0]!==null&&"key"in val[0]?val.map(pair=>`${pair.key}=${pair.value??""}`).join(`
|
|
5
|
+
`):val.join(", "):String(val)}function buildInitialConfig(providerDef,existing){let out={};if(!providerDef)return out;for(let field of providerDef.fields){if(field.kind==="secret"){out[field.key]="";continue}let raw=existing?.[field.key];raw!=null&&raw!==""?out[field.key]=fieldValueToString(raw):field.defaultValue!==void 0?out[field.key]=String(field.defaultValue):out[field.key]=""}return out}function targetToDraft(target,providerList){let def=providerList.find(p=>p.id===target.provider);return{id:target.id,isNew:!1,name:target.name,provider:target.provider,enabled:target.enabled,events:{...defaultEvents(),...target.events},config:buildInitialConfig(def,target.config),secretState:target.secretState}}function parseKvLines(text){let rows=[];for(let rawLine of text.split(/\r?\n/)){let line=rawLine.trim();if(!line)continue;let idx=line.indexOf("=");if(idx<=0)continue;let key=line.slice(0,idx).trim(),value=line.slice(idx+1).trim();key&&rows.push({key,value})}return rows}function serializeDraftConfig(draft,providerDef){let result={};if(!providerDef)return result;for(let field of providerDef.fields){let raw=draft.config[field.key]??"";if(field.kind==="secret"){let trimmed=raw.trim();trimmed!==""&&(result[field.key]=trimmed);continue}if(field.kind==="number"){let trimmed=raw.trim();if(trimmed!==""){let parsed=Number(trimmed);Number.isFinite(parsed)&&(result[field.key]=Math.trunc(parsed))}continue}if(field.kind==="csv"){let items=raw.split(/[,,\s]+/).map(s=>s.trim()).filter(Boolean);items.length>0&&(result[field.key]=items);continue}if(field.kind==="numberCsv"){let nums=raw.split(/[,,\s]+/).map(s=>Number(s.trim())).filter(n=>Number.isInteger(n));nums.length>0&&(result[field.key]=nums);continue}if(field.kind==="kvLines"){result[field.key]=parseKvLines(raw);continue}result[field.key]=raw.trim()}return result}function validateDraft(draft,providerDef,isZh){if(!draft.name.trim())return isZh?"\u8BF7\u586B\u5199\u76EE\u6807\u540D\u79F0\u3002":"Please enter a target name.";if(!providerDef)return null;for(let field of providerDef.fields){let val=(draft.config[field.key]??"").trim(),hasSavedSecret=field.kind==="secret"&&!!draft.secretState?.[field.key]?.configured;if(field.required&&!val&&!hasSavedSecret){let label=isZh?field.labelZh:field.labelEn;return isZh?`\u8BF7\u586B\u5199\u5FC5\u586B\u9879\uFF1A${label}`:`Required field missing: ${label}`}}if(draft.provider==="wxpusher"){let hasSpt=!!((draft.config.spt??"").trim()||draft.secretState?.spt?.configured),hasAppToken=!!((draft.config.appToken??"").trim()||draft.secretState?.appToken?.configured);if(!hasSpt&&!hasAppToken)return isZh?"WxPusher \u9700\u8981\u586B\u5199 SPT \u6216 App Token\u3002":"WxPusher requires either SPT or App Token."}if(draft.provider==="bark"){let user=(draft.config.basicUsername??"").trim(),hasPass=!!((draft.config.basicPassword??"").trim()||draft.secretState?.basicPassword?.configured);if(user&&!hasPass||!user&&(draft.config.basicPassword??"").trim())return isZh?"Bark Basic \u8BA4\u8BC1\u9700\u8981\u540C\u65F6\u586B\u5199\u7528\u6237\u540D\u548C\u5BC6\u7801\u3002":"Bark Basic auth requires both username and password."}if(draft.provider==="ntfy"){let authType=draft.config.authType||"none";if(authType==="bearer"){if(!((draft.config.authToken??"").trim()||draft.secretState?.authToken?.configured))return isZh?"Bearer \u8BA4\u8BC1\u9700\u8981\u586B\u5199 Token\u3002":"Bearer Token is required."}else if(authType==="basic"){let user=(draft.config.basicUsername??"").trim(),hasPass=!!((draft.config.basicPassword??"").trim()||draft.secretState?.basicPassword?.configured);if(!user||!hasPass)return isZh?"Basic \u8BA4\u8BC1\u9700\u8981\u586B\u5199\u7528\u6237\u540D\u548C\u5BC6\u7801\u3002":"Basic auth requires username and password."}}return null}function isFieldVisible(field,draft){if(draft.provider==="ntfy"){let authType=draft.config.authType||"none";if(field.key==="authToken")return authType==="bearer";if(field.key==="basicUsername"||field.key==="basicPassword")return authType==="basic"}if(draft.provider==="custom"){let method=draft.config.method||"POST",bodyType=draft.config.bodyType||"json";if(field.key==="bodyType")return method!=="GET";if(field.key==="jsonBody")return method!=="GET"&&bodyType==="json";if(field.key==="formBody")return method!=="GET"&&bodyType==="form";if(field.key==="textBody")return method!=="GET"&&bodyType==="text"}return!0}function ThirdPartySection({t,isZh,config,providers,categories,revision,busy,api,onApplyState,onError,onNotice}){let providerList=providers&&providers.length>0?providers:FALLBACK_PROVIDERS,categoryMap=categories??FALLBACK_CATEGORY_META,[selectedNewProvider,setSelectedNewProvider]=(0,import_react2.useState)(providerList[0]?.id??"bark"),[newDraft,setNewDraft]=(0,import_react2.useState)(null),[expandedIds,setExpandedIds]=(0,import_react2.useState)({}),[dirtyIds,setDirtyIds]=(0,import_react2.useState)({}),[draftsById,setDraftsById]=(0,import_react2.useState)({}),[revealedSecrets,setRevealedSecrets]=(0,import_react2.useState)({}),[pendingTargetId,setPendingTargetId]=(0,import_react2.useState)(null),[testingTargetId,setTestingTargetId]=(0,import_react2.useState)(null),[testResults,setTestResults]=(0,import_react2.useState)({}),[localError,setLocalError]=(0,import_react2.useState)({}),savedTargets=config.thirdParty.targets??[],totalCount=savedTargets.length;(0,import_react2.useEffect)(()=>{setDraftsById(prev=>{let next={};for(let target of savedTargets){let existing=prev[target.id];next[target.id]=existing&&dirtyIds[target.id]?{...existing,enabled:target.enabled,secretState:target.secretState}:targetToDraft(target,providerList)}return next})},[savedTargets,providerList,dirtyIds]);let getDraft=target=>draftsById[target.id]??targetToDraft(target,providerList),updateDraft=(targetId,updater)=>{if(newDraft&&newDraft.id===targetId){setNewDraft(prev=>prev&&updater(prev));return}setDirtyIds(prev=>prev[targetId]?prev:{...prev,[targetId]:!0}),setDraftsById(prev=>{let base=prev[targetId];return base?{...prev,[targetId]:updater(base)}:prev})},handleMasterToggle=async nextEnabled=>{onError(null);let res=await api.saveSettings({thirdParty:{enabled:nextEnabled}},revision);res.ok?onApplyState(res.value):onError(res.error?.message||t("actionError"))},handleAddTarget=()=>{if(totalCount>=MAX_TARGETS||newDraft)return;let def=providerList.find(p=>p.id===selectedNewProvider)??providerList[0],id=`draft_${Date.now()}`,draft={id,isNew:!0,name:isZh?def.labelZh:def.labelEn,provider:def.id,enabled:!0,events:defaultEvents(),config:buildInitialConfig(def)};setNewDraft(draft),setExpandedIds(prev=>({...prev,[id]:!0}))},handleProviderChange=(draftId,nextProvider)=>{let def=providerList.find(p=>p.id===nextProvider);updateDraft(draftId,prev=>({...prev,provider:nextProvider,config:buildInitialConfig(def),secretState:prev.provider===nextProvider?prev.secretState:void 0})),setLocalError(prev=>{let next={...prev};return delete next[draftId],next})},handleSaveTarget=async draft=>{let def=providerList.find(p=>p.id===draft.provider),validationError=validateDraft(draft,def,isZh);if(validationError){setLocalError(prev=>({...prev,[draft.id]:validationError}));return}setLocalError(prev=>{let next={...prev};return delete next[draft.id],next}),setPendingTargetId(draft.id),onError(null);try{let payloadTarget={...draft.isNew?{}:{id:draft.id},name:draft.name.trim(),provider:draft.provider,enabled:draft.enabled,events:draft.events,config:serializeDraftConfig(draft,def)},res=await api.saveThirdPartyTarget(payloadTarget,revision);if(res.ok){if(onApplyState(res.value),draft.isNew){setNewDraft(null);let savedList=res.value.config.thirdParty.targets,newest=savedList[savedList.length-1];newest&&setExpandedIds(prev=>({...prev,[newest.id]:!1}))}else{setDirtyIds(prev=>{let next={...prev};return delete next[draft.id],next});let fresh=res.value.config.thirdParty.targets.find(item=>item.id===draft.id);fresh&&setDraftsById(prev=>({...prev,[fresh.id]:targetToDraft(fresh,providerList)}))}onNotice(t("targetSaved"))}else setLocalError(prev=>({...prev,[draft.id]:res.error?.message||t("targetSaveFailed")}))}finally{setPendingTargetId(null)}},handleToggleTarget=async(draft,nextEnabled)=>{if(draft.isNew){updateDraft(draft.id,prev=>({...prev,enabled:nextEnabled}));return}setPendingTargetId(draft.id),onError(null);try{let res=await api.toggleThirdPartyTarget(draft.id,nextEnabled,revision);res.ok?onApplyState(res.value):onError(res.error?.message||t("actionError"))}finally{setPendingTargetId(null)}},handleDeleteTarget=async draft=>{if(draft.isNew){setNewDraft(null);return}setPendingTargetId(draft.id),onError(null);try{let res=await api.deleteThirdPartyTarget(draft.id,revision);res.ok?(onApplyState(res.value),onNotice(t("targetDeleted"))):onError(res.error?.message||t("actionError"))}finally{setPendingTargetId(null)}},handleTestTarget=async draft=>{let def=providerList.find(p=>p.id===draft.provider),validationError=validateDraft(draft,def,isZh);if(validationError){setLocalError(prev=>({...prev,[draft.id]:validationError}));return}setTestingTargetId(draft.id),setTestResults(prev=>{let next={...prev};return delete next[draft.id],next});try{let payloadTarget={...draft.isNew?{}:{id:draft.id},name:draft.name.trim(),provider:draft.provider,enabled:draft.enabled,events:draft.events,config:serializeDraftConfig(draft,def)},res=await api.testThirdPartyTarget(payloadTarget);res.ok?setTestResults(prev=>({...prev,[draft.id]:res.value})):setTestResults(prev=>({...prev,[draft.id]:{accepted:!1,errorMsg:res.error?.message||t("actionError")}}))}finally{setTestingTargetId(null)}},renderTargetCard=draft=>{let def=providerList.find(p=>p.id===draft.provider)??providerList[0],expanded=!!expandedIds[draft.id],isPending=pendingTargetId===draft.id,isTesting=testingTargetId===draft.id,testResult=testResults[draft.id],errText=localError[draft.id],subscribedLabels=NOTIFICATION_CATEGORIES.filter(cat=>draft.events[cat]).map(cat=>isZh?categoryMap[cat].labelZh:categoryMap[cat].labelEn);return(0,import_jsx_runtime3.jsxs)("div",{className:"tavlo-hooks-target-card","data-expanded":expanded?"true":"false",children:[(0,import_jsx_runtime3.jsxs)("div",{className:"tavlo-hooks-target-header",children:[(0,import_jsx_runtime3.jsxs)("div",{className:"tavlo-hooks-target-main",children:[(0,import_jsx_runtime3.jsx)(ToggleSwitch,{checked:draft.enabled,disabled:busy||isPending,label:draft.name||def.labelEn,onChange:next=>{handleToggleTarget(draft,next)},compact:!0}),(0,import_jsx_runtime3.jsx)(PlatformIcon,{provider:draft.provider,size:22}),(0,import_jsx_runtime3.jsxs)("div",{className:"tavlo-hooks-target-title-wrap",children:[(0,import_jsx_runtime3.jsxs)("div",{className:"tavlo-hooks-target-title-row",children:[(0,import_jsx_runtime3.jsx)("span",{className:"tavlo-hooks-target-name",children:draft.name||(isZh?def.labelZh:def.labelEn)}),(0,import_jsx_runtime3.jsx)("span",{className:"tavlo-hooks-badge tavlo-hooks-badge-muted",children:isZh?def.labelZh:def.labelEn}),draft.isNew&&(0,import_jsx_runtime3.jsx)("span",{className:"tavlo-hooks-badge tavlo-hooks-badge-warn",children:t("targetUnsavedBadge")})]}),(0,import_jsx_runtime3.jsx)("div",{className:"tavlo-hooks-target-events-summary",children:subscribedLabels.length>0?subscribedLabels.join(" / "):t("targetNoEvents")})]})]}),(0,import_jsx_runtime3.jsxs)("div",{className:"tavlo-hooks-target-actions",children:[(0,import_jsx_runtime3.jsxs)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-sm",disabled:busy||isTesting,onClick:()=>{handleTestTarget(draft)},children:[(0,import_jsx_runtime3.jsx)(SendIcon,{size:13}),(0,import_jsx_runtime3.jsx)("span",{children:t(isTesting?"testingBtn":"testBtn")})]}),(0,import_jsx_runtime3.jsx)("button",{type:"button",className:"tavlo-hooks-icon-btn","aria-expanded":expanded,"aria-label":t(expanded?"targetCollapse":"targetExpand"),title:t(expanded?"targetCollapse":"targetExpand"),onClick:()=>setExpandedIds(prev=>({...prev,[draft.id]:!expanded})),children:expanded?(0,import_jsx_runtime3.jsx)(ChevronDownIcon,{size:15}):(0,import_jsx_runtime3.jsx)(ChevronRightIcon,{size:15})}),(0,import_jsx_runtime3.jsx)("button",{type:"button",className:"tavlo-hooks-icon-btn tavlo-hooks-icon-btn-danger",disabled:busy||isPending,"aria-label":t("targetDeleteBtn"),title:t("targetDeleteBtn"),onClick:()=>{handleDeleteTarget(draft)},children:(0,import_jsx_runtime3.jsx)(TrashIcon,{size:14})})]})]}),testResult&&(0,import_jsx_runtime3.jsx)("div",{className:`tavlo-hooks-inline-result ${testResult.accepted?"is-success":"is-error"}`,role:"status",children:testResult.accepted?formatMessage(t("targetTestOk"),{ms:testResult.elapsedMs??0}):formatMessage(t("targetTestFail"),{msg:testResult.errorMsg||testResult.message||testResult.errorCode||"Error"})}),expanded&&(0,import_jsx_runtime3.jsxs)("div",{className:"tavlo-hooks-target-body",children:[(0,import_jsx_runtime3.jsxs)("div",{className:"tavlo-hooks-field-grid",children:[(0,import_jsx_runtime3.jsxs)("div",{className:"tavlo-hooks-field",children:[(0,import_jsx_runtime3.jsx)("label",{className:"tavlo-hooks-label",children:t("targetNameLabel")}),(0,import_jsx_runtime3.jsx)("input",{type:"text",className:"tavlo-hooks-input",value:draft.name,maxLength:64,placeholder:t("targetNamePlaceholder"),onChange:e=>{let val=e.currentTarget.value;updateDraft(draft.id,prev=>({...prev,name:val}))}})]}),(0,import_jsx_runtime3.jsxs)("div",{className:"tavlo-hooks-field",children:[(0,import_jsx_runtime3.jsx)("label",{className:"tavlo-hooks-label",children:t("targetProviderLabel")}),(0,import_jsx_runtime3.jsx)("select",{className:"tavlo-hooks-select",value:draft.provider,onChange:e=>handleProviderChange(draft.id,e.currentTarget.value),children:providerList.map(p=>(0,import_jsx_runtime3.jsx)("option",{value:p.id,children:isZh?p.labelZh:p.labelEn},p.id))})]})]}),(0,import_jsx_runtime3.jsxs)("div",{className:"tavlo-hooks-field",children:[(0,import_jsx_runtime3.jsx)("span",{className:"tavlo-hooks-label",children:t("targetEventsLabel")}),(0,import_jsx_runtime3.jsx)("div",{className:"tavlo-hooks-events-checks",children:NOTIFICATION_CATEGORIES.map(cat=>{let meta=categoryMap[cat],checked=!!draft.events[cat];return(0,import_jsx_runtime3.jsxs)("label",{className:"tavlo-hooks-check-pill","data-checked":checked?"true":"false",children:[(0,import_jsx_runtime3.jsx)("input",{type:"checkbox",checked,onChange:e=>{let nextVal=e.currentTarget.checked;updateDraft(draft.id,prev=>({...prev,events:{...prev.events,[cat]:nextVal}}))}}),(0,import_jsx_runtime3.jsx)("span",{"aria-hidden":"true",children:meta.icon}),(0,import_jsx_runtime3.jsx)("span",{children:isZh?meta.labelZh:meta.labelEn})]},cat)})})]}),(0,import_jsx_runtime3.jsx)("div",{className:"tavlo-hooks-field-grid",children:def.fields.filter(field=>isFieldVisible(field,draft)).map(field=>{let fullSpan=field.kind==="kvLines"||field.kind==="textarea",val=draft.config[field.key]??"",label=isZh?field.labelZh:field.labelEn,secretConfigured=field.kind==="secret"&&!!draft.secretState?.[field.key]?.configured,secretPreview=draft.secretState?.[field.key]?.preview,revealKey=`${draft.id}:${field.key}`,isRevealed=!!revealedSecrets[revealKey],placeholder=secretConfigured?t("secretConfiguredPlaceholder"):(isZh?field.placeholderZh:field.placeholderEn)||field.placeholder||"";return(0,import_jsx_runtime3.jsxs)("div",{className:`tavlo-hooks-field${fullSpan?" is-full":""}`,children:[(0,import_jsx_runtime3.jsxs)("label",{className:"tavlo-hooks-label",children:[(0,import_jsx_runtime3.jsx)("span",{children:label}),field.required&&(0,import_jsx_runtime3.jsx)("span",{className:"tavlo-hooks-req",children:"*"}),secretConfigured&&secretPreview&&(0,import_jsx_runtime3.jsx)("span",{className:"tavlo-hooks-secret-preview",children:secretPreview})]}),field.kind==="select"?(0,import_jsx_runtime3.jsx)("select",{className:"tavlo-hooks-select",value:val,onChange:e=>{let nextVal=e.currentTarget.value;updateDraft(draft.id,prev=>({...prev,config:{...prev.config,[field.key]:nextVal}}))},children:(field.options??[]).map(opt=>(0,import_jsx_runtime3.jsx)("option",{value:opt.value,children:isZh?opt.labelZh??opt.label??opt.value:opt.labelEn??opt.label??opt.value},opt.value))}):field.kind==="secret"?(0,import_jsx_runtime3.jsxs)("div",{className:"tavlo-hooks-secret-input-wrap",children:[(0,import_jsx_runtime3.jsx)("input",{type:isRevealed?"text":"password",className:"tavlo-hooks-input",autoComplete:"new-password",spellCheck:!1,value:val,placeholder,onChange:e=>{let nextVal=e.currentTarget.value;updateDraft(draft.id,prev=>({...prev,config:{...prev.config,[field.key]:nextVal}}))}}),(0,import_jsx_runtime3.jsx)("button",{type:"button",className:"tavlo-hooks-icon-btn","aria-label":t(isRevealed?"hideSecret":"showSecret"),title:t(isRevealed?"hideSecret":"showSecret"),onClick:()=>setRevealedSecrets(prev=>({...prev,[revealKey]:!isRevealed})),children:isRevealed?(0,import_jsx_runtime3.jsx)(EyeOffIcon,{size:14}):(0,import_jsx_runtime3.jsx)(EyeIcon,{size:14})})]}):fullSpan?(0,import_jsx_runtime3.jsx)("textarea",{rows:3,className:"tavlo-hooks-textarea",spellCheck:!1,value:val,placeholder,onChange:e=>{let nextVal=e.currentTarget.value;updateDraft(draft.id,prev=>({...prev,config:{...prev.config,[field.key]:nextVal}}))}}):(0,import_jsx_runtime3.jsx)("input",{type:field.kind==="number"?"number":"text",className:"tavlo-hooks-input",spellCheck:!1,value:val,placeholder,onChange:e=>{let nextVal=e.currentTarget.value;updateDraft(draft.id,prev=>({...prev,config:{...prev.config,[field.key]:nextVal}}))}})]},field.key)})}),errText&&(0,import_jsx_runtime3.jsx)("div",{className:"tavlo-hooks-inline-result is-error",role:"alert",children:errText}),(0,import_jsx_runtime3.jsxs)("div",{className:"tavlo-hooks-target-footer",children:[draft.isNew&&(0,import_jsx_runtime3.jsx)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-sm",disabled:isPending,onClick:()=>setNewDraft(null),children:t("targetCancelBtn")}),(0,import_jsx_runtime3.jsx)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-primary tavlo-hooks-btn-sm",disabled:busy||isPending,onClick:()=>{handleSaveTarget(draft)},children:t(isPending?"saving":"targetSaveBtn")})]})]})]},draft.id)};return(0,import_jsx_runtime3.jsxs)("div",{className:"tavlo-hooks-thirdparty",children:[(0,import_jsx_runtime3.jsxs)("div",{className:"tavlo-hooks-sub-header",children:[(0,import_jsx_runtime3.jsxs)("div",{className:"tavlo-hooks-sub-title-group",children:[(0,import_jsx_runtime3.jsx)("span",{className:"tavlo-hooks-icon-chip is-blue",children:(0,import_jsx_runtime3.jsx)(BellIcon,{size:15})}),(0,import_jsx_runtime3.jsxs)("div",{children:[(0,import_jsx_runtime3.jsxs)("div",{className:"tavlo-hooks-title-with-pills",children:[(0,import_jsx_runtime3.jsx)("h4",{className:"tavlo-hooks-sub-title",children:t("thirdPartyTitle")}),(0,import_jsx_runtime3.jsx)("span",{className:`tavlo-hooks-badge ${config.thirdParty.enabled?"tavlo-hooks-badge-success":"tavlo-hooks-badge-muted"}`,children:config.thirdParty.enabled?t("thirdPartyEnabled"):t("thirdPartyPaused")}),(0,import_jsx_runtime3.jsxs)("span",{className:"tavlo-hooks-badge tavlo-hooks-badge-mono",children:[totalCount,"/",MAX_TARGETS]})]}),(0,import_jsx_runtime3.jsx)("p",{className:"tavlo-hooks-helper",children:t("thirdPartyPrivacy")})]})]}),(0,import_jsx_runtime3.jsx)(ToggleSwitch,{checked:config.thirdParty.enabled,disabled:busy,label:t("thirdPartyTitle"),onChange:next=>{handleMasterToggle(next)}})]}),!config.thirdParty.enabled&&savedTargets.length>0&&(0,import_jsx_runtime3.jsx)("div",{className:"tavlo-hooks-banner is-muted",role:"status",children:t("thirdPartyPausedBanner")}),(0,import_jsx_runtime3.jsxs)("div",{className:"tavlo-hooks-add-bar",children:[(0,import_jsx_runtime3.jsxs)("div",{className:"tavlo-hooks-add-select-wrap",children:[(0,import_jsx_runtime3.jsx)(PlatformIcon,{provider:selectedNewProvider,size:18}),(0,import_jsx_runtime3.jsx)("select",{className:"tavlo-hooks-select","aria-label":t("targetProviderLabel"),value:selectedNewProvider,onChange:e=>setSelectedNewProvider(e.currentTarget.value),children:providerList.map(p=>(0,import_jsx_runtime3.jsx)("option",{value:p.id,children:isZh?p.labelZh:p.labelEn},p.id))})]}),(0,import_jsx_runtime3.jsxs)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-primary",disabled:busy||totalCount>=MAX_TARGETS||!!newDraft,title:totalCount>=MAX_TARGETS?t("targetLimitReached"):void 0,onClick:handleAddTarget,children:[(0,import_jsx_runtime3.jsx)(PlusIcon,{size:14}),(0,import_jsx_runtime3.jsx)("span",{children:t("thirdPartyAddBtn").replace(/^\+\s*/,"")})]})]}),(0,import_jsx_runtime3.jsxs)("div",{className:"tavlo-hooks-banner is-warn",children:[(0,import_jsx_runtime3.jsx)(AlertTriangleIcon,{size:15}),(0,import_jsx_runtime3.jsx)("span",{children:t("thirdPartyCredNotice")})]}),(0,import_jsx_runtime3.jsxs)("div",{className:"tavlo-hooks-target-list",children:[newDraft&&renderTargetCard(newDraft),savedTargets.map(target=>renderTargetCard(getDraft(target))),!newDraft&&savedTargets.length===0&&(0,import_jsx_runtime3.jsx)("div",{className:"tavlo-hooks-empty-box",children:t("thirdPartyEmpty")})]})]})}var import_jsx_runtime4=require("react/jsx-runtime"),MAX_WAV_BYTES=20*1024*1024;function NotificationSettingsSection({t,isZh,isWindows,config,customSound,providers,categories,revision,busy,api,onApplyState,onError,onNotice}){let[expanded,setExpanded]=(0,import_react3.useState)(!0),[autoCloseInput,setAutoCloseInput]=(0,import_react3.useState)(String(config.inApp.autoCloseSeconds??60)),[flashCountInput,setFlashCountInput]=(0,import_react3.useState)(String(config.systemNotifications.taskbarAttentionFlashCount??5)),[sysTestStatus,setSysTestStatus]=(0,import_react3.useState)(null),[taskbarTestStatus,setTaskbarTestStatus]=(0,import_react3.useState)(null),[soundStatus,setSoundStatus]=(0,import_react3.useState)(null),[uploadingSound,setUploadingSound]=(0,import_react3.useState)(!1),[testingSystem,setTestingSystem]=(0,import_react3.useState)(!1),[testingTaskbar,setTestingTaskbar]=(0,import_react3.useState)(!1),[webPerm,setWebPerm]=(0,import_react3.useState)(()=>typeof window<"u"&&"Notification"in window?window.Notification.permission:"granted"),soundFileInputRef=(0,import_react3.useRef)(null),previewAudioRef=(0,import_react3.useRef)(null);(0,import_react3.useEffect)(()=>()=>{previewAudioRef.current?.pause(),previewAudioRef.current=null},[]),(0,import_react3.useEffect)(()=>{setAutoCloseInput(String(config.inApp.autoCloseSeconds??60))},[config.inApp.autoCloseSeconds]),(0,import_react3.useEffect)(()=>{setFlashCountInput(String(config.systemNotifications.taskbarAttentionFlashCount??5))},[config.systemNotifications.taskbarAttentionFlashCount]);let savePatch=async patch=>{onError(null);let res=await api.saveSettings(patch,revision);res.ok?onApplyState(res.value):onError(res.error?.message||t("actionError"))},commitAutoCloseSeconds=()=>{let parsed=Math.round(Number(autoCloseInput)),clamped=Number.isFinite(parsed)?Math.min(3600,Math.max(5,parsed)):60;setAutoCloseInput(String(clamped)),clamped!==config.inApp.autoCloseSeconds&&savePatch({inApp:{autoCloseSeconds:clamped}})},commitFlashCount=nextValue=>{let raw=nextValue??Math.round(Number(flashCountInput)),clamped=Number.isFinite(raw)?Math.min(20,Math.max(1,raw)):5;setFlashCountInput(String(clamped)),clamped!==config.systemNotifications.taskbarAttentionFlashCount&&savePatch({systemNotifications:{taskbarAttentionFlashCount:clamped}})},handleTestSystem=async()=>{setTestingSystem(!0),setSysTestStatus(null);try{let res=await api.testSystemNotification();res.ok&&res.value?.ok!==!1?setSysTestStatus({ok:!0,msg:t("testSystemSent")}):setSysTestStatus({ok:!1,msg:res.error?.message||res.value?.error||t("testSystemFailed")})}finally{setTestingSystem(!1)}},handleTestTaskbar=async()=>{setTestingTaskbar(!0),setTaskbarTestStatus(null);try{let res=await api.testTaskbarFlash({mode:config.systemNotifications.taskbarAttentionMode,flashCount:config.systemNotifications.taskbarAttentionFlashCount});res.ok&&res.value?.ok!==!1?setTaskbarTestStatus({ok:!0,msg:t("testTaskbarSent")}):setTaskbarTestStatus({ok:!1,msg:res.error?.message||res.value?.error||t("testTaskbarFailed")})}finally{setTestingTaskbar(!1)}},handleSoundFileChange=async file=>{if(file){if(setSoundStatus(null),!/\.wav$/i.test(file.name)||file.size<12||file.size>MAX_WAV_BYTES){setSoundStatus({ok:!1,msg:t("soundInvalidFile")});return}setUploadingSound(!0);try{let res=await api.uploadCustomSound(file,revision);res.ok?(onApplyState(res.value),setSoundStatus({ok:!0,msg:t("saved")})):setSoundStatus({ok:!1,msg:res.error?.message||t("soundUploadFailed")})}finally{setUploadingSound(!1),soundFileInputRef.current&&(soundFileInputRef.current.value="")}}},handleClearSound=async()=>{setSoundStatus(null);let res=await api.clearCustomSound(revision);res.ok?onApplyState(res.value):setSoundStatus({ok:!1,msg:res.error?.message||t("actionError")})},handlePreviewSound=()=>{setSoundStatus(null);try{previewAudioRef.current?.pause();let audio=new Audio(api.getSoundPreviewUrl());previewAudioRef.current=audio,audio.play().catch(()=>{setSoundStatus({ok:!1,msg:t("soundPreviewFailed")})})}catch{setSoundStatus({ok:!1,msg:t("soundPreviewFailed")})}},handleRequestBrowserPerm=async()=>{if(!(typeof window>"u"||!("Notification"in window)))try{let next=await window.Notification.requestPermission();setWebPerm(next)}catch{}},activeSoundName=customSound?.filename||config.systemNotifications.customSoundFilename;return(0,import_jsx_runtime4.jsxs)("section",{className:"tavlo-hooks-card",children:[(0,import_jsx_runtime4.jsxs)("button",{type:"button",className:"tavlo-hooks-card-header","aria-expanded":expanded,onClick:()=>setExpanded(prev=>!prev),children:[(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-card-header-left",children:[(0,import_jsx_runtime4.jsx)("span",{className:"tavlo-hooks-icon-chip is-blue",children:(0,import_jsx_runtime4.jsx)(BellIcon,{size:17})}),(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-card-titles",children:[(0,import_jsx_runtime4.jsx)("h3",{children:t("notificationsTitle")}),(0,import_jsx_runtime4.jsx)("p",{children:t("notificationsSubtitle")})]})]}),(0,import_jsx_runtime4.jsx)("span",{className:"tavlo-hooks-chevron","aria-hidden":"true",children:expanded?(0,import_jsx_runtime4.jsx)(ChevronDownIcon,{size:17}):(0,import_jsx_runtime4.jsx)(ChevronRightIcon,{size:17})})]}),expanded&&(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-card-body",children:[(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-setting-block",children:[(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-row",children:[(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-row-text",children:[(0,import_jsx_runtime4.jsx)("div",{className:"tavlo-hooks-row-title",children:t("inAppTitle")}),(0,import_jsx_runtime4.jsx)("div",{className:"tavlo-hooks-helper",children:t("inAppDesc")})]}),(0,import_jsx_runtime4.jsx)(ToggleSwitch,{checked:config.inApp.enabled,disabled:busy,label:t("inAppEnabled"),onChange:next=>{savePatch({inApp:{enabled:next}})}})]}),config.inApp.enabled&&(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-subpanel",children:[(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-row",children:[(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-row-text",children:[(0,import_jsx_runtime4.jsx)("div",{className:"tavlo-hooks-row-title-sm",children:t("inAppAutoClose")}),(0,import_jsx_runtime4.jsx)("div",{className:"tavlo-hooks-helper",children:t("inAppAutoCloseHint")})]}),(0,import_jsx_runtime4.jsx)(ToggleSwitch,{checked:config.inApp.autoCloseEnabled,disabled:busy,label:t("inAppAutoClose"),onChange:next=>{savePatch({inApp:{autoCloseEnabled:next}})}})]}),config.inApp.autoCloseEnabled&&(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-inline-field",children:[(0,import_jsx_runtime4.jsx)("label",{htmlFor:"tavlo-hooks-autoclose-sec",className:"tavlo-hooks-label",children:t("inAppAutoCloseSeconds")}),(0,import_jsx_runtime4.jsx)("input",{id:"tavlo-hooks-autoclose-sec",type:"number",min:5,max:3600,step:1,className:"tavlo-hooks-input tavlo-hooks-input-sm",value:autoCloseInput,onChange:e=>setAutoCloseInput(e.currentTarget.value),onBlur:commitAutoCloseSeconds,onKeyDown:e=>{e.key==="Enter"&&(e.preventDefault(),commitAutoCloseSeconds())}})]})]})]}),(0,import_jsx_runtime4.jsx)("hr",{className:"tavlo-hooks-divider"}),(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-setting-block",children:[(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-row",children:[(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-row-text tavlo-hooks-row-with-icon",children:[(0,import_jsx_runtime4.jsx)("span",{className:"tavlo-hooks-icon-chip is-blue",children:(0,import_jsx_runtime4.jsx)(BellIcon,{size:15})}),(0,import_jsx_runtime4.jsxs)("div",{children:[(0,import_jsx_runtime4.jsx)("div",{className:"tavlo-hooks-row-title",children:t("systemNotifyTitle")}),(0,import_jsx_runtime4.jsx)("div",{className:"tavlo-hooks-helper",children:t("systemNotifyHelper")})]})]}),(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-row-controls",children:[(0,import_jsx_runtime4.jsx)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-sm",disabled:busy||testingSystem,onClick:()=>{handleTestSystem()},children:t(testingSystem?"testingBtn":"testBtn")}),(0,import_jsx_runtime4.jsx)(ToggleSwitch,{checked:config.systemNotifications.enabled,disabled:busy,label:t("systemNotifyTitle"),onChange:next=>{savePatch({systemNotifications:{enabled:next}})}})]})]}),sysTestStatus&&(0,import_jsx_runtime4.jsx)("div",{className:`tavlo-hooks-inline-result ${sysTestStatus.ok?"is-success":"is-error"}`,role:"status",children:sysTestStatus.msg}),webPerm==="default"&&(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-perm-bar",children:[(0,import_jsx_runtime4.jsx)("span",{children:t("browserPermissionHint")}),(0,import_jsx_runtime4.jsx)("button",{type:"button",className:"tavlo-hooks-link-btn",onClick:()=>{handleRequestBrowserPerm()},children:t("browserPermissionGrant")})]})]}),isWindows&&(0,import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment,{children:[(0,import_jsx_runtime4.jsx)("hr",{className:"tavlo-hooks-divider"}),(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-setting-block",children:[(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-row",children:[(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-row-text tavlo-hooks-row-with-icon",children:[(0,import_jsx_runtime4.jsx)("span",{className:"tavlo-hooks-icon-chip",children:(0,import_jsx_runtime4.jsx)(MonitorIcon,{size:15})}),(0,import_jsx_runtime4.jsxs)("div",{children:[(0,import_jsx_runtime4.jsx)("div",{className:"tavlo-hooks-row-title",children:t("taskbarTitle")}),(0,import_jsx_runtime4.jsx)("div",{className:"tavlo-hooks-helper",children:t("taskbarHelper")})]})]}),(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-row-controls",children:[(0,import_jsx_runtime4.jsx)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-sm",disabled:busy||testingTaskbar,onClick:()=>{handleTestTaskbar()},children:t(testingTaskbar?"testingBtn":"testBtn")}),(0,import_jsx_runtime4.jsx)(ToggleSwitch,{checked:config.systemNotifications.taskbarAttentionEnabled,disabled:busy,label:t("taskbarTitle"),onChange:next=>{savePatch({systemNotifications:{taskbarAttentionEnabled:next}})}})]})]}),(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-subpanel tavlo-hooks-taskbar-controls",children:[(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-field",children:[(0,import_jsx_runtime4.jsx)("span",{className:"tavlo-hooks-label",children:t("taskbarModeLabel")}),(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-segmented",role:"radiogroup","aria-label":t("taskbarModeLabel"),children:[(0,import_jsx_runtime4.jsx)("button",{type:"button",role:"radio","aria-checked":config.systemNotifications.taskbarAttentionMode==="finite",className:"tavlo-hooks-seg-btn","data-active":config.systemNotifications.taskbarAttentionMode==="finite"?"true":"false",disabled:busy,onClick:()=>{savePatch({systemNotifications:{taskbarAttentionMode:"finite"}})},children:t("taskbarModeFinite")}),(0,import_jsx_runtime4.jsx)("button",{type:"button",role:"radio","aria-checked":config.systemNotifications.taskbarAttentionMode==="untilFocused",className:"tavlo-hooks-seg-btn","data-active":config.systemNotifications.taskbarAttentionMode==="untilFocused"?"true":"false",disabled:busy,onClick:()=>{savePatch({systemNotifications:{taskbarAttentionMode:"untilFocused"}})},children:t("taskbarModeUntilFocused")})]})]}),(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-field",children:[(0,import_jsx_runtime4.jsx)("label",{htmlFor:"tavlo-hooks-flash-count",className:"tavlo-hooks-label",children:t("taskbarFlashCountLabel")}),(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-stepper",children:[(0,import_jsx_runtime4.jsx)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-sm",disabled:busy||config.systemNotifications.taskbarAttentionMode!=="finite"||config.systemNotifications.taskbarAttentionFlashCount<=1,onClick:()=>commitFlashCount(config.systemNotifications.taskbarAttentionFlashCount-1),children:"-"}),(0,import_jsx_runtime4.jsx)("input",{id:"tavlo-hooks-flash-count",type:"number",min:1,max:20,step:1,className:"tavlo-hooks-input tavlo-hooks-input-xs",disabled:busy||config.systemNotifications.taskbarAttentionMode!=="finite",value:flashCountInput,onChange:e=>setFlashCountInput(e.currentTarget.value),onBlur:()=>commitFlashCount(),onKeyDown:e=>{e.key==="Enter"&&(e.preventDefault(),commitFlashCount())}}),(0,import_jsx_runtime4.jsx)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-sm",disabled:busy||config.systemNotifications.taskbarAttentionMode!=="finite"||config.systemNotifications.taskbarAttentionFlashCount>=20,onClick:()=>commitFlashCount(config.systemNotifications.taskbarAttentionFlashCount+1),children:"+"})]})]})]}),taskbarTestStatus&&(0,import_jsx_runtime4.jsx)("div",{className:`tavlo-hooks-inline-result ${taskbarTestStatus.ok?"is-success":"is-error"}`,role:"status",children:taskbarTestStatus.msg})]})]}),(0,import_jsx_runtime4.jsx)("hr",{className:"tavlo-hooks-divider"}),(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-setting-block",children:[(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-row",children:[(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-row-text tavlo-hooks-row-with-icon",children:[(0,import_jsx_runtime4.jsx)("span",{className:"tavlo-hooks-icon-chip",children:(0,import_jsx_runtime4.jsx)(Volume2Icon,{size:15})}),(0,import_jsx_runtime4.jsxs)("div",{children:[(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-title-with-pills",children:[(0,import_jsx_runtime4.jsx)("span",{className:"tavlo-hooks-row-title",children:t("soundTitle")}),(0,import_jsx_runtime4.jsx)("span",{className:"tavlo-hooks-badge tavlo-hooks-badge-muted",children:t("soundFormatBadge")})]}),(0,import_jsx_runtime4.jsx)("div",{className:"tavlo-hooks-helper",children:t("soundHelper")})]})]}),(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-row-controls",children:[(0,import_jsx_runtime4.jsx)("input",{ref:soundFileInputRef,type:"file",accept:".wav,audio/wav",hidden:!0,onChange:e=>{handleSoundFileChange(e.currentTarget.files?.[0])}}),(0,import_jsx_runtime4.jsxs)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-sm",disabled:busy||uploadingSound,onClick:()=>soundFileInputRef.current?.click(),children:[(0,import_jsx_runtime4.jsx)(UploadIcon,{size:13}),(0,import_jsx_runtime4.jsx)("span",{children:t(uploadingSound?"soundUploading":"soundChoose")})]}),activeSoundName&&(0,import_jsx_runtime4.jsxs)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-sm",disabled:busy,onClick:()=>{handleClearSound()},children:[(0,import_jsx_runtime4.jsx)(TrashIcon,{size:13}),(0,import_jsx_runtime4.jsx)("span",{children:t("soundClear")})]}),(0,import_jsx_runtime4.jsxs)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-sm",disabled:busy||!activeSoundName,onClick:handlePreviewSound,children:[(0,import_jsx_runtime4.jsx)(PlayIcon,{size:12}),(0,import_jsx_runtime4.jsx)("span",{children:t("soundPreview")})]})]})]}),(0,import_jsx_runtime4.jsx)("div",{className:"tavlo-hooks-sound-meta",children:activeSoundName?(0,import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment,{children:[(0,import_jsx_runtime4.jsx)("code",{className:"tavlo-hooks-code-pill",children:activeSoundName}),customSound?.bytes?(0,import_jsx_runtime4.jsxs)("span",{className:"tavlo-hooks-helper",children:[Math.max(1,Math.round(customSound.bytes/1024))," KB"]}):null,(0,import_jsx_runtime4.jsx)("span",{className:"tavlo-hooks-helper",children:t("soundSetDesc")})]}):(0,import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment,{children:[(0,import_jsx_runtime4.jsx)("span",{className:"tavlo-hooks-badge tavlo-hooks-badge-muted",children:t("soundUnset")}),(0,import_jsx_runtime4.jsx)("span",{className:"tavlo-hooks-helper",children:t("soundUnsetDesc")})]})}),soundStatus&&(0,import_jsx_runtime4.jsx)("div",{className:`tavlo-hooks-inline-result ${soundStatus.ok?"is-success":"is-error"}`,role:"status",children:soundStatus.msg})]}),(0,import_jsx_runtime4.jsx)("hr",{className:"tavlo-hooks-divider"}),(0,import_jsx_runtime4.jsx)("div",{className:"tavlo-hooks-setting-block",children:(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-row",children:[(0,import_jsx_runtime4.jsxs)("div",{className:"tavlo-hooks-row-text",children:[(0,import_jsx_runtime4.jsx)("div",{className:"tavlo-hooks-row-title",children:t("suppressFocusedTitle")}),(0,import_jsx_runtime4.jsx)("div",{className:"tavlo-hooks-helper",children:t("suppressFocusedHelper")})]}),(0,import_jsx_runtime4.jsx)(ToggleSwitch,{checked:config.systemNotifications.suppressWhenFocused,disabled:busy,label:t("suppressFocusedTitle"),onChange:next=>{savePatch({systemNotifications:{suppressWhenFocused:next}})}})]})}),(0,import_jsx_runtime4.jsx)("hr",{className:"tavlo-hooks-divider"}),(0,import_jsx_runtime4.jsx)(ThirdPartySection,{t,isZh,config,providers,categories,revision,busy,api,onApplyState,onError,onNotice})]})]})}var import_jsx_runtime5=require("react/jsx-runtime");function HookSettingsPage({t,api,logBus,compact=!1}){let[state,setState]=(0,import_react4.useState)(null),[loading,setLoading]=(0,import_react4.useState)(!0),[busy,setBusy]=(0,import_react4.useState)(!1),[error,setError]=(0,import_react4.useState)(null),[notice,setNotice]=(0,import_react4.useState)(null),[conflict,setConflict]=(0,import_react4.useState)(!1),mountedRef=(0,import_react4.useRef)(!0);(0,import_react4.useEffect)(()=>(mountedRef.current=!0,()=>{mountedRef.current=!1}),[]);let isZh=detectIsZh(t),loadState=(0,import_react4.useCallback)(async()=>{setLoading(!0),setError(null),setConflict(!1);try{let res=await api.getState();if(!mountedRef.current)return;res.ok?setState(res.value):setError(res.error?.message||t("loadError"))}finally{mountedRef.current&&setLoading(!1)}},[api,t]);(0,import_react4.useEffect)(()=>{loadState()},[loadState]),(0,import_react4.useEffect)(()=>{if(!notice)return;let timer=setTimeout(()=>setNotice(null),2600);return()=>clearTimeout(timer)},[notice]);let handleApplyState=(0,import_react4.useCallback)(partial=>{setState(prev=>prev?{...prev,...partial}:partial),setConflict(!1)},[]),handleError=(0,import_react4.useCallback)(msg=>{setError(msg),msg&&/conflict|revision/i.test(msg)&&setConflict(!0)},[]),isWindows=state?.isWindows??(typeof navigator<"u"&&/Win/i.test(navigator.platform||navigator.userAgent||"")),enabledMountCount=state?Object.values(state.config.mountPoints??{}).filter(m=>m.enabled).length:0,totalMountCount=state?Math.max(state.mountPoints?.length??0,Object.keys(state.config.mountPoints??{}).length):0,activeTargetCount=state?(state.config.thirdParty?.targets??[]).filter(item=>item.enabled).length:0;return(0,import_jsx_runtime5.jsxs)("div",{className:`tavlo-hooks-root${compact?" is-compact":""}`,children:[(0,import_jsx_runtime5.jsxs)("header",{className:"tavlo-hooks-page-header",children:[(0,import_jsx_runtime5.jsxs)("div",{className:"tavlo-hooks-page-title-wrap",children:[(0,import_jsx_runtime5.jsx)("span",{className:"tavlo-hooks-hero-badge","aria-hidden":"true",children:(0,import_jsx_runtime5.jsx)(WebhookIcon,{size:20})}),(0,import_jsx_runtime5.jsxs)("div",{children:[(0,import_jsx_runtime5.jsx)("h2",{className:"tavlo-hooks-page-title",children:t("pageTitle")}),(0,import_jsx_runtime5.jsx)("p",{className:"tavlo-hooks-page-subtitle",children:t("pageSubtitle")})]})]}),(0,import_jsx_runtime5.jsxs)("div",{className:"tavlo-hooks-page-meta",children:[state&&(0,import_jsx_runtime5.jsxs)("div",{className:"tavlo-hooks-stat-pills",children:[(0,import_jsx_runtime5.jsxs)("span",{className:"tavlo-hooks-badge tavlo-hooks-badge-blue",children:["Hook ",enabledMountCount,"/",totalMountCount]}),state.config.thirdParty.enabled&&activeTargetCount>0&&(0,import_jsx_runtime5.jsxs)("span",{className:"tavlo-hooks-badge tavlo-hooks-badge-success",children:["3rd-Party ",activeTargetCount]})]}),(0,import_jsx_runtime5.jsxs)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-sm",disabled:loading||busy,onClick:()=>{loadState()},children:[(0,import_jsx_runtime5.jsx)(RefreshCwIcon,{size:13}),(0,import_jsx_runtime5.jsx)("span",{children:t("refresh")})]})]})]}),error&&(0,import_jsx_runtime5.jsxs)("div",{className:"tavlo-hooks-banner is-error",role:"alert",children:[(0,import_jsx_runtime5.jsx)(AlertTriangleIcon,{size:15}),(0,import_jsx_runtime5.jsx)("span",{className:"tavlo-hooks-banner-text",children:conflict?t("conflictError"):error}),(0,import_jsx_runtime5.jsx)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-xs",onClick:()=>{loadState()},children:t(conflict?"reload":"retry")})]}),notice&&!error&&(0,import_jsx_runtime5.jsx)("div",{className:"tavlo-hooks-banner is-success",role:"status",children:(0,import_jsx_runtime5.jsx)("span",{children:notice})}),loading&&!state?(0,import_jsx_runtime5.jsx)("div",{className:"tavlo-hooks-loading-card",role:"status",children:(0,import_jsx_runtime5.jsx)("span",{children:t("loading")})}):state?(0,import_jsx_runtime5.jsxs)("div",{className:"tavlo-hooks-sections","aria-busy":busy,children:[(0,import_jsx_runtime5.jsx)(NotificationSettingsSection,{t,isZh,isWindows:!!isWindows,config:state.config,customSound:state.customSound,providers:state.providers,categories:state.categories,revision:state.revision,busy,api,onApplyState:handleApplyState,onError:msg=>{setBusy(!1),handleError(msg)},onNotice:setNotice}),(0,import_jsx_runtime5.jsx)(HookMountPointsSection,{t,isZh,config:state.config,mountPoints:state.mountPoints,categories:state.categories,logs:state.logs,revision:state.revision,busy,api,logBus,onApplyState:handleApplyState,onError:handleError,onNotice:setNotice})]}):null]})}var import_react5=require("react"),import_react_dom2=require("react-dom"),import_jsx_runtime6=require("react/jsx-runtime"),MAX_VISIBLE_TOASTS=5;function clampSeconds(raw){let num=Number(raw);return Number.isFinite(num)?Math.min(3600,Math.max(5,Math.round(num))):60}function resolveSoundUrl(url){let clean=url.startsWith("/")?url.slice(1):url,sep=clean.includes("?")?"&":"?";return`${clean}${sep}ts=${Date.now()}`}function HookToastOverlay({t,api,logBus,openSession}){let[toasts,setToasts]=(0,import_react5.useState)([]),timersRef=(0,import_react5.useRef)(new Map),openSessionRef=(0,import_react5.useRef)(openSession);openSessionRef.current=openSession;let removeToast=id=>{let existing=timersRef.current.get(id);existing&&(clearTimeout(existing),timersRef.current.delete(id)),setToasts(prev=>prev.filter(item=>item.id!==id))};return(0,import_react5.useEffect)(()=>{let clientId=api.getClientId(),reportFocus=focusedOverride=>{if(typeof document>"u")return;let focused=typeof focusedOverride=="boolean"?focusedOverride:document.hasFocus(),visible=document.visibilityState==="visible";api.postClientState({clientId,focused,visible})};reportFocus();let onFocus=()=>reportFocus(!0),onBlur=()=>reportFocus(!1),onVisibility=()=>reportFocus(),onPageHide=()=>{api.postClientState({clientId,focused:!1,visible:!1,closing:!0})};typeof window<"u"&&(window.addEventListener("focus",onFocus),window.addEventListener("blur",onBlur),window.addEventListener("pagehide",onPageHide)),typeof document<"u"&&document.addEventListener("visibilitychange",onVisibility);let heartbeat=setInterval(()=>reportFocus(),3e4),unsubscribe=api.subscribeEvents({onNotification(payload){if(!payload||!payload.id)return;let toastId=String(payload.id);setToasts(prev=>{let withoutSame=prev.filter(item=>item.id!==toastId);return[{...payload,id:toastId,receivedAt:Date.now()},...withoutSame].slice(0,MAX_VISIBLE_TOASTS)});let oldTimer=timersRef.current.get(toastId);if(oldTimer&&(clearTimeout(oldTimer),timersRef.current.delete(toastId)),payload.autoCloseEnabled!==!1){let ms=clampSeconds(payload.autoCloseSeconds)*1e3,timer=setTimeout(()=>{removeToast(toastId)},ms);timersRef.current.set(toastId,timer)}if(payload.playWebAudio&&payload.soundUrl&&typeof Audio<"u")try{new Audio(resolveSoundUrl(payload.soundUrl)).play().catch(()=>{})}catch{}if(payload.shouldWebNotify&&!payload.hostSystemNotified&&!payload.systemNotified&&typeof window<"u"&&"Notification"in window&&window.Notification.permission==="granted")try{let osNotice=new window.Notification(payload.title||"DSH Hook",{body:payload.summary||payload.body||"",tag:toastId});osNotice.onclick=()=>{try{window.focus()}catch{}payload.sessionId&&openSessionRef.current?.(payload.sessionId),osNotice.close()}}catch{}},onDismiss(payload){payload&&setToasts(prev=>{let kept=[];for(let item of prev){let matchId=payload.id&&item.id===payload.id,matchApproval=payload.approvalId&&item.approvalId===payload.approvalId;if(matchId||matchApproval){let timer=timersRef.current.get(item.id);timer&&(clearTimeout(timer),timersRef.current.delete(item.id))}else kept.push(item)}return kept})},onLogs(payload){if(!logBus)return;let entries=Array.isArray(payload)?payload:Array.isArray(payload?.logs)?payload.logs:null;entries&&logBus.publish(entries)}}),timers=timersRef.current;return()=>{unsubscribe(),clearInterval(heartbeat),typeof window<"u"&&(window.removeEventListener("focus",onFocus),window.removeEventListener("blur",onBlur),window.removeEventListener("pagehide",onPageHide)),api.postClientState({clientId,focused:!1,visible:!1,closing:!0}),typeof document<"u"&&document.removeEventListener("visibilitychange",onVisibility);for(let timer of timers.values())clearTimeout(timer);timers.clear()}},[api,logBus]),toasts.length===0||typeof document>"u"?null:(0,import_react_dom2.createPortal)((0,import_jsx_runtime6.jsx)("div",{className:"tavlo-hooks-toast-stack",role:"region","aria-label":t("inAppTitle"),"aria-live":"polite",children:toasts.map(toast=>{let variant=toast.variant??"info",sourceLabel=toast.sessionTitle||toast.project,actionLabel=t(variant==="approval"||variant==="attention"?"toastHandleAction":"toastJumpSession");return(0,import_jsx_runtime6.jsxs)("div",{className:"tavlo-hooks-toast-card","data-variant":variant,role:"status",children:[(0,import_jsx_runtime6.jsx)("div",{className:"tavlo-hooks-toast-accent","aria-hidden":"true"}),(0,import_jsx_runtime6.jsxs)("div",{className:"tavlo-hooks-toast-body",children:[(0,import_jsx_runtime6.jsxs)("div",{className:"tavlo-hooks-toast-head",children:[(0,import_jsx_runtime6.jsxs)("div",{className:"tavlo-hooks-toast-eyebrow",children:[toast.icon&&(0,import_jsx_runtime6.jsx)("span",{"aria-hidden":"true",children:toast.icon}),(0,import_jsx_runtime6.jsx)("span",{children:toast.eventLabel||t("toastEyebrow")}),toast.hookPoint&&(0,import_jsx_runtime6.jsx)("span",{className:"tavlo-hooks-toast-point",children:toast.hookPoint})]}),(0,import_jsx_runtime6.jsx)("button",{type:"button",className:"tavlo-hooks-icon-btn","aria-label":t("toastDismiss"),onClick:()=>removeToast(toast.id),children:(0,import_jsx_runtime6.jsx)(XIcon,{size:14})})]}),(0,import_jsx_runtime6.jsx)("div",{className:"tavlo-hooks-toast-title",children:toast.title}),sourceLabel&&(0,import_jsx_runtime6.jsxs)("div",{className:"tavlo-hooks-toast-source",children:[t("toastFromPrefix"),(0,import_jsx_runtime6.jsx)("span",{children:sourceLabel})]}),(toast.summary||toast.body)&&(0,import_jsx_runtime6.jsx)("div",{className:"tavlo-hooks-toast-summary",children:toast.summary||toast.body}),toast.sessionId&&openSession&&(0,import_jsx_runtime6.jsx)("div",{className:"tavlo-hooks-toast-actions",children:(0,import_jsx_runtime6.jsx)("button",{type:"button",className:"tavlo-hooks-btn tavlo-hooks-btn-primary tavlo-hooks-btn-xs",onClick:()=>{openSession(toast.sessionId),removeToast(toast.id)},children:actionLabel})})]})]},toast.id)})}),document.body)}var import_jsx_runtime7=require("react/jsx-runtime"),SECTION_ID="tavlo-hooks.settings",OVERLAY_ID="tavlo-hooks.toast-overlay",PACKAGE_NAME="@tavlo-dsh/dsh-plugin-hooks";function HookSectionNavIcon({size=16,active}){return(0,import_jsx_runtime7.jsx)("span",{className:"tavlo-hooks-nav-icon","data-active":active?"true":"false",style:{display:"inline-flex",alignItems:"center",justifyContent:"center"},children:(0,import_jsx_runtime7.jsx)(WebhookIcon,{size})})}var inject=["slots","locale","connection"];function apply(ctx){ctx.effect(()=>ctx.locale.register(LOCALE_NS,"en",EN),"tavlo-hooks: en locale"),ctx.effect(()=>ctx.locale.register(LOCALE_NS,"zh",ZH),"tavlo-hooks: zh locale");let t=ctx.locale.bind(LOCALE_NS),api=createHooksApi(ctx.connection),logBus=createLogBus();ctx.effect(()=>{if(typeof document>"u")return;let cssText=typeof __TAVLO_HOOKS_CSS__=="string"?__TAVLO_HOOKS_CSS__:"";if(!cssText)return;let style=document.createElement("style");return style.dataset.tavloHooksStyle="true",style.textContent=cssText,document.head.appendChild(style),()=>{style.remove()}},"tavlo-hooks: scoped styles"),ctx.slots.inject("settings.section",()=>ctx.slots.register({name:"settings.section",id:SECTION_ID,order:45,label:()=>t("nav"),inject:()=>({t,api,logBus})},HookSettingsPage)),ctx.slots.inject("settings.section.icon",()=>ctx.slots.register({name:"settings.section.icon",id:SECTION_ID},HookSectionNavIcon)),ctx.slots.inject("plugins.bundle.config",()=>ctx.slots.register({name:"plugins.bundle.config",key:PACKAGE_NAME,locale:LOCALE_NS},({t:slotT,view})=>view!=="page"?null:(0,import_jsx_runtime7.jsx)(HookSettingsPage,{t:slotT??t,api,logBus,compact:!0}))),ctx.slots.inject("shell.overlay",()=>ctx.slots.register({name:"shell.overlay",id:OVERLAY_ID,inject:()=>({t,api,logBus,openSession:sessionId=>{ctx.get?.("uiWorkspace")?.openSession?.(sessionId)}})},HookToastOverlay))}return module.exports}});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
@tavlo-dsh/dsh-plugin-hooks@0.1.3
|
|
2
|
+
MIT License
|
|
3
|
+
Copyright (c) Tavlo
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
package/locale/en.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "Hooks & Notifications",
|
|
4
|
+
"description": "Subscribe to DSH approval, question, turn, tool, and subsystem hooks with in-app toasts, OS notifications, Windows taskbar attention, custom WAV alerts, cross-platform scripts, and 11 third-party channels."
|
|
5
|
+
}
|
|
6
|
+
}
|
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,79 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tavlo-dsh/dsh-plugin-hooks",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public",
|
|
6
|
+
"registry": "https://registry.npmjs.org/"
|
|
7
|
+
},
|
|
8
|
+
"description": "DSH Hook 通知与脚本扩展插件:支持全事件 Hook 挂载、应用内/系统/任务栏提醒、自定义 WAV 铃声、跨平台脚本与 11 种三方通知渠道",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"author": "Tavlo-dsh",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/Tavlo-dsh/tavlo-plugins-hooks.git"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/Tavlo-dsh/tavlo-plugins-hooks#readme",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "index.js",
|
|
18
|
+
"icon": "./icon.svg",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": "./index.js",
|
|
21
|
+
"./client": "./lib/client.js",
|
|
22
|
+
"./locale/*.json": "./locale/*.json",
|
|
23
|
+
"./icon": "./icon.svg",
|
|
24
|
+
"./package.json": "./package.json"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"index.js",
|
|
28
|
+
"src/*.js",
|
|
29
|
+
"lib/client.js",
|
|
30
|
+
"lib/client.js.LEGAL.txt",
|
|
31
|
+
"cordis.patch.yml",
|
|
32
|
+
"locale/*.json",
|
|
33
|
+
"icon.svg",
|
|
34
|
+
"README.md",
|
|
35
|
+
"LICENSE"
|
|
36
|
+
],
|
|
37
|
+
"keywords": [
|
|
38
|
+
"dsh-plugin",
|
|
39
|
+
"hooks",
|
|
40
|
+
"notifications",
|
|
41
|
+
"tavlo"
|
|
42
|
+
],
|
|
43
|
+
"dsh": {
|
|
44
|
+
"bundle": {
|
|
45
|
+
"patch": "./cordis.patch.yml"
|
|
46
|
+
},
|
|
47
|
+
"client": {
|
|
48
|
+
"platform": "web"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"dsh": "0.2.2-rc.1",
|
|
53
|
+
"node": ">=24.0.0"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "node --check index.js && node --check src/hook-catalog.js && node --check src/default-scripts.js && node --check src/config-store.js && node --check src/script-runner.js && node --check src/dsh-hook-bridge.js && node --check src/event-hub.js && node --check src/sound-manager.js && node --check src/system-notifier.js && node --check src/third-party-providers.js && node --check src/notification-dispatcher.js && node scripts/build-client.mjs && node --check lib/client.js",
|
|
57
|
+
"test": "node --test tests/*.test.mjs",
|
|
58
|
+
"prepack": "npm run build"
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@deepseek-ai/cordis": "~4.1.0",
|
|
62
|
+
"@deepseek-ai/dsh-client-connection": "0.2.2-rc.1",
|
|
63
|
+
"@deepseek-ai/dsh-credentials": "0.2.2-rc.1",
|
|
64
|
+
"@deepseek-ai/dsh-storage-domain": "0.2.2-rc.1",
|
|
65
|
+
"@deepseek-ai/dsh-subprocess": "0.2.2-rc.1",
|
|
66
|
+
"@deepseek-ai/schemastery": "3.19.0",
|
|
67
|
+
"zod": "4.4.3"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@deepseek-ai/dsh-host-webserver": "0.2.2-rc.1",
|
|
71
|
+
"@deepseek-ai/dsh-scope": "0.2.2-rc.1",
|
|
72
|
+
"@deepseek-ai/dsh-storage": "0.2.2-rc.1",
|
|
73
|
+
"@deepseek-ai/dsh-storage-json": "0.2.2-rc.1",
|
|
74
|
+
"esbuild": "0.28.2",
|
|
75
|
+
"lucide-react": "0.577.0",
|
|
76
|
+
"react": "18.3.1",
|
|
77
|
+
"react-dom": "18.3.1"
|
|
78
|
+
}
|
|
79
|
+
}
|