import*as Common from"../common/common.js";import*as SDK from"../sdk/sdk.js";import*as UI from"../ui/ui.js";import{RecordingSession}from"./RecordingSession.js";export class RecorderModel extends SDK.SDKModel.SDKModel{constructor(t){super(t),this._debuggerAgent=t.debuggerAgent(),this._domDebuggerAgent=t.domdebuggerAgent(),this._runtimeAgent=t.runtimeAgent(),this._accessibilityAgent=t.accessibilityAgent(),this._toggleRecordAction=UI.ActionRegistry.ActionRegistry.instance().action("recorder.toggle-recording"),this._state="Idle",this._currentRecordingSession=null,this._indentation=Common.Settings.Settings.instance().moduleSetting("textEditorIndent").get()}async updateState(t){this._state=t,this._toggleRecordAction.setToggled("Recording"===this._state)}isRecording(){return"Recording"===this._state}async toggleRecording(t){"Idle"===this._state?(await this.startRecording(t),await this.updateState("Recording")):"Recording"===this._state&&(await this.stopRecording(),await this.updateState("Idle"))}async startRecording(t){this._currentRecordingSession=new RecordingSession(this.target(),t,this._indentation),await this._currentRecordingSession.start()}async stopRecording(){this._currentRecordingSession&&(this._currentRecordingSession.stop(),this._currentRecordingSession=null)}}SDK.SDKModel.SDKModel.register(RecorderModel,SDK.SDKModel.Capability.None,!1);