import{j as e,r as t}from"./vendor-react-RSDKEZ60.js";import{l as n,i as a,bo as s}from"./c818056db-BBpc4u6S.js";const r=t.createContext({});function o(){return t.useContext(r)}function i({hints:t,children:n}){return e.jsx(r.Provider,{value:t,children:n})}function c(){const e=n(),[a,s]=t.useState(null);return t.useEffect(()=>{const e=window.location.hash.slice(1);s(e)},[e]),a}const d="appearance:backgroundAnimation",u=`LSS-${d}`,f="(prefers-reduced-motion: reduce)";function h(){const[e,t]=a(d,"system"),n=s(f);return{animationMode:e,setAnimationMode:t,shouldAnimate:"enabled"===e||"disabled"!==e&&!n}}function l(){if("undefined"==typeof window)return!0;const e=function(){try{const e=localStorage.getItem(u);if(!e)return"system";const t=JSON.parse(e);if(t&&"object"==typeof t&&"value"in t&&"string"==typeof t.value)return t.value}catch{}return"system"}();return"enabled"===e||"disabled"!==e&&!window.matchMedia(f).matches}function m(e){if("undefined"==typeof window)return()=>{};const t=window.matchMedia(f),n=()=>{e(l())},a=e=>{e.key===u&&n()};return t.addEventListener("change",n),window.addEventListener("storage",a),()=>{t.removeEventListener("change",n),window.removeEventListener("storage",a)}}const w=Object.freeze(Object.defineProperty({__proto__:null,DevMicSource:class{ctx;dest;cache=new Map;manifest;constructor(e={}){this.ctx=new AudioContext({sampleRate:48e3}),this.dest=this.ctx.createMediaStreamDestination(),this.manifest=e}get stream(){return this.dest.stream}async preload(e){await Promise.all(e.map(e=>this.load(e)))}async speakAsUser(e){return this.play(await this.load(e))}async speakBuffer(e){return this.play(await this.ctx.decodeAudioData(e))}async play(e){"suspended"===this.ctx.state&&await this.ctx.resume();const t=this.ctx.createBufferSource();return t.buffer=e,t.connect(this.dest),new Promise(e=>{t.addEventListener("ended",()=>e(),{once:!0}),t.start()})}close(){this.dest.stream.getTracks().forEach(e=>e.stop()),this.ctx.close()}async load(e){const t=this.cache.get(e);if(t)return t;const n=this.manifest[e];if(!n)throw new Error(`DevMicSource: no fixture for utterance ${JSON.stringify(e)}. Generate one with \`yarn workspace @ant/claude-ai gen-dev-utterance ${JSON.stringify(e)}\` and add it to the dev-loop utterance manifest.`);const a=await fetch(n);if(!a.ok)throw new Error(`DevMicSource: failed to fetch ${n} (${a.status})`);const s=await this.ctx.decodeAudioData(await a.arrayBuffer());return this.cache.set(e,s),s}}},Symbol.toStringTag,{value:"Module"}));export{i as A,w as D,c as a,h as b,l as g,m as s,o as u};
