/**
 * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
 * @license MIT
 *
 * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
 * @license MIT
 *
 * Originally forked from (with the author's permission):
 *   Fabrice Bellard's javascript vt100 for jslinux:
 *   http://bellard.org/jslinux/
 *   Copyright (c) 2011 Fabrice Bellard
 */
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
var d=class{constructor(e=new n,t=new s){this._base64=e;this._provider=t}activate(e){this._terminal=e,this._disposable=e.parser.registerOscHandler(52,t=>this._setOrReportClipboard(t))}dispose(){return this._disposable?.dispose()}_readText(e,t){let r=this._base64.encodeText(t);this._terminal?.input(`\x1B]52;${e};${r}\x07`,!1)}_setOrReportClipboard(e){let t=e.split(";");if(t.length<2)return!0;let r=t[0],a=t[1];if(a==="?"){let i=this._provider.readText(r);return i instanceof Promise?i.then(c=>(this._readText(r,c),!0)):(this._readText(r,i),!0)}let p="";try{p=this._base64.decodeText(a)}catch{}let l=this._provider.writeText(r,p);return l instanceof Promise?l.then(()=>!0):!0}},s=class{readText(e){return navigator.clipboard.readText()}writeText(e,t){return navigator.clipboard.writeText(t)}},n=class{encodeText(e){return btoa(e)}decodeText(e){try{return atob(e)}catch{}return""}};export{n as Base64,s as BrowserClipboardProvider,d as ClipboardAddon};
//# sourceMappingURL=addon-clipboard.mjs.map
