# Import trial implementation

The exact student request is in `prompt.txt`. This app extends the source files from `../02-events/`. No other app, slides, previous attempts or project history were used.

## Decisions

- The picker accepts MP3 and WAV. Choosing a file reads and decodes it before enabling Add to mixer.
- The selected filename and decoded duration appear before playback. A file selection and Add to mixer remain silent.
- The user chooses Loop or Event and a level before adding. Imported loops start off; imported events start disabled with Trigger now available.
- Import decoding uses native OfflineAudioContext. It does not create or resume the live AudioContext or connect to speakers.
- Imported sounds reuse decoded buffers. They are held only in memory, without uploads or browser storage. The page says that imports disappear on reload or close.
- Imported events use the existing event engine. Each enabled source waits 8–20 seconds initially, plays once, then chooses another wait after it ends. The wait range can be edited. A source cannot overlap itself, and different sources can overlap.
- Disable, Remove and Stop all retain the event engine cancellation rules. Stop all also turns imported loops off. A loop can be removed separately.
- The import level starts at 35%, with output at the inherited 35%. Loop and event levels can be changed after adding.
- Unsupported extensions, empty files, decode failures and invalid durations get a visible explanation. A damaged-file message suggests exporting as MP3 or WAV again.
- A newer file selection supersedes a slower pending decode. Filenames are escaped before insertion into card markup.

## Checks

- `node --test engine.test.mjs`: 9 tests passed. Seven inherited tests cover event timing, overlap, cancellation, edited wait bounds and interaction with loops. Two import tests cover offline decoding, rejected files, silent additions, chosen levels, playback through both modes and Stop all.
- `node --check` passed for app.js, import-engine.js, audio-engine.js and event-engine.js.
- No browser or server was started by this worker. Browser playback, native file selection, visual layout and real MP3/WAV decoding remain for the root agent's verification at `http://127.0.0.1:4191/apps/03-import/`.

## Limits

- File decoding depends on the browser's MP3/WAV codec support. The tests use audio and timer doubles; they do not prove decoding or audible output in a browser.
- Imported audio is decoded fully into memory. There is no persistence, streaming or size cap.
- The first complete implementation is preserved in `attempts/001/`. Its files are a restoration snapshot with paths intended for the app root.
- All changes remain local. This worker made no Git commits, pushes, deployments or remote issues.
