import*as i18n from"../../core/i18n/i18n.js";import*as UI from"../../ui/legacy/legacy.js";const UIStrings={state:"State",sampleRate:"Sample Rate",callbackBufferSize:"Callback Buffer Size",maxOutputChannels:"Max Output Channels",currentTime:"Current Time",callbackInterval:"Callback Interval",renderCapacity:"Render Capacity"},str_=i18n.i18n.registerUIStrings("panels/web_audio/AudioContextContentBuilder.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);export class ContextDetailBuilder{fragment;container;constructor(t){this.fragment=document.createDocumentFragment(),this.container=document.createElement("div"),this.container.classList.add("context-detail-container"),this.fragment.appendChild(this.container),this.build(t)}build(t){const e="realtime"===t.contextType?i18n.i18n.lockedString("AudioContext"):i18n.i18n.lockedString("OfflineAudioContext");this.addTitle(e,t.contextId),this.addEntry(i18nString(UIStrings.state),t.contextState),this.addEntry(i18nString(UIStrings.sampleRate),t.sampleRate,"Hz"),"realtime"===t.contextType&&this.addEntry(i18nString(UIStrings.callbackBufferSize),t.callbackBufferSize,"frames"),this.addEntry(i18nString(UIStrings.maxOutputChannels),t.maxOutputChannelCount,"ch")}addTitle(t,e){this.container.appendChild(UI.Fragment.html`
  <div class="context-detail-header">
  <div class="context-detail-title">${t}</div>
  <div class="context-detail-subtitle">${e}</div>
  </div>
  `)}addEntry(t,e,n){const a=e+(n?` ${n}`:"");this.container.appendChild(UI.Fragment.html`
  <div class="context-detail-row">
  <div class="context-detail-row-entry">${t}</div>
  <div class="context-detail-row-value">${a}</div>
  </div>
  `)}getFragment(){return this.fragment}}export class ContextSummaryBuilder{fragment;constructor(t,e){const n=e.currentTime.toFixed(3),a=(1e3*e.callbackIntervalMean).toFixed(3),i=(1e3*Math.sqrt(e.callbackIntervalVariance)).toFixed(3),r=(100*e.renderCapacity).toFixed(3);this.fragment=document.createDocumentFragment(),this.fragment.appendChild(UI.Fragment.html`
  <div class="context-summary-container">
  <span>${i18nString(UIStrings.currentTime)}: ${n} s</span>
  <span>\u2758</span>
  <span>${i18nString(UIStrings.callbackInterval)}: μ = ${a} ms, σ = ${i} ms</span>
  <span>\u2758</span>
  <span>${i18nString(UIStrings.renderCapacity)}: ${r} %</span>
  </div>
  `)}getFragment(){return this.fragment}}