diff --git a/.github/workflows/ci-v3.yml b/.github/workflows/ci-v3.yml new file mode 100644 index 0000000..7e1d191 --- /dev/null +++ b/.github/workflows/ci-v3.yml @@ -0,0 +1,98 @@ +name: CI v3 + +# v3(TimecodeBridge3)の Windows 検証。v3.0.0 の Windows 版は起動直後に落ちていた(app.manifest が無く WebView を埋め込めない)が、 +# タグを打つまで Windows で一度も起動しない流れだったため気づけなかった。PR と feature/v3 への push で、 +# ビルド・テスト・発行物の起動 smoke・インストーラーで入れたものの起動 smoke まで通す。 +# (GitHub の Windows ランナーには音声デバイスが無いので LTC の受信は確かめない。LTC は手元で smoke-windows.ps1 -LoopbackDevice) +on: + push: + branches: [feature/v3] + pull_request: + branches: [feature/v3] + workflow_dispatch: + +jobs: + windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: "8.0.x" + - uses: actions/setup-node@v4 + with: + node-version: "22" + cache: npm + cache-dependency-path: src/TimecodeBridge.Web/package-lock.json + - uses: ilammy/msvc-dev-cmd@v1 + + # dist の差分検査は release-v3 の macOS ジョブで行う(Windows は改行コードの自動変換で偽の差分が出る) + - name: Build Web UI + working-directory: src/TimecodeBridge.Web + shell: bash + run: | + npm ci + npm run typecheck + npm test + npm run build + + - name: Build libltc.dll + shell: cmd + run: native\libltc\build-windows.cmd native\libltc\out + + - name: Test (Ltc / Host) + shell: bash + run: | + dotnet test tests/TimecodeBridge.Ltc.Tests + dotnet test tests/TimecodeBridge.Host.Tests + + - name: Publish (win-x64) + shell: bash + run: | + set -euo pipefail + dotnet publish src/TimecodeBridge.Host/TimecodeBridge.Host.csproj \ + -c Release --self-contained -r win-x64 -o publish + test -f publish/libltc.dll + test -f publish/web/index.html + cp THIRD_PARTY_NOTICES.md publish/ + + - name: Ensure WebView2 runtime + shell: pwsh + run: | + $id = '{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}' + $pv = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\$id", "HKCU:\Software\Microsoft\EdgeUpdate\Clients\$id" | + ForEach-Object { (Get-ItemProperty $_ -ErrorAction SilentlyContinue).pv } | Where-Object { $_ -and $_ -ne '0.0.0.0' } | Select-Object -First 1 + if ($pv) { "WebView2 runtime $pv"; exit 0 } + Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/p/?LinkId=2124703" -OutFile "$env:RUNNER_TEMP\MicrosoftEdgeWebview2Setup.exe" + Start-Process "$env:RUNNER_TEMP\MicrosoftEdgeWebview2Setup.exe" -ArgumentList '/silent', '/install' -Wait + + - name: Smoke (publish) + shell: pwsh + run: pwsh tools/tcb3/smoke-windows.ps1 -Exe publish\TimecodeBridge3.exe -RunDir "$env:RUNNER_TEMP\smoke-publish" + + - name: Build installer + shell: pwsh + run: | + Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/p/?LinkId=2124703" -OutFile installer/MicrosoftEdgeWebview2Setup.exe + iscc /DAppVersion=0.0.0 installer\TimecodeBridge3.iss + + # 利用者と同じくインストーラーで入れ(ユーザー単位・サイレント)、入ったものを起動して確かめる + - name: Install and smoke (installer) + shell: pwsh + run: | + $dir = Join-Path $env:RUNNER_TEMP 'tcb3-installed' + $log = Join-Path $env:RUNNER_TEMP 'install.log' + $setup = (Get-Item installer-output\TimecodeBridge3-Setup-*.exe).FullName + $p = Start-Process $setup -ArgumentList '/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART', "/DIR=$dir", "/LOG=$log" -Wait -PassThru + if ($p.ExitCode -ne 0) { Get-Content $log -Tail 40; throw "installer exit $($p.ExitCode)" } + pwsh tools/tcb3/smoke-windows.ps1 -Exe (Join-Path $dir 'TimecodeBridge3.exe') -RunDir "$env:RUNNER_TEMP\smoke-installed" + + - uses: actions/upload-artifact@v4 + if: always() + with: + name: windows-smoke + path: | + ${{ runner.temp }}/smoke-publish/ + ${{ runner.temp }}/smoke-installed/ + ${{ runner.temp }}/install.log + if-no-files-found: ignore diff --git a/.github/workflows/release-v3.yml b/.github/workflows/release-v3.yml index 6bb7f37..87afaf9 100644 --- a/.github/workflows/release-v3.yml +++ b/.github/workflows/release-v3.yml @@ -121,6 +121,25 @@ jobs: test -f publish/libltc.dll test -f publish/web/index.html cp THIRD_PARTY_NOTICES.md publish/ + + # 起動しないビルドを出さない(v3.0.0 の Windows 版は起動直後に落ちていた)。詳しい確認は ci-v3.yml + - name: Ensure WebView2 runtime + shell: pwsh + run: | + $id = '{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}' + $pv = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\$id", "HKCU:\Software\Microsoft\EdgeUpdate\Clients\$id" | + ForEach-Object { (Get-ItemProperty $_ -ErrorAction SilentlyContinue).pv } | Where-Object { $_ -and $_ -ne '0.0.0.0' } | Select-Object -First 1 + if ($pv) { "WebView2 runtime $pv"; exit 0 } + Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/p/?LinkId=2124703" -OutFile "$env:RUNNER_TEMP\MicrosoftEdgeWebview2Setup.exe" + Start-Process "$env:RUNNER_TEMP\MicrosoftEdgeWebview2Setup.exe" -ArgumentList '/silent', '/install' -Wait + + - name: Smoke (publish) + shell: pwsh + run: pwsh tools/tcb3/smoke-windows.ps1 -Exe publish\TimecodeBridge3.exe -RunDir "$env:RUNNER_TEMP\smoke-publish" + + - name: Zip (win-x64) + shell: bash + run: | cd publish && 7z a "../TimecodeBridge3-${{ github.ref_name }}-win-x64.zip" . # WebView2 Evergreen ブートストラッパーを取得し、未導入 PC で実行するインストーラーを作る diff --git a/README.md b/README.md index 979e6ac..6b17f77 100644 --- a/README.md +++ b/README.md @@ -57,4 +57,4 @@ macOS 15 以降では、ファイルを右クリックして「開く」を選 ## ライセンス -本体は [LICENSE](LICENSE) のとおり。LTC の復号・生成に使う libltc は LGPL-2.1 で、動的リンクのまま同梱しています。同梱物の一覧は [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。 +本体は [LICENSE](LICENSE) のとおり。LTC の復号に使う libltc は LGPL-3.0-or-later で、動的リンクのまま同梱しています。同梱物の一覧は [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。 diff --git a/docs/v3/README.md b/docs/v3/README.md index 22ee6b8..33728a9 100644 --- a/docs/v3/README.md +++ b/docs/v3/README.md @@ -12,6 +12,21 @@ dotnet build src/TimecodeBridge.Host/TimecodeBridge.Host.csproj `dotnet build` は `native/libltc/out/libltc.dylib` と `src/TimecodeBridge.Web/dist` を実行ファイルの隣(`libltc.dylib`, `web/`)へコピーします。どちらかが無いとビルド時に警告が出て、起動時に見つからない旨のエラーになります。 +## 初回セットアップ(Windows) + +Visual Studio 2022(C++ によるデスクトップ開発)、.NET 8 以降の SDK、Node.js 22 以降が要ります。libltc は Developer Command Prompt(vcvars64)で `cl` を使ってビルドします。 + +```powershell +cmd /c '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" && native\libltc\build-windows.cmd native\libltc\out' +cd src\TimecodeBridge.Web; npm ci; npm run build; cd ..\.. +dotnet build src\TimecodeBridge.Host\TimecodeBridge.Host.csproj # → src\TimecodeBridge.Host\bin\Debug\net8.0\TimecodeBridge3.exe +``` + +- 日本語 Windows では libltc のビルドで C4819 の警告が出ますが、`ltc.h` のコメント内の文字(`ß` `±`)なので無害です。 +- Windows で `npm run build` すると `dist/` に差分が出ることがありますが、改行コード(CRLF/LF)だけです。コミットしないでください(`git checkout -- src/TimecodeBridge.Web/dist`)。 +- `src/TimecodeBridge.Host/app.manifest` は消さないでください。対応 OS の宣言が無いと、Avalonia が WebView 用の子ウィンドウを作れず起動直後に落ちます(v3.0.0 の Windows 版で発生)。 +- WebView2 のユーザーデータは `%LOCALAPPDATA%\TimecodeBridge3\WebView2`(`TIMECODEBRIDGE_DATA_DIR` があればその下の `WebView2`)に置きます。既定の「実行ファイルの隣」は Program Files に入れると書けず、起動直後に `E_ACCESSDENIED` で落ちます。 + ## 起動 ```sh @@ -22,13 +37,13 @@ dotnet build src/TimecodeBridge.Host/TimecodeBridge.Host.csproj | 変数 | 内容 | |---|---| -| `TIMECODEBRIDGE_SELFTEST_OUTPUT=<出力デバイス名の一部>` | 同一プロセス内で LTC(30fps, 01:00:00:00 から)を生成してその出力へ流す | +| `TIMECODEBRIDGE_SELFTEST_OUTPUT=<出力デバイス名の一部>` | 同一プロセス内で LTC(30fps, 01:00:00:00 から)を生成してその出力へ流す(macOS のみ。Windows は下記の smoke-windows.ps1 で 2 つ目の Host に生成させる) | | `TIMECODEBRIDGE_AUTOSTART_INPUT=<入力デバイス名の一部>` | 接続直後にそのデバイスで LTC 受信を始める | | `TIMECODEBRIDGE_BRIDGE_TRACE=1` / `2` | Web との送受信・受信状態を標準出力へ(2 は毎フレームの時計も) | | `TIMECODEBRIDGE_WEB_DIST=` | 同梱の web/ ではなくそのディレクトリの index.html を開く(Web 開発中に便利) | | `TIMECODEBRIDGE_LIBLTC=` | 同梱の libltc ではなくそのファイルを読み込む | | `TIMECODEBRIDGE_AUTOMATION_PORT=` | 127.0.0.1: で自動操作用の HTTP を待ち受ける(下記「人手なしの実機確認」) | -| `TIMECODEBRIDGE_DATA_DIR=` | 設定(最近使ったプロジェクト)の保存先を変える。tcb3ctl は `$TCB3_RUN_DIR/data` を渡し、試験用インスタンスが利用者の設定を書き換えないようにする | +| `TIMECODEBRIDGE_DATA_DIR=` | 設定(最近使ったプロジェクト)の保存先を変える。tcb3ctl は `$TCB3_RUN_DIR/data` を渡し、試験用インスタンスが利用者の設定を書き換えないようにする。Windows では WebView2 のユーザーデータもこの下の `WebView2` に置く | Pro Tools Audio Bridge のような仮想ループバックは、再生と取り込みが別プロセスだとタイムコードが乱れます。ハードウェアなしで確かめるときは `TIMECODEBRIDGE_SELFTEST_OUTPUT` を使ってください。 @@ -90,6 +105,21 @@ tools/tcb3/tcb3ctl reload && tools/tcb3/tcb3ctl shot /tmp/tcb3ctl/after.png # H Codex を herdr のペインで動かす場合(`herdr agent start --kind codex --pane -- -s workspace-write -a never -c sandbox_workspace_write.network_access=true`)も、この `tcb3ctl reload` / `shot` をそのまま使えます。`network_access=true` が無いとサンドボックスから 127.0.0.1 の自動操作口に届きません。Codex は撮った PNG を自分の画像表示ツールで開いて確認できます(実機で確認済み)。Codex のサンドボックスでは headless Chrome が起動できない(プロファイル先やヘルパープロセスの制約で SIGABRT)ので、見た目の確認は実機一本にしてください。ループバックのデバイス名は `TCB3_SELFTEST_DEVICE`、作業ファイルの置き場は `TCB3_RUN_DIR`(既定 `/tmp/tcb3ctl`)で変えられます。`osc_listen.py` は単体でも使え、届いた OSC を 1 行 1 メッセージの JSON で出します。 +## 人手なしの実機確認(Windows) + +tcb3ctl / smoke.sh は macOS 専用です(`pgrep`・`ps eww`・`jq` を使い、`/screenshot` も Windows では 501)。Windows では `tools/tcb3/smoke-windows.ps1`(pwsh 7、jq・python 不要)で通し確認をします。自動操作口(`/health` `/state` `/command` `/eval` など)は Windows でもそのまま使えます。 + +```powershell +pwsh tools/tcb3/smoke-windows.ps1 # Debug ビルドを起動 → Web ready → OSC 発火と受信 → 送信ログと画面 → 撮影 +pwsh tools/tcb3/smoke-windows.ps1 -Exe publish\TimecodeBridge3.exe # 発行物(CI と同じ) +pwsh tools/tcb3/smoke-windows.ps1 -LoopbackDevice "CABLE In 16ch" # 2 つ目の Host が LTC を生成してその出力へ流し、1 つ目がループバックで受けてキュー発火まで確認 +``` + +- `SMOKE PASS` / `SMOKE FAIL` で終わり、終了コードも 0 / 1。作業ファイル・ログ・撮影(`smoke.png`)は `-RunDir`(既定 `%TEMP%\tcb3-smoke`)に出ます。`-Keep` で Host を残します。 +- Windows では出力デバイスが入力一覧に「(Loopback)」付きで並び、WASAPI のループバック取り込みで受信できます(再生と取り込みが別プロセスでも乱れない)。`-LoopbackDevice` には VB-Audio Virtual Cable のような聞こえない出力を指定してください(スピーカーを指定すると LTC が鳴ります)。 +- 撮影は `PrintWindow`(PW_RENDERFULLCONTENT)で行うので、前面化しなくても WebView の中身が写ります。 +- GitHub の Windows ランナーには音声デバイスが無いので、CI(`.github/workflows/ci-v3.yml`)は `-LoopbackDevice` なしで、発行物とインストーラーで入れたものの両方を確認します。 + ## Web UI の変更 Web は Codex が担当しています。`dist/` は git 管理で、CI が再ビルドして差分が無いことを検査するため、変更後は必ず `npm run build` の結果をコミットしてください。見た目の確認は、手元の macOS では上の tcb3ctl(実機)を使ってください。Codex のサンドボックス外で素早く確認するだけなら headless Chrome でも描画できます(WebKit だけの見え方、たとえば number input のスピナーは Chrome では出ません)。 @@ -102,4 +132,6 @@ Web は Codex が担当しています。`dist/` は git 管理で、CI が再 ## リリース -`v3.*` のタグで `.github/workflows/release-v3.yml` が動き、macOS(Apple Silicon)の `TimecodeBridge3.app`(zip)と Windows の zip・インストーラー(WebView2 ランタイムを未導入なら導入)を作ります。libltc は LGPL-3.0 のため動的リンクで同梱し、`THIRD_PARTY_NOTICES.md` と `libltc-COPYING.txt` を含めます。 +`v3.*` のタグで `.github/workflows/release-v3.yml` が動き、macOS(Apple Silicon)の `TimecodeBridge3.app`(zip)と Windows の zip・インストーラー(WebView2 ランタイムを未導入なら導入)を作ります。Windows は zip にする前に発行物を smoke-windows.ps1 で起動して確かめ、起動しないビルドは出しません。libltc は LGPL-3.0 のため動的リンクで同梱し、`THIRD_PARTY_NOTICES.md` と `libltc-COPYING.txt` を含めます。 + +PR と `feature/v3` への push では `.github/workflows/ci-v3.yml` が Windows でビルド・テスト(Ltc / Host)・発行物の smoke・インストーラーを作ってサイレントインストールしたものの smoke を行います。 diff --git a/docs/v3/bridge-protocol.md b/docs/v3/bridge-protocol.md index c25e888..df25a6d 100644 --- a/docs/v3/bridge-protocol.md +++ b/docs/v3/bridge-protocol.md @@ -94,7 +94,7 @@ M0合否目安(推測): clock+wave、1000 cues表示を10分継続し、入 |`project.new/open/save/saveAs`|`{path?,suggestedName?}`|`{cancelled,path?}` / `invalidProject`,`ioError`。open/save/saveAs は `path` を渡すとネイティブダイアログを出さずにそのファイルを読む/書く(自動操作向け。フォルダが無ければ `ioError`)| |`mode.set`|`{mode}`|`{ltcStarted}` / `validation`。ltc へ切り替えたとき、選択済みの入力デバイスがあれば Host が自動で受信を再開する(未選択なら停止のまま)| |`ltc.start/stop/reconnect`|`{deviceId?}`|`deviceNotFound`,`audioError`,`nativeError`| -|`audio.refreshDevices`|`{direction}`|patch / `audioError`| +|`audio.refreshDevices`|`{direction}`|patch / `audioError`。Host は裏のスレッドでデバイスを列挙し直し、終わってから一覧の patch と result を返す(Windows で 0.5〜1 秒。その間も時計や他の command は止まらず、一覧は古いまま)。Web は result が返るまでスキャン中を表示する。一覧はこの command まで使い回す| |`receive.selectDevice`|`{deviceId}`|`deviceId` が null/空なら「未選択」に戻す(受信を止めて選択を消す)。それ以外は `ltc.reconnect` と同じ / `deviceNotFound`,`audioError`| |`receive.setOffset`|`{value}`|`{normalized}` / `validation`| |`receive.setTriggerWindow`|`{frames}`|`{frames}` / `validation`| diff --git a/docs/v3/verification-2026-09-27-windows.md b/docs/v3/verification-2026-09-27-windows.md new file mode 100644 index 0000000..fddbffd --- /dev/null +++ b/docs/v3/verification-2026-09-27-windows.md @@ -0,0 +1,52 @@ +# v3 の Windows 実機検証と修正の記録(2026-09-27) + +`verification-2026-09-14.md` の「次にやるべきこと」2 番(Windows の実機・CI)。macOS で作った v3 を Windows で初めてビルド・起動・通し確認し、見つけたものを直した。 + +## 環境 + +- Windows 11 Pro 10.0.26200(x64、日本語)、WebView2 ランタイム 153.0.4234.48 +- .NET SDK 9 / 10(net8.0 ランタイム 8.0.25 で起動)、Visual Studio 2022(MSVC 14.44)、Node.js 24、Inno Setup 6 +- 音声: VB-Audio Virtual Cable(CABLE In 16ch、16 チャンネルの出力)、Steinberg UR22C。LTC は CABLE In 16ch へ生成し、そのループバック取り込みで受信した + +## 見つかった問題と修正 + +| # | 症状 | 原因 | 修正 | +|---|---|---|---| +| 1 | **v3.0.0 の Windows 版が起動直後に落ちる**(リリースの zip で再現。GUI アプリなので利用者には何も出ずに終わる) | Host に対応 OS を宣言した `app.manifest` が無く、Avalonia が WebView(NativeControlHost)用の子ウィンドウを作れない(`Unable to create child window for native control host`) | `src/TimecodeBridge.Host/app.manifest`(Windows 10/11 の supportedOS)を追加 | +| 2 | Program Files のような書けない場所に入れると起動直後に落ちる(インストーラーで「すべてのユーザー」を選んだ場合) | WebView2 が既定で実行ファイルの隣(`TimecodeBridge3.exe.WebView2`)にユーザーデータを作ろうとして `E_ACCESSDENIED`。書き込みを禁止したフォルダで修正前の版が落ちることを再現した | `NativeWebView.EnvironmentRequested` で `UserDataFolder` を `%LOCALAPPDATA%\TimecodeBridge3\WebView2` に。アンインストール後にフォルダが残る問題も消えた | +| 3 | 入力デバイス一覧に出力デバイスが「(Loopback)」付きと無しの 2 回、同じ id で並ぶ | `HostState.BuildReceive` がキャプチャとレンダーの一覧をつないでいた。Windows ではループバック取り込みがキャプチャ側に入る(IAudioDeviceService の契約) | 入力の候補はキャプチャ側だけにした。**macOS でも出力専用デバイスが入力一覧に出なくなる**(macOS 実機では未確認) | +| 4 | 生成中にフレームレートや開始 TC を変えて「停止→再生」すると、画面は新しい設定なのに古いレートと位置のまま LTC を出す。「リセット」では新しい開始 TC を古いレートで数える(24fps の 10:59:52:00 が 30fps の 08:47:55 になる) | `generator.start` が保留中の設定を捨てて一時停止から再開し、`generator.reset` は開始 TC だけを差し替えていた(OS 共通) | 保留中の変更があれば最初から生成し直し、リセットはレートが変わっていれば生成器を作り直す。テスト 2 件を追加 | +| 5 | Host のテストが Windows で終わらない(`HostPingReportsReachabilityAndLatency`) | テストの `HostHarness.Run` が UI スレッドで非同期 command を同期待ちしており、Windows の `Ping.SendPingAsync` は必ず非同期で完了するためデッドロック。実機の Host は await しているので起きない(実機の疎通確認は成功) | `HostHarness.RunAsync` を足してテストを async に | +| 6 | Host のテスト 4 件が Windows で落ちる | パス区切り(`/` 固定)と `platform=="macos"` 固定の期待値 | パスは JSON にエスケープして渡し、期待値を OS から求める | +| 7 | ルート README の libltc が「LGPL-2.1」「復号・生成に使う」 | 同梱の COPYING は LGPL v3。生成は Core の自前の LtcEncoder | 「復号に使う libltc は LGPL-3.0-or-later」に | +| 8 | LTC受信 ⇄ 内部生成の切り替えに時間がかかる(画面の切り替えまで 内部生成へ約 0.66 秒・LTC受信へ約 2.6 秒、受信開始まで約 3.9 秒) | Windows のデバイス列挙はエンドポイントのプロパティ読みで 1 回 0.35〜0.5 秒かかる(この PC は 16 エンドポイント)。Host は状態を組み立てるたび(transport の入力デバイス名、receive / generator の一覧)とデバイスを探すたびに列挙しており、切り替え 1 回で何度も列挙していた。transport はオートミュートの切り替わりなどでも組み直す | `CachedAudioDeviceService` で一覧を「再スキャン」(audio.refreshDevices)まで使い回す。ID で見つからないときだけ一度列挙し直す(起動後に挿したデバイス)。画面の切り替えは 17〜65ms、受信開始まで約 0.2 秒に。画面の一覧が更新される契機(再スキャン)は従来どおり。再スキャンは裏のスレッドで列挙して終わってから一覧を差し替え(その間も UI スレッドは止まらない。スキャン中の状態取得 2〜6ms)、Web は result が返るまでボタンを「スキャン中…」にして帯を流す(この PC で約 0.65 秒)。最初の列挙は起動時に裏で先に始める(起動直後の状態取得 約 620ms → 59ms) | + +## 確認した範囲(修正後、すべて通過) + +- ビルド: `build-windows.cmd` で libltc.dll(日本語 Windows では `ltc.h` のコメント内の文字で C4819 が出るが無害)、Web の typecheck / test 51 件 / build(dist の差分は改行コードだけ)、Host のビルド、`dotnet publish -r win-x64 --self-contained`、`iscc` でインストーラー +- テスト: Ltc 13 件、Host 60 件 +- 起動: WebView2 で Web UI が表示される(日本語フォント・ダークテーマ・波形)。自動操作口(`/health` `/state` `/clock` `/command` `/eval`) +- LTC: 2 つの Host で 生成 → CABLE In 16ch → ループバック受信。24 / 25 / 29.97df / 30fps のいずれも同じレート(29.97 はドロップ判定)で受信、誤り率は 5 秒受けた時点で 0〜0.4%(受信開始からの累計なので、開始直後に弾かれる数フレームが効く。2.5 秒時点では 1.2% のこともあった)。モノラル 16bit の出力を 16ch デバイスへ、16ch のループバックから先頭チャンネルを取り込む経路も動く +- 生成: フレームレート・開始 TC の変更がリセット、停止→再生で反映される(修正 4 の後) +- キュー: LTC の時刻で自動発火した OSC を受信(引数 int32 と日本語の string)、手動発火、CUE SYNC、送信ログと発火記録、疎通確認(ICMP 0ms) +- 配布: 発行物を起動、インストーラーでユーザー単位にサイレントインストール → 起動して LTC 受信とキュー発火まで確認 → サイレントアンインストール(登録とフォルダが消える)、書き込みを禁止したフォルダに置いた発行物でも起動する(修正 2 の後) +- 通し確認: `tools/tcb3/smoke-windows.ps1 -LoopbackDevice "CABLE In 16ch"` を 3 回続けて SMOKE PASS + +## 追加したもの + +- `tools/tcb3/smoke-windows.ps1`: smoke.sh の Windows 版(pwsh 7、jq・python 不要)。起動 → Web ready → OSC 発火と受信 → 送信ログと画面 → WebView2 のデータが実行ファイルの隣にできていないこと → 撮影(PrintWindow)。`-LoopbackDevice` で 2 つ目の Host に LTC を生成させ、ループバック受信とキュー発火まで確かめる +- `.github/workflows/ci-v3.yml`: PR と feature/v3 への push で、Windows のビルド・テスト・発行物の smoke・インストーラーでサイレントインストールしたものの smoke(ランナーに音声デバイスが無いので LTC は確かめない) +- `release-v3.yml`: zip にする前に発行物を smoke し、起動しないビルドを出さない + +## 未対応・気づいたこと + +- **v3.0.0 の Windows 版(zip・インストーラー)は使えない状態のまま公開されている。** 修正を含めた v3.0.1 を出す必要がある +- ci-v3.yml はまだ一度も GitHub で動かしていない。ランナーで WebView2 の画面が作れるか(GUI セッション)、自動操作口の HttpListener が使えるかは初回の実行で確かめる。release-v3.yml の smoke も同じ前提なので、先に ci-v3 を通してからタグを打つ +- 修正 3・4 は macOS にも効く(入力一覧から出力専用デバイスが消える、生成の設定変更の反映)。macOS 実機での確認が要る +- 起動後に出た未処理例外はどこにも記録されない(起動エラー画面と startup-error.log は DI の組み立てでの失敗だけ)。修正 1・2 のような落ち方をしたとき利用者の手元に手がかりが残らないので、未処理例外を DataDirectory に記録する仕組みがあると良い +- `TIMECODEBRIDGE_SELFTEST_OUTPUT`(同一プロセスで生成と受信)は macOS のみ。Windows はループバック取り込みが別プロセスでも乱れないので、2 つの Host で代替した +- 自動操作口の `/screenshot` は Windows では 501 のまま(smoke-windows.ps1 は外から PrintWindow で撮る)。tcb3ctl / smoke.sh も macOS 専用のまま +- `TIMECODEBRIDGE_BRIDGE_TRACE` の標準出力は Windows では日本語が文字化けする(コンソールのコードページ)。開発用のログだけ +- ウィンドウのタイトルが「TimecodeBridge」(3 が付かない)。OS 共通 +- 実際のオーディオインターフェース(UR22C)への物理的な LTC 入出力、管理者権限での「すべてのユーザー」インストールは行っていない(後者は書き込み禁止のフォルダで代替) +- v1/v2 のテストが Windows で落ちる(v3 の対象外なので直していない): `TimecodeBridge.Tests` の CoreProjectStructureTests 12 件(実行ディレクトリからの相対パス)、OscTriggerPanelManagerTests 1 件(v3 で `Trigger` が `IOscSender.SendWithResult` に判定を任せたため、既定実装のままのテスト用スパイでは「送信先なし」にならない。OS 共通)、`TimecodeBridge.App.Tests` 2 件(macOS 前提の DI テスト、実際の利用者の設定を読む最近使ったプロジェクトのテスト) diff --git a/src/TimecodeBridge.Host/App.cs b/src/TimecodeBridge.Host/App.cs index 29d6253..a7b8334 100644 --- a/src/TimecodeBridge.Host/App.cs +++ b/src/TimecodeBridge.Host/App.cs @@ -45,9 +45,17 @@ public override void OnFrameworkInitializationCompleted() public static void ConfigureServices(IServiceCollection services) { + // 一覧は「再スキャン」まで使い回す(Windows は列挙が遅い。CachedAudioDeviceService のコメント参照)。 + // 最初の列挙は裏で先に始め、WebView の準備と重ねて起動時の待ちを隠す + services.AddSingleton(sp => + { + var devices = new CachedAudioDeviceService(OperatingSystem.IsWindows() ? new WindowsAudioDeviceService() : new CoreAudioDeviceService()); + _ = devices.RefreshAsync(); + return devices; + }); + if (OperatingSystem.IsWindows()) { - services.AddSingleton(); services.AddSingleton(sp => new TimecodeEngine( FrameRate.Fps30, sp.GetRequiredService(), @@ -57,7 +65,6 @@ public static void ConfigureServices(IServiceCollection services) } else { - services.AddSingleton(); services.AddSingleton(sp => new TimecodeEngine( FrameRate.Fps30, sp.GetRequiredService(), diff --git a/src/TimecodeBridge.Host/Bridge/CommandRouter.cs b/src/TimecodeBridge.Host/Bridge/CommandRouter.cs index 506c357..7082686 100644 --- a/src/TimecodeBridge.Host/Bridge/CommandRouter.cs +++ b/src/TimecodeBridge.Host/Bridge/CommandRouter.cs @@ -36,11 +36,17 @@ public async Task ExecuteAsync(WebMessage msg) if (msg.ExpectedRevision is { } expected && expected != _state.Revision) return Fail(id, ErrorCode.Conflict, $"状態が更新されています (expectedRevision: {expected}, currentRevision: {_state.Revision})", retryable: true); - // ダイアログを伴うものだけ非同期。それ以外は同期処理へ + // ダイアログを伴うもの・待ち時間のあるものだけ非同期。それ以外は同期処理へ try { switch (msg.Command) { + case "audio.refreshDevices": + // 列挙(Windows で 0.5〜1 秒)は裏のスレッドで行い、その間も UI スレッド(時計の送信・描画)を止めない。 + // 終わるまで古い一覧を使い、終わってから新しい一覧を送る。Web は result が返るまでスキャン中を表示する + await _state.RefreshDevicesAsync(); + _state.MarkDirty(Domain.Receive | Domain.Generator); + return Ok(id); case "project.new": return Ok(id, new { cancelled = !await _projects.NewAsync() }); case "project.open": @@ -176,9 +182,6 @@ public ResultMessage Execute(WebMessage msg) _state.MarkDirty(Domain.Receive | Domain.Transport); return Ok(id); } - case "audio.refreshDevices": - _state.MarkDirty(Domain.Receive | Domain.Generator); - return Ok(id); // ---- 受信設定 ---- case "receive.setOffset": @@ -291,7 +294,24 @@ public ResultMessage Execute(WebMessage msg) _state.MarkDirty(Domain.Generator | Domain.Transport); return Ok(id); case "generator.reset": - _engine.ResetGenerator(_state.Generator.StartTime); + // ResetGenerator は開始 TC だけを差し替え、生成器は古いレートのまま数える。レートが変わっていれば作り直す + if (_engine.ActiveSource == TimecodeSourceType.Generator && _engine.FrameRate != _state.Generator.FrameRate) + { + try + { + _engine.StartGenerator(_state.Generator); + if (!_state.GeneratorRunning) _engine.StopGenerator(); // 一時停止中なら開始位置で止めておく + } + catch (Exception ex) + { + _state.SetError(ex.Message); + return Fail(id, ErrorCode.AudioError, $"内部生成をリセットできません: {ex.Message}", retryable: true); + } + } + else + { + _engine.ResetGenerator(_state.Generator.StartTime); + } _state.GeneratorSettingsPending = false; _state.MarkDirty(Domain.Generator | Domain.NextCue); return Ok(id); diff --git a/src/TimecodeBridge.Host/Bridge/HostState.cs b/src/TimecodeBridge.Host/Bridge/HostState.cs index 14cda31..5f319a4 100644 --- a/src/TimecodeBridge.Host/Bridge/HostState.cs +++ b/src/TimecodeBridge.Host/Bridge/HostState.cs @@ -224,9 +224,11 @@ private TransportState BuildTransport() LastLtcReceivedAtUtc: _lastLtcReceivedAtUtc?.ToString("O")); } + // 入力の候補はキャプチャデバイスだけ(Windows ではレンダーデバイスのループバック取り込みもここに含まれる)。 + // レンダーデバイスを足すと、Windows では同じ id が「(Loopback)」付きと無しで二重に並び、出力専用デバイスまで入力に出る private ReceiveState BuildReceive() => new( SelectedInputDeviceId, - _devices.GetCaptureDevices().Concat(_devices.GetRenderDevices()).Select(ToDto).ToArray(), + _devices.GetCaptureDevices().Select(ToDto).ToArray(), _engine.Offset.ToString(), _cues.TriggerWindowFrames, _engine.FreerunDurationSeconds); @@ -421,12 +423,27 @@ private void OnOscSendCompleted(object? sender, OscSendResultEventArgs e) // ---- 変換 ---------------------------------------------------------------------- public string? DeviceName(string? id) => - id is null ? null : _devices.GetCaptureDevices().Concat(_devices.GetRenderDevices()).FirstOrDefault(d => d.Id == id)?.DisplayName; + id is null ? null : AllDevices().FirstOrDefault(d => d.Id == id)?.DisplayName; public IEnumerable AllDevices() => _devices.GetCaptureDevices().Concat(_devices.GetRenderDevices()); - public AudioDeviceInfo? FindDevice(string? id) => - id is null ? null : _devices.GetCaptureDevices().Concat(_devices.GetRenderDevices()).FirstOrDefault(d => d.Id == id); + /// デバイス一覧を次の取得で列挙し直す。 + public void RefreshDevices() + { + if (_devices is CachedAudioDeviceService cached) cached.Refresh(); + } + + /// 「再スキャン」。裏のスレッドで列挙し、終わるまでは古い一覧を使う。 + public Task RefreshDevicesAsync() => _devices is CachedAudioDeviceService cached ? cached.RefreshAsync() : Task.CompletedTask; + + // 一覧は使い回しなので、見つからなければ一度だけ列挙し直す(起動後に挿したデバイスを、再スキャン無しで開くプロジェクトが指している場合など) + public AudioDeviceInfo? FindDevice(string? id) + { + if (id is null) return null; + if (AllDevices().FirstOrDefault(d => d.Id == id) is { } found) return found; + RefreshDevices(); + return AllDevices().FirstOrDefault(d => d.Id == id); + } private static AudioDevice ToDto(AudioDeviceInfo d) => new(d.Id, d.DisplayName, d.IsLoopback); diff --git a/src/TimecodeBridge.Host/MainWindow.cs b/src/TimecodeBridge.Host/MainWindow.cs index 292ed5e..c78b2cd 100644 --- a/src/TimecodeBridge.Host/MainWindow.cs +++ b/src/TimecodeBridge.Host/MainWindow.cs @@ -51,6 +51,12 @@ public MainWindow(HostState state, CommandRouter router, ProjectCoordinator proj _bridge = null!; return; } + // WebView2 のユーザーデータを実行ファイルの隣に作らせない(Program Files では書けず表示できない)。生成前に聞かれるので Content より先に購読する + webView.EnvironmentRequested += (_, e) => + { + if (e is Avalonia.Platform.WindowsWebView2EnvironmentRequestedEventArgs windows) + windows.UserDataFolder = AppPaths.WebView2UserDataDirectory; + }; Content = webView; _bridge = new BridgeServer(webView, state, router, Close); _automation = DevAutomation.StartIfRequested(new HostAutomationTarget(this, webView, state, router, _bridge)); diff --git a/src/TimecodeBridge.Host/Services/AppPaths.cs b/src/TimecodeBridge.Host/Services/AppPaths.cs index 14b9571..b41c0c2 100644 --- a/src/TimecodeBridge.Host/Services/AppPaths.cs +++ b/src/TimecodeBridge.Host/Services/AppPaths.cs @@ -19,4 +19,13 @@ public static string DataDirectoryFor(string appFolderName) public static string DataDirectory => Environment.GetEnvironmentVariable(DataDirectoryVariable) is { Length: > 0 } overridden ? overridden : DataDirectoryFor(AppFolderName); + + /// + /// Windows の WebView2 のユーザーデータ(キャッシュなど)。既定の「実行ファイルの隣」は Program Files に入れると書けず表示できないので、 + /// ローミングしない LocalApplicationData の下に置く。TIMECODEBRIDGE_DATA_DIR があればその下。 + /// + public static string WebView2UserDataDirectory => + Environment.GetEnvironmentVariable(DataDirectoryVariable) is { Length: > 0 } overridden + ? Path.Combine(overridden, "WebView2") + : Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), AppFolderName, "WebView2"); } diff --git a/src/TimecodeBridge.Host/Services/CachedAudioDeviceService.cs b/src/TimecodeBridge.Host/Services/CachedAudioDeviceService.cs new file mode 100644 index 0000000..f92c3fa --- /dev/null +++ b/src/TimecodeBridge.Host/Services/CachedAudioDeviceService.cs @@ -0,0 +1,67 @@ +using TimecodeBridge.Core.Models; +using TimecodeBridge.Core.Services.Interfaces; + +namespace TimecodeBridge.Host.Services; + +/// +/// デバイス一覧を「再スキャン」(audio.refreshDevices)まで使い回す。 +/// Windows の列挙はエンドポイントのプロパティ読みで 1 回 0.5 秒ほどかかり、状態を組み立てるたびに列挙すると +/// モード切替や発火(オートミュートで transport を組み直す)のたびに UI スレッドが 1〜2 秒止まっていた。 +/// Web へ一覧を送るのは receive/generator の patch だけなので、画面の一覧が更新される契機は従来どおり。 +/// 再スキャンは で裏のスレッドで列挙し、終わるまでは古い一覧を返す。 +/// +public sealed class CachedAudioDeviceService : IAudioDeviceService +{ + private readonly IAudioDeviceService _inner; + private readonly object _lock = new(); + private IReadOnlyList? _capture; + private IReadOnlyList? _render; + private Task? _scan; + + public CachedAudioDeviceService(IAudioDeviceService inner) => _inner = inner; + + public IReadOnlyList GetCaptureDevices() + { + WaitForFirstScan(); + lock (_lock) return _capture ??= _inner.GetCaptureDevices(); + } + + public IReadOnlyList GetRenderDevices() + { + WaitForFirstScan(); + lock (_lock) return _render ??= _inner.GetRenderDevices(); + } + + /// 次の取得で(呼び出したスレッドで)列挙し直す。 + public void Refresh() + { + lock (_lock) { _capture = null; _render = null; } + } + + /// + /// 裏のスレッドで列挙し、終わったら一覧を差し替える。その間の取得は古い一覧を返す(一覧がまだ無いときだけ終わるのを待つ)。 + /// 走っている列挙があればそれを返し、二重に列挙しない。起動時の先読みにも使う。 + /// + public Task RefreshAsync() + { + lock (_lock) + { + if (_scan is { IsCompleted: false } running) return running; + return _scan = Task.Run(() => + { + var capture = _inner.GetCaptureDevices(); + var render = _inner.GetRenderDevices(); + lock (_lock) { _capture = capture; _render = render; } + }); + } + } + + private void WaitForFirstScan() + { + Task? scan; + lock (_lock) scan = _capture is null || _render is null ? _scan : null; + if (scan is null || scan.IsCompleted) return; + try { scan.Wait(); } + catch (AggregateException) { /* 失敗したら呼び出し元で同期に列挙し直す */ } + } +} diff --git a/src/TimecodeBridge.Host/TimecodeBridge.Host.csproj b/src/TimecodeBridge.Host/TimecodeBridge.Host.csproj index bec0428..d4f3223 100644 --- a/src/TimecodeBridge.Host/TimecodeBridge.Host.csproj +++ b/src/TimecodeBridge.Host/TimecodeBridge.Host.csproj @@ -14,6 +14,8 @@ 3.0.0 Major + + app.manifest diff --git a/src/TimecodeBridge.Host/app.manifest b/src/TimecodeBridge.Host/app.manifest new file mode 100644 index 0000000..f0c8a04 --- /dev/null +++ b/src/TimecodeBridge.Host/app.manifest @@ -0,0 +1,13 @@ + + + + + + + + + + + + diff --git a/src/TimecodeBridge.Web/dist/assets/app.js b/src/TimecodeBridge.Web/dist/assets/app.js index 1a5e39c..9048daa 100644 --- a/src/TimecodeBridge.Web/dist/assets/app.js +++ b/src/TimecodeBridge.Web/dist/assets/app.js @@ -1,12 +1,12 @@ -"use strict";(()=>{var le,x,Ke,Xt,K,Le,Xe,Je,qe,we,_e,he,Jt,Z={},Ge=[],qt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ce=Array.isArray;function W(e,t){for(var r in t)e[r]=t[r];return e}function Te(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Gt(e,t,r){var o,i,a,c={};for(a in t)a=="key"?o=t[a]:a=="ref"?i=t[a]:c[a]=t[a];if(arguments.length>2&&(c.children=arguments.length>3?le.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(a in e.defaultProps)c[a]===void 0&&(c[a]=e.defaultProps[a]);return se(e,c,o,i,null)}function se(e,t,r,o,i){var a={type:e,props:t,key:r,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Ke,__i:-1,__u:0};return i==null&&x.vnode!=null&&x.vnode(a),a}function H(e){return e.children}function ae(e,t){this.props=e,this.context=t}function G(e,t){if(t==null)return e.__?G(e.__,e.__i+1):null;for(var r;td&&K.sort(Je),e=K.shift(),d=K.length,e.__d&&(r=void 0,i=(o=(t=e).__v).__e,a=[],c=[],t.__P&&((r=W({},o)).__v=o.__v+1,x.vnode&&x.vnode(r),Ce(t.__P,r,o,t.__n,t.__P.namespaceURI,32&o.__u?[i]:null,a,i??G(o),!!(32&o.__u),c),r.__v=o.__v,r.__.__k[r.__i]=r,Ze(a,r,c),r.__e!=i&&ze(r)));ie.__r=0}function Qe(e,t,r,o,i,a,c,d,b,p,s){var l,f,h,A,u,_,m,g=o&&o.__k||Ge,w=t.length;for(b=zt(r,t,g,b,w),l=0;l0?se(c.type,c.props,c.key,c.ref?c.ref:null,c.__v):c).__=e,c.__b=e.__b+1,d=null,(p=c.__i=Qt(c,r,b,l))!=-1&&(l--,(d=r[p])&&(d.__u|=2)),d==null||d.__v==null?(p==-1&&(i>s?f--:ib?f--:f++,c.__u|=4))):e.__k[a]=null;if(l)for(a=0;a(s?1:0)){for(i=r-1,a=r+1;i>=0||a=0?i--:a++])!=null&&(2&p.__u)==0&&d==p.key&&b==p.type)return c}return-1}function Be(e,t,r){t[0]=="-"?e.setProperty(t,r??""):e[t]=r==null?"":typeof r!="number"||qt.test(t)?r:r+"px"}function oe(e,t,r,o,i){var a,c;e:if(t=="style")if(typeof r=="string")e.style.cssText=r;else{if(typeof o=="string"&&(e.style.cssText=o=""),o)for(t in o)r&&t in r||Be(e.style,t,"");if(r)for(t in r)o&&r[t]==o[t]||Be(e.style,t,r[t])}else if(t[0]=="o"&&t[1]=="n")a=t!=(t=t.replace(qe,"$1")),c=t.toLowerCase(),t=c in e||t=="onFocusOut"||t=="onFocusIn"?c.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=r,r?o?r.u=o.u:(r.u=we,e.addEventListener(t,a?he:_e,a)):e.removeEventListener(t,a?he:_e,a);else{if(i=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=r??"";break e}catch{}typeof r=="function"||(r==null||r===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&r==1?"":r))}}function Ve(e){return function(t){if(this.l){var r=this.l[t.type+e];if(t.t==null)t.t=we++;else if(t.t0?e:ce(e)?e.map(et):W({},e)}function Yt(e,t,r,o,i,a,c,d,b){var p,s,l,f,h,A,u,_=r.props,m=t.props,g=t.type;if(g=="svg"?i="http://www.w3.org/2000/svg":g=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),a!=null){for(p=0;p=r.__.length&&r.__.push({}),r.__[e]}function C(e){return de=1,en(mt,e)}function en(e,t,r){var o=pe(z++,2);if(o.t=e,!o.__c&&(o.__=[r?r(t):mt(void 0,t),function(d){var b=o.__N?o.__N[0]:o.__[0],p=o.t(b,d);b!==p&&(o.__N=[p,o.__[1]],o.__c.setState({}))}],o.__c=I,!I.__f)){var i=function(d,b,p){if(!o.__c.__H)return!0;var s=o.__c.__H.__.filter(function(f){return!!f.__c});if(s.every(function(f){return!f.__N}))return!a||a.call(this,d,b,p);var l=o.__c.props!==d;return s.forEach(function(f){if(f.__N){var h=f.__[0];f.__=f.__N,f.__N=void 0,h!==f.__[0]&&(l=!0)}}),a&&a.call(this,d,b,p)||l};I.__f=!0;var a=I.shouldComponentUpdate,c=I.componentWillUpdate;I.componentWillUpdate=function(d,b,p){if(this.__e){var s=a;a=void 0,i(d,b,p),a=s}c&&c.call(this,d,b,p)},I.shouldComponentUpdate=i}return o.__N||o.__}function P(e,t){var r=pe(z++,3);!M.__s&&Ee(r.__H,t)&&(r.__=e,r.u=t,I.__H.__h.push(r))}function pt(e,t){var r=pe(z++,4);!M.__s&&Ee(r.__H,t)&&(r.__=e,r.u=t,I.__h.push(r))}function $(e){return de=5,tn(function(){return{current:e}},[])}function tn(e,t){var r=pe(z++,7);return Ee(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function nn(){for(var e;e=dt.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(ue),e.__H.__h.forEach(Ae),e.__H.__h=[]}catch(t){e.__H.__h=[],M.__e(t,e.__v)}}M.__b=function(e){I=null,ot&&ot(e)},M.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ct&&ct(e,t)},M.__r=function(e){st&&st(e),z=0;var t=(I=e.__c).__H;t&&(Se===I?(t.__h=[],I.__h=[],t.__.forEach(function(r){r.__N&&(r.__=r.__N),r.u=r.__N=void 0})):(t.__h.forEach(ue),t.__h.forEach(Ae),t.__h=[],z=0)),Se=I},M.diffed=function(e){at&&at(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(dt.push(t)!==1&&rt===M.requestAnimationFrame||((rt=M.requestAnimationFrame)||rn)(nn)),t.__H.__.forEach(function(r){r.u&&(r.__H=r.u),r.u=void 0})),Se=I=null},M.__c=function(e,t){t.some(function(r){try{r.__h.forEach(ue),r.__h=r.__h.filter(function(o){return!o.__||Ae(o)})}catch(o){t.some(function(i){i.__h&&(i.__h=[])}),t=[],M.__e(o,r.__v)}}),it&&it(e,t)},M.unmount=function(e){lt&<(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach(function(o){try{ue(o)}catch(i){t=i}}),r.__H=void 0,t&&M.__e(t,r.__v))};var ut=typeof requestAnimationFrame=="function";function rn(e){var t,r=function(){clearTimeout(o),ut&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(r,35);ut&&(t=requestAnimationFrame(r))}function ue(e){var t=I,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),I=t}function Ae(e){var t=I;e.__c=e.__(),I=t}function Ee(e,t){return!e||e.length!==t.length||t.some(function(r,o){return r!==e[o]})}function mt(e,t){return typeof t=="function"?t(e):t}function ft(e,t){if(!e)return"";let r=Date.parse(e);if(Number.isNaN(r))return"";let o=r-t;if(o<=0)return"";let i=Math.ceil(o/1e3);return i<60?`${i}`:`${Math.floor(i/60)}:${String(i%60).padStart(2,"0")}`}var on=()=>({host:{sessionId:null,revision:null,state:null,clock:null,wave:null,clockSeq:-1,waveSeq:-1,connected:!1,resyncing:!1},ui:{selectedCueIds:new Set,anchorCueId:null,focusedCueId:null,cueScrollTop:0,cueColumnWidths:[38,105,280,220,50],drawerOpen:!1,drawerWidth:420,optionsOpen:!1,modalOpen:!1}});function gt(e,t){if(t.type==="snapshot")return e.host.sessionId=t.state.sessionId,e.host.revision=t.revision,e.host.state=t.state,e.host.clock=t.state.currentClock,e.host.connected=!0,e.host.resyncing=!1,"applied";if(t.type==="patch"){if(!e.host.state||t.baseRevision!==e.host.revision)return e.host.resyncing=!0,"resync";let{logsAppend:r,logsReset:o,nextCueCleared:i,openOptions:a,...c}=t.changes;return Object.assign(e.host.state,c),i&&(e.host.state.nextCue=null),a&&(e.ui.optionsOpen=!0),o?e.host.state.logs=o:r&&(e.host.state.logs=[...e.host.state.logs,...r].slice(-500)),e.host.revision=t.revision,"applied"}return t.type==="clock"?t.seq<=e.host.clockSeq?"ignored":(e.host.clockSeq=t.seq,e.host.clock=t.clock,"applied"):t.type==="wave"?t.seq<=e.host.waveSeq?"ignored":(e.host.waveSeq=t.seq,e.host.wave=t.wave,"applied"):"ignored"}var De=class{value=on();listeners=new Set;subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notify(){for(let t of this.listeners)t()}updateUi(t){Object.assign(this.value.ui,t),this.notify()}},k=new De;var sn=0,Oe=new Map;function Q(e){window.invokeCSharpAction?.(JSON.stringify(e))}function O(e,t,r){let o=`web-${Date.now()}-${++sn}`,i={protocolVersion:1,type:"command",requestId:o,command:e,args:t,...r===void 0?{}:{expectedRevision:r}};return Q(i),new Promise((a,c)=>Oe.set(o,{resolve:a,reject:c}))}function bt(e){let t=Oe.get(e.requestId);t&&(Oe.delete(e.requestId),e.ok?t.resolve(e.data):t.reject(e.error))}function vt(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName))}function _t(e,t){if(e.repeat||e.isComposing||t||vt(e.target))return null;let r=e.metaKey||e.ctrlKey,o=e.key.toLowerCase();return r&&o==="n"?"projectNew":r&&o==="o"?"projectOpen":r&&o==="s"?e.shiftKey?"projectSaveAs":"projectSave":r&&o==="z"?e.shiftKey?"redo":"undo":e.ctrlKey&&!e.metaKey&&o==="y"?"redo":e.key==="Escape"?"closeDrawer":e.key==="ArrowUp"?"selectPrevious":e.key==="ArrowDown"?"selectNext":e.key==="Enter"?"editCue":e.key==="Delete"||e.key==="Backspace"?"deleteCue":null}var ht=e=>({ok:!0,value:e}),xe=e=>({ok:!1,message:e});function Re(e,t=!1){if(!(t?/^[+-]\d{2}:\d{2}:\d{2}[:;]\d{2}$/:/^\d{2}:\d{2}:\d{2}[:;]\d{2}$/).test(e))return xe(t?"\xB1HH:MM:SS:FF \u5F62\u5F0F\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044":"HH:MM:SS:FF \u5F62\u5F0F\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044");let i=(t?e.slice(1):e).replace(";",":").split(":").map(Number);return(i[1]??99)<60&&(i[2]??99)<60?ht(e):xe("\u5206\u30FB\u79D2\u306F 00\u301C59 \u3067\u3059")}function Ie(e){return/^\/(?:[^\s/#*,?\[\]{}]+(?:\/[^\s/#*,?\[\]{}]+)*)?$/.test(e)?ht(e):xe("/ \u3067\u59CB\u307E\u308B OSC\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044")}var ee=e=>({name:"",memo:"",triggerTime:"00:00:00:00",frameRate:e,oscAddress:"/",additionalOscAddresses:"",argumentsText:"",targetHostIds:[],enabled:!0,sendTriggerTimeAsSeconds:!1,sendTimecode:"",triggerOffset:"",autoMuteOnFire:!1,autoUnmuteAfter:""}),yt=e=>({...ee(e.frameRate),name:e.name,memo:e.memo,triggerTime:e.triggerTime,oscAddress:e.oscAddress,additionalOscAddresses:e.additionalOscAddresses.join(` +"use strict";(()=>{var le,O,Ke,Xt,K,Le,Xe,Je,qe,ye,ve,_e,Jt,Z={},Ge=[],qt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ce=Array.isArray;function W(e,t){for(var r in t)e[r]=t[r];return e}function we(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Gt(e,t,r){var o,i,a,u={};for(a in t)a=="key"?o=t[a]:a=="ref"?i=t[a]:u[a]=t[a];if(arguments.length>2&&(u.children=arguments.length>3?le.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(a in e.defaultProps)u[a]===void 0&&(u[a]=e.defaultProps[a]);return se(e,u,o,i,null)}function se(e,t,r,o,i){var a={type:e,props:t,key:r,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Ke,__i:-1,__u:0};return i==null&&O.vnode!=null&&O.vnode(a),a}function H(e){return e.children}function ae(e,t){this.props=e,this.context=t}function G(e,t){if(t==null)return e.__?G(e.__,e.__i+1):null;for(var r;td&&K.sort(Je),e=K.shift(),d=K.length,e.__d&&(r=void 0,i=(o=(t=e).__v).__e,a=[],u=[],t.__P&&((r=W({},o)).__v=o.__v+1,O.vnode&&O.vnode(r),Te(t.__P,r,o,t.__n,t.__P.namespaceURI,32&o.__u?[i]:null,a,i??G(o),!!(32&o.__u),u),r.__v=o.__v,r.__.__k[r.__i]=r,Ze(a,r,u),r.__e!=i&&ze(r)));ie.__r=0}function Qe(e,t,r,o,i,a,u,d,m,p,s){var l,g,h,A,c,_,f,b=o&&o.__k||Ge,w=t.length;for(m=zt(r,t,b,m,w),l=0;l0?se(u.type,u.props,u.key,u.ref?u.ref:null,u.__v):u).__=e,u.__b=e.__b+1,d=null,(p=u.__i=Qt(u,r,m,l))!=-1&&(l--,(d=r[p])&&(d.__u|=2)),d==null||d.__v==null?(p==-1&&(i>s?g--:im?g--:g++,u.__u|=4))):e.__k[a]=null;if(l)for(a=0;a(s?1:0)){for(i=r-1,a=r+1;i>=0||a=0?i--:a++])!=null&&(2&p.__u)==0&&d==p.key&&m==p.type)return u}return-1}function Be(e,t,r){t[0]=="-"?e.setProperty(t,r??""):e[t]=r==null?"":typeof r!="number"||qt.test(t)?r:r+"px"}function oe(e,t,r,o,i){var a,u;e:if(t=="style")if(typeof r=="string")e.style.cssText=r;else{if(typeof o=="string"&&(e.style.cssText=o=""),o)for(t in o)r&&t in r||Be(e.style,t,"");if(r)for(t in r)o&&r[t]==o[t]||Be(e.style,t,r[t])}else if(t[0]=="o"&&t[1]=="n")a=t!=(t=t.replace(qe,"$1")),u=t.toLowerCase(),t=u in e||t=="onFocusOut"||t=="onFocusIn"?u.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=r,r?o?r.u=o.u:(r.u=ye,e.addEventListener(t,a?_e:ve,a)):e.removeEventListener(t,a?_e:ve,a);else{if(i=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=r??"";break e}catch{}typeof r=="function"||(r==null||r===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&r==1?"":r))}}function Ve(e){return function(t){if(this.l){var r=this.l[t.type+e];if(t.t==null)t.t=ye++;else if(t.t0?e:ce(e)?e.map(et):W({},e)}function Yt(e,t,r,o,i,a,u,d,m){var p,s,l,g,h,A,c,_=r.props,f=t.props,b=t.type;if(b=="svg"?i="http://www.w3.org/2000/svg":b=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),a!=null){for(p=0;p=r.__.length&&r.__.push({}),r.__[e]}function C(e){return de=1,en(mt,e)}function en(e,t,r){var o=pe(z++,2);if(o.t=e,!o.__c&&(o.__=[r?r(t):mt(void 0,t),function(d){var m=o.__N?o.__N[0]:o.__[0],p=o.t(m,d);m!==p&&(o.__N=[p,o.__[1]],o.__c.setState({}))}],o.__c=I,!I.__f)){var i=function(d,m,p){if(!o.__c.__H)return!0;var s=o.__c.__H.__.filter(function(g){return!!g.__c});if(s.every(function(g){return!g.__N}))return!a||a.call(this,d,m,p);var l=o.__c.props!==d;return s.forEach(function(g){if(g.__N){var h=g.__[0];g.__=g.__N,g.__N=void 0,h!==g.__[0]&&(l=!0)}}),a&&a.call(this,d,m,p)||l};I.__f=!0;var a=I.shouldComponentUpdate,u=I.componentWillUpdate;I.componentWillUpdate=function(d,m,p){if(this.__e){var s=a;a=void 0,i(d,m,p),a=s}u&&u.call(this,d,m,p)},I.shouldComponentUpdate=i}return o.__N||o.__}function P(e,t){var r=pe(z++,3);!M.__s&&Ae(r.__H,t)&&(r.__=e,r.u=t,I.__H.__h.push(r))}function pt(e,t){var r=pe(z++,4);!M.__s&&Ae(r.__H,t)&&(r.__=e,r.u=t,I.__h.push(r))}function $(e){return de=5,tn(function(){return{current:e}},[])}function tn(e,t){var r=pe(z++,7);return Ae(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function nn(){for(var e;e=dt.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(ue),e.__H.__h.forEach(Se),e.__H.__h=[]}catch(t){e.__H.__h=[],M.__e(t,e.__v)}}M.__b=function(e){I=null,ot&&ot(e)},M.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ct&&ct(e,t)},M.__r=function(e){st&&st(e),z=0;var t=(I=e.__c).__H;t&&(ke===I?(t.__h=[],I.__h=[],t.__.forEach(function(r){r.__N&&(r.__=r.__N),r.u=r.__N=void 0})):(t.__h.forEach(ue),t.__h.forEach(Se),t.__h=[],z=0)),ke=I},M.diffed=function(e){at&&at(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(dt.push(t)!==1&&rt===M.requestAnimationFrame||((rt=M.requestAnimationFrame)||rn)(nn)),t.__H.__.forEach(function(r){r.u&&(r.__H=r.u),r.u=void 0})),ke=I=null},M.__c=function(e,t){t.some(function(r){try{r.__h.forEach(ue),r.__h=r.__h.filter(function(o){return!o.__||Se(o)})}catch(o){t.some(function(i){i.__h&&(i.__h=[])}),t=[],M.__e(o,r.__v)}}),it&&it(e,t)},M.unmount=function(e){lt&<(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach(function(o){try{ue(o)}catch(i){t=i}}),r.__H=void 0,t&&M.__e(t,r.__v))};var ut=typeof requestAnimationFrame=="function";function rn(e){var t,r=function(){clearTimeout(o),ut&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(r,35);ut&&(t=requestAnimationFrame(r))}function ue(e){var t=I,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),I=t}function Se(e){var t=I;e.__c=e.__(),I=t}function Ae(e,t){return!e||e.length!==t.length||t.some(function(r,o){return r!==e[o]})}function mt(e,t){return typeof t=="function"?t(e):t}function ft(e,t){if(!e)return"";let r=Date.parse(e);if(Number.isNaN(r))return"";let o=r-t;if(o<=0)return"";let i=Math.ceil(o/1e3);return i<60?`${i}`:`${Math.floor(i/60)}:${String(i%60).padStart(2,"0")}`}var on=()=>({host:{sessionId:null,revision:null,state:null,clock:null,wave:null,clockSeq:-1,waveSeq:-1,connected:!1,resyncing:!1},ui:{selectedCueIds:new Set,anchorCueId:null,focusedCueId:null,cueScrollTop:0,cueColumnWidths:[38,105,280,220,50],drawerOpen:!1,drawerWidth:420,optionsOpen:!1,modalOpen:!1}});function gt(e,t){if(t.type==="snapshot")return e.host.sessionId=t.state.sessionId,e.host.revision=t.revision,e.host.state=t.state,e.host.clock=t.state.currentClock,e.host.connected=!0,e.host.resyncing=!1,"applied";if(t.type==="patch"){if(!e.host.state||t.baseRevision!==e.host.revision)return e.host.resyncing=!0,"resync";let{logsAppend:r,logsReset:o,nextCueCleared:i,openOptions:a,...u}=t.changes;return Object.assign(e.host.state,u),i&&(e.host.state.nextCue=null),a&&(e.ui.optionsOpen=!0),o?e.host.state.logs=o:r&&(e.host.state.logs=[...e.host.state.logs,...r].slice(-500)),e.host.revision=t.revision,"applied"}return t.type==="clock"?t.seq<=e.host.clockSeq?"ignored":(e.host.clockSeq=t.seq,e.host.clock=t.clock,"applied"):t.type==="wave"?t.seq<=e.host.waveSeq?"ignored":(e.host.waveSeq=t.seq,e.host.wave=t.wave,"applied"):"ignored"}var Ee=class{value=on();listeners=new Set;subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notify(){for(let t of this.listeners)t()}updateUi(t){Object.assign(this.value.ui,t),this.notify()}},k=new Ee;var sn=0,De=new Map;function Q(e){window.invokeCSharpAction?.(JSON.stringify(e))}function x(e,t,r){let o=`web-${Date.now()}-${++sn}`,i={protocolVersion:1,type:"command",requestId:o,command:e,args:t,...r===void 0?{}:{expectedRevision:r}};return Q(i),new Promise((a,u)=>De.set(o,{resolve:a,reject:u}))}function bt(e){let t=De.get(e.requestId);t&&(De.delete(e.requestId),e.ok?t.resolve(e.data):t.reject(e.error))}function vt(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName))}function _t(e,t){if(e.repeat||e.isComposing||t||vt(e.target))return null;let r=e.metaKey||e.ctrlKey,o=e.key.toLowerCase();return r&&o==="n"?"projectNew":r&&o==="o"?"projectOpen":r&&o==="s"?e.shiftKey?"projectSaveAs":"projectSave":r&&o==="z"?e.shiftKey?"redo":"undo":e.ctrlKey&&!e.metaKey&&o==="y"?"redo":e.key==="Escape"?"closeDrawer":e.key==="ArrowUp"?"selectPrevious":e.key==="ArrowDown"?"selectNext":e.key==="Enter"?"editCue":e.key==="Delete"||e.key==="Backspace"?"deleteCue":null}var ht=e=>({ok:!0,value:e}),xe=e=>({ok:!1,message:e});function Oe(e,t=!1){if(!(t?/^[+-]\d{2}:\d{2}:\d{2}[:;]\d{2}$/:/^\d{2}:\d{2}:\d{2}[:;]\d{2}$/).test(e))return xe(t?"\xB1HH:MM:SS:FF \u5F62\u5F0F\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044":"HH:MM:SS:FF \u5F62\u5F0F\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044");let i=(t?e.slice(1):e).replace(";",":").split(":").map(Number);return(i[1]??99)<60&&(i[2]??99)<60?ht(e):xe("\u5206\u30FB\u79D2\u306F 00\u301C59 \u3067\u3059")}function Re(e){return/^\/(?:[^\s/#*,?\[\]{}]+(?:\/[^\s/#*,?\[\]{}]+)*)?$/.test(e)?ht(e):xe("/ \u3067\u59CB\u307E\u308B OSC\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044")}var ee=e=>({name:"",memo:"",triggerTime:"00:00:00:00",frameRate:e,oscAddress:"/",additionalOscAddresses:"",argumentsText:"",targetHostIds:[],enabled:!0,sendTriggerTimeAsSeconds:!1,sendTimecode:"",triggerOffset:"",autoMuteOnFire:!1,autoUnmuteAfter:""}),yt=e=>({...ee(e.frameRate),name:e.name,memo:e.memo,triggerTime:e.triggerTime,oscAddress:e.oscAddress,additionalOscAddresses:e.additionalOscAddresses.join(` `),argumentsText:e.arguments.map(t=>`${t.type}:${t.value}`).join(` -`),targetHostIds:[...e.targetHostIds],enabled:e.enabled,sendTriggerTimeAsSeconds:e.sendTriggerTimeAsSeconds,sendTimecode:e.sendTimecode??"",triggerOffset:e.triggerOffset??"",autoMuteOnFire:e.autoMuteOnFire,autoUnmuteAfter:e.autoUnmuteAfter??""});function te(e){let t=[];for(let[r,o]of e.split(/\r?\n/).entries()){if(!o.trim())continue;let i=o.indexOf(":"),a=o.slice(0,i),c=o.slice(i+1);if(i<0||!["int32","float32","string"].includes(a))return{error:`${r+1} \u884C\u76EE\u306F type:value \u5F62\u5F0F\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044`};if(a==="string")t.push({type:a,value:c});else{let d=Number(c);if(!Number.isFinite(d)||a==="int32"&&!Number.isInteger(d))return{error:`${r+1} \u884C\u76EE\u306E\u5024\u304C\u4E0D\u6B63\u3067\u3059`};t.push(a==="int32"?{type:a,value:d}:{type:"float32",value:d})}}return{value:t}}function me(e){let t={};e.name.trim()||(t.name="\u540D\u524D\u306F\u5FC5\u9808\u3067\u3059");let r=Re(e.triggerTime);r.ok||(t.triggerTime=r.message);let o=Ie(e.oscAddress);o.ok||(t.oscAddress=o.message);let i=e.additionalOscAddresses.split(/\r?\n|,/).map(c=>c.trim()).filter(Boolean);i.some(c=>!Ie(c).ok)&&(t.additionalOscAddresses="\u5404\u884C\u306B / \u3067\u59CB\u307E\u308B\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044");let a=te(e.argumentsText);a.error&&(t.arguments=a.error);for(let[c,d,b]of[["sendTimecode",e.sendTimecode,!1],["triggerOffset",e.triggerOffset,!0],["autoUnmuteAfter",e.autoUnmuteAfter,!1]])d&&!Re(d,b).ok&&(t[c]="\u6642\u523B\u5F62\u5F0F\u304C\u4E0D\u6B63\u3067\u3059");return Object.keys(t).length?{errors:t}:{errors:t,draft:{name:e.name.trim(),memo:e.memo,triggerTime:e.triggerTime,frameRate:e.frameRate,oscAddress:e.oscAddress,additionalOscAddresses:i,arguments:a.value,targetHostIds:e.targetHostIds,enabled:e.enabled,sendTriggerTimeAsSeconds:e.sendTriggerTimeAsSeconds,sendTimecode:e.sendTimecode||null,triggerOffset:e.triggerOffset||null,autoMuteOnFire:e.autoMuteOnFire,autoUnmuteAfter:e.autoUnmuteAfter||null}}}var Me=(e,t)=>Object.fromEntries(Object.entries(e.fieldErrors??{}).filter(([r])=>r.startsWith(t+".")).map(([r,o])=>[r.slice(t.length+1),o]));var an=0,Bn=Array.isArray;function n(e,t,r,o,i,a){t||(t={});var c,d,b=t;if("ref"in b)for(d in b={},t)d=="ref"?c=t[d]:b[d]=t[d];var p={type:e,props:b,key:r,ref:c,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--an,__i:-1,__u:0,__source:i,__self:a};if(typeof e=="function"&&(c=e.defaultProps))for(d in c)b[d]===void 0&&(b[d]=c[d]);return x.vnode&&x.vnode(p),p}function Tt(e){return e.replace(/[0-9]/g,t=>String.fromCharCode(t.charCodeAt(0)-65248)).replace(/[^0-9]/g,"")}function Pe(e,t=!1){let r=t&&e.startsWith("-")?"-":"+",i=(t&&/^[+-]/.test(e)?e.slice(1):e).split(/[:;]/).slice(0,4).map(Tt);return{sign:r,parts:[i[0]??"",i[1]??"",i[2]??"",i[3]??""]}}function fe(e,t="+",r=!1){return e.every(o=>o==="")?"":`${r?t:""}${e.map(o=>o.padStart(2,"0")).join(":")}`}function wt(e,t,r){let o=Tt(r),i=[...e];if(o.length<=2)return i[t]=o,{parts:i,focus:o.length===2&&t<3?t+1:null};for(let a=t,c=0;a<4&&c0?t-1:e==="ArrowRight"&&t<3?t+1:e==="Backspace"&&r&&t>0?t-1:null}var ne=e=>e==="24"?23:e==="25"?24:29;function re(e,t,r=!1){if(e==="")return e;let{sign:o,parts:i}=Pe(e,r);return fe(i.map((a,c)=>Ct(a,c,t)),o,r)}function Ct(e,t,r){if(e==="")return e;let o=t===0?23:t===1||t===2?59:ne(r);return String(Math.min(o,Number(e))).padStart(2,"0")}function B({value:e,onChange:t,onCommit:r,frameRate:o,signed:i=!1,required:a=!1,disabled:c=!1,ariaLabel:d,class:b=""}){let p=Pe(e,i),[s,l]=C(p.parts),[f,h]=C(p.sign),A=$([]),u=$(null),_=$(p.parts);P(()=>{if(e===u.current){u.current=null;return}let y=Pe(e,i);_.current=y.parts,l(y.parts),h(y.sign)},[e,i]);let m=(y,T=f)=>{_.current=y,l(y);let S=fe(y,T,i);u.current=S,t?.(S)},g=y=>{y!==null&&A.current[y]?.focus()},w=y=>{let T=[..._.current];T[y]=Ct(T[y]??"",y,o),m(T),r?.(fe(T,f,i))};return n("span",{class:`timecode-input ${b}`,role:"group","aria-label":d,children:[i&&n("select",{class:"timecode-sign","aria-label":`${d}\u306E\u7B26\u53F7`,disabled:c,value:f,onChange:y=>{let T=y.currentTarget.value;h(T);let S=fe(_.current,T,!0);u.current=S,t?.(S),r?.(S)},children:[n("option",{value:"+",children:"+"}),n("option",{value:"-",children:"\u2212"})]}),s.map((y,T)=>n("span",{class:"timecode-segment",children:[n("input",{ref:S=>{A.current[T]=S},class:"timecode-part",inputMode:"numeric",pattern:"[0-9]*",maxlength:2,required:a,disabled:c,value:y,"aria-label":`${d} ${["\u6642","\u5206","\u79D2","\u30D5\u30EC\u30FC\u30E0"][T]??""}`,onBeforeInput:S=>{let R=S.data;R&&/[^0-9]/.test(R)&&S.preventDefault()},onCompositionStart:S=>{let R=S.currentTarget;R.blur(),window.setTimeout(()=>R.focus(),0)},onInput:S=>{let R=wt(_.current,T,S.currentTarget.value);m(R.parts),g(R.focus)},onPaste:S=>{S.preventDefault();let R=wt(_.current,T,S.clipboardData?.getData("text")??"");m(R.parts),g(R.focus)},onBlur:()=>w(T),onKeyDown:S=>{if(S.key==="ArrowUp"||S.key==="ArrowDown"){S.preventDefault();let V=T===0?23:T===1||T===2?59:ne(o),v=[..._.current],D=Number(v[T]||0);v[T]=String(Math.max(0,Math.min(V,D+(S.key==="ArrowUp"?1:-1)))).padStart(2,"0"),m(v);return}let R=ln(S.key,T,y==="");R!==null&&(S.preventDefault(),g(R))}}),T<3&&n("span",{class:"timecode-colon","aria-hidden":"true",children:":"})]})),n("small",{class:"timecode-limit",children:["FF 00\u2013",String(ne(o)).padStart(2,"0")]})]})}function X(e){return P(()=>{let t=r=>{r.key==="Escape"&&!r.isComposing&&(r.preventDefault(),e.close())};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[e.close]),n("div",{class:"modal-shade",children:n("div",{class:`dialog ${e.wide?"wide":""} ${e.class??""}`,role:"dialog","aria-modal":"true",onKeyDown:t=>t.stopPropagation(),children:[n("div",{class:"dialog-title",children:[n("b",{children:e.title}),e.titleExtra,n("button",{class:"btn",onClick:e.close,children:"\u9589\u3058\u308B"})]}),e.children]})})}var ge=X,cn=({errors:e,name:t})=>n("small",{class:"field-error",children:e[t]??""}),un=["24","25","29.97df","30"],U=({label:e,name:t,errors:r,title:o,top:i,children:a})=>n("div",{class:`cue-row ${i?"top":""}`,children:[n("span",{class:"lbl",title:o,children:e}),n("div",{class:"ctl",children:[a,t&&r[t]&&n("small",{class:"field-error",children:r[t]})]})]});function He({cue:e,frameRate:t,hosts:r,close:o,done:i}){let[a,c]=C(()=>e?yt(e):{...ee(t),targetHostIds:r.map(u=>u.id)}),[d,b]=C({}),p=(u,_)=>c(m=>({...m,[u]:_})),s=(u,_,{signed:m=!1,disabled:g=!1}={})=>n(B,{ariaLabel:_,value:a[u],frameRate:a.frameRate,signed:m,disabled:g,required:u==="triggerTime",onChange:w=>p(u,w)}),l=(u,_)=>n("label",{class:"check",children:[n("input",{type:"checkbox",checked:a[u],onChange:m=>p(u,m.currentTarget.checked)}),_]}),f=(u,_,m,g)=>n("div",{class:"check-row",children:[n("label",{class:"check",children:[n("input",{type:"checkbox","aria-label":`${_}\u3092\u6307\u5B9A`,disabled:!m,checked:a[u]!=="",onChange:w=>p(u,w.currentTarget.checked?g:"")}),"\u6307\u5B9A"]}),s(u,_,{disabled:!m||a[u]===""})]}),h=async u=>{u.preventDefault();let _=me(a);if(!_.draft){b(_.errors);return}try{await O(e?"cue.update":"cue.add",e?{id:e.id,cue:_.draft}:{cue:_.draft}),i()}catch(m){b(Me(m,"cue"))}},A=n("label",{class:"cue-frame-rate",children:[n("span",{children:"\u57FA\u6E96\u30D5\u30EC\u30FC\u30E0\u30EC\u30FC\u30C8"}),n("select",{class:"field",value:a.frameRate,onChange:u=>{let _=u.currentTarget.value;c(m=>({...m,frameRate:_,triggerTime:re(m.triggerTime,_),sendTimecode:re(m.sendTimecode,_),triggerOffset:re(m.triggerOffset,_,!0),autoUnmuteAfter:re(m.autoUnmuteAfter,_)}))},children:un.map(u=>n("option",{value:u,children:[u," fps"]}))}),n("small",{children:["FF 00\u2013",String(ne(a.frameRate)).padStart(2,"0")]})]});return n(ge,{title:e?"\u30AD\u30E5\u30FC\u3092\u7DE8\u96C6":"\u30AD\u30E5\u30FC\u3092\u8FFD\u52A0",close:o,class:"cue",titleExtra:A,children:n("form",{onSubmit:h,class:"cue-edit",children:[n(U,{label:"\u540D\u524D",name:"name",errors:d,children:n("input",{autofocus:!0,class:"field","aria-label":"\u540D\u524D",value:a.name,onInput:u=>p("name",u.currentTarget.value)})}),n(U,{label:"\u30C8\u30EA\u30AC\u30FC\u6642\u9593",name:"triggerTime",errors:d,children:s("triggerTime","\u30C8\u30EA\u30AC\u30FC\u6642\u9593")}),n(U,{label:"\u30C8\u30EA\u30AC\u30FC\u30AA\u30D5\u30BB\u30C3\u30C8",name:"triggerOffset",errors:d,title:"\u767A\u706B\u30BF\u30A4\u30DF\u30F3\u30B0\u3092\xB1\u305A\u3089\u3057\u307E\u3059\u3002\u5B9F\u969B\u306E\u767A\u706B\u6642\u523B = \u30C8\u30EA\u30AC\u30FC\u6642\u9593 \xB1 \u3053\u306E\u5024",children:s("triggerOffset","\u30C8\u30EA\u30AC\u30FC\u30AA\u30D5\u30BB\u30C3\u30C8",{signed:!0})}),n(U,{label:"OSC\u30A2\u30C9\u30EC\u30B9",errors:d,top:!0,children:[n("input",{class:"field mono","aria-label":"OSC\u30A2\u30C9\u30EC\u30B9",value:a.oscAddress,onInput:u=>p("oscAddress",u.currentTarget.value)}),d.oscAddress&&n("small",{class:"field-error",children:d.oscAddress}),n("span",{class:"hint",children:"\u8FFD\u52A0\u30A2\u30C9\u30EC\u30B9\uFF081\u884C1\u4EF6\u30FB\u5F15\u6570\u306A\u3057\u3067\u4E00\u7DD2\u306B\u9001\u4FE1\u3055\u308C\u307E\u3059\uFF09"}),n("textarea",{class:"mono","aria-label":"\u8FFD\u52A0\u30A2\u30C9\u30EC\u30B9",value:a.additionalOscAddresses,onInput:u=>p("additionalOscAddresses",u.currentTarget.value)}),d.additionalOscAddresses&&n("small",{class:"field-error",children:d.additionalOscAddresses})]}),n(U,{label:"TC\u79D2\u6570\u9001\u4FE1",errors:d,children:l("sendTriggerTimeAsSeconds","\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9\u3092\u79D2\u6570(float)\u3067\u5148\u982D\u5F15\u6570\u306B\u8FFD\u52A0")}),n(U,{label:"\u9001\u4FE1\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9",name:"sendTimecode",errors:d,title:"\u79D2\u6570\u9001\u4FE1\u3067\u9001\u308B\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9\u3002\u672A\u6307\u5B9A\u306A\u3089\u30C8\u30EA\u30AC\u30FC\u6642\u9593\u3092\u305D\u306E\u307E\u307E\u9001\u308A\u307E\u3059",children:f("sendTimecode","\u9001\u4FE1\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9",a.sendTriggerTimeAsSeconds,a.triggerTime||"00:00:00:00")}),n(U,{label:"\u767A\u706B\u6642\u30DF\u30E5\u30FC\u30C8",errors:d,title:"\u3053\u306E\u30AD\u30E5\u30FC\u306E\u767A\u706B\u3068\u540C\u6642\u306BMUTE\uFF08\u81EA\u52D5\u30AD\u30E5\u30FC\u767A\u706B\u306E\u505C\u6B62\uFF09\u3092\u639B\u3051\u307E\u3059\u3002\u518D\u751F\u4E2D\u306B\u4E0D\u616E\u306ETC\u304C\u98DB\u3093\u3067\u304D\u3066\u3082\u4ED6\u306E\u30AD\u30E5\u30FC\u304C\u8AA4\u767A\u706B\u3057\u307E\u305B\u3093",children:l("autoMuteOnFire","\u767A\u706B\u3068\u540C\u6642\u306B\u81EA\u52D5\u3067\u30DF\u30E5\u30FC\u30C8\u3059\u308B")}),n(U,{label:"\u30DF\u30E5\u30FC\u30C8\u89E3\u9664",name:"autoUnmuteAfter",errors:d,title:"\u6307\u5B9A\u6642\u9593\u306E\u7D4C\u904E\u5F8C\u306BMUTE\u3092\u81EA\u52D5\u89E3\u9664\u3057\u307E\u3059\u3002\u672A\u6307\u5B9A\u306A\u3089\u624B\u52D5\u3067\u89E3\u9664\u3059\u308B\u307E\u3067\u30DF\u30E5\u30FC\u30C8\u3092\u7DAD\u6301\u3057\u307E\u3059",children:f("autoUnmuteAfter","\u30DF\u30E5\u30FC\u30C8\u89E3\u9664\u6642\u9593",a.autoMuteOnFire,"00:00:00:00")}),n(U,{label:"OSC\u5F15\u6570",name:"arguments",errors:d,top:!0,title:"type:value \u3092 1 \u884C 1 \u4EF6\u3002\u4F8B: int32:1 / float32:0.5 / string:GO",children:n("textarea",{class:"mono","aria-label":"OSC\u5F15\u6570",placeholder:`int32:1 +`),targetHostIds:[...e.targetHostIds],enabled:e.enabled,sendTriggerTimeAsSeconds:e.sendTriggerTimeAsSeconds,sendTimecode:e.sendTimecode??"",triggerOffset:e.triggerOffset??"",autoMuteOnFire:e.autoMuteOnFire,autoUnmuteAfter:e.autoUnmuteAfter??""});function te(e){let t=[];for(let[r,o]of e.split(/\r?\n/).entries()){if(!o.trim())continue;let i=o.indexOf(":"),a=o.slice(0,i),u=o.slice(i+1);if(i<0||!["int32","float32","string"].includes(a))return{error:`${r+1} \u884C\u76EE\u306F type:value \u5F62\u5F0F\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044`};if(a==="string")t.push({type:a,value:u});else{let d=Number(u);if(!Number.isFinite(d)||a==="int32"&&!Number.isInteger(d))return{error:`${r+1} \u884C\u76EE\u306E\u5024\u304C\u4E0D\u6B63\u3067\u3059`};t.push(a==="int32"?{type:a,value:d}:{type:"float32",value:d})}}return{value:t}}function me(e){let t={};e.name.trim()||(t.name="\u540D\u524D\u306F\u5FC5\u9808\u3067\u3059");let r=Oe(e.triggerTime);r.ok||(t.triggerTime=r.message);let o=Re(e.oscAddress);o.ok||(t.oscAddress=o.message);let i=e.additionalOscAddresses.split(/\r?\n|,/).map(u=>u.trim()).filter(Boolean);i.some(u=>!Re(u).ok)&&(t.additionalOscAddresses="\u5404\u884C\u306B / \u3067\u59CB\u307E\u308B\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044");let a=te(e.argumentsText);a.error&&(t.arguments=a.error);for(let[u,d,m]of[["sendTimecode",e.sendTimecode,!1],["triggerOffset",e.triggerOffset,!0],["autoUnmuteAfter",e.autoUnmuteAfter,!1]])d&&!Oe(d,m).ok&&(t[u]="\u6642\u523B\u5F62\u5F0F\u304C\u4E0D\u6B63\u3067\u3059");return Object.keys(t).length?{errors:t}:{errors:t,draft:{name:e.name.trim(),memo:e.memo,triggerTime:e.triggerTime,frameRate:e.frameRate,oscAddress:e.oscAddress,additionalOscAddresses:i,arguments:a.value,targetHostIds:e.targetHostIds,enabled:e.enabled,sendTriggerTimeAsSeconds:e.sendTriggerTimeAsSeconds,sendTimecode:e.sendTimecode||null,triggerOffset:e.triggerOffset||null,autoMuteOnFire:e.autoMuteOnFire,autoUnmuteAfter:e.autoUnmuteAfter||null}}}var Ie=(e,t)=>Object.fromEntries(Object.entries(e.fieldErrors??{}).filter(([r])=>r.startsWith(t+".")).map(([r,o])=>[r.slice(t.length+1),o]));var an=0,Kn=Array.isArray;function n(e,t,r,o,i,a){t||(t={});var u,d,m=t;if("ref"in m)for(d in m={},t)d=="ref"?u=t[d]:m[d]=t[d];var p={type:e,props:m,key:r,ref:u,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--an,__i:-1,__u:0,__source:i,__self:a};if(typeof e=="function"&&(u=e.defaultProps))for(d in u)m[d]===void 0&&(m[d]=u[d]);return O.vnode&&O.vnode(p),p}function Tt(e){return e.replace(/[0-9]/g,t=>String.fromCharCode(t.charCodeAt(0)-65248)).replace(/[^0-9]/g,"")}function Me(e,t=!1){let r=t&&e.startsWith("-")?"-":"+",i=(t&&/^[+-]/.test(e)?e.slice(1):e).split(/[:;]/).slice(0,4).map(Tt);return{sign:r,parts:[i[0]??"",i[1]??"",i[2]??"",i[3]??""]}}function fe(e,t="+",r=!1){return e.every(o=>o==="")?"":`${r?t:""}${e.map(o=>o.padStart(2,"0")).join(":")}`}function wt(e,t,r){let o=Tt(r),i=[...e];if(o.length<=2)return i[t]=o,{parts:i,focus:o.length===2&&t<3?t+1:null};for(let a=t,u=0;a<4&&u0?t-1:e==="ArrowRight"&&t<3?t+1:e==="Backspace"&&r&&t>0?t-1:null}var ne=e=>e==="24"?23:e==="25"?24:29;function re(e,t,r=!1){if(e==="")return e;let{sign:o,parts:i}=Me(e,r);return fe(i.map((a,u)=>Ct(a,u,t)),o,r)}function Ct(e,t,r){if(e==="")return e;let o=t===0?23:t===1||t===2?59:ne(r);return String(Math.min(o,Number(e))).padStart(2,"0")}function B({value:e,onChange:t,onCommit:r,frameRate:o,signed:i=!1,required:a=!1,disabled:u=!1,ariaLabel:d,class:m=""}){let p=Me(e,i),[s,l]=C(p.parts),[g,h]=C(p.sign),A=$([]),c=$(null),_=$(p.parts);P(()=>{if(e===c.current){c.current=null;return}let y=Me(e,i);_.current=y.parts,l(y.parts),h(y.sign)},[e,i]);let f=(y,T=g)=>{_.current=y,l(y);let S=fe(y,T,i);c.current=S,t?.(S)},b=y=>{y!==null&&A.current[y]?.focus()},w=y=>{let T=[..._.current];T[y]=Ct(T[y]??"",y,o),f(T),r?.(fe(T,g,i))};return n("span",{class:`timecode-input ${m}`,role:"group","aria-label":d,children:[i&&n("select",{class:"timecode-sign","aria-label":`${d}\u306E\u7B26\u53F7`,disabled:u,value:g,onChange:y=>{let T=y.currentTarget.value;h(T);let S=fe(_.current,T,!0);c.current=S,t?.(S),r?.(S)},children:[n("option",{value:"+",children:"+"}),n("option",{value:"-",children:"\u2212"})]}),s.map((y,T)=>n("span",{class:"timecode-segment",children:[n("input",{ref:S=>{A.current[T]=S},class:"timecode-part",inputMode:"numeric",pattern:"[0-9]*",maxlength:2,required:a,disabled:u,value:y,"aria-label":`${d} ${["\u6642","\u5206","\u79D2","\u30D5\u30EC\u30FC\u30E0"][T]??""}`,onBeforeInput:S=>{let R=S.data;R&&/[^0-9]/.test(R)&&S.preventDefault()},onCompositionStart:S=>{let R=S.currentTarget;R.blur(),window.setTimeout(()=>R.focus(),0)},onInput:S=>{let R=wt(_.current,T,S.currentTarget.value);f(R.parts),b(R.focus)},onPaste:S=>{S.preventDefault();let R=wt(_.current,T,S.clipboardData?.getData("text")??"");f(R.parts),b(R.focus)},onBlur:()=>w(T),onKeyDown:S=>{if(S.key==="ArrowUp"||S.key==="ArrowDown"){S.preventDefault();let V=T===0?23:T===1||T===2?59:ne(o),v=[..._.current],D=Number(v[T]||0);v[T]=String(Math.max(0,Math.min(V,D+(S.key==="ArrowUp"?1:-1)))).padStart(2,"0"),f(v);return}let R=ln(S.key,T,y==="");R!==null&&(S.preventDefault(),b(R))}}),T<3&&n("span",{class:"timecode-colon","aria-hidden":"true",children:":"})]})),n("small",{class:"timecode-limit",children:["FF 00\u2013",String(ne(o)).padStart(2,"0")]})]})}function X(e){return P(()=>{let t=r=>{r.key==="Escape"&&!r.isComposing&&(r.preventDefault(),e.close())};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[e.close]),n("div",{class:"modal-shade",children:n("div",{class:`dialog ${e.wide?"wide":""} ${e.class??""}`,role:"dialog","aria-modal":"true",onKeyDown:t=>t.stopPropagation(),children:[n("div",{class:"dialog-title",children:[n("b",{children:e.title}),e.titleExtra,n("button",{class:"btn",onClick:e.close,children:"\u9589\u3058\u308B"})]}),e.children]})})}var ge=X,cn=({errors:e,name:t})=>n("small",{class:"field-error",children:e[t]??""}),un=["24","25","29.97df","30"],U=({label:e,name:t,errors:r,title:o,top:i,children:a})=>n("div",{class:`cue-row ${i?"top":""}`,children:[n("span",{class:"lbl",title:o,children:e}),n("div",{class:"ctl",children:[a,t&&r[t]&&n("small",{class:"field-error",children:r[t]})]})]});function Pe({cue:e,frameRate:t,hosts:r,close:o,done:i}){let[a,u]=C(()=>e?yt(e):{...ee(t),targetHostIds:r.map(c=>c.id)}),[d,m]=C({}),p=(c,_)=>u(f=>({...f,[c]:_})),s=(c,_,{signed:f=!1,disabled:b=!1}={})=>n(B,{ariaLabel:_,value:a[c],frameRate:a.frameRate,signed:f,disabled:b,required:c==="triggerTime",onChange:w=>p(c,w)}),l=(c,_)=>n("label",{class:"check",children:[n("input",{type:"checkbox",checked:a[c],onChange:f=>p(c,f.currentTarget.checked)}),_]}),g=(c,_,f,b)=>n("div",{class:"check-row",children:[n("label",{class:"check",children:[n("input",{type:"checkbox","aria-label":`${_}\u3092\u6307\u5B9A`,disabled:!f,checked:a[c]!=="",onChange:w=>p(c,w.currentTarget.checked?b:"")}),"\u6307\u5B9A"]}),s(c,_,{disabled:!f||a[c]===""})]}),h=async c=>{c.preventDefault();let _=me(a);if(!_.draft){m(_.errors);return}try{await x(e?"cue.update":"cue.add",e?{id:e.id,cue:_.draft}:{cue:_.draft}),i()}catch(f){m(Ie(f,"cue"))}},A=n("label",{class:"cue-frame-rate",children:[n("span",{children:"\u57FA\u6E96\u30D5\u30EC\u30FC\u30E0\u30EC\u30FC\u30C8"}),n("select",{class:"field",value:a.frameRate,onChange:c=>{let _=c.currentTarget.value;u(f=>({...f,frameRate:_,triggerTime:re(f.triggerTime,_),sendTimecode:re(f.sendTimecode,_),triggerOffset:re(f.triggerOffset,_,!0),autoUnmuteAfter:re(f.autoUnmuteAfter,_)}))},children:un.map(c=>n("option",{value:c,children:[c," fps"]}))}),n("small",{children:["FF 00\u2013",String(ne(a.frameRate)).padStart(2,"0")]})]});return n(ge,{title:e?"\u30AD\u30E5\u30FC\u3092\u7DE8\u96C6":"\u30AD\u30E5\u30FC\u3092\u8FFD\u52A0",close:o,class:"cue",titleExtra:A,children:n("form",{onSubmit:h,class:"cue-edit",children:[n(U,{label:"\u540D\u524D",name:"name",errors:d,children:n("input",{autofocus:!0,class:"field","aria-label":"\u540D\u524D",value:a.name,onInput:c=>p("name",c.currentTarget.value)})}),n(U,{label:"\u30C8\u30EA\u30AC\u30FC\u6642\u9593",name:"triggerTime",errors:d,children:s("triggerTime","\u30C8\u30EA\u30AC\u30FC\u6642\u9593")}),n(U,{label:"\u30C8\u30EA\u30AC\u30FC\u30AA\u30D5\u30BB\u30C3\u30C8",name:"triggerOffset",errors:d,title:"\u767A\u706B\u30BF\u30A4\u30DF\u30F3\u30B0\u3092\xB1\u305A\u3089\u3057\u307E\u3059\u3002\u5B9F\u969B\u306E\u767A\u706B\u6642\u523B = \u30C8\u30EA\u30AC\u30FC\u6642\u9593 \xB1 \u3053\u306E\u5024",children:s("triggerOffset","\u30C8\u30EA\u30AC\u30FC\u30AA\u30D5\u30BB\u30C3\u30C8",{signed:!0})}),n(U,{label:"OSC\u30A2\u30C9\u30EC\u30B9",errors:d,top:!0,children:[n("input",{class:"field mono","aria-label":"OSC\u30A2\u30C9\u30EC\u30B9",value:a.oscAddress,onInput:c=>p("oscAddress",c.currentTarget.value)}),d.oscAddress&&n("small",{class:"field-error",children:d.oscAddress}),n("span",{class:"hint",children:"\u8FFD\u52A0\u30A2\u30C9\u30EC\u30B9\uFF081\u884C1\u4EF6\u30FB\u5F15\u6570\u306A\u3057\u3067\u4E00\u7DD2\u306B\u9001\u4FE1\u3055\u308C\u307E\u3059\uFF09"}),n("textarea",{class:"mono","aria-label":"\u8FFD\u52A0\u30A2\u30C9\u30EC\u30B9",value:a.additionalOscAddresses,onInput:c=>p("additionalOscAddresses",c.currentTarget.value)}),d.additionalOscAddresses&&n("small",{class:"field-error",children:d.additionalOscAddresses})]}),n(U,{label:"TC\u79D2\u6570\u9001\u4FE1",errors:d,children:l("sendTriggerTimeAsSeconds","\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9\u3092\u79D2\u6570(float)\u3067\u5148\u982D\u5F15\u6570\u306B\u8FFD\u52A0")}),n(U,{label:"\u9001\u4FE1\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9",name:"sendTimecode",errors:d,title:"\u79D2\u6570\u9001\u4FE1\u3067\u9001\u308B\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9\u3002\u672A\u6307\u5B9A\u306A\u3089\u30C8\u30EA\u30AC\u30FC\u6642\u9593\u3092\u305D\u306E\u307E\u307E\u9001\u308A\u307E\u3059",children:g("sendTimecode","\u9001\u4FE1\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9",a.sendTriggerTimeAsSeconds,a.triggerTime||"00:00:00:00")}),n(U,{label:"\u767A\u706B\u6642\u30DF\u30E5\u30FC\u30C8",errors:d,title:"\u3053\u306E\u30AD\u30E5\u30FC\u306E\u767A\u706B\u3068\u540C\u6642\u306BMUTE\uFF08\u81EA\u52D5\u30AD\u30E5\u30FC\u767A\u706B\u306E\u505C\u6B62\uFF09\u3092\u639B\u3051\u307E\u3059\u3002\u518D\u751F\u4E2D\u306B\u4E0D\u616E\u306ETC\u304C\u98DB\u3093\u3067\u304D\u3066\u3082\u4ED6\u306E\u30AD\u30E5\u30FC\u304C\u8AA4\u767A\u706B\u3057\u307E\u305B\u3093",children:l("autoMuteOnFire","\u767A\u706B\u3068\u540C\u6642\u306B\u81EA\u52D5\u3067\u30DF\u30E5\u30FC\u30C8\u3059\u308B")}),n(U,{label:"\u30DF\u30E5\u30FC\u30C8\u89E3\u9664",name:"autoUnmuteAfter",errors:d,title:"\u6307\u5B9A\u6642\u9593\u306E\u7D4C\u904E\u5F8C\u306BMUTE\u3092\u81EA\u52D5\u89E3\u9664\u3057\u307E\u3059\u3002\u672A\u6307\u5B9A\u306A\u3089\u624B\u52D5\u3067\u89E3\u9664\u3059\u308B\u307E\u3067\u30DF\u30E5\u30FC\u30C8\u3092\u7DAD\u6301\u3057\u307E\u3059",children:g("autoUnmuteAfter","\u30DF\u30E5\u30FC\u30C8\u89E3\u9664\u6642\u9593",a.autoMuteOnFire,"00:00:00:00")}),n(U,{label:"OSC\u5F15\u6570",name:"arguments",errors:d,top:!0,title:"type:value \u3092 1 \u884C 1 \u4EF6\u3002\u4F8B: int32:1 / float32:0.5 / string:GO",children:n("textarea",{class:"mono","aria-label":"OSC\u5F15\u6570",placeholder:`int32:1 float32:0.5 -string:GO`,value:a.argumentsText,onInput:u=>p("argumentsText",u.currentTarget.value)})}),n(U,{label:"\u9001\u4FE1\u5148\u30DB\u30B9\u30C8",name:"targetHostIds",errors:d,top:!0,children:n("div",{class:"host-pick",children:[n("div",{class:"host-pick-actions",children:[n("button",{type:"button",class:"btn mini",disabled:!r.length,onClick:()=>p("targetHostIds",r.map(u=>u.id)),children:"\u5168\u9078\u629E"}),n("button",{type:"button",class:"btn mini",disabled:!a.targetHostIds.length,onClick:()=>p("targetHostIds",[]),children:"\u5168\u89E3\u9664"})]}),n("div",{class:"host-pick-list",children:r.length?r.map(u=>n("label",{class:"check",children:[n("input",{type:"checkbox",checked:a.targetHostIds.includes(u.id),onChange:_=>p("targetHostIds",_.currentTarget.checked?[...a.targetHostIds,u.id]:a.targetHostIds.filter(m=>m!==u.id))}),n("span",{children:u.name})]})):n("span",{class:"host-pick-empty",children:["\u30DB\u30B9\u30C8\u304C\u672A\u767B\u9332\u3067\u3059\u3002",n("br",{}),"\u5148\u306B\u300C\u30DB\u30B9\u30C8\u7BA1\u7406\u300D\u304B\u3089\u30DB\u30B9\u30C8\u3092\u8FFD\u52A0\u3057\u3066\u304F\u3060\u3055\u3044"]})})]})}),n(U,{label:"\u30E1\u30E2",name:"memo",errors:d,top:!0,children:n("textarea",{"aria-label":"\u30E1\u30E2",value:a.memo,onInput:u=>p("memo",u.currentTarget.value)})}),n(U,{label:"",errors:d,children:l("enabled","\u6709\u52B9")}),n("div",{class:"dialog-actions",children:[n("button",{type:"button",class:"btn",onClick:o,children:"\u30AD\u30E3\u30F3\u30BB\u30EB"}),n("button",{class:"btn primary",children:e?"\u66F4\u65B0":"\u8FFD\u52A0"})]})]})})}function kt({cue:e,close:t,done:r}){let[o,i]=C(2),[a,c]=C("00:00:00:00"),[d,b]=C("");return n(ge,{title:"\u9023\u7D9A\u8907\u88FD",close:t,children:n("form",{class:"simple-form",onSubmit:async p=>{p.preventDefault();try{await O("cue.duplicate",{id:e.id,count:o,interval:a}),r()}catch(s){b(s.message)}},children:[n("label",{children:["\u8907\u88FD\u6570",n("input",{class:"field count",type:"number",min:"1",max:"500",value:o,onInput:p=>i(Number(p.currentTarget.value))})]}),n("div",{class:"simple-row",children:[n("span",{children:"\u9593\u9694"}),n(B,{ariaLabel:"\u8907\u88FD\u306E\u9593\u9694",value:a,frameRate:e.frameRate,onChange:c})]}),n("small",{class:"hint",children:["\u300C",e.name,"\u300D\u306E ",e.effectiveTriggerTime," \u304B\u3089\u9593\u9694\u305A\u3064\u5F8C\u308D\u306B\u4E26\u3079\u307E\u3059"]}),d&&n("small",{class:"field-error",children:d}),n("div",{class:"dialog-actions",children:[n("button",{type:"button",class:"btn",onClick:t,children:"\u30AD\u30E3\u30F3\u30BB\u30EB"}),n("button",{class:"btn primary",children:"\u8907\u88FD"})]})]})})}function St({ids:e,hosts:t,frameRate:r,close:o,done:i,notice:a}){let[c,d]=C(new Set),[b,p]=C({}),[s,l]=C({}),f={oscAddress:"OSC\u30A2\u30C9\u30EC\u30B9",additionalOscAddresses:"\u8FFD\u52A0\u30A2\u30C9\u30EC\u30B9\uFF08\u30AB\u30F3\u30DE\u533A\u5207\u308A\uFF09",sendTriggerTimeAsSeconds:"TC\u79D2\u6570\u9001\u4FE1",sendTimecode:"\u9001\u4FE1\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9",targetHostIds:"\u9001\u4FE1\u5148\u30DB\u30B9\u30C8",arguments:"OSC\u5F15\u6570\uFF08type:value\u30011 \u884C 1 \u4EF6\uFF09",triggerOffset:"\u30C8\u30EA\u30AC\u30FC\u30AA\u30D5\u30BB\u30C3\u30C8",autoMuteOnFire:"\u767A\u706B\u6642\u30DF\u30E5\u30FC\u30C8",autoUnmuteAfter:"\u30DF\u30E5\u30FC\u30C8\u89E3\u9664",memo:"\u30E1\u30E2",enabled:"\u6709\u52B9"},h=["sendTimecode","triggerOffset","autoUnmuteAfter"],A=["enabled","sendTriggerTimeAsSeconds","autoMuteOnFire"];return n(ge,{title:`${e.length} \u4EF6\u3092\u4E00\u62EC\u7DE8\u96C6`,close:o,wide:!0,children:n("form",{class:"batch-form",onSubmit:async u=>{u.preventDefault();let _={};for(let m of c){let g=b[m];if(g===void 0&&(g=A.includes(m)?!1:m==="targetHostIds"?[]:""),m==="arguments"){let w=te(String(g));if(w.error){l({arguments:w.error});return}g=w.value??[]}m==="additionalOscAddresses"&&(g=String(g).split(",").map(w=>w.trim()).filter(Boolean)),h.includes(m)&&g===""&&(g=null),_[m]=g}try{let m=await O("cue.batchUpdate",{ids:e,changes:_});m.offsetSkipped>0&&a(`${m.offsetSkipped} \u4EF6\u306F\u30AA\u30D5\u30BB\u30C3\u30C8\u9069\u7528\u5F8C\u306E\u6642\u523B\u304C\u7BC4\u56F2\u5916\u306E\u305F\u3081\u30AA\u30D5\u30BB\u30C3\u30C8\u3092\u4ED8\u3051\u307E\u305B\u3093\u3067\u3057\u305F`),i()}catch(m){l(Me(m,"changes"))}},children:[Object.entries(f).map(([u,_])=>n("div",{class:"batch-row",children:[n("label",{children:[n("input",{type:"checkbox",checked:c.has(u),onChange:m=>{let g=m.currentTarget.checked;d(w=>{let y=new Set(w);return g?y.add(u):y.delete(u),y})}}),_]}),n("div",{children:[A.includes(u)?n("input",{type:"checkbox",onChange:m=>{let g=m.currentTarget.checked;p(w=>({...w,[u]:g}))}}):u==="targetHostIds"?n("div",{class:"host-pick-list",children:t.map(m=>n("label",{children:[n("input",{type:"checkbox",onChange:g=>{let w=g.currentTarget.checked;p(y=>{let T=y[u]??[];return{...y,[u]:w?[...T,m.id]:T.filter(S=>S!==m.id)}})}}),n("span",{children:m.name})]}))}):h.includes(u)?n(B,{ariaLabel:_,value:String(b[u]??""),frameRate:r,signed:u==="triggerOffset",onChange:m=>p(g=>({...g,[u]:m}))}):u==="arguments"?n("textarea",{class:"mono","aria-label":_,placeholder:`int32:1 +string:GO`,value:a.argumentsText,onInput:c=>p("argumentsText",c.currentTarget.value)})}),n(U,{label:"\u9001\u4FE1\u5148\u30DB\u30B9\u30C8",name:"targetHostIds",errors:d,top:!0,children:n("div",{class:"host-pick",children:[n("div",{class:"host-pick-actions",children:[n("button",{type:"button",class:"btn mini",disabled:!r.length,onClick:()=>p("targetHostIds",r.map(c=>c.id)),children:"\u5168\u9078\u629E"}),n("button",{type:"button",class:"btn mini",disabled:!a.targetHostIds.length,onClick:()=>p("targetHostIds",[]),children:"\u5168\u89E3\u9664"})]}),n("div",{class:"host-pick-list",children:r.length?r.map(c=>n("label",{class:"check",children:[n("input",{type:"checkbox",checked:a.targetHostIds.includes(c.id),onChange:_=>p("targetHostIds",_.currentTarget.checked?[...a.targetHostIds,c.id]:a.targetHostIds.filter(f=>f!==c.id))}),n("span",{children:c.name})]})):n("span",{class:"host-pick-empty",children:["\u30DB\u30B9\u30C8\u304C\u672A\u767B\u9332\u3067\u3059\u3002",n("br",{}),"\u5148\u306B\u300C\u30DB\u30B9\u30C8\u7BA1\u7406\u300D\u304B\u3089\u30DB\u30B9\u30C8\u3092\u8FFD\u52A0\u3057\u3066\u304F\u3060\u3055\u3044"]})})]})}),n(U,{label:"\u30E1\u30E2",name:"memo",errors:d,top:!0,children:n("textarea",{"aria-label":"\u30E1\u30E2",value:a.memo,onInput:c=>p("memo",c.currentTarget.value)})}),n(U,{label:"",errors:d,children:l("enabled","\u6709\u52B9")}),n("div",{class:"dialog-actions",children:[n("button",{type:"button",class:"btn",onClick:o,children:"\u30AD\u30E3\u30F3\u30BB\u30EB"}),n("button",{class:"btn primary",children:e?"\u66F4\u65B0":"\u8FFD\u52A0"})]})]})})}function kt({cue:e,close:t,done:r}){let[o,i]=C(2),[a,u]=C("00:00:00:00"),[d,m]=C("");return n(ge,{title:"\u9023\u7D9A\u8907\u88FD",close:t,children:n("form",{class:"simple-form",onSubmit:async p=>{p.preventDefault();try{await x("cue.duplicate",{id:e.id,count:o,interval:a}),r()}catch(s){m(s.message)}},children:[n("label",{children:["\u8907\u88FD\u6570",n("input",{class:"field count",type:"number",min:"1",max:"500",value:o,onInput:p=>i(Number(p.currentTarget.value))})]}),n("div",{class:"simple-row",children:[n("span",{children:"\u9593\u9694"}),n(B,{ariaLabel:"\u8907\u88FD\u306E\u9593\u9694",value:a,frameRate:e.frameRate,onChange:u})]}),n("small",{class:"hint",children:["\u300C",e.name,"\u300D\u306E ",e.effectiveTriggerTime," \u304B\u3089\u9593\u9694\u305A\u3064\u5F8C\u308D\u306B\u4E26\u3079\u307E\u3059"]}),d&&n("small",{class:"field-error",children:d}),n("div",{class:"dialog-actions",children:[n("button",{type:"button",class:"btn",onClick:t,children:"\u30AD\u30E3\u30F3\u30BB\u30EB"}),n("button",{class:"btn primary",children:"\u8907\u88FD"})]})]})})}function St({ids:e,hosts:t,frameRate:r,close:o,done:i,notice:a}){let[u,d]=C(new Set),[m,p]=C({}),[s,l]=C({}),g={oscAddress:"OSC\u30A2\u30C9\u30EC\u30B9",additionalOscAddresses:"\u8FFD\u52A0\u30A2\u30C9\u30EC\u30B9\uFF08\u30AB\u30F3\u30DE\u533A\u5207\u308A\uFF09",sendTriggerTimeAsSeconds:"TC\u79D2\u6570\u9001\u4FE1",sendTimecode:"\u9001\u4FE1\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9",targetHostIds:"\u9001\u4FE1\u5148\u30DB\u30B9\u30C8",arguments:"OSC\u5F15\u6570\uFF08type:value\u30011 \u884C 1 \u4EF6\uFF09",triggerOffset:"\u30C8\u30EA\u30AC\u30FC\u30AA\u30D5\u30BB\u30C3\u30C8",autoMuteOnFire:"\u767A\u706B\u6642\u30DF\u30E5\u30FC\u30C8",autoUnmuteAfter:"\u30DF\u30E5\u30FC\u30C8\u89E3\u9664",memo:"\u30E1\u30E2",enabled:"\u6709\u52B9"},h=["sendTimecode","triggerOffset","autoUnmuteAfter"],A=["enabled","sendTriggerTimeAsSeconds","autoMuteOnFire"];return n(ge,{title:`${e.length} \u4EF6\u3092\u4E00\u62EC\u7DE8\u96C6`,close:o,wide:!0,children:n("form",{class:"batch-form",onSubmit:async c=>{c.preventDefault();let _={};for(let f of u){let b=m[f];if(b===void 0&&(b=A.includes(f)?!1:f==="targetHostIds"?[]:""),f==="arguments"){let w=te(String(b));if(w.error){l({arguments:w.error});return}b=w.value??[]}f==="additionalOscAddresses"&&(b=String(b).split(",").map(w=>w.trim()).filter(Boolean)),h.includes(f)&&b===""&&(b=null),_[f]=b}try{let f=await x("cue.batchUpdate",{ids:e,changes:_});f.offsetSkipped>0&&a(`${f.offsetSkipped} \u4EF6\u306F\u30AA\u30D5\u30BB\u30C3\u30C8\u9069\u7528\u5F8C\u306E\u6642\u523B\u304C\u7BC4\u56F2\u5916\u306E\u305F\u3081\u30AA\u30D5\u30BB\u30C3\u30C8\u3092\u4ED8\u3051\u307E\u305B\u3093\u3067\u3057\u305F`),i()}catch(f){l(Ie(f,"changes"))}},children:[Object.entries(g).map(([c,_])=>n("div",{class:"batch-row",children:[n("label",{children:[n("input",{type:"checkbox",checked:u.has(c),onChange:f=>{let b=f.currentTarget.checked;d(w=>{let y=new Set(w);return b?y.add(c):y.delete(c),y})}}),_]}),n("div",{children:[A.includes(c)?n("input",{type:"checkbox",onChange:f=>{let b=f.currentTarget.checked;p(w=>({...w,[c]:b}))}}):c==="targetHostIds"?n("div",{class:"host-pick-list",children:t.map(f=>n("label",{children:[n("input",{type:"checkbox",onChange:b=>{let w=b.currentTarget.checked;p(y=>{let T=y[c]??[];return{...y,[c]:w?[...T,f.id]:T.filter(S=>S!==f.id)}})}}),n("span",{children:f.name})]}))}):h.includes(c)?n(B,{ariaLabel:_,value:String(m[c]??""),frameRate:r,signed:c==="triggerOffset",onChange:f=>p(b=>({...b,[c]:f}))}):c==="arguments"?n("textarea",{class:"mono","aria-label":_,placeholder:`int32:1 float32:0.5 -string:GO`,value:String(b[u]??""),onInput:m=>{let g=m.currentTarget.value;p(w=>({...w,[u]:g}))}}):n("input",{class:"field",value:String(b[u]??""),onInput:m=>{let g=m.currentTarget.value;p(w=>({...w,[u]:g}))}}),n(cn,{errors:s,name:u})]})]})),n("div",{class:"dialog-actions",children:[n("button",{type:"button",class:"btn",onClick:o,children:"\u30AD\u30E3\u30F3\u30BB\u30EB"}),n("button",{class:"btn primary",disabled:!c.size,children:"\u9069\u7528"})]})]})})}function J({message:e,close:t,confirm:r,confirmLabel:o="\u524A\u9664"}){return n(ge,{title:"\u78BA\u8A8D",close:t,children:[n("div",{class:"confirm-body",children:e}),n("div",{class:"dialog-actions",children:[n("button",{class:"btn",onClick:t,children:"\u30AD\u30E3\u30F3\u30BB\u30EB"}),n("button",{class:"btn danger",onClick:r,children:o})]})]})}function At({close:e,notice:t}){let r=k.value.host.state.transport;P(()=>k.updateUi({modalOpen:!0}),[]);let o=(i,a)=>void O(i,{enabled:a}).catch(c=>t(c.message));return n(X,{title:"\u30AA\u30D7\u30B7\u30E7\u30F3",close:e,children:n("div",{class:"options",children:[n("h3",{children:"\u30AA\u30FC\u30C8\u30DF\u30E5\u30FC\u30C8"}),n("label",{class:"check options-row",children:[n("input",{type:"checkbox",checked:r.autoMuteEnabled,onChange:i=>o("autoMute.setEnabled",i.currentTarget.checked)}),n("span",{children:[n("b",{children:"\u767A\u706B\u5F8C\u30AA\u30FC\u30C8\u30DF\u30E5\u30FC\u30C8\u3092\u4F7F\u3046"}),n("small",{children:"\u5207\u308B\u3068\u3001\u30AD\u30E5\u30FC\u3054\u3068\u306E\u300C\u767A\u706B\u6642\u30DF\u30E5\u30FC\u30C8\u300D\u3082\u50CD\u304D\u307E\u305B\u3093\u3002\u30AD\u30E5\u30FC\u30EA\u30B9\u30C8\u306E\u30C4\u30FC\u30EB\u30D0\u30FC\u304B\u3089\u3082\u5207\u308A\u66FF\u3048\u3089\u308C\u307E\u3059"})]})]}),n("label",{class:"check options-row",children:[n("input",{type:"checkbox",checked:r.autoMuteOnManualTrigger,onChange:i=>o("autoMute.setOnManualTrigger",i.currentTarget.checked)}),n("span",{children:[n("b",{children:"\u624B\u52D5\u3067\u53E9\u3044\u305F\u3068\u304D\u3082\u30DF\u30E5\u30FC\u30C8\u3059\u308B"}),n("small",{children:"\u884C\u306E \u25B6 \u3067\u767A\u706B\u3057\u305F\u3068\u304D\u306E\u52D5\u4F5C\u3067\u3059\u3002\u5207\u3063\u3066\u3042\u308B\u3068\u3001\u9032\u884C\u306E\u78BA\u8A8D\u3084\u5DEE\u3057\u8FBC\u307F\u3067\u53E9\u3044\u3066\u3082\u30DF\u30E5\u30FC\u30C8\u3055\u308C\u305A\u3001\u5F8C\u7D9A\u306E\u81EA\u52D5\u767A\u706B\u304C\u6B62\u307E\u308A\u307E\u305B\u3093"})]})]}),n("div",{class:"dialog-actions",children:n("button",{type:"button",class:"btn primary",onClick:e,children:"\u9589\u3058\u308B"})})]})})}var be=(e,t={})=>void O(e,t),dn=e=>be("receive.selectDevice",{deviceId:e||null});function pn(e,t,r=Date.now()){if(e!=="signalLost"&&e!=="freerun")return null;if(!t)return"\u6700\u7D42\u53D7\u4FE1\u306A\u3057";let o=Date.parse(t);return Number.isFinite(o)?`\u6700\u7D42\u53D7\u4FE1 ${Math.max(0,Math.floor((r-o)/1e3))} \u79D2\u524D`:"\u6700\u7D42\u53D7\u4FE1\u306A\u3057"}function Et(){let e=k.value.host.state,t=e.receive.selectedDeviceId,[r,o]=C(Date.now()),i=e.transport.status==="signalLost"||e.transport.status==="freerun";P(()=>{if(!i)return;o(Date.now());let c=window.setInterval(()=>o(Date.now()),1e3);return()=>window.clearInterval(c)},[i,e.transport.lastLtcReceivedAtUtc]);let a=pn(e.transport.status,e.transport.lastLtcReceivedAtUtc,r);return n("div",{class:"sec",children:[n("div",{class:"head",children:[n("b",{children:"TC \u5165\u51FA\u529B"}),n("span",{class:"tiny",children:"LTC \u53D7\u4FE1\u8A2D\u5B9A"})]}),n("div",{class:"status",children:[n("span",{children:[n("i",{class:"led"}),"\u5165\u529B ",n("b",{children:e.transport.locked?"\u63A5\u7D9A":"\u672A\u63A5\u7D9A"})]}),n("span",{children:[n("i",{class:"led"}),"LTC ",n("b",{children:e.transport.statusText}),a&&n("span",{class:"tiny muted",children:[" ",a]}),e.transport.signalErrorRatePercent!=null&&n("span",{class:"tiny muted",children:[" \u8AA4\u308A\u7387 ",e.transport.signalErrorRatePercent.toFixed(1),"%"]})]}),n("span",{children:["\u25CB \u51FA\u529B ",n("b",{children:"\u505C\u6B62"})]}),n("span",{children:[n("i",{class:"led"}),"\u9001\u51FA ",n("b",{children:e.transport.triggerMuted?"MUTE":"LIVE"})]})]}),n("div",{class:"settings",children:[n("div",{class:"set",children:[n("span",{class:"tiny",children:"\u5165\u529B\u30C7\u30D0\u30A4\u30B9"}),n("select",{class:"field","aria-label":"\u5165\u529B\u30C7\u30D0\u30A4\u30B9",value:t??"",onChange:c=>dn(c.currentTarget.value),children:[n("option",{value:"",children:"\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),e.receive.devices.map(c=>n("option",{value:c.id,children:c.name}))]}),n("button",{class:"btn",onClick:()=>be("audio.refreshDevices",{direction:"capture"}),children:"\u518D\u30B9\u30AD\u30E3\u30F3"})]}),n("div",{class:"set",children:[n("span",{class:"tiny",children:"\u63A5\u7D9A"}),n("span",{class:`field status-field ${t?"":"device-required"}`,children:t?e.transport.detailText:"\u5165\u529B\u30C7\u30D0\u30A4\u30B9\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044"}),n("button",{class:"btn",disabled:!t,onClick:()=>be("ltc.reconnect",{deviceId:t}),children:"\u518D\u63A5\u7D9A"})]}),n("div",{class:"set",children:[n("span",{class:"tiny",children:"\u30D5\u30EA\u30FC\u30E9\u30F3"}),n("input",{class:"field","aria-label":"\u30D5\u30EA\u30FC\u30E9\u30F3\uFF08\u79D2\uFF09",type:"number",min:"0",step:"0.1",value:e.receive.freerunDurationSeconds,onChange:c=>be("receive.setFreerunDuration",{seconds:Number(c.currentTarget.value)})}),n("span",{class:"tiny unit",children:"\u79D2"})]})]}),n(mn,{})]})}function mn(){let e=k.value.host.wave;if(!e)return n("div",{class:"wave",children:n("span",{class:"tiny",children:"\u6CE2\u5F62\u5F85\u6A5F\u4E2D"})});let t=Math.min(e.min.length,e.max.length),r=[];for(let o=0;o=0;o--)r.push(`${o/Math.max(1,t-1)*360},${15-(e.min[o]??0)*14}`);return n("div",{class:"wave",children:n("svg",{viewBox:"0 0 360 30",preserveAspectRatio:"none",children:n("polygon",{points:r.join(" ")})})})}var fn=e=>e==="24"?24:e==="25"?25:30;function Dt(e,t,r=10){let o=e.split(":").map(p=>Number(p));if(o.length!==4||o.some(p=>!Number.isFinite(p)))return e;let i=fn(t),a=((o[0]*60+o[1])*60+o[2])*i+o[3]+r*i,c=24*3600*i-1,d=Math.min(a,c),b=p=>String(p).padStart(2,"0");return[b(Math.floor(d/(3600*i))),b(Math.floor(d/(60*i))%60),b(Math.floor(d/i)%60),b(d%i)].join(":")}function Ot({notice:e}){let t=k.value.host.state.generator,r=()=>({startTime:t.startTime,loopEndTime:t.loopEndTime,frameRate:t.frameRate,outputDeviceId:t.selectedOutputDeviceId??"",volume:t.volume}),[o,i]=C(r),a=$(null);P(()=>i(r()),[t.startTime,t.loopEndTime,t.frameRate,t.selectedOutputDeviceId,t.volume]);let c=s=>void O("generator.configure",s).catch(l=>e(l.message)),d=(s,l)=>{let f={...o,[s]:l};i(f),c(f)},b=s=>d("loopEndTime",s?o.loopEndTime??Dt(o.startTime,o.frameRate):null),p=(s,l=!1)=>{let f={...o,volume:s};i(f),a.current!==null&&window.clearTimeout(a.current),l?c(f):a.current=window.setTimeout(()=>c(f),100)};return n("div",{class:"sec",children:[n("div",{class:"head",children:[n("b",{children:"TC \u5165\u51FA\u529B"}),n("span",{class:"tiny",children:"\u5185\u90E8\u751F\u6210\u8A2D\u5B9A"})]}),n("div",{class:"status",children:[n("span",{children:["\u25CB \u5165\u529B ",n("b",{children:"\u505C\u6B62"})]}),n("span",{children:[n("i",{class:"led"}),"\u751F\u6210 ",n("b",{children:t.running?"\u518D\u751F\u4E2D":"\u505C\u6B62"})]}),n("span",{children:[n("i",{class:"led"}),"\u51FA\u529B ",n("b",{children:t.ltcOutputActive?"\u9001\u51FA\u4E2D":"\u505C\u6B62"})]}),n("span",{children:["\u97F3\u91CF ",n("b",{children:[Math.round(o.volume*100),"%"]})]})]}),n("div",{class:"settings generator-settings",children:[n("label",{class:"wide-control",children:[n("span",{class:"tiny",children:"\u958B\u59CB TC"}),n(B,{value:o.startTime,frameRate:o.frameRate,ariaLabel:"\u958B\u59CB\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9",required:!0,onChange:s=>d("startTime",s)})]}),n("label",{class:"wide-control",children:[n("span",{class:"tiny",children:"\u30EB\u30FC\u30D7"}),n("span",{class:"loop-toggle",children:[n("input",{type:"checkbox",checked:o.loopEndTime!==null,onChange:s=>b(s.currentTarget.checked)}),n("span",{children:"\u958B\u59CB TC \u304B\u3089\u4E0B\u306E\u6642\u523B\u307E\u3067\u3092\u7E70\u308A\u8FD4\u3059"})]})]}),o.loopEndTime!==null&&n("label",{class:"wide-control",children:[n("span",{class:"tiny",children:"\u7D42\u4E86 TC"}),n(B,{value:o.loopEndTime,frameRate:o.frameRate,ariaLabel:"\u30EB\u30FC\u30D7\u7D42\u4E86\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9",required:!0,onChange:s=>d("loopEndTime",s)})]}),n("label",{children:[n("span",{class:"tiny",children:"FPS"}),n("select",{class:"field",value:o.frameRate,onChange:s=>d("frameRate",s.currentTarget.value),children:["24","25","29.97df","30"].map(s=>n("option",{value:s,children:s}))})]}),n("label",{class:"wide-control",children:[n("span",{class:"tiny",children:"\u51FA\u529B\u30C7\u30D0\u30A4\u30B9"}),n("select",{class:"field",value:o.outputDeviceId,onChange:s=>d("outputDeviceId",s.currentTarget.value),children:[n("option",{value:"",children:"\u306A\u3057\uFF08\u51FA\u529B\u3057\u306A\u3044\uFF09"}),t.outputDevices.map(s=>n("option",{value:s.id,children:s.name}))]})]}),n("label",{class:"wide-control volume-control",children:[n("span",{class:"tiny",children:"\u97F3\u91CF"}),n("input",{type:"range",min:"0",max:"1",step:"0.01",value:o.volume,onInput:s=>p(Number(s.currentTarget.value)),onPointerUp:s=>p(Number(s.currentTarget.value),!0)})]})]}),t.running&&t.settingsPendingReset&&n("small",{class:"pending-note",children:"\u8A2D\u5B9A\u306F\u518D\u751F\u3057\u76F4\u3059\u3068\u53CD\u6620\u3055\u308C\u307E\u3059"}),n("div",{class:"generator-actions",children:[n("button",{class:`btn transport-toggle ${t.running?"danger":""}`,onClick:()=>void O(t.running?"generator.stop":"generator.start",{}).catch(s=>e(s.message)),children:t.running?"\u25A0 \u505C\u6B62":"\u25B6 \u518D\u751F"}),n("button",{class:"btn",onClick:()=>void O("generator.reset",{}).catch(s=>e(s.message)),children:"\u30EA\u30BB\u30C3\u30C8"})]})]})}function gn(e){let t={};e.name.trim()||(t.name="\u540D\u524D\u306F\u5FC5\u9808\u3067\u3059"),e.ipAddress.trim()||(t.ipAddress="IP \u30A2\u30C9\u30EC\u30B9\u306F\u5FC5\u9808\u3067\u3059");let r=Number(e.port);return(!Number.isInteger(r)||r<1||r>65535)&&(t.port="1\u301C65535 \u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"),t}var bn=e=>Object.fromEntries(Object.entries(e.fieldErrors??{}).filter(([t])=>t.startsWith("host.")).map(([t,r])=>[t.slice(5),r]));function vn({host:e,close:t}){let[r,o]=C({name:e?.name??"",ipAddress:e?.ipAddress??"",port:String(e?.port??53e3)}),[i,a]=C({});P(()=>k.updateUi({modalOpen:!0}),[]);let c=(d,b)=>n("label",{class:"form-field",children:[n("span",{children:b}),n("input",{autofocus:d==="name",class:"field",value:r[d],onInput:p=>{let s=p.currentTarget.value;o(l=>({...l,[d]:s}))}}),n("small",{class:"field-error",children:i[d]??""})]});return n(X,{title:e?"\u30DB\u30B9\u30C8\u3092\u7DE8\u96C6":"\u30DB\u30B9\u30C8\u3092\u8FFD\u52A0",close:t,children:n("form",{class:"simple-form host-form",onSubmit:async d=>{d.preventDefault();let b=gn(r);if(Object.keys(b).length){a(b);return}try{let p={name:r.name.trim(),ipAddress:r.ipAddress.trim(),port:Number(r.port),enabled:e?.enabled??!0};await O(e?"host.update":"host.add",e?{id:e.id,host:p}:{host:p}),t()}catch(p){a(bn(p))}},children:[c("name","\u540D\u524D"),c("ipAddress","IP \u30A2\u30C9\u30EC\u30B9"),c("port","\u30DD\u30FC\u30C8"),n("div",{class:"dialog-actions",children:[n("button",{type:"button",class:"btn",onClick:t,children:"\u30AD\u30E3\u30F3\u30BB\u30EB"}),n("button",{class:"btn primary",children:e?"\u66F4\u65B0":"\u8FFD\u52A0"})]})]})})}function _n(e,t,r){let o=t.filter(c=>c.targetHostIds.includes(e.id)).length,i=r.filter(c=>c.targetHostIds.includes(e.id)).length,a=[o?`\u30AD\u30E5\u30FC ${o} \u4EF6`:"",i?`\u30DD\u30F3\u51FA\u3057 ${i} \u4EF6`:""].filter(Boolean).join("\u3068");return a?`\u300C${e.name}\u300D\u3092\u524A\u9664\u3057\u307E\u3059\u304B\uFF1F ${a}\u304C\u9001\u4FE1\u5148\u306B\u3057\u3066\u3044\u307E\u3059\u3002\u524A\u9664\u3059\u308B\u3068\u305D\u308C\u3089\u306F\u9001\u4FE1\u5148\u3092\u5931\u3044\u307E\u3059`:`\u300C${e.name}\u300D\u3092\u524A\u9664\u3057\u307E\u3059\u304B\uFF1F`}function xt({notice:e}){let t=k.value.host.state,[r,o]=C(null),[i,a]=C(null),c=()=>{o(null),a(null),k.updateUi({modalOpen:!1})},d=(b,p)=>void O(b,p).then(s=>{if(b==="host.ping"){let l=s??{};e(l.reachable===void 0?"\u758E\u901A\u78BA\u8A8D\u3092\u9001\u4FE1\u3057\u307E\u3057\u305F":l.reachable?`\u758E\u901A OK \xB7 ${l.latencyMs??"--"} ms`:"\u758E\u901A\u3067\u304D\u307E\u305B\u3093")}}).catch(s=>e(s.message));return n(H,{children:[n("div",{class:"panel-toolbar",children:[n("b",{children:"\u9001\u4FE1\u5148\u30DB\u30B9\u30C8"}),n("button",{class:"btn right",onClick:()=>o("new"),children:"\uFF0B \u8FFD\u52A0"})]}),n("div",{class:"host-list",children:t.hosts.map(b=>n("div",{class:`host-row ${b.enabled?"":"disabled"}`,children:[n("span",{class:`reach ${b.reachability}`}),n("b",{class:"host-name",children:b.name}),n("span",{class:"mono host-address",children:[b.ipAddress,":",b.port]}),n("div",{class:"host-actions",children:[n("label",{children:[n("input",{type:"checkbox",checked:b.enabled,onChange:p=>d("host.setEnabled",{id:b.id,enabled:p.currentTarget.checked})}),"\u6709\u52B9"]}),n("button",{class:"btn",onClick:()=>d("host.ping",{id:b.id}),children:"\u758E\u901A\u78BA\u8A8D"}),n("button",{class:"btn",onClick:()=>o(b),children:"\u7DE8\u96C6"}),n("button",{class:"btn danger-link",onClick:()=>{a(b),k.updateUi({modalOpen:!0})},children:"\u524A\u9664"})]})]}))}),r&&n(vn,{host:r==="new"?void 0:r,close:c})," ",i&&n(J,{message:_n(i,t.cues,t.triggerPanel.buttons),close:c,confirm:()=>{d("host.remove",{id:i.id}),c()}})]})}var hn=e=>[...e].sort((t,r)=>Date.parse(r.timestampUtc)-Date.parse(t.timestampUtc));function Rt(){let[e,t]=C(!1),r=hn(k.value.host.state.logs),o=e?r.filter(c=>!c.success):r,i=$(null),a=$(!0);return pt(()=>{let c=i.current;c&&a.current&&(c.scrollTop=0)},[o.length]),n(H,{children:[n("div",{class:"panel-toolbar",children:[n("b",{children:"\u9001\u4FE1\u30ED\u30B0"}),n("span",{class:"tiny",children:"\u65B0\u3057\u3044\u9806"}),n("label",{class:"check tiny log-filter",children:[n("input",{type:"checkbox",checked:e,onChange:c=>t(c.currentTarget.checked)}),"\u5931\u6557\u306E\u307F"]}),n("button",{class:"btn right",onClick:()=>void O("logs.clear",{}),children:"\u30AF\u30EA\u30A2"})]}),n("div",{class:"dock log-dock",ref:i,onScroll:c=>{a.current=c.currentTarget.scrollTop<4},children:o.length?o.map(c=>n("div",{class:c.success?"log-success":"failure",children:[n("time",{children:new Date(c.timestampUtc).toLocaleTimeString("ja-JP")}),n("span",{children:c.message})]})):n("div",{class:"muted",children:e&&r.length?"\u5931\u6557\u3057\u305F\u9001\u4FE1\u306F\u3042\u308A\u307E\u305B\u3093":"\u9001\u4FE1\u30ED\u30B0\u306F\u3042\u308A\u307E\u305B\u3093"})})]})}function It({notice:e}){let t=k.value.host.state,[r,o]=C("logs");return n(H,{children:[n("div",{class:"sec",children:[n("div",{class:"head",children:[n("b",{children:"Cue-Sync \u9001\u4FE1\u8A2D\u5B9A"}),n("span",{class:"tiny mono",children:t.cueSync.oscAddress})]}),n("div",{class:"set",children:[n("span",{class:"tiny",children:"OSC\u30A2\u30C9\u30EC\u30B9"}),n("input",{class:"field mono","aria-label":"Cue-Sync OSC\u30A2\u30C9\u30EC\u30B9",value:t.cueSync.oscAddress,onChange:i=>void O("cueSync.configure",{oscAddress:i.currentTarget.value,targetHostIds:t.cueSync.targetHostIds})}),n("button",{class:"btn",onClick:()=>void O("cueSync.send",{}),children:"\u5358\u767A\u9001\u4FE1"})]}),n("div",{class:"hosts",children:[t.hosts.map(i=>n("label",{children:[n("input",{type:"checkbox",checked:t.cueSync.targetHostIds.includes(i.id),onChange:a=>void O("cueSync.configure",{oscAddress:t.cueSync.oscAddress,targetHostIds:a.currentTarget.checked?[...t.cueSync.targetHostIds,i.id]:t.cueSync.targetHostIds.filter(c=>c!==i.id)})}),n("span",{children:i.name})]})),n("span",{class:"tiny",children:[t.cueSync.targetHostIds.length," / ",t.hosts.length," \u6709\u52B9"]})]})]}),n("div",{class:"tab-panel",children:[n("div",{class:"tabs",children:[n("button",{class:`tab ${r==="logs"?"on":""}`,onClick:()=>o("logs"),children:"\u9001\u4FE1\u30ED\u30B0"}),n("button",{class:`tab ${r==="hosts"?"on":""}`,onClick:()=>o("hosts"),children:"\u30DB\u30B9\u30C8\u7BA1\u7406"})]}),r==="logs"?n(Rt,{}):n(xt,{notice:e})]})]})}function Mt(e,t){let r=[];for(let o of t){let i=o.runtime.flashToken,a=e.get(o.id);e.set(o.id,i),a!==void 0&&i>a&&r.push(o.id)}return r}function yn({cell:e,close:t,notice:r}){let o=e.button,[i,a]=C(o?.label??""),[c,d]=C(o?.oscAddress??"/"),[b,p]=C(o?.arguments.map(u=>`${u.type}:${u.value}`).join(` -`)??""),[s,l]=C(o?.targetHostIds??[]),[f,h]=C({}),A=k.value.host.state;return P(()=>k.updateUi({modalOpen:!0}),[]),n(X,{title:o?"\u30DD\u30F3\u51FA\u3057\u30DC\u30BF\u30F3\u3092\u7DE8\u96C6":"\u30DD\u30F3\u51FA\u3057\u30DC\u30BF\u30F3\u3092\u4F5C\u6210",close:t,children:n("form",{class:"cue-form",onSubmit:async u=>{u.preventDefault();let _={};i.trim()||(_.label="\u30E9\u30D9\u30EB\u306F\u5FC5\u9808\u3067\u3059"),c.startsWith("/")||(_.oscAddress="/ \u3067\u59CB\u3081\u3066\u304F\u3060\u3055\u3044");let m=te(b);if(m.error&&(_.arguments=m.error),Object.keys(_).length){h(_);return}try{await O("triggerPanel.upsertButton",{button:{...o?{id:o.id}:{},row:e.row,column:e.column,label:i.trim(),oscAddress:c,arguments:m.value??[],targetHostIds:s}}),t()}catch(g){r(g.message)}},children:[n("label",{class:"form-field",children:[n("span",{children:"\u30E9\u30D9\u30EB"}),n("input",{autofocus:!0,class:"field",value:i,onInput:u=>a(u.currentTarget.value)}),n("small",{class:"field-error",children:f.label})]}),n("label",{class:"form-field",children:[n("span",{children:"OSC\u30A2\u30C9\u30EC\u30B9"}),n("input",{class:"field mono",value:c,onInput:u=>d(u.currentTarget.value)}),n("small",{class:"field-error",children:f.oscAddress})]}),n("label",{class:"form-field",children:[n("span",{children:"OSC\u5F15\u6570\uFF08type:value\u30011 \u884C 1 \u4EF6\uFF09"}),n("textarea",{class:"mono",value:b,onInput:u=>p(u.currentTarget.value),placeholder:`int32:1 +string:GO`,value:String(m[c]??""),onInput:f=>{let b=f.currentTarget.value;p(w=>({...w,[c]:b}))}}):n("input",{class:"field",value:String(m[c]??""),onInput:f=>{let b=f.currentTarget.value;p(w=>({...w,[c]:b}))}}),n(cn,{errors:s,name:c})]})]})),n("div",{class:"dialog-actions",children:[n("button",{type:"button",class:"btn",onClick:o,children:"\u30AD\u30E3\u30F3\u30BB\u30EB"}),n("button",{class:"btn primary",disabled:!u.size,children:"\u9069\u7528"})]})]})})}function J({message:e,close:t,confirm:r,confirmLabel:o="\u524A\u9664"}){return n(ge,{title:"\u78BA\u8A8D",close:t,children:[n("div",{class:"confirm-body",children:e}),n("div",{class:"dialog-actions",children:[n("button",{class:"btn",onClick:t,children:"\u30AD\u30E3\u30F3\u30BB\u30EB"}),n("button",{class:"btn danger",onClick:r,children:o})]})]})}function At({close:e,notice:t}){let r=k.value.host.state.transport;P(()=>k.updateUi({modalOpen:!0}),[]);let o=(i,a)=>void x(i,{enabled:a}).catch(u=>t(u.message));return n(X,{title:"\u30AA\u30D7\u30B7\u30E7\u30F3",close:e,children:n("div",{class:"options",children:[n("h3",{children:"\u30AA\u30FC\u30C8\u30DF\u30E5\u30FC\u30C8"}),n("label",{class:"check options-row",children:[n("input",{type:"checkbox",checked:r.autoMuteEnabled,onChange:i=>o("autoMute.setEnabled",i.currentTarget.checked)}),n("span",{children:[n("b",{children:"\u767A\u706B\u5F8C\u30AA\u30FC\u30C8\u30DF\u30E5\u30FC\u30C8\u3092\u4F7F\u3046"}),n("small",{children:"\u5207\u308B\u3068\u3001\u30AD\u30E5\u30FC\u3054\u3068\u306E\u300C\u767A\u706B\u6642\u30DF\u30E5\u30FC\u30C8\u300D\u3082\u50CD\u304D\u307E\u305B\u3093\u3002\u30AD\u30E5\u30FC\u30EA\u30B9\u30C8\u306E\u30C4\u30FC\u30EB\u30D0\u30FC\u304B\u3089\u3082\u5207\u308A\u66FF\u3048\u3089\u308C\u307E\u3059"})]})]}),n("label",{class:"check options-row",children:[n("input",{type:"checkbox",checked:r.autoMuteOnManualTrigger,onChange:i=>o("autoMute.setOnManualTrigger",i.currentTarget.checked)}),n("span",{children:[n("b",{children:"\u624B\u52D5\u3067\u53E9\u3044\u305F\u3068\u304D\u3082\u30DF\u30E5\u30FC\u30C8\u3059\u308B"}),n("small",{children:"\u884C\u306E \u25B6 \u3067\u767A\u706B\u3057\u305F\u3068\u304D\u306E\u52D5\u4F5C\u3067\u3059\u3002\u5207\u3063\u3066\u3042\u308B\u3068\u3001\u9032\u884C\u306E\u78BA\u8A8D\u3084\u5DEE\u3057\u8FBC\u307F\u3067\u53E9\u3044\u3066\u3082\u30DF\u30E5\u30FC\u30C8\u3055\u308C\u305A\u3001\u5F8C\u7D9A\u306E\u81EA\u52D5\u767A\u706B\u304C\u6B62\u307E\u308A\u307E\u305B\u3093"})]})]}),n("div",{class:"dialog-actions",children:n("button",{type:"button",class:"btn primary",onClick:e,children:"\u9589\u3058\u308B"})})]})})}var He=(e,t={})=>void x(e,t),dn=e=>He("receive.selectDevice",{deviceId:e||null});async function pn(e){e(!0);try{await x("audio.refreshDevices",{direction:"capture"})}catch{}finally{e(!1)}}function mn(e,t,r=Date.now()){if(e!=="signalLost"&&e!=="freerun")return null;if(!t)return"\u6700\u7D42\u53D7\u4FE1\u306A\u3057";let o=Date.parse(t);return Number.isFinite(o)?`\u6700\u7D42\u53D7\u4FE1 ${Math.max(0,Math.floor((r-o)/1e3))} \u79D2\u524D`:"\u6700\u7D42\u53D7\u4FE1\u306A\u3057"}function Et(){let e=k.value.host.state,t=e.receive.selectedDeviceId,[r,o]=C(Date.now()),[i,a]=C(!1),u=e.transport.status==="signalLost"||e.transport.status==="freerun";P(()=>{if(!u)return;o(Date.now());let m=window.setInterval(()=>o(Date.now()),1e3);return()=>window.clearInterval(m)},[u,e.transport.lastLtcReceivedAtUtc]);let d=mn(e.transport.status,e.transport.lastLtcReceivedAtUtc,r);return n("div",{class:"sec",children:[n("div",{class:"head",children:[n("b",{children:"TC \u5165\u51FA\u529B"}),n("span",{class:"tiny",children:"LTC \u53D7\u4FE1\u8A2D\u5B9A"})]}),n("div",{class:"status",children:[n("span",{children:[n("i",{class:"led"}),"\u5165\u529B ",n("b",{children:e.transport.locked?"\u63A5\u7D9A":"\u672A\u63A5\u7D9A"})]}),n("span",{children:[n("i",{class:"led"}),"LTC ",n("b",{children:e.transport.statusText}),d&&n("span",{class:"tiny muted",children:[" ",d]}),e.transport.signalErrorRatePercent!=null&&n("span",{class:"tiny muted",children:[" \u8AA4\u308A\u7387 ",e.transport.signalErrorRatePercent.toFixed(1),"%"]})]}),n("span",{children:["\u25CB \u51FA\u529B ",n("b",{children:"\u505C\u6B62"})]}),n("span",{children:[n("i",{class:"led"}),"\u9001\u51FA ",n("b",{children:e.transport.triggerMuted?"MUTE":"LIVE"})]})]}),n("div",{class:"settings",children:[n("div",{class:"set device-set",children:[n("span",{class:"tiny",children:"\u5165\u529B\u30C7\u30D0\u30A4\u30B9"}),n("select",{class:"field","aria-label":"\u5165\u529B\u30C7\u30D0\u30A4\u30B9",value:t??"",onChange:m=>dn(m.currentTarget.value),children:[n("option",{value:"",children:"\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),e.receive.devices.map(m=>n("option",{value:m.id,children:m.name}))]}),n(fn,{scanning:i,onClick:()=>void pn(a)})]}),n("div",{class:"set",children:[n("span",{class:"tiny",children:"\u63A5\u7D9A"}),n("span",{class:`field status-field ${t?"":"device-required"}`,children:t?e.transport.detailText:"\u5165\u529B\u30C7\u30D0\u30A4\u30B9\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044"}),n("button",{class:"btn",disabled:!t,onClick:()=>He("ltc.reconnect",{deviceId:t}),children:"\u518D\u63A5\u7D9A"})]}),n("div",{class:"set",children:[n("span",{class:"tiny",children:"\u30D5\u30EA\u30FC\u30E9\u30F3"}),n("input",{class:"field","aria-label":"\u30D5\u30EA\u30FC\u30E9\u30F3\uFF08\u79D2\uFF09",type:"number",min:"0",step:"0.1",value:e.receive.freerunDurationSeconds,onChange:m=>He("receive.setFreerunDuration",{seconds:Number(m.currentTarget.value)})}),n("span",{class:"tiny unit",children:"\u79D2"})]})]}),n(gn,{})]})}function fn({scanning:e,onClick:t}){return n(H,{children:[n("button",{class:"btn rescan",disabled:e,"aria-busy":e,onClick:t,children:e?"\u30B9\u30AD\u30E3\u30F3\u4E2D\u2026":"\u518D\u30B9\u30AD\u30E3\u30F3"}),e&&n("div",{class:"scan-progress",role:"progressbar","aria-label":"\u30C7\u30D0\u30A4\u30B9\u3092\u30B9\u30AD\u30E3\u30F3\u4E2D",children:n("i",{})})]})}function gn(){let e=k.value.host.wave;if(!e)return n("div",{class:"wave",children:n("span",{class:"tiny",children:"\u6CE2\u5F62\u5F85\u6A5F\u4E2D"})});let t=Math.min(e.min.length,e.max.length),r=[];for(let o=0;o=0;o--)r.push(`${o/Math.max(1,t-1)*360},${15-(e.min[o]??0)*14}`);return n("div",{class:"wave",children:n("svg",{viewBox:"0 0 360 30",preserveAspectRatio:"none",children:n("polygon",{points:r.join(" ")})})})}var bn=e=>e==="24"?24:e==="25"?25:30;function Dt(e,t,r=10){let o=e.split(":").map(p=>Number(p));if(o.length!==4||o.some(p=>!Number.isFinite(p)))return e;let i=bn(t),a=((o[0]*60+o[1])*60+o[2])*i+o[3]+r*i,u=24*3600*i-1,d=Math.min(a,u),m=p=>String(p).padStart(2,"0");return[m(Math.floor(d/(3600*i))),m(Math.floor(d/(60*i))%60),m(Math.floor(d/i)%60),m(d%i)].join(":")}function xt({notice:e}){let t=k.value.host.state.generator,r=()=>({startTime:t.startTime,loopEndTime:t.loopEndTime,frameRate:t.frameRate,outputDeviceId:t.selectedOutputDeviceId??"",volume:t.volume}),[o,i]=C(r),a=$(null);P(()=>i(r()),[t.startTime,t.loopEndTime,t.frameRate,t.selectedOutputDeviceId,t.volume]);let u=s=>void x("generator.configure",s).catch(l=>e(l.message)),d=(s,l)=>{let g={...o,[s]:l};i(g),u(g)},m=s=>d("loopEndTime",s?o.loopEndTime??Dt(o.startTime,o.frameRate):null),p=(s,l=!1)=>{let g={...o,volume:s};i(g),a.current!==null&&window.clearTimeout(a.current),l?u(g):a.current=window.setTimeout(()=>u(g),100)};return n("div",{class:"sec",children:[n("div",{class:"head",children:[n("b",{children:"TC \u5165\u51FA\u529B"}),n("span",{class:"tiny",children:"\u5185\u90E8\u751F\u6210\u8A2D\u5B9A"})]}),n("div",{class:"status",children:[n("span",{children:["\u25CB \u5165\u529B ",n("b",{children:"\u505C\u6B62"})]}),n("span",{children:[n("i",{class:"led"}),"\u751F\u6210 ",n("b",{children:t.running?"\u518D\u751F\u4E2D":"\u505C\u6B62"})]}),n("span",{children:[n("i",{class:"led"}),"\u51FA\u529B ",n("b",{children:t.ltcOutputActive?"\u9001\u51FA\u4E2D":"\u505C\u6B62"})]}),n("span",{children:["\u97F3\u91CF ",n("b",{children:[Math.round(o.volume*100),"%"]})]})]}),n("div",{class:"settings generator-settings",children:[n("label",{class:"wide-control",children:[n("span",{class:"tiny",children:"\u958B\u59CB TC"}),n(B,{value:o.startTime,frameRate:o.frameRate,ariaLabel:"\u958B\u59CB\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9",required:!0,onChange:s=>d("startTime",s)})]}),n("label",{class:"wide-control",children:[n("span",{class:"tiny",children:"\u30EB\u30FC\u30D7"}),n("span",{class:"loop-toggle",children:[n("input",{type:"checkbox",checked:o.loopEndTime!==null,onChange:s=>m(s.currentTarget.checked)}),n("span",{children:"\u958B\u59CB TC \u304B\u3089\u4E0B\u306E\u6642\u523B\u307E\u3067\u3092\u7E70\u308A\u8FD4\u3059"})]})]}),o.loopEndTime!==null&&n("label",{class:"wide-control",children:[n("span",{class:"tiny",children:"\u7D42\u4E86 TC"}),n(B,{value:o.loopEndTime,frameRate:o.frameRate,ariaLabel:"\u30EB\u30FC\u30D7\u7D42\u4E86\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9",required:!0,onChange:s=>d("loopEndTime",s)})]}),n("label",{children:[n("span",{class:"tiny",children:"FPS"}),n("select",{class:"field",value:o.frameRate,onChange:s=>d("frameRate",s.currentTarget.value),children:["24","25","29.97df","30"].map(s=>n("option",{value:s,children:s}))})]}),n("label",{class:"wide-control",children:[n("span",{class:"tiny",children:"\u51FA\u529B\u30C7\u30D0\u30A4\u30B9"}),n("select",{class:"field",value:o.outputDeviceId,onChange:s=>d("outputDeviceId",s.currentTarget.value),children:[n("option",{value:"",children:"\u306A\u3057\uFF08\u51FA\u529B\u3057\u306A\u3044\uFF09"}),t.outputDevices.map(s=>n("option",{value:s.id,children:s.name}))]})]}),n("label",{class:"wide-control volume-control",children:[n("span",{class:"tiny",children:"\u97F3\u91CF"}),n("input",{type:"range",min:"0",max:"1",step:"0.01",value:o.volume,onInput:s=>p(Number(s.currentTarget.value)),onPointerUp:s=>p(Number(s.currentTarget.value),!0)})]})]}),t.running&&t.settingsPendingReset&&n("small",{class:"pending-note",children:"\u8A2D\u5B9A\u306F\u518D\u751F\u3057\u76F4\u3059\u3068\u53CD\u6620\u3055\u308C\u307E\u3059"}),n("div",{class:"generator-actions",children:[n("button",{class:`btn transport-toggle ${t.running?"danger":""}`,onClick:()=>void x(t.running?"generator.stop":"generator.start",{}).catch(s=>e(s.message)),children:t.running?"\u25A0 \u505C\u6B62":"\u25B6 \u518D\u751F"}),n("button",{class:"btn",onClick:()=>void x("generator.reset",{}).catch(s=>e(s.message)),children:"\u30EA\u30BB\u30C3\u30C8"})]})]})}function vn(e){let t={};e.name.trim()||(t.name="\u540D\u524D\u306F\u5FC5\u9808\u3067\u3059"),e.ipAddress.trim()||(t.ipAddress="IP \u30A2\u30C9\u30EC\u30B9\u306F\u5FC5\u9808\u3067\u3059");let r=Number(e.port);return(!Number.isInteger(r)||r<1||r>65535)&&(t.port="1\u301C65535 \u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"),t}var _n=e=>Object.fromEntries(Object.entries(e.fieldErrors??{}).filter(([t])=>t.startsWith("host.")).map(([t,r])=>[t.slice(5),r]));function hn({host:e,close:t}){let[r,o]=C({name:e?.name??"",ipAddress:e?.ipAddress??"",port:String(e?.port??53e3)}),[i,a]=C({});P(()=>k.updateUi({modalOpen:!0}),[]);let u=(d,m)=>n("label",{class:"form-field",children:[n("span",{children:m}),n("input",{autofocus:d==="name",class:"field",value:r[d],onInput:p=>{let s=p.currentTarget.value;o(l=>({...l,[d]:s}))}}),n("small",{class:"field-error",children:i[d]??""})]});return n(X,{title:e?"\u30DB\u30B9\u30C8\u3092\u7DE8\u96C6":"\u30DB\u30B9\u30C8\u3092\u8FFD\u52A0",close:t,children:n("form",{class:"simple-form host-form",onSubmit:async d=>{d.preventDefault();let m=vn(r);if(Object.keys(m).length){a(m);return}try{let p={name:r.name.trim(),ipAddress:r.ipAddress.trim(),port:Number(r.port),enabled:e?.enabled??!0};await x(e?"host.update":"host.add",e?{id:e.id,host:p}:{host:p}),t()}catch(p){a(_n(p))}},children:[u("name","\u540D\u524D"),u("ipAddress","IP \u30A2\u30C9\u30EC\u30B9"),u("port","\u30DD\u30FC\u30C8"),n("div",{class:"dialog-actions",children:[n("button",{type:"button",class:"btn",onClick:t,children:"\u30AD\u30E3\u30F3\u30BB\u30EB"}),n("button",{class:"btn primary",children:e?"\u66F4\u65B0":"\u8FFD\u52A0"})]})]})})}function yn(e,t,r){let o=t.filter(u=>u.targetHostIds.includes(e.id)).length,i=r.filter(u=>u.targetHostIds.includes(e.id)).length,a=[o?`\u30AD\u30E5\u30FC ${o} \u4EF6`:"",i?`\u30DD\u30F3\u51FA\u3057 ${i} \u4EF6`:""].filter(Boolean).join("\u3068");return a?`\u300C${e.name}\u300D\u3092\u524A\u9664\u3057\u307E\u3059\u304B\uFF1F ${a}\u304C\u9001\u4FE1\u5148\u306B\u3057\u3066\u3044\u307E\u3059\u3002\u524A\u9664\u3059\u308B\u3068\u305D\u308C\u3089\u306F\u9001\u4FE1\u5148\u3092\u5931\u3044\u307E\u3059`:`\u300C${e.name}\u300D\u3092\u524A\u9664\u3057\u307E\u3059\u304B\uFF1F`}function Ot({notice:e}){let t=k.value.host.state,[r,o]=C(null),[i,a]=C(null),u=()=>{o(null),a(null),k.updateUi({modalOpen:!1})},d=(m,p)=>void x(m,p).then(s=>{if(m==="host.ping"){let l=s??{};e(l.reachable===void 0?"\u758E\u901A\u78BA\u8A8D\u3092\u9001\u4FE1\u3057\u307E\u3057\u305F":l.reachable?`\u758E\u901A OK \xB7 ${l.latencyMs??"--"} ms`:"\u758E\u901A\u3067\u304D\u307E\u305B\u3093")}}).catch(s=>e(s.message));return n(H,{children:[n("div",{class:"panel-toolbar",children:[n("b",{children:"\u9001\u4FE1\u5148\u30DB\u30B9\u30C8"}),n("button",{class:"btn right",onClick:()=>o("new"),children:"\uFF0B \u8FFD\u52A0"})]}),n("div",{class:"host-list",children:t.hosts.map(m=>n("div",{class:`host-row ${m.enabled?"":"disabled"}`,children:[n("span",{class:`reach ${m.reachability}`}),n("b",{class:"host-name",children:m.name}),n("span",{class:"mono host-address",children:[m.ipAddress,":",m.port]}),n("div",{class:"host-actions",children:[n("label",{children:[n("input",{type:"checkbox",checked:m.enabled,onChange:p=>d("host.setEnabled",{id:m.id,enabled:p.currentTarget.checked})}),"\u6709\u52B9"]}),n("button",{class:"btn",onClick:()=>d("host.ping",{id:m.id}),children:"\u758E\u901A\u78BA\u8A8D"}),n("button",{class:"btn",onClick:()=>o(m),children:"\u7DE8\u96C6"}),n("button",{class:"btn danger-link",onClick:()=>{a(m),k.updateUi({modalOpen:!0})},children:"\u524A\u9664"})]})]}))}),r&&n(hn,{host:r==="new"?void 0:r,close:u})," ",i&&n(J,{message:yn(i,t.cues,t.triggerPanel.buttons),close:u,confirm:()=>{d("host.remove",{id:i.id}),u()}})]})}var wn=e=>[...e].sort((t,r)=>Date.parse(r.timestampUtc)-Date.parse(t.timestampUtc));function Rt(){let[e,t]=C(!1),r=wn(k.value.host.state.logs),o=e?r.filter(u=>!u.success):r,i=$(null),a=$(!0);return pt(()=>{let u=i.current;u&&a.current&&(u.scrollTop=0)},[o.length]),n(H,{children:[n("div",{class:"panel-toolbar",children:[n("b",{children:"\u9001\u4FE1\u30ED\u30B0"}),n("span",{class:"tiny",children:"\u65B0\u3057\u3044\u9806"}),n("label",{class:"check tiny log-filter",children:[n("input",{type:"checkbox",checked:e,onChange:u=>t(u.currentTarget.checked)}),"\u5931\u6557\u306E\u307F"]}),n("button",{class:"btn right",onClick:()=>void x("logs.clear",{}),children:"\u30AF\u30EA\u30A2"})]}),n("div",{class:"dock log-dock",ref:i,onScroll:u=>{a.current=u.currentTarget.scrollTop<4},children:o.length?o.map(u=>n("div",{class:u.success?"log-success":"failure",children:[n("time",{children:new Date(u.timestampUtc).toLocaleTimeString("ja-JP")}),n("span",{children:u.message})]})):n("div",{class:"muted",children:e&&r.length?"\u5931\u6557\u3057\u305F\u9001\u4FE1\u306F\u3042\u308A\u307E\u305B\u3093":"\u9001\u4FE1\u30ED\u30B0\u306F\u3042\u308A\u307E\u305B\u3093"})})]})}function It({notice:e}){let t=k.value.host.state,[r,o]=C("logs");return n(H,{children:[n("div",{class:"sec",children:[n("div",{class:"head",children:[n("b",{children:"Cue-Sync \u9001\u4FE1\u8A2D\u5B9A"}),n("span",{class:"tiny mono",children:t.cueSync.oscAddress})]}),n("div",{class:"set",children:[n("span",{class:"tiny",children:"OSC\u30A2\u30C9\u30EC\u30B9"}),n("input",{class:"field mono","aria-label":"Cue-Sync OSC\u30A2\u30C9\u30EC\u30B9",value:t.cueSync.oscAddress,onChange:i=>void x("cueSync.configure",{oscAddress:i.currentTarget.value,targetHostIds:t.cueSync.targetHostIds})}),n("button",{class:"btn",onClick:()=>void x("cueSync.send",{}),children:"\u5358\u767A\u9001\u4FE1"})]}),n("div",{class:"hosts",children:[t.hosts.map(i=>n("label",{children:[n("input",{type:"checkbox",checked:t.cueSync.targetHostIds.includes(i.id),onChange:a=>void x("cueSync.configure",{oscAddress:t.cueSync.oscAddress,targetHostIds:a.currentTarget.checked?[...t.cueSync.targetHostIds,i.id]:t.cueSync.targetHostIds.filter(u=>u!==i.id)})}),n("span",{children:i.name})]})),n("span",{class:"tiny",children:[t.cueSync.targetHostIds.length," / ",t.hosts.length," \u6709\u52B9"]})]})]}),n("div",{class:"tab-panel",children:[n("div",{class:"tabs",children:[n("button",{class:`tab ${r==="logs"?"on":""}`,onClick:()=>o("logs"),children:"\u9001\u4FE1\u30ED\u30B0"}),n("button",{class:`tab ${r==="hosts"?"on":""}`,onClick:()=>o("hosts"),children:"\u30DB\u30B9\u30C8\u7BA1\u7406"})]}),r==="logs"?n(Rt,{}):n(Ot,{notice:e})]})]})}function Mt(e,t){let r=[];for(let o of t){let i=o.runtime.flashToken,a=e.get(o.id);e.set(o.id,i),a!==void 0&&i>a&&r.push(o.id)}return r}function Tn({cell:e,close:t,notice:r}){let o=e.button,[i,a]=C(o?.label??""),[u,d]=C(o?.oscAddress??"/"),[m,p]=C(o?.arguments.map(c=>`${c.type}:${c.value}`).join(` +`)??""),[s,l]=C(o?.targetHostIds??[]),[g,h]=C({}),A=k.value.host.state;return P(()=>k.updateUi({modalOpen:!0}),[]),n(X,{title:o?"\u30DD\u30F3\u51FA\u3057\u30DC\u30BF\u30F3\u3092\u7DE8\u96C6":"\u30DD\u30F3\u51FA\u3057\u30DC\u30BF\u30F3\u3092\u4F5C\u6210",close:t,children:n("form",{class:"cue-form",onSubmit:async c=>{c.preventDefault();let _={};i.trim()||(_.label="\u30E9\u30D9\u30EB\u306F\u5FC5\u9808\u3067\u3059"),u.startsWith("/")||(_.oscAddress="/ \u3067\u59CB\u3081\u3066\u304F\u3060\u3055\u3044");let f=te(m);if(f.error&&(_.arguments=f.error),Object.keys(_).length){h(_);return}try{await x("triggerPanel.upsertButton",{button:{...o?{id:o.id}:{},row:e.row,column:e.column,label:i.trim(),oscAddress:u,arguments:f.value??[],targetHostIds:s}}),t()}catch(b){r(b.message)}},children:[n("label",{class:"form-field",children:[n("span",{children:"\u30E9\u30D9\u30EB"}),n("input",{autofocus:!0,class:"field",value:i,onInput:c=>a(c.currentTarget.value)}),n("small",{class:"field-error",children:g.label})]}),n("label",{class:"form-field",children:[n("span",{children:"OSC\u30A2\u30C9\u30EC\u30B9"}),n("input",{class:"field mono",value:u,onInput:c=>d(c.currentTarget.value)}),n("small",{class:"field-error",children:g.oscAddress})]}),n("label",{class:"form-field",children:[n("span",{children:"OSC\u5F15\u6570\uFF08type:value\u30011 \u884C 1 \u4EF6\uFF09"}),n("textarea",{class:"mono",value:m,onInput:c=>p(c.currentTarget.value),placeholder:`int32:1 float32:0.5 -string:GO`}),n("small",{class:"field-error",children:f.arguments})]}),n("fieldset",{children:[n("legend",{children:"\u9001\u4FE1\u5148\u30DB\u30B9\u30C8"}),A.hosts.map(u=>n("label",{children:[n("input",{type:"checkbox",checked:s.includes(u.id),onChange:_=>l(_.currentTarget.checked?[...s,u.id]:s.filter(m=>m!==u.id))}),n("span",{children:u.name})]}))]}),n("div",{class:"dialog-actions",children:[n("button",{type:"button",class:"btn",onClick:t,children:"\u30AD\u30E3\u30F3\u30BB\u30EB"}),n("button",{class:"btn primary",children:"\u4FDD\u5B58"})]})]})})}function Pt({notice:e}){let t=k.value.host.state,r=k.value.ui,[o,i]=C(!1),[a,c]=C(null),[d,b]=C(null),[p,s]=C(null),[l,f]=C({}),h=(g,w)=>{let y=t.triggerPanel.buttons.filter(T=>T.row>=g||T.column>=w).length;if(y>0){s({rows:g,columns:w,lost:y}),k.updateUi({modalOpen:!0});return}O("triggerPanel.configureGrid",{rows:g,columns:w})},A=()=>{c(null),s(null),b(null),k.updateUi({modalOpen:!1})},u=async g=>{try{let w=await O("triggerPanel.fire",{id:g.id});f(y=>({...y,[g.id]:w.sent===!1?w.reason??"\u9001\u4FE1\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F":"\u9001\u4FE1\u3057\u307E\u3057\u305F"}))}catch(w){f(y=>({...y,[g.id]:w.message}))}},_=Array.from({length:t.triggerPanel.rows*t.triggerPanel.columns},(g,w)=>{let y=Math.floor(w/t.triggerPanel.columns),T=w%t.triggerPanel.columns;return{row:y,column:T,button:t.triggerPanel.buttons.find(S=>S.row===y&&S.column===T)}}),m=g=>{let w=g.clientX,y=r.drawerWidth;g.currentTarget.setPointerCapture(g.pointerId);let T=R=>k.updateUi({drawerWidth:Math.min(900,Math.max(280,y-(R.clientX-w)))}),S=()=>{window.removeEventListener("pointermove",T),window.removeEventListener("pointerup",S)};window.addEventListener("pointermove",T),window.addEventListener("pointerup",S)};return n("section",{class:`osc-panel ${r.drawerOpen?"open":""}`,"aria-hidden":!r.drawerOpen,children:[n("i",{class:"osc-resize",onPointerDown:m,title:"\u30C9\u30E9\u30C3\u30B0\u3067\u5E45\u3092\u5909\u3048\u3089\u308C\u307E\u3059"}),n("div",{class:"dh",children:[n("h2",{children:"OSC \u30DD\u30F3\u51FA\u3057"}),n("button",{class:"btn close","aria-label":"OSC \u30DD\u30F3\u51FA\u3057\u3092\u9589\u3058\u308B",title:"\u9589\u3058\u308B\uFF08Esc\uFF09",onClick:()=>k.updateUi({drawerOpen:!1}),children:"\u2715"}),n("div",{class:"dh-row",children:[n("button",{class:`btn ${o?"":"primary"}`,onClick:()=>i(!1),children:"\u5B9F\u884C\u30E2\u30FC\u30C9"}),n("button",{class:`btn ${o?"primary":""}`,onClick:()=>i(!0),children:"\u7DE8\u96C6\u30E2\u30FC\u30C9"}),o&&n(H,{children:[n("label",{class:"grid-size",children:["\u884C ",n("input",{class:"field",type:"number",min:"1",max:"12",value:t.triggerPanel.rows,onChange:g=>h(Number(g.currentTarget.value),t.triggerPanel.columns)})]}),n("label",{class:"grid-size",children:["\u5217 ",n("input",{class:"field",type:"number",min:"1",max:"12",value:t.triggerPanel.columns,onChange:g=>h(t.triggerPanel.rows,Number(g.currentTarget.value))})]})]}),n("span",{class:"muted",children:[t.triggerPanel.rows," \u884C \xD7 ",t.triggerPanel.columns," \u5217"]})]})]}),n("div",{class:`grid ${o?"editing":""}`,style:{gridTemplateColumns:`repeat(${t.triggerPanel.columns},1fr)`,gridTemplateRows:`repeat(${t.triggerPanel.rows},1fr)`},children:_.map(g=>g.button?n("div",{class:"trigger-cell",children:[n("button",{class:"trig",onClick:()=>o?c(g):void u(g.button),children:g.button.label}),l[g.button.id]&&n("small",{class:l[g.button.id]==="\u9001\u4FE1\u3057\u307E\u3057\u305F"?"":"failure",children:l[g.button.id]}),o&&n("button",{class:"cell-remove","aria-label":`${g.button.label}\u3092\u524A\u9664`,onClick:()=>{b(g.button),k.updateUi({modalOpen:!0})},children:"\xD7"})]}):n("button",{class:"empty-cell","aria-label":`${g.row+1}\u884C${g.column+1}\u5217\u306B\u30DC\u30BF\u30F3\u3092\u4F5C\u6210`,disabled:!o,onClick:()=>c(g),children:o?"\uFF0B":""}))}),a&&n(yn,{cell:a,close:A,notice:e})," ",d&&n(J,{message:`\u300C${d.label}\u300D\u3092\u524A\u9664\u3057\u307E\u3059\u304B\uFF1F`,close:A,confirm:()=>{O("triggerPanel.removeButton",{id:d.id}),A()}}),p&&n(J,{message:`${p.rows} \u884C \xD7 ${p.columns} \u5217\u306B\u7E2E\u5C0F\u3059\u308B\u3068\u3001\u7BC4\u56F2\u5916\u306E\u30DC\u30BF\u30F3 ${p.lost} \u500B\u304C\u6D88\u3048\u307E\u3059\u3002\u7D9A\u3051\u307E\u3059\u304B\uFF1F`,confirmLabel:"\u7E2E\u5C0F",close:A,confirm:()=>{O("triggerPanel.configureGrid",{rows:p.rows,columns:p.columns}),A()}})]})}var Ft=e=>e.hosts.filter(t=>t.enabled&&e.cueSync.targetHostIds.includes(t.id)).length;function wn(e,t){e?.sentCount===0&&t("\u9001\u4FE1\u5148\u30DB\u30B9\u30C8\u304C\u3042\u308A\u307E\u305B\u3093")}function Tn(e,t,r){if(Ft(e)===0){t("Cue-Sync \u306E\u9001\u4FE1\u5148\u30DB\u30B9\u30C8\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044");return}O("cueSync.send",{}).then(()=>r()).catch(o=>t(o.message))}var Cn=new Map,Y=new Map,kn=e=>e.split(/[\\/]/).pop()||e,Sn=e=>e==null||!Number.isFinite(e)?"-- dBFS":`${e>=0?"":"\u2212"}${Math.abs(e).toFixed(1)} dBFS`,Ht=0;function An({current:e,frameRate:t,apply:r}){let[o,i]=C(e),[a,c]=C(e);a!==e&&(c(e),i(e));let d=o!==e,b=$({draft:o,current:e});return b.current={draft:o,current:e},n("span",{class:"offset-editor",children:[n(B,{class:"monitor-offset",value:o,frameRate:t,signed:!0,ariaLabel:"\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9\u30AA\u30D5\u30BB\u30C3\u30C8",onChange:i}),n("button",{class:`btn mini ${d?"primary":""}`,disabled:!d,onClick:()=>{let{draft:s,current:l}=b.current;s!==l&&r(s)},children:"\u78BA\u5B9A"}),d&&n("span",{class:"tiny offset-pending",children:"\u672A\u78BA\u5B9A"})]})}function Ut(){let[,e]=C(0),[t,r]=C(null),[o,i]=C(!1),[a,c]=C(""),[d,b]=C(0),p=k.value,s=p.host.state,l=p.host.clock??s?.currentClock;P(()=>k.subscribe(()=>{for(let v of Mt(Cn,k.value.host.state?.cues??[])){let D=(Y.get(v)??0)+1;Y.set(v,D),window.setTimeout(()=>{Y.get(v)===D&&(Y.delete(v),e(E=>E+1))},700)}e(v=>v+1)}),[]),P(()=>k.updateUi({modalOpen:t!==null}),[t]),P(()=>{if(!a)return;let v=window.setTimeout(()=>c(""),4e3);return()=>window.clearTimeout(v)},[a]),P(()=>{let v=()=>Q({protocolVersion:1,type:"viewport",waveformWidth:360,devicePixelRatio:window.devicePixelRatio,visible:document.visibilityState==="visible"});return v(),window.addEventListener("resize",v),document.addEventListener("visibilitychange",v),()=>{window.removeEventListener("resize",v),document.removeEventListener("visibilitychange",v)}},[]);let f=()=>s?.cues.filter(v=>p.ui.selectedCueIds.has(v.id))??[],h=()=>{f().length&&r(f().length===1?"edit":"batch")},A=()=>{f().length&&r("remove")},u=(v,D={})=>void O(v,D).catch(E=>c(E.message)),_=()=>b(v=>v+1),m=()=>{s&&Tn(s,c,_)},g=v=>void O("mode.set",{mode:v}).then(D=>{v==="ltc"&&D?.ltcStarted===!1&&c("\u5165\u529B\u30C7\u30D0\u30A4\u30B9\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044")}).catch(D=>c(D.message));if(P(()=>{let v=D=>{let E=_t(D,p.ui.modalOpen);if(E)if(D.preventDefault(),E==="closeDrawer")k.updateUi({drawerOpen:!1});else if(E==="editCue")h();else if(E==="deleteCue")A();else if(E==="selectPrevious"||E==="selectNext"){if(!s)return;let F=Math.max(0,s.cues.findIndex(j=>j.id===p.ui.focusedCueId)),L=s.cues[Math.max(0,Math.min(s.cues.length-1,F+(E==="selectNext"?1:-1)))];L&&k.updateUi({focusedCueId:L.id,selectedCueIds:new Set([L.id])})}else u({projectNew:"project.new",projectOpen:"project.open",projectSave:"project.save",projectSaveAs:"project.saveAs",undo:"app.undo",redo:"app.redo"}[E])};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)}),!s||!l)return n("main",{class:"app loading",children:"HOST \u306B\u63A5\u7D9A\u3057\u3066\u3044\u307E\u3059\u2026"});let w=(v,D)=>{let E=new Set(p.ui.selectedCueIds);if(D.metaKey||D.ctrlKey)E.has(v)?E.delete(v):E.add(v);else if(D.shiftKey&&p.ui.anchorCueId){let F=s.cues.findIndex(j=>j.id===p.ui.anchorCueId),L=s.cues.findIndex(j=>j.id===v);E=new Set(s.cues.slice(Math.min(F,L),Math.max(F,L)+1).map(j=>j.id))}else E=new Set([v]);k.updateUi({selectedCueIds:E,focusedCueId:v,anchorCueId:v})},y=v=>{i(!1),u(v)},T=()=>r(null),S=(v,D)=>{let E=D.clientX,F=[...p.ui.cueColumnWidths];D.currentTarget.setPointerCapture(D.pointerId);let L=Bt=>{let je=Bt.clientX-E,Vt=Math.max(38,(F[v]??38)+je),Kt=Math.max(50,(F[v+1]??50)-je),ve=[...F];ve[v]=Vt,ve[v+1]=Kt,k.updateUi({cueColumnWidths:ve})},j=()=>{window.removeEventListener("pointermove",L),window.removeEventListener("pointerup",j)};window.addEventListener("pointermove",L),window.addEventListener("pointerup",j)},R=s.transport.triggerMuted?ft(s.transport.autoUnmuteAtUtc,Date.now()):"",V={"--cue-cols":p.ui.cueColumnWidths.map(v=>`${v}px`).join(" ")};return n(H,{children:[n("div",{class:`split ${p.ui.drawerOpen?"osc-open":""}`,style:{"--osc-width":`${p.ui.drawerWidth}px`},children:[n("main",{class:"app",children:[n("header",{children:[n("b",{children:"TIMEcode BRIDGE 3"}),n("button",{class:"project-button",onClick:()=>i(!o),children:[s.project.displayName,"\u3000\u25CF ",s.project.dirty?"\u672A\u4FDD\u5B58":"\u4FDD\u5B58\u6E08\u307F"]}),o&&n("div",{class:"project-menu",children:[n("button",{onClick:()=>y("project.new"),children:"\u65B0\u898F"}),n("button",{onClick:()=>y("project.open"),children:"\u958B\u304F\u2026"}),n("button",{onClick:()=>y("project.save"),children:"\u4FDD\u5B58"}),n("button",{onClick:()=>y("project.saveAs"),children:"\u540D\u524D\u3092\u4ED8\u3051\u3066\u4FDD\u5B58\u2026"}),s.project.recentFiles.length>0&&n(H,{children:[n("div",{class:"project-menu-sep",children:"\u6700\u8FD1\u4F7F\u3063\u305F\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8"}),s.project.recentFiles.map(v=>n("button",{class:"recent",title:v,onClick:()=>{i(!1),u("project.open",{path:v})},children:kn(v)}))]})]}),n("button",{class:"btn","aria-label":"\u53D6\u308A\u6D88\u3059",disabled:!s.project.canUndo,onClick:()=>u("app.undo"),children:"\u21B6"}),n("button",{class:"btn","aria-label":"\u3084\u308A\u76F4\u3059",disabled:!s.project.canRedo,onClick:()=>u("app.redo"),children:"\u21B7"}),n("span",{class:"right muted",children:[n("i",{class:"led"}),"ENGINE ONLINE\u3000 ",l.frameRate," FPS / ",l.dropFrame?"DROP":"NON-DROP"]})]}),n("section",{class:"monitor",children:[n("div",{children:[n("span",{class:"tiny",children:[n("i",{class:"led"}),"\u53D7\u4FE1\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9 / OFFSET\u9069\u7528\u5F8C"]}),n("div",{class:"tc",children:l.display}),n("span",{class:"tiny monitor-offset-line",children:["RAW\u3000",n("span",{class:"mono",children:l.raw}),"\u3000 OFFSET\u3000",n(An,{current:s.receive.offset,frameRate:l.frameRate,apply:v=>u("receive.setOffset",{value:v})}),"\u3000 ",s.transport.locked?"LOCK":"UNLOCK"," / ",Sn(p.host.wave?.levelDbfs)]})]}),n("div",{class:"next",children:[n("span",{class:"tiny",children:["NEXT CUE ",n("b",{class:"right",children:["T\u2212 ",s.nextCue?l.framesUntilNextCue??"--":"--","f"]})]}),n("div",{class:"next-main",children:[n("strong",{children:s.nextCue?.effectiveTriggerTime??"--:--:--:--"}),n("b",{children:s.nextCue?.name??"\u6B21\u306E\u30AD\u30E5\u30FC\u306F\u3042\u308A\u307E\u305B\u3093"})]}),n("span",{class:"tiny mono",children:s.nextCue?s.cues.find(v=>v.id===s.nextCue?.id)?.oscAddress:"\u2014"})]}),n("div",{class:"majorbox",children:[n("button",{class:`major ${d===0?"":d%2?"flash-a":"flash-b"}`,onClick:m,children:["CUE SYNC",n("small",{children:[Ft(s),"\u30DB\u30B9\u30C8\u3078\u9001\u4FE1"]})]}),n("button",{class:`major ${s.transport.triggerMuted?"on":""}`,onClick:()=>u("mute.set",{muted:!s.transport.triggerMuted}),children:[s.transport.triggerMuted?"MUTE":"LIVE",R&&n("b",{class:"mute-countdown",children:R}),n("small",{children:R?"\u5F8C\u306B\u81EA\u52D5\u89E3\u9664":`\u30AD\u30E5\u30FC\u9001\u51FA ${s.transport.triggerMuted?"\u505C\u6B62":"\u6709\u52B9"}`})]})]})]}),n("section",{class:"work",children:[n("section",{class:"cues",style:V,children:[n("div",{class:"tool",children:[n("h2",{children:"\u30AD\u30E5\u30FC\u30EA\u30B9\u30C8"}),n("label",{class:"judge-control muted",title:"\u3053\u306E\u5E45(\u30D5\u30EC\u30FC\u30E0)\u4EE5\u5185\u306E\u524D\u9032\u3084\u5F8C\u9000\u306F\u901A\u5E38\u518D\u751F\u30FB\u30B8\u30C3\u30BF\u30FC\u3068\u3057\u3066\u6271\u3044\u3001\u53D6\u308A\u3053\u307C\u3057\u305F\u9593\u306E\u30AD\u30E5\u30FC\u3082\u767A\u706B\u3057\u307E\u3059\u3002\u8D85\u3048\u3066\u98DB\u3093\u3060\u3089\u982D\u51FA\u3057(\u30B7\u30FC\u30AF)\u3084\u5DFB\u304D\u623B\u3057\u3068\u3057\u3066\u9014\u4E2D\u306E\u30AD\u30E5\u30FC\u306F\u767A\u706B\u3057\u307E\u305B\u3093",children:[n("span",{children:"\u30B8\u30E3\u30F3\u30D7\u5224\u5B9A"}),n("span",{"aria-hidden":"true",children:"\xB1"}),n("input",{class:"inline-input judge-input",type:"number",value:s.receive.triggerWindowFrames,min:"0",step:"1","aria-label":"\u30B8\u30E3\u30F3\u30D7\u5224\u5B9A\uFF08\u30D5\u30EC\u30FC\u30E0\uFF09",onChange:v=>u("receive.setTriggerWindow",{frames:Number(v.currentTarget.value)})}),n("span",{"aria-hidden":"true",children:"f"})]}),n("button",{class:"btn",onClick:()=>r("add"),children:"\uFF0B \u8FFD\u52A0"}),n("button",{class:"btn",disabled:!f().length,onClick:h,children:f().length>1?"\u4E00\u62EC\u7DE8\u96C6":"\u7DE8\u96C6"}),n("button",{class:"btn",disabled:f().length!==1,onClick:()=>u("cue.duplicate",{id:f()[0].id}),children:"\u8907\u88FD"}),n("button",{class:"btn",disabled:f().length!==1,onClick:()=>r("duplicate"),children:"\u9023\u7D9A\u8907\u88FD"}),n("button",{class:"btn",disabled:!f().length,onClick:A,children:"\u524A\u9664"}),n("button",{class:`btn right auto-mute-toggle ${s.transport.autoMuteEnabled?"on":""}`,"aria-pressed":s.transport.autoMuteEnabled,title:"\u30AD\u30E5\u30FC\u767A\u706B\u5F8C\u306E\u81EA\u52D5\u30DF\u30E5\u30FC\u30C8\u3092\u307E\u3068\u3081\u3066\u5165\u5207\u3057\u307E\u3059\u3002\u5207\u308B\u3068\u3001\u30AD\u30E5\u30FC\u3054\u3068\u306E\u300C\u767A\u706B\u6642\u30DF\u30E5\u30FC\u30C8\u300D\u3082\u50CD\u304D\u307E\u305B\u3093",onClick:()=>u("autoMute.setEnabled",{enabled:!s.transport.autoMuteEnabled}),children:["\u30AA\u30FC\u30C8\u30DF\u30E5\u30FC\u30C8 ",s.transport.autoMuteEnabled?"ON":"OFF"]}),n("button",{class:"btn",onClick:()=>u("cue.sortByTime"),children:"\u6642\u9593\u9806"})]}),n("div",{class:"cols",children:["\u6709\u52B9","\u30C8\u30EA\u30AC\u30FC\u6642\u9593","\u30AD\u30E5\u30FC\u540D","OSC\u30A2\u30C9\u30EC\u30B9","\u624B\u52D5"].map((v,D)=>n("span",{children:[v,D<4&&n("i",{class:"resize-handle",onPointerDown:E=>S(D,E)})]}))}),n("div",{class:"list",children:s.cues.map(v=>n("div",{class:`row ${v.id===l.nextCueId?"current":""} ${v.enabled?"":"disabled"} ${p.ui.selectedCueIds.has(v.id)?"selected":""} ${Y.has(v.id)?Y.get(v.id)%2?"fired-a":"fired-b":""}`,tabIndex:0,"aria-label":`${v.name} ${v.effectiveTriggerTime}`,onPointerDown:()=>{Ht=Date.now()},onFocus:()=>{Date.now()-Ht<300||p.ui.selectedCueIds.has(v.id)||k.updateUi({selectedCueIds:new Set([v.id]),focusedCueId:v.id,anchorCueId:v.id})},onClick:D=>w(v.id,D),onDblClick:D=>{D.target.closest("button,input")||h()},children:[n("span",{children:n("input",{type:"checkbox","aria-label":`${v.name}\u3092${v.enabled?"\u7121\u52B9":"\u6709\u52B9"}\u306B\u3059\u308B`,checked:v.enabled,onChange:D=>u("cue.setEnabled",{id:v.id,enabled:D.currentTarget.checked})})}),n("span",{class:"mono",children:v.effectiveTriggerTime}),n("span",{children:[v.name,s.transport.autoMutedCueId===v.id&&n("b",{class:"mute-tag",children:["MUTE",R?` ${R}`:""]})]}),n("span",{class:"mono",children:v.oscAddress}),n("button",{class:"btn fire","aria-label":`${v.name}\u3092\u767A\u706B`,onClick:D=>{D.stopPropagation(),O("cue.fire",{id:v.id}).then(E=>wn(E,c)).catch(E=>c(E.message))},children:"\u25B6"})]},v.id))}),n("div",{class:"footcue",children:[n("span",{class:"tag",children:"NEXT"}),n("b",{class:"mono",children:s.nextCue?.effectiveTriggerTime}),n("span",{children:s.nextCue?.name})]})]}),n("aside",{class:"side",children:[n("div",{class:"sec",children:[n("div",{class:"head",children:[n("b",{children:"\u52D5\u4F5C\u30E2\u30FC\u30C9"}),n("span",{class:"tiny",children:s.transport.statusText})]}),n("div",{class:"mode",children:[n("button",{class:s.mode==="ltc"?"active":"",onClick:()=>g("ltc"),children:"LTC\u53D7\u4FE1"}),n("button",{class:s.mode==="generate"?"active":"",onClick:()=>g("generate"),children:"\u5185\u90E8\u751F\u6210"})]})]}),s.mode==="ltc"?n(Et,{}):n(Ot,{notice:c}),n(It,{notice:c})]})]}),n("footer",{children:[n("span",{children:[n("i",{class:"led"}),s.mode==="ltc"?"LTC INPUT":"LTC GENERATOR"," ",s.transport.locked?"LOCK":"UNLOCK",s.transport.detailText?` \xB7 ${s.transport.detailText}`:""]}),n("button",{class:"btn right","aria-pressed":p.ui.drawerOpen,title:"OSC \u30DD\u30F3\u51FA\u3057\u30D1\u30CD\u30EB\u3092\u53F3\u306B\u958B\u9589\u3057\u307E\u3059",onClick:()=>k.updateUi({drawerOpen:!p.ui.drawerOpen}),children:p.ui.drawerOpen?"\u25E7 OSC \u30DD\u30F3\u51FA\u3057\u3092\u9589\u3058\u308B":"\u25E8 OSC \u30DD\u30F3\u51FA\u3057\u3092\u958B\u304F"})]}),a&&n("div",{class:"toast",onClick:()=>c(""),children:a})]}),n(Pt,{notice:c})]}),p.ui.optionsOpen&&n(At,{notice:c,close:()=>k.updateUi({optionsOpen:!1,modalOpen:!1})})," ",t==="add"&&n(He,{frameRate:l.frameRate,hosts:s.hosts,close:T,done:T})," ",t==="edit"&&n(He,{cue:f()[0],frameRate:l.frameRate,hosts:s.hosts,close:T,done:T})," ",t==="batch"&&n(St,{ids:f().map(v=>v.id),hosts:s.hosts,frameRate:l.frameRate,close:T,done:T,notice:c})," ",t==="duplicate"&&n(kt,{cue:f()[0],close:T,done:T})," ",t==="remove"&&n(J,{message:`\u9078\u629E\u3057\u305F ${f().length} \u4EF6\u306E\u30AD\u30E5\u30FC\u3092\u524A\u9664\u3057\u307E\u3059\u304B\uFF1F`,close:T,confirm:()=>{u("cue.remove",{ids:f().map(v=>v.id)}),T()}})]})}var q=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),N=e=>typeof e=="number"&&Number.isFinite(e);function Nt(e){return q(e)&&typeof e.raw=="string"&&typeof e.display=="string"&&N(e.totalFrames)&&["24","25","29.97df","30"].includes(String(e.frameRate))&&typeof e.dropFrame=="boolean"&&N(e.receivedAtMonotonicMs)}function En(e){return!q(e)||e.protocolVersion!==1||typeof e.type!="string"?!1:e.type==="clock"?N(e.seq)&&Nt(e.clock):e.type==="wave"?N(e.seq)&&q(e.wave)&&N(e.wave.sampleRate)&&N(e.wave.windowMs)&&Array.isArray(e.wave.min)&&Array.isArray(e.wave.max)&&e.wave.min.every(N)&&e.wave.max.every(N)&&(e.wave.levelDbfs===null||N(e.wave.levelDbfs)):e.type==="snapshot"?N(e.revision)&&q(e.state)&&typeof e.state.sessionId=="string"&&Array.isArray(e.state.cues)&&q(e.state.transport)&&Nt(e.state.currentClock):e.type==="patch"?N(e.revision)&&N(e.baseRevision)&&q(e.changes):e.type==="result"?typeof e.requestId=="string"&&typeof e.ok=="boolean"&&(e.ok||q(e.error)):!1}function $t(e){try{let t=typeof e=="string"?JSON.parse(e):e;return En(t)?t:null}catch{return null}}var Fe=(e,t,r,o)=>({id:e,name:t,memo:"",triggerTime:r,effectiveTriggerTime:r,frameRate:"30",oscAddress:o,additionalOscAddresses:[],arguments:[],targetHostIds:["qlab"],enabled:!0,sendTriggerTimeAsSeconds:!1,sendTimecode:null,triggerOffset:null,autoMuteOnFire:!1,autoUnmuteAfter:null,runtime:{lastTriggeredAtUtc:null,flashToken:0}});function Dn(){return{sessionId:"fake-session",project:{displayName:"show_A.tcb3",filePath:null,dirty:!1,canUndo:!1,canRedo:!1,recentFiles:[]},mode:"ltc",transport:{status:"receiving",statusText:"\u53D7\u4FE1\u4E2D",detailText:"CH 1 \xB7 48 kHz",signalErrorRatePercent:0,locked:!0,triggerMuted:!1,autoMuteEnabled:!1,autoMuteOnManualTrigger:!1,autoMutedCueId:null,autoUnmuteAtUtc:null,lastLtcReceivedAtUtc:null},receive:{selectedDeviceId:"in",devices:[{id:"in",name:"UR44 \u2014 Input 1 / 2",loopback:!1}],offset:"+00:00:00:08",triggerWindowFrames:3,freerunDurationSeconds:1},generator:{running:!1,startTime:"01:00:00:00",loopEndTime:null,frameRate:"30",selectedOutputDeviceId:"out",outputDevices:[{id:"out",name:"UR44 \u2014 Output 1 / 2",loopback:!1}],volume:.4,ltcOutputActive:!1,settingsPendingReset:!1},currentClock:{raw:"01:24:16:00",display:"01:24:16:08",totalFrames:151688,frameRate:"30",dropFrame:!1,receivedAtMonotonicMs:0,nextCueId:"cue-2",framesUntilNextCue:112},nextCue:{id:"cue-2",name:"\u30BF\u30A4\u30C8\u30EB OUT",triggerTime:"01:24:20:00",effectiveTriggerTime:"01:24:20:00",framesUntil:112},cues:[Fe("cue-1","\u672C\u7DE8 IN","01:23:40:00","/qlab/go"),Fe("cue-2","\u30BF\u30A4\u30C8\u30EB OUT","01:24:20:00","/video/title/out")],hosts:[{id:"qlab",name:"QLab \u2014 Main",ipAddress:"192.168.1.20",port:53e3,enabled:!0,reachability:"reachable"},{id:"reso",name:"Resolume \u2014 Stage",ipAddress:"192.168.1.31",port:7e3,enabled:!0,reachability:"reachable"}],cueSync:{oscAddress:"/cuesync",targetHostIds:["qlab","reso"]},triggerPanel:{rows:4,columns:4,buttons:[{id:"go",row:0,column:0,label:"GO",oscAddress:"/go",arguments:[],targetHostIds:["qlab"]}]},logs:[{id:"log-1",timestampUtc:new Date(Date.now()-1e3).toISOString(),message:"fake-host \u3092\u958B\u59CB\u3057\u307E\u3057\u305F",success:!0}],uiCapabilities:{supportsNativeOpenDialog:!1,supportsNativeSaveDialog:!1,platform:"macos"}}}function jt(){let e=Dn(),t=1,r=0,o=10,i=!0,a=null,c=p=>queueMicrotask(()=>i&&window.tcb.receive(JSON.stringify(p))),d=p=>{let{logsAppend:s,logsReset:l,...f}=p;e={...e,...f},l&&(e.logs=l),s&&(e.logs=[...e.logs,...s]),c({protocolVersion:1,type:"patch",baseRevision:t,revision:++t,changes:p})},b=p=>{let s=JSON.parse(p);if(s.type==="ready"||s.type==="resync"){c({protocolVersion:1,type:"snapshot",revision:t,state:e}),a===null&&(a=window.setInterval(()=>c({protocolVersion:1,type:"clock",seq:++r,clock:{...e.currentClock,receivedAtMonotonicMs:performance.now()}}),100));return}if(s.type!=="command")return;let l=s.args,f=u=>c({protocolVersion:1,type:"result",requestId:s.requestId,ok:!0,data:u,revision:t}),h=u=>c({protocolVersion:1,type:"result",requestId:s.requestId,ok:!1,error:{code:"validation",message:"\u5165\u529B\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044",retryable:!1,fieldErrors:u}}),A=(u,_=!0)=>d({logsAppend:[{id:`log-${++o}`,timestampUtc:new Date().toISOString(),message:u,success:_}]});if(s.command==="mode.set"){let u=l.mode,_=u==="ltc"&&!!e.receive.selectedDeviceId;d({mode:u,transport:{...e.transport,status:_?"receiving":"stopped",statusText:_?"\u53D7\u4FE1\u4E2D":u==="ltc"?"\u505C\u6B62\u4E2D":"\u751F\u6210\u5F85\u6A5F",locked:_}}),f({ltcStarted:_});return}if(s.command==="ltc.stop"){d({transport:{...e.transport,status:"stopped",statusText:"\u505C\u6B62",locked:!1}}),f();return}if(s.command==="receive.selectDevice"&&!(l.deviceId??"")){d({receive:{...e.receive,selectedDeviceId:null},transport:{...e.transport,status:"stopped",statusText:"\u505C\u6B62\u4E2D",locked:!1}}),f();return}if(s.command==="receive.selectDevice"){d({receive:{...e.receive,selectedDeviceId:l.deviceId},transport:{...e.transport,status:"receiving",statusText:"\u53D7\u4FE1\u4E2D",locked:!0}}),f();return}if(s.command==="ltc.start"||s.command==="ltc.reconnect"){d({receive:{...e.receive,selectedDeviceId:l.deviceId??e.receive.selectedDeviceId},transport:{...e.transport,status:"receiving",statusText:"\u53D7\u4FE1\u4E2D",locked:!0}}),f();return}if(s.command==="receive.setFreerunDuration"){d({receive:{...e.receive,freerunDurationSeconds:Number(l.seconds)}}),f();return}if(s.command==="audio.refreshDevices"){d(l.direction==="capture"?{receive:{...e.receive}}:{generator:{...e.generator}}),f();return}if(s.command==="generator.configure"){d({generator:{...e.generator,startTime:l.startTime,loopEndTime:l.loopEndTime??null,frameRate:l.frameRate,selectedOutputDeviceId:l.outputDeviceId||null,volume:l.volume,settingsPendingReset:e.generator.running}}),f();return}if(s.command==="generator.start"||s.command==="generator.stop"){let u=s.command.endsWith("start");d({generator:{...e.generator,running:u,ltcOutputActive:u&&!!e.generator.selectedOutputDeviceId,settingsPendingReset:!1},transport:{...e.transport,status:u?"receiving":"stopped",statusText:u?"\u751F\u6210\u4E2D":"\u505C\u6B62"}}),f();return}if(s.command==="generator.reset"){d({generator:{...e.generator,running:!1,ltcOutputActive:!1,settingsPendingReset:!1},currentClock:{...e.currentClock,raw:e.generator.startTime,display:e.generator.startTime}}),f();return}if(s.command==="host.add"||s.command==="host.update"){let u=l.host,_={...u.name?{}:{"host.name":"\u5FC5\u9808"},...u.ipAddress?{}:{"host.ipAddress":"\u5FC5\u9808"},...u.port>=1&&u.port<=65535?{}:{"host.port":"1\u301C65535"}};if(Object.keys(_).length){h(_);return}let m=s.command==="host.add"?`host-${++o}`:String(l.id),g={id:m,name:u.name,ipAddress:u.ipAddress,port:u.port,enabled:u.enabled??!0,reachability:"unknown"};d({hosts:s.command==="host.add"?[...e.hosts,g]:e.hosts.map(w=>w.id===m?g:w)}),f({id:m});return}if(s.command==="host.remove"){d({hosts:e.hosts.filter(u=>u.id!==l.id)}),f();return}if(s.command==="host.setEnabled"){d({hosts:e.hosts.map(u=>u.id===l.id?{...u,enabled:!!l.enabled}:u)}),f();return}if(s.command==="host.ping"){d({hosts:e.hosts.map(u=>u.id===l.id?{...u,reachability:"reachable"}:u)}),f({reachable:!0,latencyMs:2});return}if(s.command==="triggerPanel.configureGrid"){d({triggerPanel:{...e.triggerPanel,rows:Number(l.rows),columns:Number(l.columns),buttons:e.triggerPanel.buttons.filter(u=>u.rowm.id!==u),_]}}),f({id:u});return}if(s.command==="triggerPanel.removeButton"){d({triggerPanel:{...e.triggerPanel,buttons:e.triggerPanel.buttons.filter(u=>u.id!==l.id)}}),f();return}if(s.command==="triggerPanel.fire"){A(`\u30DD\u30F3\u51FA\u3057: ${e.triggerPanel.buttons.find(u=>u.id===l.id)?.label??l.id}`),f({sent:!0,sentCount:1,skippedHostIds:[],reason:"None"});return}if(s.command==="logs.clear"){d({logsReset:[]}),f();return}if(s.command==="cueSync.configure"){d({cueSync:{...e.cueSync,...l}}),f();return}if(s.command==="cueSync.send"){A("Cue-Sync \u3092\u9001\u4FE1\u3057\u307E\u3057\u305F"),f({sent:!0,sentCount:2,skippedHostIds:[]});return}if(s.command==="cue.add"||s.command==="cue.update"){let u=l.cue,_={...ee(u.frameRate??"30"),...u,additionalOscAddresses:(u.additionalOscAddresses??[]).join(` -`),argumentsText:(u.arguments??[]).map(y=>`${y.type}:${y.value}`).join(` -`),sendTimecode:u.sendTimecode??"",triggerOffset:u.triggerOffset??"",autoUnmuteAfter:u.autoUnmuteAfter??""},m=me(_);if(!m.draft){h(Object.fromEntries(Object.entries(m.errors).map(([y,T])=>[`cue.${y}`,T])));return}let g=s.command==="cue.add"?`cue-${++o}`:String(l.id),w={...Fe(g,m.draft.name,m.draft.triggerTime,m.draft.oscAddress),...m.draft,id:g,effectiveTriggerTime:m.draft.triggerTime};d({cues:s.command==="cue.add"?[...e.cues,w]:e.cues.map(y=>y.id===g?w:y),project:{...e.project,dirty:!0,canUndo:!0}}),f({id:g});return}if(s.command==="cue.remove"){d({cues:e.cues.filter(u=>!l.ids.includes(u.id))}),f();return}if(s.command==="cue.duplicate"){let u=e.cues.find(m=>m.id===l.id),_=[];if(u){let m=Array.from({length:Number(l.count??1)},(g,w)=>{let y=`cue-${++o}`;return _.push(y),{...u,id:y,name:`${u.name} (\u30B3\u30D4\u30FC${w?` ${w+1}`:""})`}});d({cues:[...e.cues,...m]})}f({ids:_});return}if(s.command==="cue.batchUpdate"){d({cues:e.cues.map(u=>l.ids.includes(u.id)?{...u,...l.changes}:u)}),f({updated:l.ids.length,offsetSkipped:0});return}if(s.command.startsWith("project.")){d({...s.command==="project.new"?{cues:[]}:{},project:{...e.project,displayName:s.command==="project.new"?"\u540D\u79F0\u672A\u8A2D\u5B9A.tcb3":e.project.displayName,dirty:!1,canUndo:!1,canRedo:!1}}),f({cancelled:!1});return}if(s.command==="app.undo"||s.command==="app.redo"){d({project:{...e.project,canUndo:s.command==="app.redo",canRedo:s.command==="app.undo"}}),f();return}s.command==="mute.set"&&d({transport:{...e.transport,triggerMuted:!!l.muted}}),s.command==="cue.setEnabled"&&d({cues:e.cues.map(u=>u.id===l.id?{...u,enabled:!!l.enabled}:u)}),f()};return window.invokeCSharpAction=b,{dispose:()=>{i=!1,a!==null&&window.clearInterval(a),window.invokeCSharpAction===b&&delete window.invokeCSharpAction}}}var Ue=!1,Ne=!1;function On(){Ne=!0,!Ue&&(Ue=!0,requestAnimationFrame(()=>{Ue=!1,Ne&&(Ne=!1,k.notify())}))}var $e=()=>Q({protocolVersion:1,type:"ready",clientVersion:"3.0.0",capabilities:["clock-latest-only","wave-minmax","m1","m2a","m2b","m3"]});function Lt(e=800){let t=!1,r=null,o=window.setTimeout(()=>{t||window.invokeCSharpAction||(r=jt(),$e())},e);return window.tcb={receive:i=>{let a=$t(i);if(!a)return;if(a.type==="result"){bt(a);return}gt(k.value,a)==="resync"&&Q({protocolVersion:1,type:"resync",currentRevision:k.value.host.revision,reason:"patch baseRevision mismatch"}),On()},hostAttached:()=>{t=!0,window.clearTimeout(o),r?.dispose(),r=null,$e()}},$e(),{dispose:()=>{t=!0,window.clearTimeout(o),r?.dispose(),r=null}}}Lt();var Wt=document.getElementById("app");if(!Wt)throw new Error("Missing #app mount point");nt(n(Ut,{}),Wt);})(); +string:GO`}),n("small",{class:"field-error",children:g.arguments})]}),n("fieldset",{children:[n("legend",{children:"\u9001\u4FE1\u5148\u30DB\u30B9\u30C8"}),A.hosts.map(c=>n("label",{children:[n("input",{type:"checkbox",checked:s.includes(c.id),onChange:_=>l(_.currentTarget.checked?[...s,c.id]:s.filter(f=>f!==c.id))}),n("span",{children:c.name})]}))]}),n("div",{class:"dialog-actions",children:[n("button",{type:"button",class:"btn",onClick:t,children:"\u30AD\u30E3\u30F3\u30BB\u30EB"}),n("button",{class:"btn primary",children:"\u4FDD\u5B58"})]})]})})}function Pt({notice:e}){let t=k.value.host.state,r=k.value.ui,[o,i]=C(!1),[a,u]=C(null),[d,m]=C(null),[p,s]=C(null),[l,g]=C({}),h=(b,w)=>{let y=t.triggerPanel.buttons.filter(T=>T.row>=b||T.column>=w).length;if(y>0){s({rows:b,columns:w,lost:y}),k.updateUi({modalOpen:!0});return}x("triggerPanel.configureGrid",{rows:b,columns:w})},A=()=>{u(null),s(null),m(null),k.updateUi({modalOpen:!1})},c=async b=>{try{let w=await x("triggerPanel.fire",{id:b.id});g(y=>({...y,[b.id]:w.sent===!1?w.reason??"\u9001\u4FE1\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F":"\u9001\u4FE1\u3057\u307E\u3057\u305F"}))}catch(w){g(y=>({...y,[b.id]:w.message}))}},_=Array.from({length:t.triggerPanel.rows*t.triggerPanel.columns},(b,w)=>{let y=Math.floor(w/t.triggerPanel.columns),T=w%t.triggerPanel.columns;return{row:y,column:T,button:t.triggerPanel.buttons.find(S=>S.row===y&&S.column===T)}}),f=b=>{let w=b.clientX,y=r.drawerWidth;b.currentTarget.setPointerCapture(b.pointerId);let T=R=>k.updateUi({drawerWidth:Math.min(900,Math.max(280,y-(R.clientX-w)))}),S=()=>{window.removeEventListener("pointermove",T),window.removeEventListener("pointerup",S)};window.addEventListener("pointermove",T),window.addEventListener("pointerup",S)};return n("section",{class:`osc-panel ${r.drawerOpen?"open":""}`,"aria-hidden":!r.drawerOpen,children:[n("i",{class:"osc-resize",onPointerDown:f,title:"\u30C9\u30E9\u30C3\u30B0\u3067\u5E45\u3092\u5909\u3048\u3089\u308C\u307E\u3059"}),n("div",{class:"dh",children:[n("h2",{children:"OSC \u30DD\u30F3\u51FA\u3057"}),n("button",{class:"btn close","aria-label":"OSC \u30DD\u30F3\u51FA\u3057\u3092\u9589\u3058\u308B",title:"\u9589\u3058\u308B\uFF08Esc\uFF09",onClick:()=>k.updateUi({drawerOpen:!1}),children:"\u2715"}),n("div",{class:"dh-row",children:[n("button",{class:`btn ${o?"":"primary"}`,onClick:()=>i(!1),children:"\u5B9F\u884C\u30E2\u30FC\u30C9"}),n("button",{class:`btn ${o?"primary":""}`,onClick:()=>i(!0),children:"\u7DE8\u96C6\u30E2\u30FC\u30C9"}),o&&n(H,{children:[n("label",{class:"grid-size",children:["\u884C ",n("input",{class:"field",type:"number",min:"1",max:"12",value:t.triggerPanel.rows,onChange:b=>h(Number(b.currentTarget.value),t.triggerPanel.columns)})]}),n("label",{class:"grid-size",children:["\u5217 ",n("input",{class:"field",type:"number",min:"1",max:"12",value:t.triggerPanel.columns,onChange:b=>h(t.triggerPanel.rows,Number(b.currentTarget.value))})]})]}),n("span",{class:"muted",children:[t.triggerPanel.rows," \u884C \xD7 ",t.triggerPanel.columns," \u5217"]})]})]}),n("div",{class:`grid ${o?"editing":""}`,style:{gridTemplateColumns:`repeat(${t.triggerPanel.columns},1fr)`,gridTemplateRows:`repeat(${t.triggerPanel.rows},1fr)`},children:_.map(b=>b.button?n("div",{class:"trigger-cell",children:[n("button",{class:"trig",onClick:()=>o?u(b):void c(b.button),children:b.button.label}),l[b.button.id]&&n("small",{class:l[b.button.id]==="\u9001\u4FE1\u3057\u307E\u3057\u305F"?"":"failure",children:l[b.button.id]}),o&&n("button",{class:"cell-remove","aria-label":`${b.button.label}\u3092\u524A\u9664`,onClick:()=>{m(b.button),k.updateUi({modalOpen:!0})},children:"\xD7"})]}):n("button",{class:"empty-cell","aria-label":`${b.row+1}\u884C${b.column+1}\u5217\u306B\u30DC\u30BF\u30F3\u3092\u4F5C\u6210`,disabled:!o,onClick:()=>u(b),children:o?"\uFF0B":""}))}),a&&n(Tn,{cell:a,close:A,notice:e})," ",d&&n(J,{message:`\u300C${d.label}\u300D\u3092\u524A\u9664\u3057\u307E\u3059\u304B\uFF1F`,close:A,confirm:()=>{x("triggerPanel.removeButton",{id:d.id}),A()}}),p&&n(J,{message:`${p.rows} \u884C \xD7 ${p.columns} \u5217\u306B\u7E2E\u5C0F\u3059\u308B\u3068\u3001\u7BC4\u56F2\u5916\u306E\u30DC\u30BF\u30F3 ${p.lost} \u500B\u304C\u6D88\u3048\u307E\u3059\u3002\u7D9A\u3051\u307E\u3059\u304B\uFF1F`,confirmLabel:"\u7E2E\u5C0F",close:A,confirm:()=>{x("triggerPanel.configureGrid",{rows:p.rows,columns:p.columns}),A()}})]})}var Ft=e=>e.hosts.filter(t=>t.enabled&&e.cueSync.targetHostIds.includes(t.id)).length;function Cn(e,t){e?.sentCount===0&&t("\u9001\u4FE1\u5148\u30DB\u30B9\u30C8\u304C\u3042\u308A\u307E\u305B\u3093")}function kn(e,t,r){if(Ft(e)===0){t("Cue-Sync \u306E\u9001\u4FE1\u5148\u30DB\u30B9\u30C8\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044");return}x("cueSync.send",{}).then(()=>r()).catch(o=>t(o.message))}var Sn=new Map,Y=new Map,An=e=>e.split(/[\\/]/).pop()||e,En=e=>e==null||!Number.isFinite(e)?"-- dBFS":`${e>=0?"":"\u2212"}${Math.abs(e).toFixed(1)} dBFS`,Ht=0;function Dn({current:e,frameRate:t,apply:r}){let[o,i]=C(e),[a,u]=C(e);a!==e&&(u(e),i(e));let d=o!==e,m=$({draft:o,current:e});return m.current={draft:o,current:e},n("span",{class:"offset-editor",children:[n(B,{class:"monitor-offset",value:o,frameRate:t,signed:!0,ariaLabel:"\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9\u30AA\u30D5\u30BB\u30C3\u30C8",onChange:i}),n("button",{class:`btn mini ${d?"primary":""}`,disabled:!d,onClick:()=>{let{draft:s,current:l}=m.current;s!==l&&r(s)},children:"\u78BA\u5B9A"}),d&&n("span",{class:"tiny offset-pending",children:"\u672A\u78BA\u5B9A"})]})}function Ut(){let[,e]=C(0),[t,r]=C(null),[o,i]=C(!1),[a,u]=C(""),[d,m]=C(0),p=k.value,s=p.host.state,l=p.host.clock??s?.currentClock;P(()=>k.subscribe(()=>{for(let v of Mt(Sn,k.value.host.state?.cues??[])){let D=(Y.get(v)??0)+1;Y.set(v,D),window.setTimeout(()=>{Y.get(v)===D&&(Y.delete(v),e(E=>E+1))},700)}e(v=>v+1)}),[]),P(()=>k.updateUi({modalOpen:t!==null}),[t]),P(()=>{if(!a)return;let v=window.setTimeout(()=>u(""),4e3);return()=>window.clearTimeout(v)},[a]),P(()=>{let v=()=>Q({protocolVersion:1,type:"viewport",waveformWidth:360,devicePixelRatio:window.devicePixelRatio,visible:document.visibilityState==="visible"});return v(),window.addEventListener("resize",v),document.addEventListener("visibilitychange",v),()=>{window.removeEventListener("resize",v),document.removeEventListener("visibilitychange",v)}},[]);let g=()=>s?.cues.filter(v=>p.ui.selectedCueIds.has(v.id))??[],h=()=>{g().length&&r(g().length===1?"edit":"batch")},A=()=>{g().length&&r("remove")},c=(v,D={})=>void x(v,D).catch(E=>u(E.message)),_=()=>m(v=>v+1),f=()=>{s&&kn(s,u,_)},b=v=>void x("mode.set",{mode:v}).then(D=>{v==="ltc"&&D?.ltcStarted===!1&&u("\u5165\u529B\u30C7\u30D0\u30A4\u30B9\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044")}).catch(D=>u(D.message));if(P(()=>{let v=D=>{let E=_t(D,p.ui.modalOpen);if(E)if(D.preventDefault(),E==="closeDrawer")k.updateUi({drawerOpen:!1});else if(E==="editCue")h();else if(E==="deleteCue")A();else if(E==="selectPrevious"||E==="selectNext"){if(!s)return;let F=Math.max(0,s.cues.findIndex(j=>j.id===p.ui.focusedCueId)),L=s.cues[Math.max(0,Math.min(s.cues.length-1,F+(E==="selectNext"?1:-1)))];L&&k.updateUi({focusedCueId:L.id,selectedCueIds:new Set([L.id])})}else c({projectNew:"project.new",projectOpen:"project.open",projectSave:"project.save",projectSaveAs:"project.saveAs",undo:"app.undo",redo:"app.redo"}[E])};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)}),!s||!l)return n("main",{class:"app loading",children:"HOST \u306B\u63A5\u7D9A\u3057\u3066\u3044\u307E\u3059\u2026"});let w=(v,D)=>{let E=new Set(p.ui.selectedCueIds);if(D.metaKey||D.ctrlKey)E.has(v)?E.delete(v):E.add(v);else if(D.shiftKey&&p.ui.anchorCueId){let F=s.cues.findIndex(j=>j.id===p.ui.anchorCueId),L=s.cues.findIndex(j=>j.id===v);E=new Set(s.cues.slice(Math.min(F,L),Math.max(F,L)+1).map(j=>j.id))}else E=new Set([v]);k.updateUi({selectedCueIds:E,focusedCueId:v,anchorCueId:v})},y=v=>{i(!1),c(v)},T=()=>r(null),S=(v,D)=>{let E=D.clientX,F=[...p.ui.cueColumnWidths];D.currentTarget.setPointerCapture(D.pointerId);let L=Bt=>{let je=Bt.clientX-E,Vt=Math.max(38,(F[v]??38)+je),Kt=Math.max(50,(F[v+1]??50)-je),be=[...F];be[v]=Vt,be[v+1]=Kt,k.updateUi({cueColumnWidths:be})},j=()=>{window.removeEventListener("pointermove",L),window.removeEventListener("pointerup",j)};window.addEventListener("pointermove",L),window.addEventListener("pointerup",j)},R=s.transport.triggerMuted?ft(s.transport.autoUnmuteAtUtc,Date.now()):"",V={"--cue-cols":p.ui.cueColumnWidths.map(v=>`${v}px`).join(" ")};return n(H,{children:[n("div",{class:`split ${p.ui.drawerOpen?"osc-open":""}`,style:{"--osc-width":`${p.ui.drawerWidth}px`},children:[n("main",{class:"app",children:[n("header",{children:[n("b",{children:"TIMEcode BRIDGE 3"}),n("button",{class:"project-button",onClick:()=>i(!o),children:[s.project.displayName,"\u3000\u25CF ",s.project.dirty?"\u672A\u4FDD\u5B58":"\u4FDD\u5B58\u6E08\u307F"]}),o&&n("div",{class:"project-menu",children:[n("button",{onClick:()=>y("project.new"),children:"\u65B0\u898F"}),n("button",{onClick:()=>y("project.open"),children:"\u958B\u304F\u2026"}),n("button",{onClick:()=>y("project.save"),children:"\u4FDD\u5B58"}),n("button",{onClick:()=>y("project.saveAs"),children:"\u540D\u524D\u3092\u4ED8\u3051\u3066\u4FDD\u5B58\u2026"}),s.project.recentFiles.length>0&&n(H,{children:[n("div",{class:"project-menu-sep",children:"\u6700\u8FD1\u4F7F\u3063\u305F\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8"}),s.project.recentFiles.map(v=>n("button",{class:"recent",title:v,onClick:()=>{i(!1),c("project.open",{path:v})},children:An(v)}))]})]}),n("button",{class:"btn","aria-label":"\u53D6\u308A\u6D88\u3059",disabled:!s.project.canUndo,onClick:()=>c("app.undo"),children:"\u21B6"}),n("button",{class:"btn","aria-label":"\u3084\u308A\u76F4\u3059",disabled:!s.project.canRedo,onClick:()=>c("app.redo"),children:"\u21B7"}),n("span",{class:"right muted",children:[n("i",{class:"led"}),"ENGINE ONLINE\u3000 ",l.frameRate," FPS / ",l.dropFrame?"DROP":"NON-DROP"]})]}),n("section",{class:"monitor",children:[n("div",{children:[n("span",{class:"tiny",children:[n("i",{class:"led"}),"\u53D7\u4FE1\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9 / OFFSET\u9069\u7528\u5F8C"]}),n("div",{class:"tc",children:l.display}),n("span",{class:"tiny monitor-offset-line",children:["RAW\u3000",n("span",{class:"mono",children:l.raw}),"\u3000 OFFSET\u3000",n(Dn,{current:s.receive.offset,frameRate:l.frameRate,apply:v=>c("receive.setOffset",{value:v})}),"\u3000 ",s.transport.locked?"LOCK":"UNLOCK"," / ",En(p.host.wave?.levelDbfs)]})]}),n("div",{class:"next",children:[n("span",{class:"tiny",children:["NEXT CUE ",n("b",{class:"right",children:["T\u2212 ",s.nextCue?l.framesUntilNextCue??"--":"--","f"]})]}),n("div",{class:"next-main",children:[n("strong",{children:s.nextCue?.effectiveTriggerTime??"--:--:--:--"}),n("b",{children:s.nextCue?.name??"\u6B21\u306E\u30AD\u30E5\u30FC\u306F\u3042\u308A\u307E\u305B\u3093"})]}),n("span",{class:"tiny mono",children:s.nextCue?s.cues.find(v=>v.id===s.nextCue?.id)?.oscAddress:"\u2014"})]}),n("div",{class:"majorbox",children:[n("button",{class:`major ${d===0?"":d%2?"flash-a":"flash-b"}`,onClick:f,children:["CUE SYNC",n("small",{children:[Ft(s),"\u30DB\u30B9\u30C8\u3078\u9001\u4FE1"]})]}),n("button",{class:`major ${s.transport.triggerMuted?"on":""}`,onClick:()=>c("mute.set",{muted:!s.transport.triggerMuted}),children:[s.transport.triggerMuted?"MUTE":"LIVE",R&&n("b",{class:"mute-countdown",children:R}),n("small",{children:R?"\u5F8C\u306B\u81EA\u52D5\u89E3\u9664":`\u30AD\u30E5\u30FC\u9001\u51FA ${s.transport.triggerMuted?"\u505C\u6B62":"\u6709\u52B9"}`})]})]})]}),n("section",{class:"work",children:[n("section",{class:"cues",style:V,children:[n("div",{class:"tool",children:[n("h2",{children:"\u30AD\u30E5\u30FC\u30EA\u30B9\u30C8"}),n("label",{class:"judge-control muted",title:"\u3053\u306E\u5E45(\u30D5\u30EC\u30FC\u30E0)\u4EE5\u5185\u306E\u524D\u9032\u3084\u5F8C\u9000\u306F\u901A\u5E38\u518D\u751F\u30FB\u30B8\u30C3\u30BF\u30FC\u3068\u3057\u3066\u6271\u3044\u3001\u53D6\u308A\u3053\u307C\u3057\u305F\u9593\u306E\u30AD\u30E5\u30FC\u3082\u767A\u706B\u3057\u307E\u3059\u3002\u8D85\u3048\u3066\u98DB\u3093\u3060\u3089\u982D\u51FA\u3057(\u30B7\u30FC\u30AF)\u3084\u5DFB\u304D\u623B\u3057\u3068\u3057\u3066\u9014\u4E2D\u306E\u30AD\u30E5\u30FC\u306F\u767A\u706B\u3057\u307E\u305B\u3093",children:[n("span",{children:"\u30B8\u30E3\u30F3\u30D7\u5224\u5B9A"}),n("span",{"aria-hidden":"true",children:"\xB1"}),n("input",{class:"inline-input judge-input",type:"number",value:s.receive.triggerWindowFrames,min:"0",step:"1","aria-label":"\u30B8\u30E3\u30F3\u30D7\u5224\u5B9A\uFF08\u30D5\u30EC\u30FC\u30E0\uFF09",onChange:v=>c("receive.setTriggerWindow",{frames:Number(v.currentTarget.value)})}),n("span",{"aria-hidden":"true",children:"f"})]}),n("button",{class:"btn",onClick:()=>r("add"),children:"\uFF0B \u8FFD\u52A0"}),n("button",{class:"btn",disabled:!g().length,onClick:h,children:g().length>1?"\u4E00\u62EC\u7DE8\u96C6":"\u7DE8\u96C6"}),n("button",{class:"btn",disabled:g().length!==1,onClick:()=>c("cue.duplicate",{id:g()[0].id}),children:"\u8907\u88FD"}),n("button",{class:"btn",disabled:g().length!==1,onClick:()=>r("duplicate"),children:"\u9023\u7D9A\u8907\u88FD"}),n("button",{class:"btn",disabled:!g().length,onClick:A,children:"\u524A\u9664"}),n("button",{class:`btn right auto-mute-toggle ${s.transport.autoMuteEnabled?"on":""}`,"aria-pressed":s.transport.autoMuteEnabled,title:"\u30AD\u30E5\u30FC\u767A\u706B\u5F8C\u306E\u81EA\u52D5\u30DF\u30E5\u30FC\u30C8\u3092\u307E\u3068\u3081\u3066\u5165\u5207\u3057\u307E\u3059\u3002\u5207\u308B\u3068\u3001\u30AD\u30E5\u30FC\u3054\u3068\u306E\u300C\u767A\u706B\u6642\u30DF\u30E5\u30FC\u30C8\u300D\u3082\u50CD\u304D\u307E\u305B\u3093",onClick:()=>c("autoMute.setEnabled",{enabled:!s.transport.autoMuteEnabled}),children:["\u30AA\u30FC\u30C8\u30DF\u30E5\u30FC\u30C8 ",s.transport.autoMuteEnabled?"ON":"OFF"]}),n("button",{class:"btn",onClick:()=>c("cue.sortByTime"),children:"\u6642\u9593\u9806"})]}),n("div",{class:"cols",children:["\u6709\u52B9","\u30C8\u30EA\u30AC\u30FC\u6642\u9593","\u30AD\u30E5\u30FC\u540D","OSC\u30A2\u30C9\u30EC\u30B9","\u624B\u52D5"].map((v,D)=>n("span",{children:[v,D<4&&n("i",{class:"resize-handle",onPointerDown:E=>S(D,E)})]}))}),n("div",{class:"list",children:s.cues.map(v=>n("div",{class:`row ${v.id===l.nextCueId?"current":""} ${v.enabled?"":"disabled"} ${p.ui.selectedCueIds.has(v.id)?"selected":""} ${Y.has(v.id)?Y.get(v.id)%2?"fired-a":"fired-b":""}`,tabIndex:0,"aria-label":`${v.name} ${v.effectiveTriggerTime}`,onPointerDown:()=>{Ht=Date.now()},onFocus:()=>{Date.now()-Ht<300||p.ui.selectedCueIds.has(v.id)||k.updateUi({selectedCueIds:new Set([v.id]),focusedCueId:v.id,anchorCueId:v.id})},onClick:D=>w(v.id,D),onDblClick:D=>{D.target.closest("button,input")||h()},children:[n("span",{children:n("input",{type:"checkbox","aria-label":`${v.name}\u3092${v.enabled?"\u7121\u52B9":"\u6709\u52B9"}\u306B\u3059\u308B`,checked:v.enabled,onChange:D=>c("cue.setEnabled",{id:v.id,enabled:D.currentTarget.checked})})}),n("span",{class:"mono",children:v.effectiveTriggerTime}),n("span",{children:[v.name,s.transport.autoMutedCueId===v.id&&n("b",{class:"mute-tag",children:["MUTE",R?` ${R}`:""]})]}),n("span",{class:"mono",children:v.oscAddress}),n("button",{class:"btn fire","aria-label":`${v.name}\u3092\u767A\u706B`,onClick:D=>{D.stopPropagation(),x("cue.fire",{id:v.id}).then(E=>Cn(E,u)).catch(E=>u(E.message))},children:"\u25B6"})]},v.id))}),n("div",{class:"footcue",children:[n("span",{class:"tag",children:"NEXT"}),n("b",{class:"mono",children:s.nextCue?.effectiveTriggerTime}),n("span",{children:s.nextCue?.name})]})]}),n("aside",{class:"side",children:[n("div",{class:"sec",children:[n("div",{class:"head",children:[n("b",{children:"\u52D5\u4F5C\u30E2\u30FC\u30C9"}),n("span",{class:"tiny",children:s.transport.statusText})]}),n("div",{class:"mode",children:[n("button",{class:s.mode==="ltc"?"active":"",onClick:()=>b("ltc"),children:"LTC\u53D7\u4FE1"}),n("button",{class:s.mode==="generate"?"active":"",onClick:()=>b("generate"),children:"\u5185\u90E8\u751F\u6210"})]})]}),s.mode==="ltc"?n(Et,{}):n(xt,{notice:u}),n(It,{notice:u})]})]}),n("footer",{children:[n("span",{children:[n("i",{class:"led"}),s.mode==="ltc"?"LTC INPUT":"LTC GENERATOR"," ",s.transport.locked?"LOCK":"UNLOCK",s.transport.detailText?` \xB7 ${s.transport.detailText}`:""]}),n("button",{class:"btn right","aria-pressed":p.ui.drawerOpen,title:"OSC \u30DD\u30F3\u51FA\u3057\u30D1\u30CD\u30EB\u3092\u53F3\u306B\u958B\u9589\u3057\u307E\u3059",onClick:()=>k.updateUi({drawerOpen:!p.ui.drawerOpen}),children:p.ui.drawerOpen?"\u25E7 OSC \u30DD\u30F3\u51FA\u3057\u3092\u9589\u3058\u308B":"\u25E8 OSC \u30DD\u30F3\u51FA\u3057\u3092\u958B\u304F"})]}),a&&n("div",{class:"toast",onClick:()=>u(""),children:a})]}),n(Pt,{notice:u})]}),p.ui.optionsOpen&&n(At,{notice:u,close:()=>k.updateUi({optionsOpen:!1,modalOpen:!1})})," ",t==="add"&&n(Pe,{frameRate:l.frameRate,hosts:s.hosts,close:T,done:T})," ",t==="edit"&&n(Pe,{cue:g()[0],frameRate:l.frameRate,hosts:s.hosts,close:T,done:T})," ",t==="batch"&&n(St,{ids:g().map(v=>v.id),hosts:s.hosts,frameRate:l.frameRate,close:T,done:T,notice:u})," ",t==="duplicate"&&n(kt,{cue:g()[0],close:T,done:T})," ",t==="remove"&&n(J,{message:`\u9078\u629E\u3057\u305F ${g().length} \u4EF6\u306E\u30AD\u30E5\u30FC\u3092\u524A\u9664\u3057\u307E\u3059\u304B\uFF1F`,close:T,confirm:()=>{c("cue.remove",{ids:g().map(v=>v.id)}),T()}})]})}var q=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),N=e=>typeof e=="number"&&Number.isFinite(e);function Nt(e){return q(e)&&typeof e.raw=="string"&&typeof e.display=="string"&&N(e.totalFrames)&&["24","25","29.97df","30"].includes(String(e.frameRate))&&typeof e.dropFrame=="boolean"&&N(e.receivedAtMonotonicMs)}function xn(e){return!q(e)||e.protocolVersion!==1||typeof e.type!="string"?!1:e.type==="clock"?N(e.seq)&&Nt(e.clock):e.type==="wave"?N(e.seq)&&q(e.wave)&&N(e.wave.sampleRate)&&N(e.wave.windowMs)&&Array.isArray(e.wave.min)&&Array.isArray(e.wave.max)&&e.wave.min.every(N)&&e.wave.max.every(N)&&(e.wave.levelDbfs===null||N(e.wave.levelDbfs)):e.type==="snapshot"?N(e.revision)&&q(e.state)&&typeof e.state.sessionId=="string"&&Array.isArray(e.state.cues)&&q(e.state.transport)&&Nt(e.state.currentClock):e.type==="patch"?N(e.revision)&&N(e.baseRevision)&&q(e.changes):e.type==="result"?typeof e.requestId=="string"&&typeof e.ok=="boolean"&&(e.ok||q(e.error)):!1}function $t(e){try{let t=typeof e=="string"?JSON.parse(e):e;return xn(t)?t:null}catch{return null}}var Fe=(e,t,r,o)=>({id:e,name:t,memo:"",triggerTime:r,effectiveTriggerTime:r,frameRate:"30",oscAddress:o,additionalOscAddresses:[],arguments:[],targetHostIds:["qlab"],enabled:!0,sendTriggerTimeAsSeconds:!1,sendTimecode:null,triggerOffset:null,autoMuteOnFire:!1,autoUnmuteAfter:null,runtime:{lastTriggeredAtUtc:null,flashToken:0}});function On(){return{sessionId:"fake-session",project:{displayName:"show_A.tcb3",filePath:null,dirty:!1,canUndo:!1,canRedo:!1,recentFiles:[]},mode:"ltc",transport:{status:"receiving",statusText:"\u53D7\u4FE1\u4E2D",detailText:"CH 1 \xB7 48 kHz",signalErrorRatePercent:0,locked:!0,triggerMuted:!1,autoMuteEnabled:!1,autoMuteOnManualTrigger:!1,autoMutedCueId:null,autoUnmuteAtUtc:null,lastLtcReceivedAtUtc:null},receive:{selectedDeviceId:"in",devices:[{id:"in",name:"UR44 \u2014 Input 1 / 2",loopback:!1}],offset:"+00:00:00:08",triggerWindowFrames:3,freerunDurationSeconds:1},generator:{running:!1,startTime:"01:00:00:00",loopEndTime:null,frameRate:"30",selectedOutputDeviceId:"out",outputDevices:[{id:"out",name:"UR44 \u2014 Output 1 / 2",loopback:!1}],volume:.4,ltcOutputActive:!1,settingsPendingReset:!1},currentClock:{raw:"01:24:16:00",display:"01:24:16:08",totalFrames:151688,frameRate:"30",dropFrame:!1,receivedAtMonotonicMs:0,nextCueId:"cue-2",framesUntilNextCue:112},nextCue:{id:"cue-2",name:"\u30BF\u30A4\u30C8\u30EB OUT",triggerTime:"01:24:20:00",effectiveTriggerTime:"01:24:20:00",framesUntil:112},cues:[Fe("cue-1","\u672C\u7DE8 IN","01:23:40:00","/qlab/go"),Fe("cue-2","\u30BF\u30A4\u30C8\u30EB OUT","01:24:20:00","/video/title/out")],hosts:[{id:"qlab",name:"QLab \u2014 Main",ipAddress:"192.168.1.20",port:53e3,enabled:!0,reachability:"reachable"},{id:"reso",name:"Resolume \u2014 Stage",ipAddress:"192.168.1.31",port:7e3,enabled:!0,reachability:"reachable"}],cueSync:{oscAddress:"/cuesync",targetHostIds:["qlab","reso"]},triggerPanel:{rows:4,columns:4,buttons:[{id:"go",row:0,column:0,label:"GO",oscAddress:"/go",arguments:[],targetHostIds:["qlab"]}]},logs:[{id:"log-1",timestampUtc:new Date(Date.now()-1e3).toISOString(),message:"fake-host \u3092\u958B\u59CB\u3057\u307E\u3057\u305F",success:!0}],uiCapabilities:{supportsNativeOpenDialog:!1,supportsNativeSaveDialog:!1,platform:"macos"}}}function jt(){let e=On(),t=1,r=0,o=10,i=!0,a=null,u=p=>queueMicrotask(()=>i&&window.tcb.receive(JSON.stringify(p))),d=p=>{let{logsAppend:s,logsReset:l,...g}=p;e={...e,...g},l&&(e.logs=l),s&&(e.logs=[...e.logs,...s]),u({protocolVersion:1,type:"patch",baseRevision:t,revision:++t,changes:p})},m=p=>{let s=JSON.parse(p);if(s.type==="ready"||s.type==="resync"){u({protocolVersion:1,type:"snapshot",revision:t,state:e}),a===null&&(a=window.setInterval(()=>u({protocolVersion:1,type:"clock",seq:++r,clock:{...e.currentClock,receivedAtMonotonicMs:performance.now()}}),100));return}if(s.type!=="command")return;let l=s.args,g=c=>u({protocolVersion:1,type:"result",requestId:s.requestId,ok:!0,data:c,revision:t}),h=c=>u({protocolVersion:1,type:"result",requestId:s.requestId,ok:!1,error:{code:"validation",message:"\u5165\u529B\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044",retryable:!1,fieldErrors:c}}),A=(c,_=!0)=>d({logsAppend:[{id:`log-${++o}`,timestampUtc:new Date().toISOString(),message:c,success:_}]});if(s.command==="mode.set"){let c=l.mode,_=c==="ltc"&&!!e.receive.selectedDeviceId;d({mode:c,transport:{...e.transport,status:_?"receiving":"stopped",statusText:_?"\u53D7\u4FE1\u4E2D":c==="ltc"?"\u505C\u6B62\u4E2D":"\u751F\u6210\u5F85\u6A5F",locked:_}}),g({ltcStarted:_});return}if(s.command==="ltc.stop"){d({transport:{...e.transport,status:"stopped",statusText:"\u505C\u6B62",locked:!1}}),g();return}if(s.command==="receive.selectDevice"&&!(l.deviceId??"")){d({receive:{...e.receive,selectedDeviceId:null},transport:{...e.transport,status:"stopped",statusText:"\u505C\u6B62\u4E2D",locked:!1}}),g();return}if(s.command==="receive.selectDevice"){d({receive:{...e.receive,selectedDeviceId:l.deviceId},transport:{...e.transport,status:"receiving",statusText:"\u53D7\u4FE1\u4E2D",locked:!0}}),g();return}if(s.command==="ltc.start"||s.command==="ltc.reconnect"){d({receive:{...e.receive,selectedDeviceId:l.deviceId??e.receive.selectedDeviceId},transport:{...e.transport,status:"receiving",statusText:"\u53D7\u4FE1\u4E2D",locked:!0}}),g();return}if(s.command==="receive.setFreerunDuration"){d({receive:{...e.receive,freerunDurationSeconds:Number(l.seconds)}}),g();return}if(s.command==="audio.refreshDevices"){d(l.direction==="capture"?{receive:{...e.receive}}:{generator:{...e.generator}}),g();return}if(s.command==="generator.configure"){d({generator:{...e.generator,startTime:l.startTime,loopEndTime:l.loopEndTime??null,frameRate:l.frameRate,selectedOutputDeviceId:l.outputDeviceId||null,volume:l.volume,settingsPendingReset:e.generator.running}}),g();return}if(s.command==="generator.start"||s.command==="generator.stop"){let c=s.command.endsWith("start");d({generator:{...e.generator,running:c,ltcOutputActive:c&&!!e.generator.selectedOutputDeviceId,settingsPendingReset:!1},transport:{...e.transport,status:c?"receiving":"stopped",statusText:c?"\u751F\u6210\u4E2D":"\u505C\u6B62"}}),g();return}if(s.command==="generator.reset"){d({generator:{...e.generator,running:!1,ltcOutputActive:!1,settingsPendingReset:!1},currentClock:{...e.currentClock,raw:e.generator.startTime,display:e.generator.startTime}}),g();return}if(s.command==="host.add"||s.command==="host.update"){let c=l.host,_={...c.name?{}:{"host.name":"\u5FC5\u9808"},...c.ipAddress?{}:{"host.ipAddress":"\u5FC5\u9808"},...c.port>=1&&c.port<=65535?{}:{"host.port":"1\u301C65535"}};if(Object.keys(_).length){h(_);return}let f=s.command==="host.add"?`host-${++o}`:String(l.id),b={id:f,name:c.name,ipAddress:c.ipAddress,port:c.port,enabled:c.enabled??!0,reachability:"unknown"};d({hosts:s.command==="host.add"?[...e.hosts,b]:e.hosts.map(w=>w.id===f?b:w)}),g({id:f});return}if(s.command==="host.remove"){d({hosts:e.hosts.filter(c=>c.id!==l.id)}),g();return}if(s.command==="host.setEnabled"){d({hosts:e.hosts.map(c=>c.id===l.id?{...c,enabled:!!l.enabled}:c)}),g();return}if(s.command==="host.ping"){d({hosts:e.hosts.map(c=>c.id===l.id?{...c,reachability:"reachable"}:c)}),g({reachable:!0,latencyMs:2});return}if(s.command==="triggerPanel.configureGrid"){d({triggerPanel:{...e.triggerPanel,rows:Number(l.rows),columns:Number(l.columns),buttons:e.triggerPanel.buttons.filter(c=>c.rowf.id!==c),_]}}),g({id:c});return}if(s.command==="triggerPanel.removeButton"){d({triggerPanel:{...e.triggerPanel,buttons:e.triggerPanel.buttons.filter(c=>c.id!==l.id)}}),g();return}if(s.command==="triggerPanel.fire"){A(`\u30DD\u30F3\u51FA\u3057: ${e.triggerPanel.buttons.find(c=>c.id===l.id)?.label??l.id}`),g({sent:!0,sentCount:1,skippedHostIds:[],reason:"None"});return}if(s.command==="logs.clear"){d({logsReset:[]}),g();return}if(s.command==="cueSync.configure"){d({cueSync:{...e.cueSync,...l}}),g();return}if(s.command==="cueSync.send"){A("Cue-Sync \u3092\u9001\u4FE1\u3057\u307E\u3057\u305F"),g({sent:!0,sentCount:2,skippedHostIds:[]});return}if(s.command==="cue.add"||s.command==="cue.update"){let c=l.cue,_={...ee(c.frameRate??"30"),...c,additionalOscAddresses:(c.additionalOscAddresses??[]).join(` +`),argumentsText:(c.arguments??[]).map(y=>`${y.type}:${y.value}`).join(` +`),sendTimecode:c.sendTimecode??"",triggerOffset:c.triggerOffset??"",autoUnmuteAfter:c.autoUnmuteAfter??""},f=me(_);if(!f.draft){h(Object.fromEntries(Object.entries(f.errors).map(([y,T])=>[`cue.${y}`,T])));return}let b=s.command==="cue.add"?`cue-${++o}`:String(l.id),w={...Fe(b,f.draft.name,f.draft.triggerTime,f.draft.oscAddress),...f.draft,id:b,effectiveTriggerTime:f.draft.triggerTime};d({cues:s.command==="cue.add"?[...e.cues,w]:e.cues.map(y=>y.id===b?w:y),project:{...e.project,dirty:!0,canUndo:!0}}),g({id:b});return}if(s.command==="cue.remove"){d({cues:e.cues.filter(c=>!l.ids.includes(c.id))}),g();return}if(s.command==="cue.duplicate"){let c=e.cues.find(f=>f.id===l.id),_=[];if(c){let f=Array.from({length:Number(l.count??1)},(b,w)=>{let y=`cue-${++o}`;return _.push(y),{...c,id:y,name:`${c.name} (\u30B3\u30D4\u30FC${w?` ${w+1}`:""})`}});d({cues:[...e.cues,...f]})}g({ids:_});return}if(s.command==="cue.batchUpdate"){d({cues:e.cues.map(c=>l.ids.includes(c.id)?{...c,...l.changes}:c)}),g({updated:l.ids.length,offsetSkipped:0});return}if(s.command.startsWith("project.")){d({...s.command==="project.new"?{cues:[]}:{},project:{...e.project,displayName:s.command==="project.new"?"\u540D\u79F0\u672A\u8A2D\u5B9A.tcb3":e.project.displayName,dirty:!1,canUndo:!1,canRedo:!1}}),g({cancelled:!1});return}if(s.command==="app.undo"||s.command==="app.redo"){d({project:{...e.project,canUndo:s.command==="app.redo",canRedo:s.command==="app.undo"}}),g();return}s.command==="mute.set"&&d({transport:{...e.transport,triggerMuted:!!l.muted}}),s.command==="cue.setEnabled"&&d({cues:e.cues.map(c=>c.id===l.id?{...c,enabled:!!l.enabled}:c)}),g()};return window.invokeCSharpAction=m,{dispose:()=>{i=!1,a!==null&&window.clearInterval(a),window.invokeCSharpAction===m&&delete window.invokeCSharpAction}}}var Ue=!1,Ne=!1;function Rn(){Ne=!0,!Ue&&(Ue=!0,requestAnimationFrame(()=>{Ue=!1,Ne&&(Ne=!1,k.notify())}))}var $e=()=>Q({protocolVersion:1,type:"ready",clientVersion:"3.0.0",capabilities:["clock-latest-only","wave-minmax","m1","m2a","m2b","m3"]});function Lt(e=800){let t=!1,r=null,o=window.setTimeout(()=>{t||window.invokeCSharpAction||(r=jt(),$e())},e);return window.tcb={receive:i=>{let a=$t(i);if(!a)return;if(a.type==="result"){bt(a);return}gt(k.value,a)==="resync"&&Q({protocolVersion:1,type:"resync",currentRevision:k.value.host.revision,reason:"patch baseRevision mismatch"}),Rn()},hostAttached:()=>{t=!0,window.clearTimeout(o),r?.dispose(),r=null,$e()}},$e(),{dispose:()=>{t=!0,window.clearTimeout(o),r?.dispose(),r=null}}}Lt();var Wt=document.getElementById("app");if(!Wt)throw new Error("Missing #app mount point");nt(n(Ut,{}),Wt);})(); diff --git a/src/TimecodeBridge.Web/dist/styles/m3.css b/src/TimecodeBridge.Web/dist/styles/m3.css index 80afc5b..b1601a7 100644 --- a/src/TimecodeBridge.Web/dist/styles/m3.css +++ b/src/TimecodeBridge.Web/dist/styles/m3.css @@ -48,3 +48,4 @@ .auto-mute-toggle.on{border-color:#6a7c7b;background:#2a3334} /* MUTE ボタンの残り秒。本番で離れた位置からでも読めるよう、ボタン本体と同じ大きさで出す */ .major .mute-countdown{margin-left:8px;font-variant-numeric:tabular-nums} +.device-set{position:relative}.device-set .rescan{min-width:calc(6em + 20px)}.scan-progress{position:absolute;left:78px;right:0;bottom:-4px;height:2px;overflow:hidden;background:var(--l);border-radius:1px}.scan-progress>i{display:block;width:30%;height:100%;background:var(--a);animation:scan-slide 1s ease-in-out infinite}@keyframes scan-slide{from{transform:translateX(-100%)}to{transform:translateX(340%)}}@media (prefers-reduced-motion:reduce){.scan-progress>i{width:100%;animation:none;opacity:.6}} diff --git a/src/TimecodeBridge.Web/src/components/receive-panel.tsx b/src/TimecodeBridge.Web/src/components/receive-panel.tsx index 27dfdef..e271cd5 100644 --- a/src/TimecodeBridge.Web/src/components/receive-panel.tsx +++ b/src/TimecodeBridge.Web/src/components/receive-panel.tsx @@ -5,6 +5,8 @@ import {command} from "../commands"; const run=(name:Parameters[0],args:unknown={})=>void command(name,args); export const selectReceiveDevice=(value:string):void=>run("receive.selectDevice",{deviceId:value||null}); +/** 再スキャン。Host は裏のスレッドで列挙し終えてから result を返すので、それまでスキャン中を表示する(失敗は Host のエラー表示に出る) */ +export async function rescanDevices(setScanning:(scanning:boolean)=>void):Promise{setScanning(true);try{await command("audio.refreshDevices",{direction:"capture"})}catch{/* 表示は Host 側 */}finally{setScanning(false)}} export function lastLtcText(status:string,lastReceived:string|null,now=Date.now()):string|null { if(status!=="signalLost"&&status!=="freerun") return null; @@ -17,6 +19,7 @@ export function lastLtcText(status:string,lastReceived:string|null,now=Date.now( export function ReceivePanel():JSX.Element { const s=appStore.value.host.state!,deviceId=s.receive.selectedDeviceId; const[now,setNow]=useState(Date.now()); + const[scanning,setScanning]=useState(false); const showLast=s.transport.status==="signalLost"||s.transport.status==="freerun"; useEffect(()=>{ if(!showLast) return; @@ -25,7 +28,10 @@ export function ReceivePanel():JSX.Element { return()=>window.clearInterval(timer); },[showLast,s.transport.lastLtcReceivedAtUtc]); const lastText=lastLtcText(s.transport.status,s.transport.lastLtcReceivedAtUtc,now); - return
TC 入出力LTC 受信設定
入力 {s.transport.locked?"接続":"未接続"}LTC {s.transport.statusText}{lastText&& {lastText}}{s.transport.signalErrorRatePercent!=null&& 誤り率 {s.transport.signalErrorRatePercent.toFixed(1)}%}○ 出力 停止送出 {s.transport.triggerMuted?"MUTE":"LIVE"}
入力デバイス
接続{deviceId?s.transport.detailText:"入力デバイスを選んでください"}
フリーランrun("receive.setFreerunDuration",{seconds:Number(e.currentTarget.value)})}/>秒
; + return
TC 入出力LTC 受信設定
入力 {s.transport.locked?"接続":"未接続"}LTC {s.transport.statusText}{lastText&& {lastText}}{s.transport.signalErrorRatePercent!=null&& 誤り率 {s.transport.signalErrorRatePercent.toFixed(1)}%}○ 出力 停止送出 {s.transport.triggerMuted?"MUTE":"LIVE"}
入力デバイスvoid rescanDevices(setScanning)}/>
接続{deviceId?s.transport.detailText:"入力デバイスを選んでください"}
フリーランrun("receive.setFreerunDuration",{seconds:Number(e.currentTarget.value)})}/>秒
; } +/** 再スキャンのボタンと、スキャン中に入力デバイス欄の下へ流す帯(進み具合は測れないので不定の帯) */ +export function RescanButton({scanning,onClick}:{scanning:boolean;onClick:()=>void}):JSX.Element {return <>{scanning&&
}} + export function Wave():JSX.Element {const wave=appStore.value.host.wave;if(!wave)return
波形待機中
;const n=Math.min(wave.min.length,wave.max.length),p:string[]=[];for(let i=0;i=0;i--)p.push(`${i/Math.max(1,n-1)*360},${15-(wave.min[i]??0)*14}`);return
} diff --git a/src/TimecodeBridge.Web/src/styles/m3.css b/src/TimecodeBridge.Web/src/styles/m3.css index 80afc5b..b1601a7 100644 --- a/src/TimecodeBridge.Web/src/styles/m3.css +++ b/src/TimecodeBridge.Web/src/styles/m3.css @@ -48,3 +48,4 @@ .auto-mute-toggle.on{border-color:#6a7c7b;background:#2a3334} /* MUTE ボタンの残り秒。本番で離れた位置からでも読めるよう、ボタン本体と同じ大きさで出す */ .major .mute-countdown{margin-left:8px;font-variant-numeric:tabular-nums} +.device-set{position:relative}.device-set .rescan{min-width:calc(6em + 20px)}.scan-progress{position:absolute;left:78px;right:0;bottom:-4px;height:2px;overflow:hidden;background:var(--l);border-radius:1px}.scan-progress>i{display:block;width:30%;height:100%;background:var(--a);animation:scan-slide 1s ease-in-out infinite}@keyframes scan-slide{from{transform:translateX(-100%)}to{transform:translateX(340%)}}@media (prefers-reduced-motion:reduce){.scan-progress>i{width:100%;animation:none;opacity:.6}} diff --git a/src/TimecodeBridge.Web/tests/receive-panel.test.ts b/src/TimecodeBridge.Web/tests/receive-panel.test.ts index 6187a09..c51e202 100644 --- a/src/TimecodeBridge.Web/tests/receive-panel.test.ts +++ b/src/TimecodeBridge.Web/tests/receive-panel.test.ts @@ -1,5 +1,16 @@ import assert from "node:assert/strict"; import test from "node:test"; -import {selectReceiveDevice} from "../src/components/receive-panel"; +import {h} from "preact"; +import render from "preact-render-to-string"; +import {acceptResult} from "../src/commands"; +import {RescanButton,rescanDevices,selectReceiveDevice} from "../src/components/receive-panel"; -test("selecting the empty receive device sends receive.selectDevice with null",()=>{const messages:string[]=[];Object.defineProperty(globalThis,"window",{value:{invokeCSharpAction:(json:string)=>messages.push(json)},writable:true,configurable:true});selectReceiveDevice("");assert.equal(messages.length,1);const message=JSON.parse(messages[0]!);assert.equal(message.command,"receive.selectDevice");assert.deepEqual(message.args,{deviceId:null})}); +function captureMessages():string[]{const messages:string[]=[];Object.defineProperty(globalThis,"window",{value:{invokeCSharpAction:(json:string)=>messages.push(json)},writable:true,configurable:true});return messages} + +test("selecting the empty receive device sends receive.selectDevice with null",()=>{const messages=captureMessages();selectReceiveDevice("");assert.equal(messages.length,1);const message=JSON.parse(messages[0]!);assert.equal(message.command,"receive.selectDevice");assert.deepEqual(message.args,{deviceId:null})}); + +test("rescan shows scanning until the host returns the result",async()=>{const messages=captureMessages();const states:boolean[]=[];const done=rescanDevices(v=>states.push(v));assert.deepEqual(states,[true]);const message=JSON.parse(messages[0]!);assert.equal(message.command,"audio.refreshDevices");assert.deepEqual(message.args,{direction:"capture"});acceptResult({protocolVersion:1,type:"result",requestId:message.requestId,ok:true});await done;assert.deepEqual(states,[true,false])}); + +test("rescan stops showing scanning when the host reports an error",async()=>{const messages=captureMessages();const states:boolean[]=[];const done=rescanDevices(v=>states.push(v));const message=JSON.parse(messages[0]!);acceptResult({protocolVersion:1,type:"result",requestId:message.requestId,ok:false,error:{code:"audioError",message:"x",retryable:true}});await done;assert.deepEqual(states,[true,false])}); + +test("rescan button is disabled with an indeterminate progress bar while scanning",()=>{const idle=render(h(RescanButton,{scanning:false,onClick:()=>{}}));assert.match(idle,/再スキャン/);assert.doesNotMatch(idle,/progressbar/);assert.doesNotMatch(idle,/disabled/);const busy=render(h(RescanButton,{scanning:true,onClick:()=>{}}));assert.match(busy,/スキャン中…/);assert.match(busy,/disabled/);assert.match(busy,/role="progressbar"/)}); diff --git a/tests/TimecodeBridge.Host.Tests/CommandRouterTests.cs b/tests/TimecodeBridge.Host.Tests/CommandRouterTests.cs index 7601ee2..13efe6b 100644 --- a/tests/TimecodeBridge.Host.Tests/CommandRouterTests.cs +++ b/tests/TimecodeBridge.Host.Tests/CommandRouterTests.cs @@ -283,11 +283,11 @@ public void HostAddValidatesAndRegisters() } [AvaloniaFact] - public void HostPingReportsReachabilityAndLatency() + public async Task HostPingReportsReachabilityAndLatency() { var h = new HostHarness(); h.Hosts.AddHost(new OscHost { Id = "lo", Name = "Local", IpAddress = "127.0.0.1", Port = 9000 }); - var r = h.Run("host.ping", """{"id":"lo"}"""); + var r = await h.RunAsync("host.ping", """{"id":"lo"}"""); Assert.True(r.Ok, r.Error?.Message); var data = System.Text.Json.JsonSerializer.SerializeToElement(r.Data, Protocol.Json); Assert.True(data.GetProperty("reachable").GetBoolean()); @@ -328,4 +328,99 @@ public void GeneratorConfigureAndStart() Assert.True(h.Run("generator.stop").Ok); Assert.False(h.State.GeneratorRunning); } + + [AvaloniaFact] + public async Task DeviceListsAreEnumeratedOnceUntilRescan() + { + var h = new HostHarness(); + h.State.BuildSnapshot(); + var afterFirst = h.Devices.Enumerations; + h.State.BuildSnapshot(); + h.Run("mode.set", """{"mode":"generate"}"""); + h.State.SelectedInputDeviceId = "in-1"; + h.Run("mode.set", """{"mode":"ltc"}"""); + h.State.BuildSnapshot(); + Assert.Equal(afterFirst, h.Devices.Enumerations); // 状態を組み立てても、切り替えても列挙し直さない + + h.Devices.Capture.Add(new("in-2", "UR22C", false)); + Assert.DoesNotContain(h.State.BuildSnapshot().Receive.Devices, d => d.Id == "in-2"); + Assert.True((await h.RunAsync("audio.refreshDevices", """{"direction":"capture"}""")).Ok); // 再スキャンで反映 + Assert.Contains(h.State.BuildSnapshot().Receive.Devices, d => d.Id == "in-2"); + } + + [AvaloniaFact(Timeout = 10_000)] + public async Task RescanRunsInBackgroundAndKeepsOldListUntilDone() + { + var h = new HostHarness(); + h.State.BuildSnapshot(); + using var gate = new ManualResetEventSlim(false); + h.Devices.Gate = gate; // 以後の列挙は gate が開くまで終わらない + h.Devices.Capture.Add(new("in-2", "UR22C", false)); + + var rescan = h.RunAsync("audio.refreshDevices", """{"direction":"capture"}"""); + Assert.False(rescan.IsCompleted); // 列挙が終わるまで result を返さない(Web はその間スキャン中を表示する) + Assert.DoesNotContain(h.State.BuildSnapshot().Receive.Devices, d => d.Id == "in-2"); // 列挙中も止まらず古い一覧を返す + Assert.True(h.Run("mode.set", """{"mode":"generate"}""").Ok); // ほかの command も止まらない + + gate.Set(); + Assert.True((await rescan).Ok); + Assert.Contains(h.State.BuildSnapshot().Receive.Devices, d => d.Id == "in-2"); + } + + [AvaloniaFact] + public void SelectingDeviceMissingFromCachedListRescansOnce() + { + var h = new HostHarness(); + h.State.BuildSnapshot(); + h.Devices.Capture.Add(new("in-2", "UR22C", false)); // 起動後に挿したデバイス(再スキャン前) + Assert.True(h.Run("receive.selectDevice", """{"deviceId":"in-2"}""").Ok); + Assert.Contains("StartLtc:in-2:False", h.Engine.Calls); + Assert.Equal(ErrorCode.DeviceNotFound, h.Run("receive.selectDevice", """{"deviceId":"none"}""").Error!.Code); + } + + [AvaloniaFact] + public void GeneratorStartAfterPauseAppliesPendingSettingsInsteadOfResuming() + { + var h = new HostHarness(); + h.Run("generator.configure", """{"startTime":"01:00:00:00","frameRate":"30"}"""); + h.Run("generator.start"); + h.Engine.ActiveSource = TimecodeSourceType.Generator; + h.Engine.CurrentRawTimecode = new TimecodeValue(1, 0, 5, 0, FrameRate.Fps30); + h.Run("generator.stop"); + + Assert.True(h.Run("generator.start").Ok); // 設定を変えていなければ止めた位置から再開 + Assert.Equal("ResumeGenerator", h.Engine.Calls[^1]); + + h.Run("generator.stop"); + h.Run("generator.configure", """{"startTime":"02:00:00:00","frameRate":"25"}"""); + Assert.True(h.State.GeneratorSettingsPending); + Assert.True(h.Run("generator.start").Ok); // 保留中の変更があれば新しい設定で最初から + Assert.Equal("StartGenerator:02:00:00:00", h.Engine.Calls[^1]); + Assert.False(h.State.GeneratorSettingsPending); + } + + [AvaloniaFact] + public void GeneratorResetRebuildsWhenFrameRateChanged() + { + var h = new HostHarness(); + h.Run("generator.configure", """{"startTime":"01:00:00:00","frameRate":"30"}"""); + h.Run("generator.start"); + h.Engine.ActiveSource = TimecodeSourceType.Generator; + h.Engine.FrameRate = FrameRate.Fps30; + + h.Run("generator.configure", """{"startTime":"03:00:00:00"}"""); + Assert.True(h.Run("generator.reset").Ok); // レートが同じなら開始 TC だけ差し替える + Assert.Equal("ResetGenerator:03:00:00:00", h.Engine.Calls[^1]); + + h.Run("generator.configure", """{"frameRate":"24"}"""); + Assert.True(h.Run("generator.reset").Ok); // レートが変われば生成器ごと作り直す + Assert.Equal("StartGenerator:03:00:00:00", h.Engine.Calls[^1]); + Assert.False(h.State.GeneratorSettingsPending); + + h.Run("generator.stop"); + h.Engine.FrameRate = FrameRate.Fps24; + h.Run("generator.configure", """{"frameRate":"25"}"""); + Assert.True(h.Run("generator.reset").Ok); // 一時停止中なら作り直したあと開始位置で止める + Assert.Equal(new[] { "StartGenerator:03:00:00:00", "StopGenerator" }, h.Engine.Calls.TakeLast(2)); + } } diff --git a/tests/TimecodeBridge.Host.Tests/CueEditingCommandTests.cs b/tests/TimecodeBridge.Host.Tests/CueEditingCommandTests.cs index d348e0e..2161017 100644 --- a/tests/TimecodeBridge.Host.Tests/CueEditingCommandTests.cs +++ b/tests/TimecodeBridge.Host.Tests/CueEditingCommandTests.cs @@ -174,7 +174,7 @@ public void SaveThenOpenRoundTripsProjectAndSourceSettings() Assert.False(h.Project.HasUnsavedChanges); var h2 = new HostHarness(); - var r = h2.Run("project.open", $$"""{"path":"{{path.Replace("\\", "/")}}"}"""); + var r = h2.Run("project.open", $$"""{"path":{{JsonSerializer.Serialize(path)}}}"""); Assert.True(r.Ok, r.Error?.Message); Assert.Equal("false", Data(r, "cancelled")); Assert.Single(h2.Cues.Cues); @@ -202,7 +202,7 @@ public void SaveWithExplicitPathWritesWithoutDialog() { var h = new HostHarness(); h.Run("cue.add", """{"cue":{"name":"A","triggerTime":"00:00:01:00","oscAddress":"/a"}}"""); - var r = h.Run("project.saveAs", $$"""{"path":"{{path.Replace("\\", "/")}}"}"""); + var r = h.Run("project.saveAs", $$"""{"path":{{JsonSerializer.Serialize(path)}}}"""); Assert.True(r.Ok, r.Error?.Message); Assert.Equal("false", Data(r, "cancelled")); Assert.True(File.Exists(path)); diff --git a/tests/TimecodeBridge.Host.Tests/Fakes.cs b/tests/TimecodeBridge.Host.Tests/Fakes.cs index 96c0853..db02b10 100644 --- a/tests/TimecodeBridge.Host.Tests/Fakes.cs +++ b/tests/TimecodeBridge.Host.Tests/Fakes.cs @@ -72,8 +72,14 @@ public void Complete(string address, string host, bool success, string? error = public sealed class FakeDeviceService : IAudioDeviceService { - public List Capture { get; } = new() { new("in-1", "Audio Bridge 2-A", false) }; - public List Render { get; } = new() { new("out-1", "Speakers", false), new("loop-1", "Loopback", true) }; - public IReadOnlyList GetCaptureDevices() => Capture; - public IReadOnlyList GetRenderDevices() => Render; + // IAudioDeviceService の契約どおり、ループバック取り込みはキャプチャ側に並ぶ(WindowsAudioDeviceService と同じ) + public List Capture { get; } = new() { new("in-1", "Audio Bridge 2-A", false), new("loop-1", "Loopback", true) }; + public List Render { get; } = new() { new("out-1", "Speakers", false) }; + /// 列挙した回数(実機では 1 回が重い) + public int Enumerations { get; private set; } + /// 設定すると、列挙はこれが開くまで終わらない(実機の遅い列挙の代わり) + public ManualResetEventSlim? Gate { get; set; } + // 実機の列挙と同じく、その時点の写しを返す + public IReadOnlyList GetCaptureDevices() { Gate?.Wait(); Enumerations++; return Capture.ToArray(); } + public IReadOnlyList GetRenderDevices() { Gate?.Wait(); Enumerations++; return Render.ToArray(); } } diff --git a/tests/TimecodeBridge.Host.Tests/HostHarness.cs b/tests/TimecodeBridge.Host.Tests/HostHarness.cs index 3e3a82d..13d7f7e 100644 --- a/tests/TimecodeBridge.Host.Tests/HostHarness.cs +++ b/tests/TimecodeBridge.Host.Tests/HostHarness.cs @@ -26,16 +26,23 @@ public HostHarness() Osc.HostRegistry = Hosts; Cues = new CueManager(Engine, Osc); Panel = new OscTriggerPanelManager(Osc, Hosts); - State = new HostState(Engine, Cues, Hosts, Osc, Panel, Project, Devices, Recent); + State = new HostState(Engine, Cues, Hosts, Osc, Panel, Project, new CachedAudioDeviceService(Devices), Recent); // 本番(App)と同じく一覧を使い回す Projects = new ProjectCoordinator(State, Engine, Cues, Hosts, Panel, Project, Recent); Router = new CommandRouter(State, Engine, Cues, Hosts, Panel, Projects); } - public ResultMessage Run(string command, string argsJson = "{}", string requestId = "r1", long? expectedRevision = null) + public ResultMessage Run(string command, string argsJson = "{}", string requestId = "r1", long? expectedRevision = null) => + RunAsync(command, argsJson, requestId, expectedRevision).GetAwaiter().GetResult(); + + /// + /// 本当に非同期で完了する command(host.ping など)用。 は UI スレッドで同期待ちするため、 + /// 継続が UI スレッドへ戻る command ではデッドロックする(Windows の Ping.SendPingAsync は必ず非同期で完了する)。 + /// + public Task RunAsync(string command, string argsJson = "{}", string requestId = "r1", long? expectedRevision = null) { var revision = expectedRevision is null ? "" : $$""", "expectedRevision":{{expectedRevision}}"""; var json = $$"""{"protocolVersion":1,"type":"command","requestId":"{{requestId}}","command":"{{command}}","args":{{argsJson}}{{revision}}}"""; var msg = JsonSerializer.Deserialize(json, Protocol.Json)!; - return Router.ExecuteAsync(msg).GetAwaiter().GetResult(); + return Router.ExecuteAsync(msg); } } diff --git a/tests/TimecodeBridge.Host.Tests/ProtocolTests.cs b/tests/TimecodeBridge.Host.Tests/ProtocolTests.cs index b9e1a42..c49de2f 100644 --- a/tests/TimecodeBridge.Host.Tests/ProtocolTests.cs +++ b/tests/TimecodeBridge.Host.Tests/ProtocolTests.cs @@ -62,8 +62,9 @@ public void SnapshotSerializesWithoutThrowing() using var doc = JsonDocument.Parse(json); var state = doc.RootElement.GetProperty("state"); Assert.Equal("ltc", state.GetProperty("mode").GetString()); - Assert.Equal(3, state.GetProperty("receive").GetProperty("devices").GetArrayLength()); - Assert.Equal("macos", state.GetProperty("uiCapabilities").GetProperty("platform").GetString()); + var inputs = state.GetProperty("receive").GetProperty("devices").EnumerateArray().Select(d => d.GetProperty("id").GetString()).ToArray(); + Assert.Equal(new[] { "in-1", "loop-1" }, inputs); // 出力専用デバイス(out-1)は入力候補に出さない + Assert.Equal(OperatingSystem.IsWindows() ? "windows" : "macos", state.GetProperty("uiCapabilities").GetProperty("platform").GetString()); Assert.Equal("停止中", state.GetProperty("transport").GetProperty("statusText").GetString()); } } diff --git a/tests/TimecodeBridge.Host.Tests/RecentProjectsStoreTests.cs b/tests/TimecodeBridge.Host.Tests/RecentProjectsStoreTests.cs index 8b3a794..b4225b6 100644 --- a/tests/TimecodeBridge.Host.Tests/RecentProjectsStoreTests.cs +++ b/tests/TimecodeBridge.Host.Tests/RecentProjectsStoreTests.cs @@ -16,7 +16,7 @@ public void AddsToFrontDeduplicatesAndCapsAtTen() for (int i = 0; i < 12; i++) store.Add($"/p/show{i}.json"); store.Add("/p/show3.json"); Assert.Equal(RecentProjectsStore.Max, store.Items.Count); - Assert.Equal("/p/show3.json", store.Items[0]); + Assert.Equal(Path.GetFullPath("/p/show3.json"), store.Items[0]); // Windows では C:\p\show3.json Assert.Equal(1, store.Items.Count(p => p.EndsWith("show3.json"))); var reloaded = new RecentProjectsStore(path, Path.Combine(Path.GetTempPath(), "none.json")); diff --git a/tools/tcb3/smoke-windows.ps1 b/tools/tcb3/smoke-windows.ps1 new file mode 100644 index 0000000..784ce31 --- /dev/null +++ b/tools/tcb3/smoke-windows.ps1 @@ -0,0 +1,178 @@ +<# +.SYNOPSIS + TimecodeBridge v3(Host)の Windows 通し確認。smoke.sh の Windows 版で、jq・pgrep・python は要らない(pwsh 7)。 + 起動 → Web が ready → OSC を発火して受信 → 送信ログと画面を確認 → 撮影、を行い SMOKE PASS / SMOKE FAIL で終わる。 + -LoopbackDevice を付けると 2 つ目の Host でその出力へ LTC を生成し、1 つ目がその出力のループバック取り込みで受信して、 + LTC の時刻でキューが発火し OSC が届くところまで確かめる(VB-Audio Virtual Cable などの聞こえない出力を指定すること)。 +.EXAMPLE + pwsh tools/tcb3/smoke-windows.ps1 # Debug ビルド + pwsh tools/tcb3/smoke-windows.ps1 -Exe publish\TimecodeBridge3.exe # 発行物(CI) + pwsh tools/tcb3/smoke-windows.ps1 -LoopbackDevice "CABLE In 16ch" # LTC 生成 → ループバック受信も +#> +param( + [string]$Exe = (Join-Path $PSScriptRoot '..\..\src\TimecodeBridge.Host\bin\Debug\net8.0\TimecodeBridge3.exe'), + [int]$Port = 47310, + [int]$OscPort = 9110, + [string]$RunDir = (Join-Path ([IO.Path]::GetTempPath()) 'tcb3-smoke'), + [string]$LoopbackDevice = '', + [int]$ReadyTimeoutSec = 60, + [switch]$Keep +) +$ErrorActionPreference = 'Stop' +$script:fails = 0 +function Ok([string]$m) { Write-Host "ok $m" } +function Ng([string]$m) { Write-Host "NG $m"; $script:fails++ } + +function Api([int]$port, [string]$method, [string]$path, [string]$body = $null, [string]$contentType = 'application/json; charset=utf-8') { + $uri = "http://127.0.0.1:$port$path" + if ($null -eq $body) { return Invoke-RestMethod -Uri $uri -Method $method -TimeoutSec 30 } + return Invoke-RestMethod -Uri $uri -Method $method -TimeoutSec 30 -ContentType $contentType -Body ([Text.Encoding]::UTF8.GetBytes($body)) +} +function Cmd([int]$port, [string]$name, $arguments = $null) { + $msg = @{ command = $name } + if ($null -ne $arguments) { $msg.args = $arguments } + return Api $port POST /command ($msg | ConvertTo-Json -Depth 10 -Compress) +} +function Eval([int]$port, [string]$js) { return (Api $port POST /eval $js 'text/plain; charset=utf-8').result } +function State([int]$port) { return (Api $port GET /state).state } +function Clock([int]$port) { return Api $port GET /clock } + +$script:hosts = @() +function Start-Host([int]$port, [string]$name) { + $dir = Join-Path $RunDir $name + New-Item -ItemType Directory -Force (Join-Path $dir 'data') | Out-Null + # 試験用インスタンスが利用者の設定(最近使ったプロジェクト)を書き換えないよう、設定保存先を分ける + $env:TIMECODEBRIDGE_AUTOMATION_PORT = "$port" + $env:TIMECODEBRIDGE_DATA_DIR = Join-Path $dir 'data' + $env:TIMECODEBRIDGE_BRIDGE_TRACE = '1' + try { + $p = Start-Process -FilePath $exePath -WorkingDirectory (Split-Path $exePath) -PassThru ` + -RedirectStandardOutput (Join-Path $dir 'host.log') -RedirectStandardError (Join-Path $dir 'host.err.log') + } + finally { + Remove-Item Env:TIMECODEBRIDGE_AUTOMATION_PORT, Env:TIMECODEBRIDGE_DATA_DIR, Env:TIMECODEBRIDGE_BRIDGE_TRACE -ErrorAction SilentlyContinue + } + $script:hosts += $p + $deadline = (Get-Date).AddSeconds($ReadyTimeoutSec) + while ((Get-Date) -lt $deadline) { + if ($p.HasExited) { + Get-Content (Join-Path $dir 'host.log'), (Join-Path $dir 'host.err.log') -ErrorAction SilentlyContinue | Select-Object -Last 40 | Write-Host + throw "$name(port $port)が起動直後に終了しました(exit $($p.ExitCode))" + } + try { if ((Api $port GET /health).webReady) { Ok "$name 起動 pid=$($p.Id) port=$port"; return $p } } catch { } + Start-Sleep -Milliseconds 500 + } + Get-Content (Join-Path $dir 'host.log') -ErrorAction SilentlyContinue | Select-Object -Last 40 | Write-Host + throw "$name(port $port)が $ReadyTimeoutSec 秒待っても Web ready になりません" +} + +# ウィンドウを PrintWindow(PW_RENDERFULLCONTENT)で撮る。前面化しないので、他のウィンドウに隠れていても WebView の中身が写る +Add-Type -AssemblyName System.Drawing +Add-Type @' +using System; +using System.Runtime.InteropServices; +public static class Tcb3Window { + [StructLayout(LayoutKind.Sequential)] public struct RECT { public int L, T, R, B; } + [DllImport("user32.dll")] public static extern bool SetProcessDpiAwarenessContext(IntPtr v); + [DllImport("user32.dll")] public static extern bool GetWindowRect(IntPtr h, out RECT r); + [DllImport("user32.dll")] public static extern bool PrintWindow(IntPtr h, IntPtr hdc, uint flags); +} +'@ +function Save-Shot([Diagnostics.Process]$p, [string]$out) { + [void][Tcb3Window]::SetProcessDpiAwarenessContext([IntPtr]-4) + $p.Refresh() + $h = $p.MainWindowHandle + if ($h -eq [IntPtr]::Zero) { Ng "撮影: ウィンドウが見つかりません"; return } + $r = New-Object Tcb3Window+RECT + [void][Tcb3Window]::GetWindowRect($h, [ref]$r) + $bmp = New-Object Drawing.Bitmap ([Math]::Max(1, $r.R - $r.L)), ([Math]::Max(1, $r.B - $r.T)) + $g = [Drawing.Graphics]::FromImage($bmp) + $hdc = $g.GetHdc() + $ok = [Tcb3Window]::PrintWindow($h, $hdc, 2) + $g.ReleaseHdc($hdc); $g.Dispose() + $bmp.Save($out, [Drawing.Imaging.ImageFormat]::Png); $bmp.Dispose() + if ($ok) { Ok "撮影 $out" } else { Ng "撮影: PrintWindow が失敗しました" } +} + +# OSC を 1 通受けてアドレスを返す(届かなければ $null)。ループバックだけに束縛するのでファイアウォールの確認は出ない +function Receive-Osc([Net.Sockets.UdpClient]$udp, [int]$timeoutMs) { + $udp.Client.ReceiveTimeout = $timeoutMs + $from = New-Object Net.IPEndPoint ([Net.IPAddress]::Any), 0 + try { $bytes = $udp.Receive([ref]$from) } catch [Net.Sockets.SocketException] { return $null } + $end = [Array]::IndexOf($bytes, [byte]0) + return [Text.Encoding]::ASCII.GetString($bytes, 0, [Math]::Max(0, $end)) +} + +$exePath = (Resolve-Path $Exe).Path +# WebView2 のユーザーデータが実行ファイルの隣に作られていないか(Program Files に入れると書けず表示できない)。以前の実行の残りは数えない +$besideExe = "$exePath.WebView2" +$besideExeExisted = Test-Path $besideExe +New-Item -ItemType Directory -Force $RunDir | Out-Null +$udp = New-Object Net.Sockets.UdpClient (New-Object Net.IPEndPoint ([Net.IPAddress]::Loopback), $OscPort) +try { + $main = Start-Host $Port 'main' + + $s = State $Port + if ($s.uiCapabilities.platform -eq 'windows') { Ok 'uiCapabilities.platform=windows' } else { Ng "platform=$($s.uiCapabilities.platform)" } + if ((Eval $Port "document.body.innerText.includes('キューリスト')") -eq 'true') { Ok 'Web UI が描画されている' } else { Ng 'Web UI に「キューリスト」がありません' } + if ($besideExeExisted -or -not (Test-Path $besideExe)) { Ok 'WebView2 のユーザーデータを実行ファイルの隣に作らない' } else { Ng "WebView2 のユーザーデータが実行ファイルの隣にできた: $besideExe" } + + # ホストとキューを登録し、手動発火した OSC が届くか + $hid = (Cmd $Port host.add @{ host = @{ name = 'smoke'; ipAddress = '127.0.0.1'; port = $OscPort } }).data.id + if ($hid) { Ok "host.add $hid" } else { Ng 'host.add 失敗' } + $ping = Cmd $Port host.ping @{ id = $hid } + if ($ping.ok -and $ping.data.reachable) { Ok "host.ping $($ping.data.latencyMs)ms" } else { Ng "host.ping: $($ping | ConvertTo-Json -Compress)" } + $cue = @{ name = 'smoke-manual'; triggerTime = '00:00:10:00'; oscAddress = '/smoke/manual'; targetHostIds = @($hid); arguments = @(@{ type = 'int32'; value = 1 }, @{ type = 'string'; value = '日本語' }) } + $cid = (Cmd $Port cue.add @{ cue = $cue }).data.id + if ($cid) { Ok "cue.add $cid" } else { Ng 'cue.add 失敗' } + $fire = Cmd $Port cue.fire @{ id = $cid } + if ($fire.ok -and $fire.data.sentCount -eq 1) { Ok 'cue.fire sentCount=1' } else { Ng "cue.fire: $($fire | ConvertTo-Json -Compress)" } + $addr = Receive-Osc $udp 5000 + if ($addr -eq '/smoke/manual') { Ok "OSC 受信 $addr" } else { Ng "OSC が届かない(受信: $addr)" } + Start-Sleep -Milliseconds 500 + $s = State $Port + if ($s.logs | Where-Object { $_.success -and $_.message -like '/smoke/manual*' }) { Ok '送信ログに成功が残る' } else { Ng '送信ログに /smoke/manual がありません' } + if ((Eval $Port "document.body.innerText.includes('smoke-manual')") -eq 'true') { Ok 'キューが画面に出ている' } else { Ng 'キューが画面に出ていません' } + + if ($LoopbackDevice) { + # 2 つ目の Host で LTC を生成してその出力へ流し、1 つ目はその出力のループバック取り込みで受ける + $gen = Start-Host ($Port + 1) 'gen' + $out = (State ($Port + 1)).generator.outputDevices | Where-Object { $_.name -like "*$LoopbackDevice*" } | Select-Object -First 1 + $in = (State $Port).receive.devices | Where-Object { $_.loopback -and $_.name -like "*$LoopbackDevice*" } | Select-Object -First 1 + if (-not $out -or -not $in) { throw "デバイス '$LoopbackDevice' の出力またはループバック入力が見つかりません" } + [void](Cmd ($Port + 1) mode.set @{ mode = 'generate' }) + [void](Cmd ($Port + 1) generator.configure @{ startTime = '01:00:00:00'; frameRate = '30'; outputDeviceId = $out.id; volume = 0.8 }) + [void](Cmd ($Port + 1) generator.start) + [void](Cmd $Port receive.selectDevice @{ deviceId = $in.id }) + $deadline = (Get-Date).AddSeconds(15) + do { Start-Sleep -Milliseconds 500; $t = (State $Port).transport } while ($t.status -ne 'receiving' -and (Get-Date) -lt $deadline) + if ($t.status -eq 'receiving') { Ok "LTC 受信 ($($in.name))" } else { Ng "LTC を受信できない: $($t.statusText) $($t.detailText)" } + $c1 = Clock $Port; Start-Sleep -Seconds 2; $c2 = Clock $Port + if ($c2.totalFrames - $c1.totalFrames -ge 45 -and $c2.frameRate -eq '30') { Ok "時計が進む $($c1.display) → $($c2.display) ($($c2.frameRate)fps)" } else { Ng "時計: $($c1.display) → $($c2.display) $($c2.frameRate)" } + # 誤り率は受信開始からの累計で、開始直後に弾かれる数フレームが最初の数秒は大きく効くので、5 秒以上受けてから見る + Start-Sleep -Seconds 3 + $err = (State $Port).transport.signalErrorRatePercent + if ($null -ne $err -and $err -lt 2) { Ok "誤り率 $([Math]::Round($err, 2))%" } else { Ng "誤り率 $err%" } + + # 受信した LTC の時刻でキューが発火するか(3 秒後) + $f = (Clock $Port).totalFrames + 90 + $trig = '{0:00}:{1:00}:{2:00}:{3:00}' -f [Math]::Floor($f / 108000), ([Math]::Floor($f / 1800) % 60), ([Math]::Floor($f / 30) % 60), ($f % 30) + $lcue = @{ name = 'smoke-ltc'; triggerTime = $trig; frameRate = '30'; oscAddress = '/smoke/ltc'; targetHostIds = @($hid) } + [void](Cmd $Port cue.add @{ cue = $lcue }) + $addr = Receive-Osc $udp 10000 + if ($addr -eq '/smoke/ltc') { Ok "LTC $trig で発火した OSC を受信" } else { Ng "LTC 発火の OSC が届かない(受信: $addr)" } + Save-Shot $gen (Join-Path $RunDir 'smoke-gen.png') + } + + Start-Sleep -Milliseconds 500 + Save-Shot $main (Join-Path $RunDir 'smoke.png') +} +catch { + Ng $_.Exception.Message +} +finally { + $udp.Dispose() + if (-not $Keep) { foreach ($p in $script:hosts) { if (-not $p.HasExited) { Stop-Process -Id $p.Id -Force -ErrorAction SilentlyContinue } } } +} + +if ($script:fails -eq 0) { Write-Host 'SMOKE PASS'; exit 0 } else { Write-Host "SMOKE FAIL ($script:fails)"; exit 1 }