phirepass-widgets 0.0.117 → 0.0.118

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.md +1 -12
  2. package/dist/cjs/{index-DehquNXP.js → index-C3v5xmUo.js} +2 -74
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/phirepass-rdp.cjs.entry.js +5 -16
  5. package/dist/cjs/phirepass-sftp-client.cjs.entry.js +1470 -0
  6. package/dist/cjs/phirepass-terminal.cjs.entry.js +4 -4
  7. package/dist/cjs/phirepass-widgets.cjs.js +2 -2
  8. package/dist/cjs/{protocol-BjOgJZ9-.js → protocol-DCBMfc2u.js} +21 -277
  9. package/dist/collection/collection-manifest.json +0 -2
  10. package/dist/collection/common/channel.js +1 -21
  11. package/dist/collection/components/phirepass-rdp/phirepass-rdp.js +13 -36
  12. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.css +0 -122
  13. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.js +31 -181
  14. package/dist/collection/components/phirepass-terminal/phirepass-terminal.js +2 -2
  15. package/dist/collection/phirepass-channel_bg.wasm +0 -0
  16. package/dist/components/index.js +1 -1
  17. package/dist/components/p-CsYQJXY2.js +1 -0
  18. package/dist/components/phirepass-rdp.js +1 -1
  19. package/dist/components/phirepass-sftp-client.js +1 -1
  20. package/dist/components/phirepass-terminal.js +5 -5
  21. package/dist/esm/{index-BinptKL7.js → index-BVOulYtW.js} +2 -74
  22. package/dist/esm/loader.js +3 -3
  23. package/dist/esm/phirepass-rdp.entry.js +5 -16
  24. package/dist/esm/phirepass-sftp-client.entry.js +1468 -0
  25. package/dist/esm/phirepass-terminal.entry.js +4 -4
  26. package/dist/esm/phirepass-widgets.js +3 -3
  27. package/dist/esm/{protocol-BekUePpu.js → protocol-CsYQJXY2.js} +20 -276
  28. package/dist/phirepass-widgets/{p-9e6f9220.entry.js → p-7ea2fdbc.entry.js} +5 -5
  29. package/dist/phirepass-widgets/p-BVOulYtW.js +3 -0
  30. package/dist/phirepass-widgets/p-CsYQJXY2.js +1 -0
  31. package/dist/phirepass-widgets/p-c1c616ca.entry.js +1 -0
  32. package/dist/phirepass-widgets/p-f1bc04a8.entry.js +1 -0
  33. package/dist/phirepass-widgets/phirepass-channel_bg.wasm +0 -0
  34. package/dist/phirepass-widgets/phirepass-widgets.esm.js +1 -1
  35. package/dist/types/common/channel.d.ts +0 -30
  36. package/dist/types/components/phirepass-rdp/phirepass-rdp.d.ts +0 -10
  37. package/dist/types/components/phirepass-sftp-client/phirepass-sftp-client.d.ts +0 -30
  38. package/dist/types/components.d.ts +34 -434
  39. package/package.json +4 -18
  40. package/dist/cjs/phirepass-downloader_3.cjs.entry.js +0 -3823
  41. package/dist/collection/common/fetch.js +0 -44
  42. package/dist/collection/components/phirepass-downloader/form.js +0 -69
  43. package/dist/collection/components/phirepass-downloader/format.js +0 -105
  44. package/dist/collection/components/phirepass-downloader/jobs.js +0 -393
  45. package/dist/collection/components/phirepass-downloader/phirepass-downloader.css +0 -1109
  46. package/dist/collection/components/phirepass-downloader/phirepass-downloader.js +0 -1466
  47. package/dist/collection/components/phirepass-downloader/source.js +0 -120
  48. package/dist/collection/components/phirepass-downloader/views/dialogs.js +0 -34
  49. package/dist/collection/components/phirepass-downloader/views/fetch-form.js +0 -65
  50. package/dist/collection/components/phirepass-downloader/views/icons.js +0 -34
  51. package/dist/collection/components/phirepass-downloader/views/job-row.js +0 -91
  52. package/dist/collection/components/phirepass-downloader/views/notices.js +0 -15
  53. package/dist/collection/components/phirepass-downloader/views/states.js +0 -19
  54. package/dist/collection/components/phirepass-media-player/phirepass-media-player.css +0 -225
  55. package/dist/collection/components/phirepass-media-player/phirepass-media-player.js +0 -549
  56. package/dist/collection/components/phirepass-media-player/player.js +0 -118
  57. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.fetch.js +0 -35
  58. package/dist/collection/testing/fixtures.js +0 -219
  59. package/dist/collection/testing/mock-channel.js +0 -410
  60. package/dist/components/p-B4kFfbHE.js +0 -1
  61. package/dist/components/p-BekUePpu.js +0 -1
  62. package/dist/components/p-DIf-Ru26.js +0 -1
  63. package/dist/components/phirepass-downloader.d.ts +0 -11
  64. package/dist/components/phirepass-downloader.js +0 -1
  65. package/dist/components/phirepass-media-player.d.ts +0 -11
  66. package/dist/components/phirepass-media-player.js +0 -1
  67. package/dist/esm/phirepass-downloader_3.entry.js +0 -3819
  68. package/dist/phirepass-widgets/p-6a192c8d.entry.js +0 -1
  69. package/dist/phirepass-widgets/p-BekUePpu.js +0 -1
  70. package/dist/phirepass-widgets/p-BinptKL7.js +0 -3
  71. package/dist/phirepass-widgets/p-fe1ce8da.entry.js +0 -1
  72. package/dist/types/common/fetch.d.ts +0 -167
  73. package/dist/types/components/phirepass-downloader/form.d.ts +0 -54
  74. package/dist/types/components/phirepass-downloader/format.d.ts +0 -17
  75. package/dist/types/components/phirepass-downloader/jobs.d.ts +0 -123
  76. package/dist/types/components/phirepass-downloader/phirepass-downloader.d.ts +0 -238
  77. package/dist/types/components/phirepass-downloader/source.d.ts +0 -61
  78. package/dist/types/components/phirepass-downloader/views/dialogs.d.ts +0 -52
  79. package/dist/types/components/phirepass-downloader/views/fetch-form.d.ts +0 -31
  80. package/dist/types/components/phirepass-downloader/views/icons.d.ts +0 -5
  81. package/dist/types/components/phirepass-downloader/views/job-row.d.ts +0 -21
  82. package/dist/types/components/phirepass-downloader/views/notices.d.ts +0 -18
  83. package/dist/types/components/phirepass-downloader/views/states.d.ts +0 -38
  84. package/dist/types/components/phirepass-media-player/phirepass-media-player.d.ts +0 -82
  85. package/dist/types/components/phirepass-media-player/player.d.ts +0 -53
  86. package/dist/types/components/phirepass-sftp-client/phirepass-sftp-client.fetch.d.ts +0 -40
  87. package/dist/types/testing/fixtures.d.ts +0 -25
  88. package/dist/types/testing/mock-channel.d.ts +0 -132
@@ -1 +1 @@
1
- import{h as t,t as e,p as i,H as s,c as a,a as o}from"./index.js";import{_ as r,E as n,C as d,a as l,P as c}from"./p-BekUePpu.js";import{d as h,s as b,i as p,D as m}from"./p-B4kFfbHE.js";import{I as g,d as f}from"./p-DIf-Ru26.js";function u(t){return t.endsWith(".phirepass-part")}const y=/\.(mp4|m4v|webm|mkv|mov|mp3|m4a|flac|ogg|oga|opus|wav)$/i;function v(t){const e=t.replace(/\/{2,}/g,"/");return e.length>1?e.replace(/\/+$/,""):e}function x(t,e){return v(t)===v(e)}const w=({count:e,onClick:i})=>t("button",{type:"button",class:"action fetch",onClick:i,title:"Fetch from a link, magnet or torrent","aria-label":"Fetch from a link, magnet or torrent"},t(g,{name:"fetch",size:14}),e>0&&t("span",{class:"badge","aria-label":e+" active"},e)),k=({name:e,busy:i,onCancel:s,onConfirm:a})=>t("section",{class:"delete-modal visible"},t("div",{class:"delete-dialog",role:"dialog","aria-modal":"true","aria-label":"This file is still downloading",tabindex:-1,onKeyDown:t=>{"Escape"===t.key&&s()}},t("div",{class:"title"},"This file is still downloading"),t("div",{class:"message"},"Deleting ",t("span",{class:"file-name inline"},e)," deletes its download."),t("div",{class:"modal-actions"},t("button",{type:"button",class:"btn secondary",onClick:s,disabled:i},"Keep it"),t("button",{type:"button",class:"btn destructive",onClick:a,disabled:i},"Delete download")))),I=({menu:e,onFetch:i,onDownload:s,onRename:a,onDelete:o,onClose:r})=>t("div",{class:"context-backdrop",onClick:r,onContextMenu:t=>(t.preventDefault(),r())},t("div",{class:"context-menu",role:"menu","aria-label":"Actions for "+e.name,style:{left:e.x+"px",top:e.y+"px"},onClick:t=>t.stopPropagation()},t("button",{type:"button",role:"menuitem",class:"primary",onClick:i},t(g,{name:"fetch",size:13})," Download torrent contents here"),t("hr",null),t("button",{type:"button",role:"menuitem",onClick:s},"Download"),t("button",{type:"button",role:"menuitem",onClick:a},"Rename"),t("button",{type:"button",role:"menuitem",class:"danger",onClick:o},"Delete"))),_=i(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.maximizeEvent=a(this,"maximize"),this.connectionStateChanged=a(this,"connectionStateChanged")}get el_host(){return this}channel;domReady=!1;runtimeReady=!1;connected=!1;uploadInputEl;msgId=1;activeUploadToken=0;pendingUploadStarts=new Map;pendingUploadAcks=new Map;pendingDownloadStarts=new Map;activeDownloads=new Map;activeDownloadMsgId;pendingOps=new Map;promptInputEl;editorPath="";editorTextEl;session_id;name="SFTP";description="Client";hideHeader=!1;serverHost="phirepass.com";serverPort=443;allowInsecure=!1;heartbeatInterval=3e4;nodeId;serviceId;token;onNodeIdChange(t,e){this.reset_session_state(),this.channel&&this.channel.is_connected()&&this.close_comms(),t&&(this.open_comms(),this.channel.connect(),this.status="Connecting...")}serverId;channelFactory;onServerIdChange(t,e){this.onNodeIdChange(this.nodeId,this.nodeId)}maximizeEvent;async maximize(){this.max=!this.max}async minimize(){this.max=!1}connectionStateChanged;max=!1;show_login_screen=!1;show_login_screen_username=!1;show_error=!1;error_message="";show_login_screen_password=!1;show_navigation=!1;breadcrumbs=[];current_dir=".";listing=[];show_content=!1;show_loader=!1;version="";status="Disconnected";selected_item=null;show_upload_modal=!1;upload_progress=0;upload_file_name="";upload_speed="--";upload_finished=!1;show_download_modal=!1;download_progress=0;download_file_name="";download_speed="--";download_finished=!1;show_delete_modal=!1;delete_file_name="";delete_loading=!1;delete_is_dir=!1;delete_recursive=!1;delete_error="";prompt_kind=null;prompt_value="";prompt_error="";prompt_busy=!1;chmod_target=null;chmod_mode=0;chmod_error="";chmod_busy=!1;show_editor=!1;editor_name="";editor_text="";editor_saved_text="";editor_busy="";editor_error="";editor_confirm_discard=!1;editor_loaded=!1;filter="";sort_key="name";sort_asc=!0;channel_ready=!1;fetch_count=0;fresh_names=[];part_delete=null;torrent_menu=null;listing_player=null;downloaderEl;fetch_enabled(){return b(this.channel)}stream_base(){return`${this.allowInsecure?"http":"https"}://${this.serverHost}${!this.allowInsecure&&443===this.serverPort||this.allowInsecure&&80===this.serverPort?"":":"+this.serverPort}`}on_fetch_completed(t){x(function(t){return v(t.sub_dir?`${t.dest_root}/${t.sub_dir}`:t.dest_root)}(t),this.current_dir)&&(this.fresh_names=[...this.fresh_names.filter((e=>e!==t.name)),t.name],this.refresh_directory())}on_show_in_folder(t){this.fresh_names=[t.name],x(t.path,this.current_dir)||this.list_breadcrumb(t.path)}async on_row_context_menu(t,e){if("File"!==t.kind||!/\.torrent$/i.test(t.name)||!this.downloaderEl)return;const i=this.item_path(t);if(e.preventDefault(),null===await this.downloaderEl.torrentPathFor(i))return;const s=this.el_host.getBoundingClientRect();this.selected_item=t,this.torrent_menu={x:e.clientX-s.left,y:e.clientY-s.top,path:i,name:t.name}}async play_listing_file(t,e){e.preventDefault(),e.stopPropagation();const i=this.channel;if("function"!=typeof i.send_sftp_open_stream)return;const s=this.item_path(t);try{const e=await this.run_op("play",(t=>i.send_sftp_open_stream(this.nodeId,this.session_id,s,t)));if("Stream"!==e.result||!e.token)throw Error("The node did not open a stream.");this.listing_player={src:`${this.stream_base()}/api/web/stream/${encodeURIComponent(this.nodeId)}/t/${encodeURIComponent(e.token)}`,name:t.name,key:`node:${this.nodeId}:${s}`}}catch(t){this.error_message=this.error_text(t),this.show_error=!0}}listing_can_play(){return"function"==typeof this.channel?.send_sftp_open_stream}toggle_max(){this.maximizeEvent?.emit(!this.max)}async connectedCallback(){this.channelFactory||await r(),this.open_comms(),this.runtimeReady=!0,this.nodeId?this.try_connect():console.warn("Prop node_id is not set. Cannot connect to terminal.")}componentDidLoad(){this.domReady=!0,this.try_connect()}async disconnectedCallback(){this.connected=!1,this.domReady=!1,this.runtimeReady=!1,this.cancel_active_upload(),this.cancel_active_download(),this.clear_pending_operations(),this.close_comms()}next_msg_id(){const t=this.msgId;return this.msgId+=1,t}clear_pending_operations(){this.pendingUploadStarts.forEach((t=>{window.clearTimeout(t.timeout),t.reject(Error("Upload start aborted"))})),this.pendingUploadStarts.clear(),this.pendingUploadAcks.forEach((t=>{window.clearTimeout(t.timeout),t.reject(Error("Upload chunk aborted"))})),this.pendingUploadAcks.clear(),this.pendingDownloadStarts.forEach((t=>{window.clearTimeout(t.timeout),t.reject(Error("Download start aborted"))})),this.pendingDownloadStarts.clear(),this.pendingOps.forEach((t=>{window.clearTimeout(t.timeout),t.reject(Error(`Could not ${t.verb}: the session ended.`))})),this.pendingOps.clear(),this.activeDownloads.clear()}cancel_active_upload(){this.activeUploadToken+=1,this.upload_progress=0,this.upload_finished=!1,this.upload_speed="--"}cancel_active_download(){void 0!==this.activeDownloadMsgId&&this.activeDownloads.delete(this.activeDownloadMsgId),this.activeDownloadMsgId=void 0,this.download_progress=0,this.download_finished=!1,this.download_speed="--"}format_duration(t){if(!Number.isFinite(t)||t<0)return"--";if(t<60)return t.toFixed(0)+"s";const e=Math.floor(t/60);return e<60?`${e}m ${Math.floor(t%60)}s`:`${Math.floor(e/60)}h ${e%60}m`}format_percent(t){return(Number.isFinite(t)?t:0).toFixed(2)+"%"}format_transfer_rate(t){return!Number.isFinite(t)||t<=0?"--":this.format_size(t)+"/s"}update_upload_progress(t,e,i){if(this.upload_progress=Math.max(0,Math.min(100,e>0?t/e*100:0)),t>=e)return this.upload_finished=!0,void(this.upload_speed="--");const s=(performance.now()-i)/1e3,a=s>0?t/s:0;this.upload_speed=this.format_transfer_rate(a);const o=a>0?(e-t)/a:NaN;this.status=`Uploading ${this.format_size(t)} / ${this.format_size(e)} (ETA ${this.format_duration(o)})`}update_download_progress(t,e,i){if(this.download_progress=Math.max(0,Math.min(100,e>0?t/e*100:0)),t>=e)return this.download_finished=!0,void(this.download_speed="--");const s=(Date.now()-i)/1e3,a=s>0?t/s:0;this.download_speed=this.format_transfer_rate(a);const o=a>0?(e-t)/a:NaN;this.status=`Downloading ${this.format_size(t)} / ${this.format_size(e)} (ETA ${this.format_duration(o)})`}connect(){this.connected=!0,this.channel.connect(),this.status="Connecting..."}try_connect(){!this.connected&&this.domReady&&this.runtimeReady&&this.channel&&this.connect()}create_web_socket_endpoint(){const t=this.allowInsecure?"ws":"wss";return this.allowInsecure||443!==this.serverPort?this.allowInsecure&&80===this.serverPort?`${t}://${this.serverHost}`:`${t}://${this.serverHost}:${this.serverPort}`:`${t}://${this.serverHost}`}handle_error(t){if(void 0!==t.msg_id){const e=this.pendingUploadStarts.get(t.msg_id);e&&(window.clearTimeout(e.timeout),e.reject(Error(t.message||"Upload start failed")),this.pendingUploadStarts.delete(t.msg_id));const i=this.pendingDownloadStarts.get(t.msg_id);i&&(window.clearTimeout(i.timeout),i.reject(Error(t.message||"Download start failed")),this.pendingDownloadStarts.delete(t.msg_id)),this.activeDownloads.has(t.msg_id)&&(this.activeDownloads.delete(t.msg_id),this.activeDownloadMsgId===t.msg_id&&(this.activeDownloadMsgId=void 0),this.download_finished=!1);const s=this.pendingOps.get(t.msg_id);if(s)return window.clearTimeout(s.timeout),this.pendingOps.delete(t.msg_id),s.reject(Error(t.message||`Could not ${s.verb}.`)),void(this.show_loader=!1)}switch(t.kind){case n.Generic:case n.Authentication:this.error_message=t.message||"An unknown error occurred.",this.show_error=!0;break;case n.RequiresUsername:this.show_login_screen_username=!0,this.show_login_screen_password=!1,this.show_login_screen=!0;break;case n.RequiresPassword:this.show_login_screen_username=!1,this.show_login_screen_password=!0,this.show_login_screen=!0;break;case n.RequiresUsernamePassword:this.show_login_screen_username=!0,this.show_login_screen_password=!0,this.show_login_screen=!0}setTimeout((()=>{this.show_loader=!1}),1e3)}handle_auth_success(t){this.clear_creds_buffer(),this.version=t.version,this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.channel.open_sftp_tunnel(this.nodeId,this.serviceId),this.status="Connected",this.channel_ready=!0}handle_tunnel_opened(t){this.session_id=t.sid,this.channel.send_sftp_list_data(this.nodeId,this.session_id,this.current_dir)}handle_sftp_list_items(t){setTimeout((()=>{this.show_loader=!1}),500),t.path!==this.current_dir&&(this.filter=""),t.path!==this.current_dir&&(this.fresh_names=[]),this.listing=t.dir.items,this.current_dir=t.path,this.breadcrumbs=t.path.split("/").map(((t,e,i)=>""===t&&0===e?{label:"/",path:"/"}:{label:t,path:i.slice(0,e+1).join("/")})),this.show_content=!0,this.show_navigation=!0,console.log("Received SFTP list items:",t)}handle_upload_start_response(t){if(void 0===t.msg_id)return;const e=this.pendingUploadStarts.get(t.msg_id);e&&(window.clearTimeout(e.timeout),e.resolve(t.response.upload_id),this.pendingUploadStarts.delete(t.msg_id))}handle_upload_chunk_ack(t){const e=`${t.upload_id}_${t.chunk_index}`,i=this.pendingUploadAcks.get(e);i&&(window.clearTimeout(i.timeout),i.resolve(),this.pendingUploadAcks.delete(e))}handle_download_start_response(t){if(void 0===t.msg_id)return;const e=this.pendingDownloadStarts.get(t.msg_id);e&&(window.clearTimeout(e.timeout),e.resolve({download_id:t.response.download_id,total_size:t.response.total_size,total_chunks:t.response.total_chunks}),this.pendingDownloadStarts.delete(t.msg_id))}finalize_download(t){const e=this.activeDownloads.get(t);if(!e)return;const i=Array.from(e.chunks.entries()).sort(((t,e)=>t[0]-e[0])).map((([,t])=>t)).map((t=>new Uint8Array(t))),s=new Blob(i,{type:"application/octet-stream"}),a=URL.createObjectURL(s),o=document.createElement("a");o.href=a,o.download=e.filename,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a),this.activeDownloads.delete(t),this.activeDownloadMsgId===t&&(this.activeDownloadMsgId=void 0),this.download_finished=!0,this.status="Connected"}handle_download_chunk(t){if(void 0===t.msg_id)return;const e=this.activeDownloads.get(t.msg_id);if(!e||!this.session_id)return;const i=new Uint8Array(t.chunk.data);e.chunks.set(t.chunk.chunk_index,i);const s=Array.from(e.chunks.values()).reduce(((t,e)=>t+e.length),0);this.update_download_progress(s,e.total_size,e.startTime),this.channel.send_sftp_download_ack(this.nodeId,this.session_id,e.download_id,t.chunk.chunk_index),e.chunks.size>=e.total_chunks&&this.finalize_download(t.msg_id)}async start_download(t){if(!this.session_id)return;this.selected_item=t,this.download_file_name=t.name,this.download_progress=0,this.download_finished=!1,this.download_speed="--",this.show_download_modal=!0,this.show_error=!1;const e=this.next_msg_id();this.activeDownloadMsgId=e,this.activeDownloads.set(e,{filename:t.name,chunks:new Map,total_chunks:0,total_size:0,download_id:0,startTime:Date.now()});const i=new Promise(((t,i)=>{const s=window.setTimeout((()=>{this.pendingDownloadStarts.delete(e),i(Error("Download start timeout"))}),1e4);this.pendingDownloadStarts.set(e,{timeout:s,resolve:t,reject:i})}));try{this.channel.send_sftp_download_start(this.nodeId,this.session_id,t.path,t.name,e);const{download_id:s,total_chunks:a,total_size:o}=await i,r=this.activeDownloads.get(e);if(!r)return;r.download_id=s,r.total_chunks=a,r.total_size=o}catch(t){this.activeDownloads.delete(e),this.activeDownloadMsgId===e&&(this.activeDownloadMsgId=void 0),this.show_error=!0,this.error_message=t instanceof Error?t.message:"Failed to start download",this.cancel_download()}}async upload_file(t){if(!this.session_id)return;const e=this.activeUploadToken+1;this.activeUploadToken=e,this.upload_file_name=t.name,this.upload_progress=0,this.upload_finished=!1,this.upload_speed="--",this.show_upload_modal=!0,this.show_error=!1,this.status="Uploading...";const i=65536,s=Math.max(1,Math.ceil(t.size/i)),a=this.next_msg_id(),o=new Promise(((t,e)=>{const i=window.setTimeout((()=>{this.pendingUploadStarts.delete(a),e(Error("Upload start timeout"))}),1e4);this.pendingUploadStarts.set(a,{timeout:i,resolve:t,reject:e})}));try{this.channel.send_sftp_upload_start(this.nodeId,this.session_id,t.name,this.current_dir,s,BigInt(t.size),a);const r=await o;let n=0;const d=performance.now();for(let a=0;a<s;a+=1){if(e!==this.activeUploadToken)throw Error("Upload cancelled");const s=a*i,o=Math.min(s+i,t.size),l=new Uint8Array(await t.slice(s,o).arrayBuffer());await new Promise(((t,e)=>{const i=`${r}_${a}`,s=window.setTimeout((()=>{this.pendingUploadAcks.delete(i),e(Error(`Upload chunk ${a+1} timed out`))}),3e4);this.pendingUploadAcks.set(i,{timeout:s,resolve:t,reject:e}),this.channel.send_sftp_upload_chunk(this.nodeId,this.session_id,r,a,l.length,l,null)})),n+=l.length,this.update_upload_progress(n,t.size,d)}this.upload_progress=100,this.upload_finished=!0,this.status="Connected",this.refresh_directory()}catch(t){"Upload cancelled"!==t.message&&(this.show_error=!0,this.error_message=t instanceof Error?t.message:"Upload failed"),this.upload_finished=!1,this.status="Connected"}}handle_op_result(t){if(void 0===t.msg_id)return;const e=this.pendingOps.get(t.msg_id);e&&(window.clearTimeout(e.timeout),this.pendingOps.delete(t.msg_id),e.resolve(t.result))}run_op(t,e,i=3e4){if(!this.session_id)return Promise.reject(Error("No active SFTP session."));const s=this.next_msg_id();return new Promise(((a,o)=>{const r=window.setTimeout((()=>{this.pendingOps.delete(s),o(Error(`Timed out trying to ${t}. This node's agent may be too old to support it.`))}),i);this.pendingOps.set(s,{verb:t,timeout:r,resolve:a,reject:o});try{e(s)}catch(t){window.clearTimeout(r),this.pendingOps.delete(s),o(t instanceof Error?t:Error(t+""))}}))}error_text(t){return t instanceof Error?t.message:t+""}item_path(t){return this.join_path(t.path,t.name)}join_path(t,e){return t&&"/"!==t?t.endsWith("/")?`${t}${e}`:`${t}/${e}`:"/"+e}invalid_name(t){return t?"."===t||".."===t?"That name is reserved.":t.includes("/")?'A name cannot contain "/".':t.includes("\0")?"A name cannot contain a null byte.":"":"Enter a name."}handle_tunnel_data(t){console.log("received tunnel data:",t)}handle_tunnel_closed(t){this.clear_creds_buffer(),this.close_comms()}open_comms(){const t=this.create_web_socket_endpoint()+"/api/web/ws";this.channel=this.channelFactory?this.channelFactory(t,this.nodeId,this.serverId||void 0):this.serverId?new d(t,this.nodeId,this.serverId):new d(t,this.nodeId),this.channel.on_connection_open((()=>{this.connectionStateChanged.emit([l.Connected]),this.channel.authenticate(this.token,this.nodeId),this.status="Authenticating..."})),this.channel.on_connection_close((()=>{this.connectionStateChanged.emit([l.Disconnected]),this.status="Disconnected",this.channel_ready=!1})),this.channel.on_connection_error((t=>{this.connectionStateChanged.emit([l.Error,t]),this.status="Error "+t.message})),this.channel.on_connection_message((()=>{})),this.channel.on_protocol_message((t=>{const{web:e}=t.data;if(p(e)||e.type===c.Error&&(e.msg_id??0)>=m)this.downloaderEl?.receive(t);else switch(e.type){case c.Error:this.handle_error(e);break;case c.AuthSuccess:this.handle_auth_success(e);break;case c.TunnelOpened:this.handle_tunnel_opened(e);break;case c.TunnelClosed:this.handle_tunnel_closed(e);break;case c.TunnelData:this.handle_tunnel_data(e);break;case c.SFTPListItems:this.handle_sftp_list_items(e);break;case c.SFTPUploadStartResponse:this.handle_upload_start_response(e);break;case c.SFTPUploadChunkAck:this.handle_upload_chunk_ack(e);break;case c.SFTPDownloadStartResponse:this.handle_download_start_response(e);break;case c.SFTPDownloadChunk:this.handle_download_chunk(e);break;case c.SFTPOpResult:this.handle_op_result(e);break;default:console.warn("Unhandled protocol message type:",e)}}))}close_comms(){this.cancel_active_upload(),this.cancel_active_download(),this.clear_pending_operations(),this.channel&&(this.channel.stop_heartbeat(),this.channel.disconnect())}clear_creds_buffer(){}reset_session_state(){this.clear_creds_buffer()}list_breadcrumb(t){this.show_loader=!0,this.selected_item=null,this.channel.send_sftp_list_data(this.nodeId,this.session_id,t)}go_to_parent_directory(){this.session_id&&"/"!==this.current_dir&&this.list_breadcrumb(this.breadcrumbs[this.breadcrumbs.length-2]?.path||"/")}refresh_directory(){this.session_id&&this.list_breadcrumb(this.current_dir)}disconnect_session(){this.close_comms(),this.session_id=void 0,this.show_loader=!1,this.show_content=!1,this.breadcrumbs=[],this.current_dir=".",this.listing=[],this.show_navigation=!1,this.show_login_screen_username=!1,this.show_login_screen_password=!1,this.show_login_screen=!1,this.show_upload_modal=!1,this.show_download_modal=!1,this.show_delete_modal=!1,this.upload_progress=0,this.download_progress=0,this.upload_finished=!1,this.download_finished=!1,this.delete_loading=!1,this.delete_file_name="",this.delete_error="",this.delete_is_dir=!1,this.delete_recursive=!1,this.prompt_kind=null,this.prompt_value="",this.prompt_error="",this.prompt_busy=!1,this.chmod_target=null,this.chmod_error="",this.chmod_busy=!1,this.show_editor=!1,this.editor_busy="",this.editor_error="",this.editor_confirm_discard=!1,this.editor_loaded=!1,this.filter="",this.version="",this.status="Disconnected",this.channel_ready=!1,this.part_delete=null,this.torrent_menu=null,this.listing_player=null}on_file_row_action(t,e){e.preventDefault(),e.stopPropagation(),"File"===t.kind&&this.start_download(t)}on_file_delete_action(t,e){e.preventDefault(),e.stopPropagation(),this.selected_item=t,"File"===t.kind&&u(t.name)&&this.downloaderEl?this.downloaderEl.jobForPath(this.item_path(t)).then((e=>{e?this.part_delete={download_id:e.download_id,name:t.name,busy:!1}:this.open_delete_prompt(t)})):this.open_delete_prompt(t)}open_delete_prompt(t){this.delete_file_name=t.name,this.delete_is_dir="Folder"===t.kind,this.delete_recursive=!1,this.delete_error="",this.delete_loading=!1,this.show_delete_modal=!0}cancel_delete(){this.delete_loading||(this.show_delete_modal=!1,this.delete_file_name="",this.delete_error="",this.delete_is_dir=!1,this.delete_recursive=!1)}async confirm_delete(){if(this.delete_loading)return;const t=this.selected_item;if(!this.session_id||!t)return void(this.show_delete_modal=!1);const e=this.item_path(t),i=this.delete_is_dir&&this.delete_recursive;this.delete_loading=!0,this.delete_error="",this.show_error=!1,this.status=`Deleting ${t.name}...`;try{await this.run_op("delete",(t=>this.channel.send_sftp_remove(this.nodeId,this.session_id,e,i,t)),i?3e5:3e4),this.delete_loading=!1,this.show_delete_modal=!1,this.delete_file_name="",this.delete_is_dir=!1,this.delete_recursive=!1,this.status="Connected",this.refresh_directory()}catch(t){this.delete_loading=!1,this.delete_error=this.error_text(t),this.status="Connected"}}open_mkdir(){this.session_id&&(this.prompt_kind="mkdir",this.prompt_value="",this.prompt_error="",this.prompt_busy=!1)}on_rename_action(t,e){e.preventDefault(),e.stopPropagation(),this.session_id&&(this.selected_item=t,this.prompt_kind="rename",this.prompt_value=t.name,this.prompt_error="",this.prompt_busy=!1)}close_prompt(){this.prompt_busy||(this.prompt_kind=null,this.prompt_value="",this.prompt_error="",this.promptInputEl=void 0)}async submit_prompt(){if(this.prompt_busy||!this.session_id)return;const t=this.prompt_kind,e=this.prompt_value.trim(),i=this.invalid_name(e);if(i)return void(this.prompt_error=i);const s=this.selected_item;if("rename"===t&&s&&e===s.name)this.close_prompt();else{this.prompt_busy=!0,this.prompt_error="",this.show_error=!1;try{if("mkdir"===t){const t=this.join_path(this.current_dir,e);this.status=`Creating ${e}...`,await this.run_op("create the folder",(e=>this.channel.send_sftp_mkdir(this.nodeId,this.session_id,t,e)))}else{if("rename"!==t||!s)return this.prompt_busy=!1,void this.close_prompt();{const t=this.item_path(s),i=this.join_path(s.path,e);this.status=`Renaming ${s.name}...`,await this.run_op("rename",(e=>this.channel.send_sftp_rename(this.nodeId,this.session_id,t,i,e)))}}this.prompt_busy=!1,this.prompt_kind=null,this.prompt_value="",this.promptInputEl=void 0,this.status="Connected",this.refresh_directory()}catch(t){this.prompt_busy=!1,this.prompt_error=this.error_text(t),this.status="Connected"}}}on_chmod_action(t,e){e.preventDefault(),e.stopPropagation(),this.session_id&&(this.selected_item=t,this.chmod_target=t,this.chmod_mode=4095&(t.attributes.permissions??0),this.chmod_error="",this.chmod_busy=!1)}close_chmod(){this.chmod_busy||(this.chmod_target=null,this.chmod_error="")}toggle_chmod_bit(t){this.chmod_busy||(this.chmod_mode=4095&(this.chmod_mode^t))}on_chmod_octal_input(t){const e=t.trim();/^[0-7]{1,4}$/.test(e)?(this.chmod_error="",this.chmod_mode=4095&parseInt(e,8)):this.chmod_error="Enter up to four octal digits, 0-7."}async submit_chmod(){const t=this.chmod_target;if(this.chmod_busy||!this.session_id||!t)return;const e=this.item_path(t),i=4095&this.chmod_mode;this.chmod_busy=!0,this.chmod_error="",this.show_error=!1,this.status=`Setting permissions on ${t.name}...`;try{await this.run_op("change permissions",(t=>this.channel.send_sftp_chmod(this.nodeId,this.session_id,e,i,t))),this.chmod_busy=!1,this.chmod_target=null,this.status="Connected",this.refresh_directory()}catch(t){this.chmod_busy=!1,this.chmod_error=this.error_text(t),this.status="Connected"}}async on_edit_action(t,e){if(e.preventDefault(),e.stopPropagation(),!this.session_id||"File"!==t.kind)return;const i=this.item_path(t);this.selected_item=t,this.show_editor=!0,this.editorPath=i,this.editor_name=t.name,this.editor_text="",this.editor_saved_text="",this.editor_error="",this.editor_confirm_discard=!1,this.editor_loaded=!1,this.editor_busy="loading",this.status=`Opening ${t.name}...`;try{const t=await this.run_op("open the file",(t=>this.channel.send_sftp_read_file(this.nodeId,this.session_id,i,t)),6e4);if("FileContents"!==t.result)throw Error("The agent answered without any file contents.");const e=this.decode_text(t.contents instanceof Uint8Array?t.contents:new Uint8Array(t.contents));this.editor_text=e,this.editor_saved_text=e,this.editor_loaded=!0,this.editor_busy="",this.status="Connected"}catch(t){this.editor_busy="",this.editor_error=this.error_text(t),this.status="Connected"}}decode_text(t){if(t.includes(0))throw Error("This looks like a binary file. Download it instead of editing it here.");try{return new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch{throw Error("This file is not valid UTF-8. Download it instead of editing it here.")}}editor_is_dirty(){return this.editor_loaded&&this.editor_text!==this.editor_saved_text}close_editor(t=!1){"saving"!==this.editor_busy&&(t||!this.editor_is_dirty()?(this.show_editor=!1,this.editor_confirm_discard=!1,this.editor_loaded=!1,this.editorPath="",this.editor_name="",this.editor_text="",this.editor_saved_text="",this.editor_error="",this.editor_busy="",this.editorTextEl=void 0):this.editor_confirm_discard=!0)}async save_editor(){if(this.editor_busy||!this.session_id||!this.editorPath)return;const t=this.editorPath,e=this.editor_text;this.editor_busy="saving",this.editor_error="",this.show_error=!1,this.status=`Saving ${this.editor_name}...`;try{await this.run_op("save the file",(i=>this.channel.send_sftp_write_file(this.nodeId,this.session_id,t,(new TextEncoder).encode(e),i)),6e4),this.editor_saved_text=e,this.editor_busy="",this.status="Connected",this.refresh_directory()}catch(t){this.editor_busy="",this.editor_error=this.error_text(t),this.status="Connected"}}toggle_sort(t){this.sort_key!==t?(this.sort_key=t,this.sort_asc=!0):this.sort_asc=!this.sort_asc}visible_listing(){const t=this.filter.trim().toLowerCase(),e=t?this.listing.filter((e=>e.name.toLowerCase().includes(t))):[...this.listing],i=this.sort_asc?1:-1;return e.sort(((t,e)=>{if(t.kind!==e.kind)return"Folder"===t.kind?-1:1;switch(this.sort_key){case"size":return i*((t.attributes.size??0)-(e.attributes.size??0));case"modified":return i*((t.attributes.modified??0)-(e.attributes.modified??0));default:return i*t.name.localeCompare(e.name,void 0,{numeric:!0,sensitivity:"base"})}}))}sort_indicator(t){return this.sort_key!==t?"":this.sort_asc?" ▲":" ▼"}on_listing_keydown(t){if(this.prompt_kind||this.chmod_target||this.show_editor||this.show_delete_modal)return;const e=this.selected_item;switch(t.key){case"Backspace":t.preventDefault(),this.go_to_parent_directory();break;case"F5":t.preventDefault(),this.refresh_directory();break;case"F2":e&&(t.preventDefault(),this.on_rename_action(e,t));break;case"Delete":e&&(t.preventDefault(),this.on_file_delete_action(e,t));break;case"Enter":e&&(t.preventDefault(),this.list_directory(e))}}on_modal_keydown(t,e){"Escape"===t.key&&(t.preventDefault(),t.stopPropagation(),e())}focus_once(t,e,i){t&&t!==e&&(i(t),requestAnimationFrame((()=>t.focus())))}open_upload_picker(){this.uploadInputEl?.click()}on_upload_selected(t){const e=t.target,i=e.files?.[0];i&&(this.upload_file(i),e.value="")}cancel_upload(){this.cancel_active_upload(),this.show_upload_modal=!1,this.upload_file_name="",this.upload_speed="--",this.status="Connected",this.refresh_directory()}cancel_download(){this.cancel_active_download(),this.show_download_modal=!1,this.download_file_name="",this.download_speed="--",this.status="Connected",this.refresh_directory()}is_selected(t){return!!this.selected_item&&this.selected_item.path===t.path&&this.selected_item.name===t.name}list_directory(t){if(!this.session_id)return void console.warn("No active session. Cannot list directory.");if("File"===t.kind)return console.warn("Cannot list directory of a file. Ignoring click."),void(this.selected_item=t);const e=this.item_path(t);e!==this.current_dir?(this.show_loader=!0,this.selected_item=null,this.channel.send_sftp_list_data(this.nodeId,this.session_id,e)):console.warn("Already in this directory. Ignoring click.")}format_size(t){if(void 0===t||Number.isNaN(t))return"-";if(t<1024)return t+" B";let e=t,i=-1;for(;e>=1024&&i<4;)e/=1024,i+=1;return`${e.toFixed(e>=10?1:2)} ${["KB","MB","GB","TB","PB"][i]}`}mode_type_to_char(t,e){switch(61440&t){case 49152:return"s";case 40960:return"l";case 32768:return"-";case 24576:return"b";case 16384:return"d";case 8192:return"c";case 4096:return"p";default:return"Folder"===e?"d":"-"}}format_permissions(t,e){if(null==t)return"-";if("string"==typeof t){const i=t.trim();return/^[bcdlps-][rwxStTs-]{9}$/.test(i)?i:/^[0-7]{3,4}$/.test(i)?this.format_permissions(parseInt(i,8),e):/^\d+$/.test(i)?this.format_permissions(parseInt(i,10),e):i||"-"}const i=t,s=this.mode_type_to_char(i,e),a=[256&i?"r":"-",128&i?"w":"-",64&i?"x":"-",32&i?"r":"-",16&i?"w":"-",8&i?"x":"-",4&i?"r":"-",2&i?"w":"-",1&i?"x":"-"];return 2048&i&&(a[2]="x"===a[2]?"s":"S"),1024&i&&(a[5]="x"===a[5]?"s":"S"),512&i&&(a[8]="x"===a[8]?"t":"T"),`${s}${a.join("")}`}render(){return t(o,{key:"c8a576625404b5653c066c2844160c40cff71603",class:{default:!this.max,max:this.max}},t("section",{key:"87cc1357c8cba09dc857ac0035d701ee46f72ad3",class:"listing"},!this.hideHeader&&t("header",{key:"f034a4a4d6498c8f813174566ce7ff258f6d98fb"},t("section",{key:"ce24941dbd0beffe42d5fa6bad89542d25e57ff8",class:"title"},t("img",{key:"808e0b3f448e15ceb5a7daccce98f9314eb5b758",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoNDYsIDE4NCwgMTM4KSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiCiAgICBjbGFzcz0ibHVjaWRlIGx1Y2lkZS10ZXJtaW5hbCB3LTMuNSBoLTMuNSB0ZXh0LXByaW1hcnkiPgogICAgPHBvbHlsaW5lIHBvaW50cz0iNCAxNyAxMCAxMSA0IDUiPjwvcG9seWxpbmU+CiAgICA8bGluZSB4MT0iMTIiIHgyPSIyMCIgeTE9IjE5IiB5Mj0iMTkiPjwvbGluZT4KPC9zdmc+Cg==",alt:"SFTP Client"}),t("div",{key:"4b4e8244a97167010abc5ba2a518f9c7fd465b39",class:"text"},t("div",{key:"dc32511596fb480ef7fb280941b9de8099b5ff05",class:"name"},this.name),t("div",{key:"fc477ea5670b74c40f4af20022dac4f02bc8b96c",class:"description"},this.description))),t("section",{key:"35beb6cd84dea257e428cca3338db239eed37cdb",class:"actions"},t("div",{key:"7adecc9ecb0a24721fcf6e82f73b58d38946801e",class:"action",onClick:()=>this.toggle_max()},t("img",{key:"e63674064553d3809a1d563bbe6fc83ad0aceb80",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTE1LCAxMjMsIDE0MCkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtbWF4aW1pemUyIHctMyBoLTMiPgogICAgPHBvbHlsaW5lIHBvaW50cz0iMTUgMyAyMSAzIDIxIDkiPjwvcG9seWxpbmU+CiAgICA8cG9seWxpbmUgcG9pbnRzPSI5IDIxIDMgMjEgMyAxNSI+PC9wb2x5bGluZT4KICAgIDxsaW5lIHgxPSIyMSIgeDI9IjE0IiB5MT0iMyIgeTI9IjEwIj48L2xpbmU+CiAgICA8bGluZSB4MT0iMyIgeDI9IjEwIiB5MT0iMjEiIHkyPSIxNCI+PC9saW5lPgo8L3N2Zz4K",alt:"Maximize"})))),t("main",{key:"4bef9055a683d18e391c2620ba2351282a1165ca"},this.show_navigation&&t("nav",{key:"e08ac22ec258e081195785661907d170b86bd83d",class:"navigation"},t("div",{key:"026e32148d4062a7e6be2b58192676dc0102e2dd",class:"breadcrumbs"},this.breadcrumbs.map(((e,i,s)=>t("span",{key:i,class:"breadcrumb-container"},t("span",{key:i,onClick:()=>this.list_breadcrumb(e.path),class:"breadcrumb"},e.label),i<s.length-1&&t("img",{class:"arrow",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIgogICAgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIKICAgIGNsYXNzPSJsdWNpZGUgbHVjaWRlLWNoZXZyb24tcmlnaHQgdy0zIGgtMyB0ZXh0LW11dGVkLWZvcmVncm91bmQvNTAgc2hyaW5rLTAiPgogICAgPHBhdGggZD0ibTkgMTggNi02LTYtNiI+PC9wYXRoPgo8L3N2Zz4K"}))))),t("section",{key:"04f0111d530f2cb9a64bb0557b72820bd13832bf",class:"actions","aria-label":"SFTP actions"},t("input",{key:"fb28f1861a4dd9c83aaa4a20a5d25dde3e6337c7",class:"filter",type:"search",autocorrect:"off",autocapitalize:"none",autoComplete:"off",placeholder:"Filter","aria-label":"Filter this directory",value:this.filter,onInput:t=>this.filter=t.target.value}),t("button",{key:"5e173f8426eee17b08b05547e9ba033746a5a84a",type:"button",class:"action",onClick:()=>this.go_to_parent_directory(),title:"Go to parent directory","aria-label":"Go to parent directory"},t("img",{key:"64ed13f7093abc57f9b73638b902b160d11c1fd3",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtYXJyb3ctdXAgdy0zLjUgaC0zLjUiPgogICAgPHBhdGggZD0ibTUgMTIgNy03IDcgNyI+PC9wYXRoPgogICAgPHBhdGggZD0iTTEyIDE5VjUiPjwvcGF0aD4KPC9zdmc+Cg==",alt:"Go up"})),t("button",{key:"e6a7d97bc089f3b023d06213852aec8e5cd83d18",type:"button",class:"action",onClick:()=>this.refresh_directory(),title:"Refresh","aria-label":"Refresh"},t("img",{key:"66590858743453d7fc0fbb578e98da2a8bc762d5",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtcmVmcmVzaC1jdyB3LTMuNSBoLTMuNSI+CiAgICA8cGF0aCBkPSJNMyAxMmE5IDkgMCAwIDEgOS05IDkuNzUgOS43NSAwIDAgMSA2Ljc0IDIuNzRMMjEgOCI+PC9wYXRoPgogICAgPHBhdGggZD0iTTIxIDN2NWgtNSI+PC9wYXRoPgogICAgPHBhdGggZD0iTTIxIDEyYTkgOSAwIDAgMS05IDkgOS43NSA5Ljc1IDAgMCAxLTYuNzQtMi43NEwzIDE2Ij48L3BhdGg+CiAgICA8cGF0aCBkPSJNOCAxNkgzdjUiPjwvcGF0aD4KPC9zdmc+Cg==",alt:"Refresh"})),t("button",{key:"8eca55beb0377394da8fae85546b25ee74c0f6f9",type:"button",class:"action",onClick:()=>this.open_mkdir(),title:"New folder","aria-label":"New folder"},t("svg",{key:"12d1fc50a9e325a1214462f2a06d734ab38ff1c1",xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},t("path",{key:"7148c12cc461d1778ccfb3e3129786655f780dc2",d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"}),t("line",{key:"a5701765411cff983baa1c4248a383c3a3a9dca6",x1:"12",x2:"12",y1:"10",y2:"16"}),t("line",{key:"9c22835c4279619e8c8cd130007d07ed19795366",x1:"9",x2:"15",y1:"13",y2:"13"}))),this.fetch_enabled()&&t(w,{key:"259d3c2e7bdadac5d1ed77724628459e6c440e09",count:this.fetch_count,onClick:()=>{this.downloaderEl?.openFetch(this.current_dir)}}),t("button",{key:"f744681697e23f2f2892a01b625490fc66999592",type:"button",class:"action",onClick:()=>this.open_upload_picker(),title:"Upload","aria-label":"Upload"},t("img",{key:"bcb2e3f7c283f4213b0a27cb97afd3e61f8d954e",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtdXBsb2FkIHctMy41IGgtMy41Ij4KICAgIDxwYXRoIGQ9Ik0yMSAxNXY0YTIgMiAwIDAgMS0yIDJINWEyIDIgMCAwIDEtMi0ydi00Ij48L3BhdGg+CiAgICA8cG9seWxpbmUgcG9pbnRzPSIxNyA4IDEyIDMgNyA4Ij48L3BvbHlsaW5lPgogICAgPGxpbmUgeDE9IjEyIiB4Mj0iMTIiIHkxPSIzIiB5Mj0iMTUiPjwvbGluZT4KPC9zdmc+Cg==",alt:"Upload"})),t("button",{key:"5348bc25576e559e7b2f05ec6378fe72fc8483f5",type:"button",class:"action disconnect",onClick:()=>this.disconnect_session(),title:"Disconnect","aria-label":"Disconnect"},"DISCONNECT"))),t("input",{key:"7daf75741416f3aeb759ddc6c94106167291d641",type:"file",ref:t=>this.uploadInputEl=t,onChange:t=>this.on_upload_selected(t),style:{display:"none"}}),this.show_content&&t("div",{key:"e384c122d7454b16d13066a7cc6f7f3aa1414feb",class:"content",tabindex:0,onKeyDown:t=>this.on_listing_keydown(t)},t("table",{key:"bd1b14b317290eb59cb867a2bfbf23fb63b2fa94"},t("thead",{key:"c414438b0e8f2a776643bdaaf6441b01ed7c3be3"},t("tr",{key:"fd7d0947644aa0e0eb93d56dfacb8fe545c805f3"},t("th",{key:"8e62f0daaaad938db61b85586aeb138844877ebe",class:"sortable",onClick:()=>this.toggle_sort("name"),title:"Sort by name"},"Name",this.sort_indicator("name")),t("th",{key:"f2d3e287c8f0f97e23c173c10393d0eec4e4a752",class:"sortable",onClick:()=>this.toggle_sort("size"),title:"Sort by size"},"Size",this.sort_indicator("size")),t("th",{key:"d62906a8dd76c22cfcf2c7a82d37ffe8ac3582ba"},"Permissions"),t("th",{key:"d5ce78f188629f956704a70a8d2280a1db945666"},"Owner"),t("th",{key:"42d52536f0c5daa29af06c892c5ca3f79b888216",class:"sortable",onClick:()=>this.toggle_sort("modified"),title:"Sort by modified date"},"Modified",this.sort_indicator("modified")),t("th",{key:"4b80527286d771950be9219387fb938e92f07b63",class:"action-col","aria-label":"Actions"}))),t("tbody",{key:"1959c3f04257c8c1a2e93b4717a6eef9a7999437"},this.visible_listing().map(((e,i)=>t("tr",{key:i,class:{selected:this.is_selected(e),part:"File"===e.kind&&u(e.name),fresh:"File"===e.kind&&this.fresh_names.includes(e.name)},onClick:()=>this.list_directory(e),onContextMenu:t=>{this.on_row_context_menu(e,t)}},t("td",null,t("img","Folder"===e.kind?{class:"kind",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoNDYsIDE4NCwgMTM4KSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiCiAgICBjbGFzcz0ibHVjaWRlIGx1Y2lkZS1mb2xkZXIgdy0zLjUgaC0zLjUgdGV4dC1wcmltYXJ5IHNocmluay0wIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTIwIDIwYTIgMiAwIDAgMCAyLTJWOGEyIDIgMCAwIDAtMi0yaC03LjlhMiAyIDAgMCAxLTEuNjktLjlMOS42IDMuOUEyIDIgMCAwIDAgNy45MyAzSDRhMiAyIDAgMCAwLTIgMnYxM2EyIDIgMCAwIDAgMiAyWiI+PC9wYXRoPgo8L3N2Zz4K",alt:"Folder"}:{class:"kind",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTE1LCAxMjMsIDE0MCkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtZmlsZSB3LTMuNSBoLTMuNSB0ZXh0LW11dGVkLWZvcmVncm91bmQgc2hyaW5rLTAiPgogICAgPHBhdGggZD0iTTE1IDJINmEyIDIgMCAwIDAtMiAydjE2YTIgMiAwIDAgMCAyIDJoMTJhMiAyIDAgMCAwIDItMlY3WiI+PC9wYXRoPgogICAgPHBhdGggZD0iTTE0IDJ2NGEyIDIgMCAwIDAgMiAyaDQiPjwvcGF0aD4KPC9zdmc+Cg==",alt:"File"}),t("span",{class:"name "+e.kind.toLowerCase()},e.name)),t("td",null,"Folder"===e.kind?"-":this.format_size(e.attributes.size)),t("td",null,this.format_permissions(e.attributes.permissions,e.kind)),t("td",null,e.attributes.user??"-"),t("td",null,new Date(1e3*e.attributes.modified).toLocaleString()),t("td",{class:"action-col"},t("div",{class:"file-actions"},"File"===e.kind&&function(t){return y.test(t)&&!u(t)}(e.name)&&this.listing_can_play()&&t("button",{type:"button",class:"file-action",onClick:t=>{this.play_listing_file(e,t)},title:"Play","aria-label":"Play "+e.name},t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true"},t("path",{d:"M7 5v14l12-7z"}))),"File"===e.kind&&t("button",{type:"button",class:"file-action",onClick:t=>this.on_edit_action(e,t),title:"Edit","aria-label":"Edit "+e.name},t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},t("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t("path",{d:"M18.5 2.5a2.12 2.12 0 0 1 3 3L12 15l-4 1 1-4Z"}))),"File"===e.kind&&t("button",{type:"button",class:"file-action",onClick:t=>this.on_file_row_action(e,t),title:"Download","aria-label":"Download "+e.name},t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},t("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),t("polyline",{points:"7 10 12 15 17 10"}),t("line",{x1:"12",x2:"12",y1:"15",y2:"3"}))),t("button",{type:"button",class:"file-action",onClick:t=>this.on_rename_action(e,t),title:"Rename","aria-label":"Rename "+e.name},t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},t("path",{d:"M12 20h9"}),t("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"}))),t("button",{type:"button",class:"file-action",onClick:t=>this.on_chmod_action(e,t),title:"Permissions","aria-label":"Change permissions on "+e.name},t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},t("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),t("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"}))),t("button",{type:"button",class:"file-action delete",onClick:t=>this.on_file_delete_action(e,t),title:"Delete","aria-label":"Delete "+e.name},t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},t("polyline",{points:"3 6 5 6 21 6"}),t("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),t("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),t("line",{x1:"10",x2:"10",y1:"11",y2:"17"}),t("line",{x1:"14",x2:"14",y1:"11",y2:"17"})))))))),0===this.visible_listing().length&&t("tr",{key:"94619eb9cf5506a57c6d085ac6b91d41b7770553",class:"empty"},t("td",{key:"87161e6091cf501364eda0d0b1072a937f8c9946",colSpan:6},this.filter?`Nothing here matches "${this.filter}".`:"This directory is empty."))))),this.show_loader&&t("div",{key:"db0f871976de1f36a72fa947441e0fb1f6051438",class:"loader"},"Loading..."),this.show_error&&t("div",{key:"8870f437cfe246be74479d98f0a0d5a2bc72f781",class:"error"},this.error_message)),this.fetch_enabled()&&t("phirepass-downloader",{key:"917af582cad03523807ef641710f85bd74bb317e",ref:t=>this.downloaderEl=t,compact:!0,channel:this.channel,connected:this.channel_ready,nodeId:this.nodeId,browsingService:this.serviceId,browsingPath:this.current_dir,streamBase:this.stream_base(),onPhirepassActiveCount:t=>this.fetch_count=t.detail.n,onPhirepassFetchCompleted:t=>this.on_fetch_completed(t.detail),onPhirepassShowInFolder:t=>this.on_show_in_folder(t.detail)}),t("footer",{key:"ff3c726b1762ca1789b1f3cd795613d9e64ec445"},t("section",{key:"47e1cbc5a79ee62355136341add2b67456d1a462",class:"status"},this.status,this.selected_item&&t("span",{key:"c828889045b7d0cca91ce0703a577f9a35a708e0",class:"selected-item"},this.selected_item.name)),t("section",{key:"9e16fe486979999adadd80483542709570a5992d",class:"version"},this.version?"Version: "+this.version:""))),this.show_login_screen&&t("section",{key:"4da9c7934d550538c3bd488c7ad455af30ff4e00",class:{creds:!0,blurred:this.show_login_screen}},t("form",{key:"576cc82e5cd90978039e1e644af04194485b86d6",class:"auth",onSubmit:t=>{const e=new FormData(t.target);let i,s;this.show_login_screen_username&&(i=e.get("username")),this.show_login_screen_password&&(s=e.get("password")),this.channel.open_sftp_tunnel(this.nodeId,this.serviceId,i,s),this.show_login_screen_username=!1,this.show_login_screen_password=!1,this.show_login_screen=!1,this.show_loader=!0,t.stopPropagation(),t.preventDefault()}},t("div",{key:"27098f0a63b4ceddd4e0bf0d84b3b3f321a3f512",class:"title"},"SFTP Connection"),this.show_login_screen_username&&t("div",{key:"2714b5b014572d4f58523ddb79bde232bf9b65f1"},t("label",{key:"8f0c73f148cc08fc8db445cd99fbab060807fe12",htmlFor:"username"},"Username"),t("input",{key:"c64fd60eb284e8a77d0943380cb3fcbacbc333fa",autocorrect:"off",autocapitalize:"none",autoComplete:"off",id:"username",name:"username",type:"text",placeholder:""})),this.show_login_screen_password&&t("div",{key:"2d84bbacefcb3b4ba84a9b8ce74bd662fa62c8b3"},t("label",{key:"0ce1b8309229d45ab0f54d5e2de1e40b3fab57f0",htmlFor:"password"},"Password"),t("input",{key:"5752cbe6e72c332be94c0b9a813a66526ab06f3c",autocorrect:"off",autocapitalize:"none",autoComplete:"off",id:"password",name:"password",type:"password",placeholder:""})),t("div",{key:"e272596a07a758d008a90a2c2290e589feeb8b3f"},t("button",{key:"5ddb365a8b700a8d5051539bed3c9aafef20a099",type:"submit"},"Connect")))),this.show_upload_modal&&t("section",{key:"b4314fc5bb3ace26757d690ff4113954144362f6",class:{"upload-modal":!0,visible:this.show_upload_modal}},t("div",{key:"8d152c11c9c27528b667199e6cd66e7129506be6",class:"upload-dialog",role:"dialog","aria-modal":"true","aria-label":"Upload progress"},t("div",{key:"703aa9f78b0248f026ae168d95db2aaaea65a6ce",class:"title"},"Uploading File"),t("div",{key:"8e9bceaea052b871b2b6700684384515260c864c",class:"file-name",title:this.upload_file_name},this.upload_file_name),t("div",{key:"0c3f7be58a562e339dea87904297d0407bddb289",class:"progress-track",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":this.upload_progress},t("div",{key:"e003866966bdae3af7e9321b288dd23424491a16",class:"progress-fill",style:{width:this.upload_progress+"%"}})),t("div",{key:"ac5e45111e0d694b09c4af709378e827288ad418",class:"progress-meta"},t("div",{key:"63e5c77d6af531e49fe9817167d945fc6e80e1be",class:"progress-speed"},this.upload_speed),t("div",{key:"369628aa1ba577c4a4a9fa13930985716830b993",class:"progress-value"},this.format_percent(this.upload_progress))),t("button",{key:"da4984bb0fc81d65a8f2876aa1aaba5dc8ea9da8",type:"button",class:{cancel:!0,finished:this.upload_finished},onClick:()=>this.cancel_upload()},this.upload_finished?"Close":"Cancel"))),this.show_download_modal&&t("section",{key:"88a14959b710af2dcced2fc37b7c404272571084",class:{"download-modal":!0,visible:this.show_download_modal}},t("div",{key:"86bbc1dd32612e7b63c4af35b366fe0a74597ed9",class:"download-dialog",role:"dialog","aria-modal":"true","aria-label":"Download progress"},t("div",{key:"8c3edb4fc04ffaecb3fbd5b6d1aeab4211d7876c",class:"title"},"Downloading File"),t("div",{key:"4815f43687f525c0b6f598e98f9df237a4253dd9",class:"file-name",title:this.download_file_name},this.download_file_name),t("div",{key:"095ac5ffbcb3f4a1bfe5742232752baffb93308e",class:"progress-track",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":this.download_progress},t("div",{key:"6a1f3d4ddbbda2c8a4069b59c7882ddcddee5b4d",class:"progress-fill",style:{width:this.download_progress+"%"}})),t("div",{key:"db52703f7105f26aa4234eb6b623524362ced064",class:"progress-meta"},t("div",{key:"a12b2578badf08fc272f3533db2fd93fa946a4b2",class:"progress-speed"},this.download_speed),t("div",{key:"3b2b1d92c4534d6f7adf01d64a1593af504f98d0",class:"progress-value"},this.format_percent(this.download_progress))),t("button",{key:"f9a668ef58d9566ebaf66ad9219d619005294a6f",type:"button",class:{cancel:!0,finished:this.download_finished},onClick:()=>this.cancel_download()},this.download_finished?"Close":"Cancel"))),this.show_delete_modal&&t("section",{key:"cbcf699a17d748a8a7fa3daf1d96f42e47847bd6",class:{"delete-modal":!0,visible:this.show_delete_modal}},t("div",{key:"3ac99ddba7dc86a7712a4cbb1516254a62f88ef4",class:"delete-dialog",role:"dialog","aria-modal":"true","aria-label":"Delete confirmation",tabindex:-1,onKeyDown:t=>this.on_modal_keydown(t,(()=>this.cancel_delete()))},t("div",{key:"5075e7e7fda69e6941980d3bb257b30bd61d1b03",class:"title"},this.delete_is_dir?"Delete Folder":"Delete File"),t("div",{key:"a9bc63a90afc0f56caccdda8c782abf761b06fa9",class:"message"},this.delete_loading?this.delete_recursive?"Deleting the folder and everything in it...":"Deleting...":`Are you sure you want to delete this ${this.delete_is_dir?"folder":"file"}?`),t("div",{key:"50a72830064fc1352787d6ac761a13e8c6d2d5ce",class:"file-name",title:this.delete_file_name},this.delete_file_name),this.delete_is_dir&&t("label",{key:"528ba9b17f186d54e98fa5abe26d649721880eab",class:"checkline"},t("input",{key:"33dc78531ac4833e95460b93de7d211979a7973b",type:"checkbox",checked:this.delete_recursive,disabled:this.delete_loading,onChange:t=>this.delete_recursive=t.target.checked}),t("span",{key:"68517a96007ba248bbcac1fffaae2b048c4aafaf"},"Delete everything inside it too")),!this.delete_is_dir||this.delete_recursive?null:t("div",{class:"hint"},"Without this, the remote refuses a folder that is not empty."),this.delete_error&&t("div",{key:"fb0df28a4daa756166deec9dd18c0acae8874202",class:"dialog-error"},this.delete_error),this.delete_loading&&t("div",{key:"114fcfea0367efd1f2df2d06beeba2013058ff73",class:"delete-loader","aria-hidden":"true"},t("span",{key:"2b07a71d733ba7606fa45f0d24548b2b63dcc798",class:"spinner"})),t("div",{key:"44cfc262272484fdbd41257c39457d42de6e1f29",class:"modal-actions"},t("button",{key:"5035eb462279fb4e89036a34b5b5b64eee052706",type:"button",class:"btn secondary",onClick:()=>this.cancel_delete(),disabled:this.delete_loading},"Cancel"),t("button",{key:"f16d9f97ce99691c0cfbbad16679bb1dc3affbc9",type:"button",class:"btn destructive",onClick:()=>this.confirm_delete(),disabled:this.delete_loading},this.delete_loading?"Deleting...":"Delete")))),this.prompt_kind&&t("section",{key:"8ee05b491fbc60b2fa9115fa7a88b60960e3326a",class:"prompt-modal visible"},t("div",{key:"46622ceafa285047e2df9082251d7a02e38cb49f",class:"prompt-dialog",role:"dialog","aria-modal":"true","aria-label":"mkdir"===this.prompt_kind?"New folder":"Rename",tabindex:-1,onKeyDown:t=>this.on_modal_keydown(t,(()=>this.close_prompt()))},t("div",{key:"1dce2a864f58590017238fc76810297190dc223f",class:"title"},"mkdir"===this.prompt_kind?"New Folder":"Rename"),t("div",{key:"556e931df541d9ca07a58882cf658572c23276fe",class:"message"},"mkdir"===this.prompt_kind?"Create a folder in "+this.current_dir:"Give it a new name. Existing names are not overwritten."),t("form",{key:"b6a5807b0208576e15468912c48bcdc314cf2d41",onSubmit:t=>{t.preventDefault(),t.stopPropagation(),this.submit_prompt()}},t("input",{key:"d7ad180a2b431046905f37ee8ba21e6933f8eb09",class:"dialog-input",type:"text",autocorrect:"off",autocapitalize:"none",autoComplete:"off",spellcheck:!1,"aria-label":"Name",disabled:this.prompt_busy,value:this.prompt_value,onInput:t=>this.prompt_value=t.target.value,ref:t=>this.focus_once(t,this.promptInputEl,(t=>this.promptInputEl=t))}),this.prompt_error&&t("div",{key:"c0afc0bc34860b1c8bcfea5087d8afca425edf6a",class:"dialog-error"},this.prompt_error),t("div",{key:"91899e1d57a82434cc859e7d90636bd9f1df2545",class:"modal-actions"},t("button",{key:"24f1d359789dbd40e8d98ddf220acf2e5cdbb1e1",type:"button",class:"btn secondary",onClick:()=>this.close_prompt(),disabled:this.prompt_busy},"Cancel"),t("button",{key:"3a5ae8f5edbbe70c226d9ec01d204b0f276607cd",type:"submit",class:"btn primary",disabled:this.prompt_busy},this.prompt_busy?"Working...":"mkdir"===this.prompt_kind?"Create":"Rename"))))),this.chmod_target&&t("section",{key:"3f5daa368a81ae49fd074c33979fad6d9dc1e79f",class:"prompt-modal visible"},t("div",{key:"a2cfc7cbecbead9ccd977e74213c48ba47d5e0f7",class:"prompt-dialog",role:"dialog","aria-modal":"true","aria-label":"Change permissions",tabindex:-1,onKeyDown:t=>this.on_modal_keydown(t,(()=>this.close_chmod()))},t("div",{key:"6db7c2771db3bf9dc4c16c506c95fbadc01b24d5",class:"title"},"Permissions"),t("div",{key:"c6fba2cffb84fd01ac51171ddedc140978652756",class:"file-name",title:this.chmod_target.name},this.chmod_target.name),t("table",{key:"fc871c448ad4ad75754256f0b4d9ce9e5188ea90",class:"perm-grid"},t("thead",{key:"b2de44bba7219257af5e16687f1f9e44b64429b8"},t("tr",{key:"b4e964c7281f8088385d1707df0c638b99c0e1e7"},t("th",{key:"a0bebfa92a96c6276a8c57bbd56555c1c8cacbd2","aria-label":"Class"}),t("th",{key:"c7618c92048861c4ee94d0fb8078c6dd719d9603"},"Read"),t("th",{key:"23d0d6cbf7de82f337d4230e0286174a5fc6bd97"},"Write"),t("th",{key:"fbbe7fafe3aa03ed29db6038157167362c736f9c"},"Execute"))),t("tbody",{key:"5468214c98eb5e6278cade8d46bcae62394d0205"},[{label:"Owner",read:256,write:128,exec:64},{label:"Group",read:32,write:16,exec:8},{label:"Other",read:4,write:2,exec:1}].map((e=>t("tr",{key:e.label},t("th",{scope:"row"},e.label),[e.read,e.write,e.exec].map((i=>t("td",{key:i},t("input",{type:"checkbox","aria-label":`${e.label} ${i}`,disabled:this.chmod_busy,checked:!!(this.chmod_mode&i),onChange:()=>this.toggle_chmod_bit(i)}))))))))),t("div",{key:"61a09c4521472a61f3f7e71fe651cb42f125ed81",class:"perm-special"},[{label:"setuid",bit:2048},{label:"setgid",bit:1024},{label:"sticky",bit:512}].map((e=>t("label",{key:e.label,class:"checkline"},t("input",{type:"checkbox",disabled:this.chmod_busy,checked:!!(this.chmod_mode&e.bit),onChange:()=>this.toggle_chmod_bit(e.bit)}),t("span",null,e.label))))),t("div",{key:"49370f167cbe30ee221f6373d4261571b25be38b",class:"perm-octal"},t("label",{key:"f0b17a2ed4c59cbbaf02cd34cc847c773118faef",htmlFor:"chmod-octal"},"Octal"),t("input",{key:"020ec6003d98553c663cceb92502f6391c60691b",id:"chmod-octal",class:"dialog-input",type:"text",autocorrect:"off",autocapitalize:"none",autoComplete:"off",spellcheck:!1,maxlength:4,disabled:this.chmod_busy,value:this.chmod_mode.toString(8).padStart(4,"0"),onInput:t=>this.on_chmod_octal_input(t.target.value)}),t("span",{key:"4cc7a1cbe4ddfb565f44b5ef3fd116feb879b6c0",class:"perm-preview"},this.format_permissions(this.chmod_mode,this.chmod_target.kind))),this.chmod_error&&t("div",{key:"99cc2d982aef130ea75fa61765d17921186cc2fb",class:"dialog-error"},this.chmod_error),t("div",{key:"d5796750cfa9eb9304340bb9fd091eea7781f3cc",class:"modal-actions"},t("button",{key:"dffe3756b1b4e593ff71663e931df57d53c4a842",type:"button",class:"btn secondary",onClick:()=>this.close_chmod(),disabled:this.chmod_busy},"Cancel"),t("button",{key:"cb30401112b8f500b49e6974dc67ae9065319539",type:"button",class:"btn primary",onClick:()=>{this.submit_chmod()},disabled:this.chmod_busy},this.chmod_busy?"Applying...":"Apply")))),this.show_editor&&t("section",{key:"c9be5edfe1feea95ca51495503dc0c1c3b213d70",class:"editor-modal visible"},t("div",{key:"bf7c2aec8559b42017dc7142bc8a12f0fb4f1c39",class:"editor-dialog",role:"dialog","aria-modal":"true","aria-label":"Editing "+this.editor_name,tabindex:-1,onKeyDown:t=>{if((t.ctrlKey||t.metaKey)&&"s"===t.key)return t.preventDefault(),void this.save_editor();this.on_modal_keydown(t,(()=>this.close_editor()))}},t("div",{key:"fb6c305fc54a7c5f419a133c9477a69b489b77f0",class:"editor-head"},t("div",{key:"9b22c14a92be28cc42ea900b4907d4411f5e3c7d",class:"title"},this.editor_name,this.editor_is_dirty()?" *":""),t("button",{key:"2c800c08e12448ddf3c0f92f34257960ea0ea713",type:"button",class:"editor-close",onClick:()=>this.close_editor(),"aria-label":"Close editor",disabled:"saving"===this.editor_busy},"x")),"loading"===this.editor_busy?t("div",{class:"editor-loading"},"Loading..."):t("textarea",{class:"editor-text",spellcheck:!1,autocorrect:"off",autocapitalize:"none",autoComplete:"off","aria-label":"File contents",disabled:"saving"===this.editor_busy||!this.editor_loaded,value:this.editor_text,onInput:t=>this.editor_text=t.target.value,ref:t=>this.focus_once(t,this.editorTextEl,(t=>this.editorTextEl=t))}),this.editor_error&&t("div",{key:"7918d367cbe8c9a3c179a20f8083b9c4e067ad79",class:"dialog-error"},this.editor_error),this.editor_confirm_discard&&t("div",{key:"6b2ba93692a575bd2c6253dcd7c9abb65807a900",class:"dialog-error"},"Unsaved changes. Close anyway?"),t("div",{key:"879a150fdb6501ad95847a09f984f5acd9301830",class:"modal-actions"},this.editor_confirm_discard?t("button",{type:"button",class:"btn destructive",onClick:()=>this.close_editor(!0)},"Discard"):t("button",{type:"button",class:"btn secondary",onClick:()=>this.close_editor(),disabled:"saving"===this.editor_busy},"Close"),t("button",{key:"e034f852259bcf75f6ba28159706862cfefbe5fa",type:"button",class:"btn primary",onClick:()=>{this.save_editor()},disabled:!!this.editor_busy||!this.editor_is_dirty()},"saving"===this.editor_busy?"Saving...":"Save")))),this.part_delete&&t(k,{key:"e7789b9ddf6e9d7f9e479aa390e7391e61c208f7",name:this.part_delete.name,busy:this.part_delete.busy,onCancel:()=>this.part_delete=null,onConfirm:()=>{const t=this.part_delete;this.part_delete={...t,busy:!0},this.downloaderEl?.deleteDownload(t.download_id).finally((()=>{this.part_delete=null,this.refresh_directory()}))}}),this.torrent_menu&&t(I,{key:"094cd2ab17cf975825db6afefcf205855221a03b",menu:this.torrent_menu,onClose:()=>this.torrent_menu=null,onFetch:()=>{const t=this.torrent_menu.path;this.torrent_menu=null,this.downloaderEl?.startTorrentPath(t)},onDownload:()=>{const t=this.selected_item;this.torrent_menu=null,t&&this.start_download(t)},onRename:()=>{const t=this.selected_item;this.torrent_menu=null,t&&this.on_rename_action(t,new window.Event("click"))},onDelete:()=>{const t=this.selected_item;this.torrent_menu=null,t&&this.on_file_delete_action(t,new window.Event("click"))}}),this.listing_player&&t("section",{key:"f5b06ff083b4af19a7c4cc336d8be172c0e646e1",class:"player-modal visible"},t("phirepass-media-player",{key:"b2770268f3fb6af053a6a52da1e346d8ae3cdda9",src:this.listing_player.src,name:this.listing_player.name,status:"On the node",positionKey:this.listing_player.key,onPhirepassPlayerClose:()=>this.listing_player=null})))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}static get style(){return":host{--radius:0.375rem;--card:220 18% 10%;--border:220 15% 18%;--primary:160 60% 45%;--radius:0.375rem;--destructive:0 70% 50%;--muted:220 15% 13%;--muted-foreground:220 10% 50%;--primary-foreground:220 20% 7%;--scroll-track:220 16% 12%;--scroll-thumb:220 12% 34%;--scroll-thumb-hover:160 45% 44%;font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace;height:100%;width:100%;border:1px solid hsl(var(--border));background-color:hsl(var(--card));border-radius:var(--radius);overflow:hidden;display:flex;flex-direction:column;position:relative;container-type:inline-size;.listing{height:100%;display:flex;flex-direction:column;justify-content:space-between;min-height:0;header{height:30px;background:rgba(28, 31, 38, 0.6);border-bottom:1px solid hsl(var(--border));display:flex;align-items:center;justify-content:space-between;.actions{display:flex;align-items:center;.action{cursor:pointer;padding:4px;display:flex;align-items:center;z-index:1;img{height:14px;padding:4px;border-radius:4px}&:hover{background-color:hsl(var(--border) / 0.6)}}}.title{color:hsl(var(--primary));height:14px;padding:0 12px;display:flex;align-items:center;font-size:0.75rem;line-height:1rem;img{height:14px;margin-right:5px}.text{display:flex;flex-direction:row;justify-content:center;margin-top:2px;.name{margin-right:10px}.description{color:hsl(var(--muted-foreground))}}}}main{flex:1;display:flex;flex-direction:column;position:relative;min-height:0;overflow:hidden;.loader{color:hsl(var(--muted-foreground));font-size:13px;animation:pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;text-align:center;display:flex;align-items:center;justify-content:center;position:absolute;height:100%;width:100%;background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px)}.error{font-size:13px;text-align:center;color:hsl(var(--destructive));height:100%;display:flex;align-items:center;justify-content:center}.navigation{height:25px;padding:10px;font-size:0.75rem;line-height:1rem;background-color:hsl(var(--card));display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid hsl(var(--border));position:sticky;top:0;z-index:3;.breadcrumbs{display:flex;align-items:center;margin-right:10px;.breadcrumb-container{white-space:nowrap;.breadcrumb{color:hsl(var(--primary));margin-right:4px;cursor:pointer;&:after{margin-left:4px}&:hover{color:rgb(189, 219, 209)}&:last-child{margin-right:0;color:rgb(189, 219, 209);cursor:default}}}.arrow{height:12px;width:12px;opacity:0.6;top:2px;margin-right:4px;position:relative}}.actions{display:flex;align-items:center;gap:8px}.filter{height:1.5rem;width:110px;padding:0 6px;font:inherit;font-size:0.68rem;color:rgb(189, 219, 209);background-color:hsl(var(--muted));border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);outline:none;&::placeholder{color:hsl(var(--muted-foreground))}&:focus{border-color:hsl(var(--primary))}}.action{border:none;background:transparent;color:rgb(189, 219, 209);font-size:1.1rem;line-height:1;padding:2px 4px;border-radius:4px;cursor:pointer;&:hover{background-color:hsl(var(--border) / 0.6)}img{height:14px;width:14px;display:block}}.action.disconnect{color:#ff4d5f;font-size:0.65rem;letter-spacing:0.08em;padding:4px 8px;&:hover{color:#ff6b7a;background-color:hsl(var(--destructive) / 0.12)}}}.content{flex:1;min-height:0;outline:none;overflow:auto;font-size:0.75rem;line-height:1rem;scrollbar-width:thin;scrollbar-color:hsl(var(--scroll-thumb)) hsl(var(--scroll-track));&:focus-visible{box-shadow:inset 0 0 0 1px hsl(var(--primary) / 0.5)}&::-webkit-scrollbar{width:10px;height:10px}&::-webkit-scrollbar-track{background:hsl(var(--scroll-track))}&::-webkit-scrollbar-thumb{background:hsl(var(--scroll-thumb));border-radius:999px;border:2px solid hsl(var(--scroll-track))}&::-webkit-scrollbar-thumb:hover{background:hsl(var(--scroll-thumb-hover))}table{width:100%;border-collapse:separate;border-spacing:0;table-layout:auto;thead{background-color:hsl(var(--muted));border-bottom:1px solid hsl(var(--border));th.sortable{cursor:pointer;user-select:none;&:hover{color:hsl(var(--primary))}}th{padding:8px 10px;text-align:left;color:hsl(var(--muted-foreground));position:sticky;top:0;z-index:2;background-color:hsl(var(--muted));border-bottom:1px solid hsl(var(--border));line-height:0.95rem;&.action-col{width:58px;min-width:58px;padding:0 10px}&:first-child{width:30%;min-width:180px;max-width:195px}&:nth-child(2),&:nth-child(3),&:nth-child(4),&:nth-child(5){white-space:nowrap;width:1%}}}tbody{padding:10px 10px;tr.empty{cursor:default;td{color:hsl(var(--muted-foreground));text-align:center;padding:18px 8px}&:hover{background:transparent}}tr{border-bottom:1px solid hsl(var(--border) / 0.4);td{padding:10px 10px 9px;color:hsl(var(--muted-foreground));&:first-child{min-width:180px;max-width:195px;white-space:nowrap;.name{display:inline-block;max-width:calc(100% - 26px);overflow:hidden;text-overflow:ellipsis;vertical-align:middle}}&:nth-child(2),&:nth-child(3),&:nth-child(4),&:nth-child(5){white-space:nowrap}&.action-col{width:58px;min-width:58px;text-align:center;padding-left:1px;padding-right:1px;.file-actions{display:flex;align-items:center;justify-content:center;gap:8px}.file-action{border:none;background:transparent;color:hsl(var(--muted-foreground));width:16px;height:16px;border-radius:3px;cursor:pointer;opacity:0;visibility:hidden;pointer-events:none;transition:opacity 120ms ease;padding:0;svg{width:12px;height:12px;display:block;margin:0 auto}&:hover{color:hsl(var(--primary))}&.delete:hover{color:hsl(var(--destructive))}}}.name{&.file{color:rgb(189, 219, 209)}&.folder{color:hsl(var(--primary))}}.kind{height:14px;width:14px;margin-right:5px;top:3px;position:relative}}&:hover{cursor:pointer;background-color:hsl(var(--muted) / 0.4);td.action-col .file-action{opacity:1;visibility:visible;pointer-events:auto;color:hsl(var(--primary))}}&.selected{background-color:hsl(var(--primary) / 0.3);td.action-col .file-action{opacity:1;visibility:visible;pointer-events:auto}&:hover{background-color:hsl(var(--primary) / 0.4)}}}}}}}footer{height:25px;background:rgba(28, 31, 38, 0.6);border-top:1px solid hsl(var(--border));font-size:0.75rem;line-height:1rem;display:flex;align-items:center;justify-content:space-between;padding:0 10px;.status{font-size:0.65rem;color:hsl(var(--muted-foreground));.selected-item{margin-left:10px;color:hsl(var(--primary))}}.version{font-size:0.65rem;color:hsl(var(--muted-foreground))}}}.creds{position:absolute;top:0;left:0;height:100%;width:100%;display:flex;justify-content:center;align-items:center;;&.blurred{background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px)}.auth{display:flex;flex-direction:column;background:hsl(var(--card));position:relative;background-color:rgba(21, 24, 30, 0.95);border:1px solid hsl(var(--border));padding:30px;box-shadow:rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0.5) 0px 25px 50px -12px;border-radius:var(--radius);.title{margin-bottom:12px;color:hsl(var(--primary))}label{font-size:0.75rem;line-height:1rem;margin-bottom:1rem;color:hsl(var(--muted-foreground))}input{font-size:0.875rem;line-height:1.25rem;padding-top:0.5rem;padding-bottom:0.5rem;padding-left:0.75rem;padding-right:0.75rem;background-color:rgb(28, 31, 38);border-color:rgb(39, 44, 53);border-width:1px;border-radius:calc(var(--radius) - 2px);width:100%;margin-bottom:12px;color:rgb(189, 219, 209);box-sizing:border-box;&:focus{outline:none;border-color:hsl(var(--primary));box-shadow:0 0 0 1px hsl(var(--primary))}}button[type='submit']{margin-top:12px;width:100%;background-color:hsl(var(--primary));color:hsl(var(--primary-foreground));letter-spacing:0.05em;font-size:13px;font-weight:500;padding:0.5rem 1rem;border-radius:calc(var(--radius) - 2px);height:2rem;cursor:pointer;border:none;&:hover{background-color:hsl(var(--primary) / 0.9)}}}}.upload-modal,.download-modal,.delete-modal,.prompt-modal{position:absolute;inset:0;display:none;align-items:center;justify-content:center;background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px);z-index:6;&.visible{display:flex}.upload-dialog,.download-dialog,.delete-dialog,.prompt-dialog{width:min(360px, calc(100% - 24px));background-color:rgba(21, 24, 30, 0.96);border:1px solid hsl(var(--border));border-radius:var(--radius);padding:16px;box-shadow:rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0.5) 0px 25px 50px -12px;.title{color:hsl(var(--primary));font-size:0.8rem;margin-bottom:8px}.file-name{color:rgb(189, 219, 209);font-size:0.72rem;line-height:1rem;margin-bottom:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.progress-track{width:100%;height:10px;border-radius:999px;background-color:hsl(var(--muted));overflow:hidden;border:1px solid hsl(var(--border));.progress-fill{height:100%;width:0;background:linear-gradient(90deg, hsl(var(--primary) / 0.7), hsl(var(--primary)));transition:width 140ms ease}}.progress-meta{margin-top:8px;margin-bottom:12px;display:flex;align-items:center;justify-content:space-between;gap:10px}.progress-speed{color:hsl(var(--muted-foreground));font-size:0.75rem;font-variant-numeric:tabular-nums;line-height:1.4;text-align:left}.progress-value{color:hsl(var(--muted-foreground));font-size:0.75rem;font-variant-numeric:tabular-nums;line-height:1.4;text-align:right}.cancel{margin-top:14px;width:100%;height:2rem;border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);background:hsl(var(--muted));color:rgb(189, 219, 209);font-size:0.75rem;letter-spacing:0.03em;cursor:pointer;&:hover{border-color:hsl(var(--primary));color:hsl(var(--primary))}&.finished{background-color:hsl(var(--primary));border-color:hsl(var(--primary));color:hsl(var(--primary-foreground));&:hover{background-color:hsl(var(--primary) / 0.9);border-color:hsl(var(--primary) / 0.9);color:hsl(var(--primary-foreground))}}}.message{color:rgb(189, 219, 209);font-size:0.74rem;line-height:1rem;margin-bottom:8px}.modal-actions{margin-top:14px;display:grid;grid-template-columns:1fr 1fr;gap:8px;.btn{height:2rem;border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);font-size:0.75rem;letter-spacing:0.03em;cursor:pointer;&:disabled{opacity:0.65;cursor:not-allowed}}.btn.secondary{background:hsl(var(--muted));color:rgb(189, 219, 209);&:hover{border-color:hsl(var(--primary));color:hsl(var(--primary))}}.btn.destructive{background:hsl(var(--destructive));border-color:hsl(var(--destructive));color:white;&:hover{background:hsl(var(--destructive) / 0.9);border-color:hsl(var(--destructive) / 0.9)}}}.dialog-input{width:100%;box-sizing:border-box;height:2rem;padding:0 8px;font:inherit;font-size:0.75rem;color:rgb(189, 219, 209);background-color:hsl(var(--muted));border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);outline:none;&:focus{border-color:hsl(var(--primary))}&:disabled{opacity:0.65}}.dialog-error{margin-top:8px;font-size:0.7rem;line-height:0.95rem;color:#ff6b7a}.hint{margin-top:4px;font-size:0.66rem;line-height:0.9rem;color:hsl(var(--muted-foreground))}.checkline{margin-top:8px;display:flex;align-items:center;gap:6px;font-size:0.72rem;color:rgb(189, 219, 209);cursor:pointer;input{accent-color:hsl(var(--primary));margin:0}}.perm-grid{margin-top:10px;width:100%;border-collapse:collapse;font-size:0.68rem;th{color:hsl(var(--muted-foreground));font-weight:normal;text-align:center;padding:2px 0}th[scope='row']{text-align:left;color:rgb(189, 219, 209)}td{text-align:center;padding:2px 0}input{accent-color:hsl(var(--primary));margin:0}}.perm-special{margin-top:4px;display:flex;gap:12px;.checkline{margin-top:4px;font-size:0.66rem}}.perm-octal{margin-top:10px;display:flex;align-items:center;gap:8px;label{font-size:0.68rem;color:hsl(var(--muted-foreground))}.dialog-input{width:4.5rem;text-align:center;letter-spacing:0.1em}.perm-preview{font-size:0.7rem;color:hsl(var(--primary))}}.modal-actions .btn.primary{background:hsl(var(--primary));border-color:hsl(var(--primary));color:hsl(var(--primary-foreground));&:hover:not(:disabled){background:hsl(var(--primary) / 0.9);border-color:hsl(var(--primary) / 0.9)}}.delete-loader{margin-top:4px;display:flex;justify-content:center;.spinner{width:16px;height:16px;border:2px solid hsl(var(--muted-foreground) / 0.35);border-top-color:hsl(var(--primary));border-radius:50%;animation:spin 0.7s linear infinite}}}}.editor-modal{position:absolute;inset:0;display:none;align-items:center;justify-content:center;background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px);z-index:7;&.visible{display:flex}.editor-dialog{width:min(860px, calc(100% - 24px));height:min(620px, calc(100% - 24px));display:flex;flex-direction:column;background-color:rgba(21, 24, 30, 0.98);border:1px solid hsl(var(--border));border-radius:var(--radius);padding:16px;box-shadow:rgba(0, 0, 0, 0.5) 0px 25px 50px -12px;outline:none;.editor-head{display:flex;align-items:center;justify-content:space-between;gap:8px;.title{color:hsl(var(--primary));font-size:0.8rem;margin-bottom:8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.editor-close{border:none;background:transparent;color:hsl(var(--muted-foreground));font-size:0.85rem;line-height:1;padding:2px 6px;border-radius:4px;cursor:pointer;&:hover:not(:disabled){color:hsl(var(--primary));background-color:hsl(var(--border) / 0.6)}&:disabled{opacity:0.5;cursor:not-allowed}}}.editor-loading{flex:1;display:flex;align-items:center;justify-content:center;font-size:0.75rem;color:hsl(var(--muted-foreground))}.editor-text{flex:1;min-height:0;width:100%;box-sizing:border-box;resize:none;padding:10px;font:inherit;font-size:0.75rem;line-height:1.15rem;tab-size:4;white-space:pre;overflow:auto;color:rgb(189, 219, 209);background-color:hsl(var(--muted));border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);outline:none;&:focus{border-color:hsl(var(--primary) / 0.6)}&:disabled{opacity:0.65}}.dialog-error{margin-top:8px;font-size:0.7rem;line-height:0.95rem;color:#ff6b7a}.modal-actions{margin-top:14px;display:flex;justify-content:flex-end;gap:8px;.btn{height:2rem;min-width:6rem;border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);font-size:0.75rem;letter-spacing:0.03em;cursor:pointer;&:disabled{opacity:0.65;cursor:not-allowed}}.btn.secondary{background:hsl(var(--muted));color:rgb(189, 219, 209);&:hover:not(:disabled){border-color:hsl(var(--primary));color:hsl(var(--primary))}}.btn.destructive{background:hsl(var(--destructive));border-color:hsl(var(--destructive));color:white}.btn.primary{background:hsl(var(--primary));border-color:hsl(var(--primary));color:hsl(var(--primary-foreground));&:hover:not(:disabled){background:hsl(var(--primary) / 0.9);border-color:hsl(var(--primary) / 0.9)}}}}}}@keyframes spin{to{transform:rotate(360deg)}}:host(.max){height:100vh;width:100vw;position:fixed;top:0;left:0;z-index:9999}@container (max-width: 699px){:host .listing main .content table thead th:nth-child(4),:host .listing main .content table tbody td:nth-child(4){display:none}}@container (max-width: 635px){:host .listing main .content table thead th:nth-child(3),:host .listing main .content table tbody td:nth-child(3){display:none}}@container (max-width: 530px){:host .listing main .content table thead th:nth-child(5),:host .listing main .content table tbody td:nth-child(5){display:none}:host .listing footer .status{display:none}}@container (max-width: 370px){:host .listing main .content table thead th:nth-child(2),:host .listing main .content table tbody td:nth-child(2){display:none}:host .listing main .content table thead th:first-child,:host .listing main .content table tbody td:first-child{width:100%;min-width:0;max-width:none}:host .listing main .content table tbody td:first-child .name{max-width:100%}}@container (max-width: 295px){:host .listing main .content table tbody td:first-child .name{max-width:120px}}@container (max-width: 635px){:host .listing main .content table tbody tr td.action-col .file-action{opacity:1;visibility:visible;pointer-events:auto;width:36px;height:36px;border-radius:8px}:host .listing main .content table tbody tr td.action-col .file-action svg{width:17px;height:17px}:host .listing main .content table thead th.action-col,:host .listing main .content table tbody td.action-col{width:92px;min-width:92px}:host .listing main .content table tbody td.action-col .file-actions{gap:4px}:host .listing main .content table tbody tr:hover{background-color:transparent}:host .listing main .content table tbody tr.selected:hover{background-color:hsl(var(--primary) / 0.3)}:host .listing main .content table tbody td{padding:13px 10px 12px}:host .listing main .content table thead th{padding:12px 10px}:host .listing main .navigation{height:auto;min-height:44px;padding:6px 8px}:host .listing main .navigation .action{padding:10px;border-radius:8px}:host .listing main .navigation .action img{height:17px;width:17px}:host .listing main .navigation .action.disconnect{padding:10px 12px}:host .listing main .navigation .filter{height:2.25rem;font-size:16px;width:8rem}:host .listing header .actions .action{padding:8px}:host .listing header .actions .action img{height:17px}:host .modal .upload-dialog .cancel,:host .modal .download-dialog .cancel,:host .modal .delete-dialog .cancel,:host .modal .prompt-dialog .cancel,:host .modal .upload-dialog .modal-actions .btn,:host .modal .download-dialog .modal-actions .btn,:host .modal .delete-dialog .modal-actions .btn,:host .modal .prompt-dialog .modal-actions .btn{height:2.75rem}:host .modal .prompt-dialog .dialog-input,:host .auth input{height:2.5rem;font-size:16px}:host .modal .prompt-dialog .perm-grid input,:host .modal .prompt-dialog .perm-special input{width:20px;height:20px}:host .modal .prompt-dialog .perm-grid td,:host .modal .prompt-dialog .perm-grid th{padding:7px 0}}:host .listing main .navigation .action.fetch{position:relative;display:inline-grid;place-items:center;color:hsl(var(--primary))}:host .listing main .navigation .action.fetch .badge{position:absolute;top:-5px;right:-6px;min-width:15px;height:15px;padding:0 4px;border-radius:8px;background:hsl(var(--primary));color:hsl(var(--primary-foreground));font-size:9px;font-weight:700;line-height:15px;text-align:center}:host .listing main .content table tbody tr.part td{color:hsl(var(--muted-foreground));font-style:italic}:host .listing main .content table tbody tr.fresh{background-color:hsl(var(--primary) / 0.1)}:host .listing main .content table tbody tr.fresh .name::after{content:'new';margin-left:8px;font-size:10px;padding:1px 6px;border-radius:3px;background:hsl(var(--primary));color:hsl(var(--primary-foreground));font-weight:600;font-style:normal}:host .delete-dialog .file-name.inline{display:inline;padding:0;border:0;background:none}:host .context-backdrop{position:absolute;inset:0;z-index:8}:host .context-menu{position:absolute;min-width:220px;max-width:calc(100% - 16px);padding:4px;background:hsl(var(--card));border:1px solid hsl(var(--border));border-radius:6px;box-shadow:0 12px 30px -10px rgba(0, 0, 0, 0.7);display:flex;flex-direction:column;font-size:12px;button{display:flex;align-items:center;gap:8px;text-align:left;padding:6px 10px;border:0;border-radius:4px;background:transparent;color:rgb(189, 219, 209);font:inherit;cursor:pointer;&:hover,&:focus-visible{background:hsl(var(--muted));outline:none}&.primary{color:hsl(var(--primary))}&.danger{color:hsl(var(--destructive))}}hr{border:0;border-top:1px solid hsl(var(--border));margin:4px 0}}:host .player-modal{position:absolute;inset:0;z-index:7;display:grid;place-items:center;padding:10px;background:rgba(5, 7, 9, 0.6);phirepass-media-player{width:min(100%, 880px)}}"}},[513,"phirepass-sftp-client",{name:[1],description:[1],hideHeader:[4,"hide-header"],serverHost:[1,"server-host"],serverPort:[2,"server-port"],allowInsecure:[4,"allow-insecure"],heartbeatInterval:[2,"heartbeat-interval"],nodeId:[1,"node-id"],serviceId:[1,"service-id"],token:[1],serverId:[1,"server-id"],channelFactory:[16],max:[32],show_login_screen:[32],show_login_screen_username:[32],show_error:[32],error_message:[32],show_login_screen_password:[32],show_navigation:[32],breadcrumbs:[32],current_dir:[32],listing:[32],show_content:[32],show_loader:[32],version:[32],status:[32],selected_item:[32],show_upload_modal:[32],upload_progress:[32],upload_file_name:[32],upload_speed:[32],upload_finished:[32],show_download_modal:[32],download_progress:[32],download_file_name:[32],download_speed:[32],download_finished:[32],show_delete_modal:[32],delete_file_name:[32],delete_loading:[32],delete_is_dir:[32],delete_recursive:[32],delete_error:[32],prompt_kind:[32],prompt_value:[32],prompt_error:[32],prompt_busy:[32],chmod_target:[32],chmod_mode:[32],chmod_error:[32],chmod_busy:[32],show_editor:[32],editor_name:[32],editor_text:[32],editor_saved_text:[32],editor_busy:[32],editor_error:[32],editor_confirm_discard:[32],editor_loaded:[32],filter:[32],sort_key:[32],sort_asc:[32],channel_ready:[32],fetch_count:[32],fresh_names:[32],part_delete:[32],torrent_menu:[32],listing_player:[32],maximize:[64],minimize:[64]},void 0,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}]);function C(){"undefined"!=typeof customElements&&["phirepass-sftp-client","phirepass-downloader","phirepass-media-player"].forEach((t=>{switch(t){case"phirepass-sftp-client":customElements.get(e(t))||customElements.define(e(t),_);break;case"phirepass-downloader":customElements.get(e(t))||h();break;case"phirepass-media-player":customElements.get(e(t))||f()}}))}C();const M=_,D=C;export{M as PhirepassSftpClient,D as defineCustomElement}
1
+ import{t as e,p as t,H as i,c as a,h as s,a as o}from"./index.js";import{_ as r,E as d,C as n,a as l,P as c}from"./p-CsYQJXY2.js";const h=t(class extends i{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.maximizeEvent=a(this,"maximize"),this.connectionStateChanged=a(this,"connectionStateChanged")}channel;domReady=!1;runtimeReady=!1;connected=!1;uploadInputEl;msgId=1;activeUploadToken=0;pendingUploadStarts=new Map;pendingUploadAcks=new Map;pendingDownloadStarts=new Map;activeDownloads=new Map;activeDownloadMsgId;pendingOps=new Map;promptInputEl;editorPath="";editorTextEl;session_id;name="SFTP";description="Client";hideHeader=!1;serverHost="phirepass.com";serverPort=443;allowInsecure=!1;heartbeatInterval=3e4;nodeId;serviceId;token;onNodeIdChange(e,t){this.reset_session_state(),this.channel&&this.channel.is_connected()&&this.close_comms(),e&&(this.open_comms(),this.channel.connect(),this.status="Connecting...")}serverId;channelFactory;onServerIdChange(e,t){this.onNodeIdChange(this.nodeId,this.nodeId)}maximizeEvent;async maximize(){this.max=!this.max}async minimize(){this.max=!1}connectionStateChanged;max=!1;show_login_screen=!1;show_login_screen_username=!1;show_error=!1;error_message="";show_login_screen_password=!1;show_navigation=!1;breadcrumbs=[];current_dir=".";listing=[];show_content=!1;show_loader=!1;version="";status="Disconnected";selected_item=null;show_upload_modal=!1;upload_progress=0;upload_file_name="";upload_speed="--";upload_finished=!1;show_download_modal=!1;download_progress=0;download_file_name="";download_speed="--";download_finished=!1;show_delete_modal=!1;delete_file_name="";delete_loading=!1;delete_is_dir=!1;delete_recursive=!1;delete_error="";prompt_kind=null;prompt_value="";prompt_error="";prompt_busy=!1;chmod_target=null;chmod_mode=0;chmod_error="";chmod_busy=!1;show_editor=!1;editor_name="";editor_text="";editor_saved_text="";editor_busy="";editor_error="";editor_confirm_discard=!1;editor_loaded=!1;filter="";sort_key="name";sort_asc=!0;toggle_max(){this.maximizeEvent?.emit(!this.max)}async connectedCallback(){this.channelFactory||await r(),this.open_comms(),this.runtimeReady=!0,this.nodeId?this.try_connect():console.warn("Prop node_id is not set. Cannot connect to terminal.")}componentDidLoad(){this.domReady=!0,this.try_connect()}async disconnectedCallback(){this.connected=!1,this.domReady=!1,this.runtimeReady=!1,this.cancel_active_upload(),this.cancel_active_download(),this.clear_pending_operations(),this.close_comms()}next_msg_id(){const e=this.msgId;return this.msgId+=1,e}clear_pending_operations(){this.pendingUploadStarts.forEach((e=>{window.clearTimeout(e.timeout),e.reject(Error("Upload start aborted"))})),this.pendingUploadStarts.clear(),this.pendingUploadAcks.forEach((e=>{window.clearTimeout(e.timeout),e.reject(Error("Upload chunk aborted"))})),this.pendingUploadAcks.clear(),this.pendingDownloadStarts.forEach((e=>{window.clearTimeout(e.timeout),e.reject(Error("Download start aborted"))})),this.pendingDownloadStarts.clear(),this.pendingOps.forEach((e=>{window.clearTimeout(e.timeout),e.reject(Error(`Could not ${e.verb}: the session ended.`))})),this.pendingOps.clear(),this.activeDownloads.clear()}cancel_active_upload(){this.activeUploadToken+=1,this.upload_progress=0,this.upload_finished=!1,this.upload_speed="--"}cancel_active_download(){void 0!==this.activeDownloadMsgId&&this.activeDownloads.delete(this.activeDownloadMsgId),this.activeDownloadMsgId=void 0,this.download_progress=0,this.download_finished=!1,this.download_speed="--"}format_duration(e){if(!Number.isFinite(e)||e<0)return"--";if(e<60)return e.toFixed(0)+"s";const t=Math.floor(e/60);return t<60?`${t}m ${Math.floor(e%60)}s`:`${Math.floor(t/60)}h ${t%60}m`}format_percent(e){return(Number.isFinite(e)?e:0).toFixed(2)+"%"}format_transfer_rate(e){return!Number.isFinite(e)||e<=0?"--":this.format_size(e)+"/s"}update_upload_progress(e,t,i){if(this.upload_progress=Math.max(0,Math.min(100,t>0?e/t*100:0)),e>=t)return this.upload_finished=!0,void(this.upload_speed="--");const a=(performance.now()-i)/1e3,s=a>0?e/a:0;this.upload_speed=this.format_transfer_rate(s);const o=s>0?(t-e)/s:NaN;this.status=`Uploading ${this.format_size(e)} / ${this.format_size(t)} (ETA ${this.format_duration(o)})`}update_download_progress(e,t,i){if(this.download_progress=Math.max(0,Math.min(100,t>0?e/t*100:0)),e>=t)return this.download_finished=!0,void(this.download_speed="--");const a=(Date.now()-i)/1e3,s=a>0?e/a:0;this.download_speed=this.format_transfer_rate(s);const o=s>0?(t-e)/s:NaN;this.status=`Downloading ${this.format_size(e)} / ${this.format_size(t)} (ETA ${this.format_duration(o)})`}connect(){this.connected=!0,this.channel.connect(),this.status="Connecting..."}try_connect(){!this.connected&&this.domReady&&this.runtimeReady&&this.channel&&this.connect()}create_web_socket_endpoint(){const e=this.allowInsecure?"ws":"wss";return this.allowInsecure||443!==this.serverPort?this.allowInsecure&&80===this.serverPort?`${e}://${this.serverHost}`:`${e}://${this.serverHost}:${this.serverPort}`:`${e}://${this.serverHost}`}handle_error(e){if(void 0!==e.msg_id){const t=this.pendingUploadStarts.get(e.msg_id);t&&(window.clearTimeout(t.timeout),t.reject(Error(e.message||"Upload start failed")),this.pendingUploadStarts.delete(e.msg_id));const i=this.pendingDownloadStarts.get(e.msg_id);i&&(window.clearTimeout(i.timeout),i.reject(Error(e.message||"Download start failed")),this.pendingDownloadStarts.delete(e.msg_id)),this.activeDownloads.has(e.msg_id)&&(this.activeDownloads.delete(e.msg_id),this.activeDownloadMsgId===e.msg_id&&(this.activeDownloadMsgId=void 0),this.download_finished=!1);const a=this.pendingOps.get(e.msg_id);if(a)return window.clearTimeout(a.timeout),this.pendingOps.delete(e.msg_id),a.reject(Error(e.message||`Could not ${a.verb}.`)),void(this.show_loader=!1)}switch(e.kind){case d.Generic:case d.Authentication:this.error_message=e.message||"An unknown error occurred.",this.show_error=!0;break;case d.RequiresUsername:this.show_login_screen_username=!0,this.show_login_screen_password=!1,this.show_login_screen=!0;break;case d.RequiresPassword:this.show_login_screen_username=!1,this.show_login_screen_password=!0,this.show_login_screen=!0;break;case d.RequiresUsernamePassword:this.show_login_screen_username=!0,this.show_login_screen_password=!0,this.show_login_screen=!0}setTimeout((()=>{this.show_loader=!1}),1e3)}handle_auth_success(e){this.clear_creds_buffer(),this.version=e.version,this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.channel.open_sftp_tunnel(this.nodeId,this.serviceId),this.status="Connected"}handle_tunnel_opened(e){this.session_id=e.sid,this.channel.send_sftp_list_data(this.nodeId,this.session_id,this.current_dir)}handle_sftp_list_items(e){setTimeout((()=>{this.show_loader=!1}),500),e.path!==this.current_dir&&(this.filter=""),this.listing=e.dir.items,this.current_dir=e.path,this.breadcrumbs=e.path.split("/").map(((e,t,i)=>""===e&&0===t?{label:"/",path:"/"}:{label:e,path:i.slice(0,t+1).join("/")})),this.show_content=!0,this.show_navigation=!0,console.log("Received SFTP list items:",e)}handle_upload_start_response(e){if(void 0===e.msg_id)return;const t=this.pendingUploadStarts.get(e.msg_id);t&&(window.clearTimeout(t.timeout),t.resolve(e.response.upload_id),this.pendingUploadStarts.delete(e.msg_id))}handle_upload_chunk_ack(e){const t=`${e.upload_id}_${e.chunk_index}`,i=this.pendingUploadAcks.get(t);i&&(window.clearTimeout(i.timeout),i.resolve(),this.pendingUploadAcks.delete(t))}handle_download_start_response(e){if(void 0===e.msg_id)return;const t=this.pendingDownloadStarts.get(e.msg_id);t&&(window.clearTimeout(t.timeout),t.resolve({download_id:e.response.download_id,total_size:e.response.total_size,total_chunks:e.response.total_chunks}),this.pendingDownloadStarts.delete(e.msg_id))}finalize_download(e){const t=this.activeDownloads.get(e);if(!t)return;const i=Array.from(t.chunks.entries()).sort(((e,t)=>e[0]-t[0])).map((([,e])=>e)).map((e=>new Uint8Array(e))),a=new Blob(i,{type:"application/octet-stream"}),s=URL.createObjectURL(a),o=document.createElement("a");o.href=s,o.download=t.filename,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(s),this.activeDownloads.delete(e),this.activeDownloadMsgId===e&&(this.activeDownloadMsgId=void 0),this.download_finished=!0,this.status="Connected"}handle_download_chunk(e){if(void 0===e.msg_id)return;const t=this.activeDownloads.get(e.msg_id);if(!t||!this.session_id)return;const i=new Uint8Array(e.chunk.data);t.chunks.set(e.chunk.chunk_index,i);const a=Array.from(t.chunks.values()).reduce(((e,t)=>e+t.length),0);this.update_download_progress(a,t.total_size,t.startTime),this.channel.send_sftp_download_ack(this.nodeId,this.session_id,t.download_id,e.chunk.chunk_index),t.chunks.size>=t.total_chunks&&this.finalize_download(e.msg_id)}async start_download(e){if(!this.session_id)return;this.selected_item=e,this.download_file_name=e.name,this.download_progress=0,this.download_finished=!1,this.download_speed="--",this.show_download_modal=!0,this.show_error=!1;const t=this.next_msg_id();this.activeDownloadMsgId=t,this.activeDownloads.set(t,{filename:e.name,chunks:new Map,total_chunks:0,total_size:0,download_id:0,startTime:Date.now()});const i=new Promise(((e,i)=>{const a=window.setTimeout((()=>{this.pendingDownloadStarts.delete(t),i(Error("Download start timeout"))}),1e4);this.pendingDownloadStarts.set(t,{timeout:a,resolve:e,reject:i})}));try{this.channel.send_sftp_download_start(this.nodeId,this.session_id,e.path,e.name,t);const{download_id:a,total_chunks:s,total_size:o}=await i,r=this.activeDownloads.get(t);if(!r)return;r.download_id=a,r.total_chunks=s,r.total_size=o}catch(e){this.activeDownloads.delete(t),this.activeDownloadMsgId===t&&(this.activeDownloadMsgId=void 0),this.show_error=!0,this.error_message=e instanceof Error?e.message:"Failed to start download",this.cancel_download()}}async upload_file(e){if(!this.session_id)return;const t=this.activeUploadToken+1;this.activeUploadToken=t,this.upload_file_name=e.name,this.upload_progress=0,this.upload_finished=!1,this.upload_speed="--",this.show_upload_modal=!0,this.show_error=!1,this.status="Uploading...";const i=65536,a=Math.max(1,Math.ceil(e.size/i)),s=this.next_msg_id(),o=new Promise(((e,t)=>{const i=window.setTimeout((()=>{this.pendingUploadStarts.delete(s),t(Error("Upload start timeout"))}),1e4);this.pendingUploadStarts.set(s,{timeout:i,resolve:e,reject:t})}));try{this.channel.send_sftp_upload_start(this.nodeId,this.session_id,e.name,this.current_dir,a,BigInt(e.size),s);const r=await o;let d=0;const n=performance.now();for(let s=0;s<a;s+=1){if(t!==this.activeUploadToken)throw Error("Upload cancelled");const a=s*i,o=Math.min(a+i,e.size),l=new Uint8Array(await e.slice(a,o).arrayBuffer());await new Promise(((e,t)=>{const i=`${r}_${s}`,a=window.setTimeout((()=>{this.pendingUploadAcks.delete(i),t(Error(`Upload chunk ${s+1} timed out`))}),3e4);this.pendingUploadAcks.set(i,{timeout:a,resolve:e,reject:t}),this.channel.send_sftp_upload_chunk(this.nodeId,this.session_id,r,s,l.length,l,null)})),d+=l.length,this.update_upload_progress(d,e.size,n)}this.upload_progress=100,this.upload_finished=!0,this.status="Connected",this.refresh_directory()}catch(e){"Upload cancelled"!==e.message&&(this.show_error=!0,this.error_message=e instanceof Error?e.message:"Upload failed"),this.upload_finished=!1,this.status="Connected"}}handle_op_result(e){if(void 0===e.msg_id)return;const t=this.pendingOps.get(e.msg_id);t&&(window.clearTimeout(t.timeout),this.pendingOps.delete(e.msg_id),t.resolve(e.result))}run_op(e,t,i=3e4){if(!this.session_id)return Promise.reject(Error("No active SFTP session."));const a=this.next_msg_id();return new Promise(((s,o)=>{const r=window.setTimeout((()=>{this.pendingOps.delete(a),o(Error(`Timed out trying to ${e}. This node's agent may be too old to support it.`))}),i);this.pendingOps.set(a,{verb:e,timeout:r,resolve:s,reject:o});try{t(a)}catch(e){window.clearTimeout(r),this.pendingOps.delete(a),o(e instanceof Error?e:Error(e+""))}}))}error_text(e){return e instanceof Error?e.message:e+""}item_path(e){return this.join_path(e.path,e.name)}join_path(e,t){return e&&"/"!==e?e.endsWith("/")?`${e}${t}`:`${e}/${t}`:"/"+t}invalid_name(e){return e?"."===e||".."===e?"That name is reserved.":e.includes("/")?'A name cannot contain "/".':e.includes("\0")?"A name cannot contain a null byte.":"":"Enter a name."}handle_tunnel_data(e){console.log("received tunnel data:",e)}handle_tunnel_closed(e){this.clear_creds_buffer(),this.close_comms()}open_comms(){const e=this.create_web_socket_endpoint()+"/api/web/ws";this.channel=this.channelFactory?this.channelFactory(e,this.nodeId,this.serverId||void 0):this.serverId?new n(e,this.nodeId,this.serverId):new n(e,this.nodeId),this.channel.on_connection_open((()=>{this.connectionStateChanged.emit([l.Connected]),this.channel.authenticate(this.token,this.nodeId),this.status="Authenticating..."})),this.channel.on_connection_close((()=>{this.connectionStateChanged.emit([l.Disconnected]),this.status="Disconnected"})),this.channel.on_connection_error((e=>{this.connectionStateChanged.emit([l.Error,e]),this.status="Error "+e.message})),this.channel.on_connection_message((()=>{})),this.channel.on_protocol_message((e=>{const{web:t}=e.data;switch(t.type){case c.Error:this.handle_error(t);break;case c.AuthSuccess:this.handle_auth_success(t);break;case c.TunnelOpened:this.handle_tunnel_opened(t);break;case c.TunnelClosed:this.handle_tunnel_closed(t);break;case c.TunnelData:this.handle_tunnel_data(t);break;case c.SFTPListItems:this.handle_sftp_list_items(t);break;case c.SFTPUploadStartResponse:this.handle_upload_start_response(t);break;case c.SFTPUploadChunkAck:this.handle_upload_chunk_ack(t);break;case c.SFTPDownloadStartResponse:this.handle_download_start_response(t);break;case c.SFTPDownloadChunk:this.handle_download_chunk(t);break;case c.SFTPOpResult:this.handle_op_result(t);break;default:console.warn("Unhandled protocol message type:",t)}}))}close_comms(){this.cancel_active_upload(),this.cancel_active_download(),this.clear_pending_operations(),this.channel&&(this.channel.stop_heartbeat(),this.channel.disconnect())}clear_creds_buffer(){}reset_session_state(){this.clear_creds_buffer()}list_breadcrumb(e){this.show_loader=!0,this.selected_item=null,this.channel.send_sftp_list_data(this.nodeId,this.session_id,e)}go_to_parent_directory(){this.session_id&&"/"!==this.current_dir&&this.list_breadcrumb(this.breadcrumbs[this.breadcrumbs.length-2]?.path||"/")}refresh_directory(){this.session_id&&this.list_breadcrumb(this.current_dir)}disconnect_session(){this.close_comms(),this.session_id=void 0,this.show_loader=!1,this.show_content=!1,this.breadcrumbs=[],this.current_dir=".",this.listing=[],this.show_navigation=!1,this.show_login_screen_username=!1,this.show_login_screen_password=!1,this.show_login_screen=!1,this.show_upload_modal=!1,this.show_download_modal=!1,this.show_delete_modal=!1,this.upload_progress=0,this.download_progress=0,this.upload_finished=!1,this.download_finished=!1,this.delete_loading=!1,this.delete_file_name="",this.delete_error="",this.delete_is_dir=!1,this.delete_recursive=!1,this.prompt_kind=null,this.prompt_value="",this.prompt_error="",this.prompt_busy=!1,this.chmod_target=null,this.chmod_error="",this.chmod_busy=!1,this.show_editor=!1,this.editor_busy="",this.editor_error="",this.editor_confirm_discard=!1,this.editor_loaded=!1,this.filter="",this.version="",this.status="Disconnected"}on_file_row_action(e,t){t.preventDefault(),t.stopPropagation(),"File"===e.kind&&this.start_download(e)}on_file_delete_action(e,t){t.preventDefault(),t.stopPropagation(),this.selected_item=e,this.delete_file_name=e.name,this.delete_is_dir="Folder"===e.kind,this.delete_recursive=!1,this.delete_error="",this.delete_loading=!1,this.show_delete_modal=!0}cancel_delete(){this.delete_loading||(this.show_delete_modal=!1,this.delete_file_name="",this.delete_error="",this.delete_is_dir=!1,this.delete_recursive=!1)}async confirm_delete(){if(this.delete_loading)return;const e=this.selected_item;if(!this.session_id||!e)return void(this.show_delete_modal=!1);const t=this.item_path(e),i=this.delete_is_dir&&this.delete_recursive;this.delete_loading=!0,this.delete_error="",this.show_error=!1,this.status=`Deleting ${e.name}...`;try{await this.run_op("delete",(e=>this.channel.send_sftp_remove(this.nodeId,this.session_id,t,i,e)),i?3e5:3e4),this.delete_loading=!1,this.show_delete_modal=!1,this.delete_file_name="",this.delete_is_dir=!1,this.delete_recursive=!1,this.status="Connected",this.refresh_directory()}catch(e){this.delete_loading=!1,this.delete_error=this.error_text(e),this.status="Connected"}}open_mkdir(){this.session_id&&(this.prompt_kind="mkdir",this.prompt_value="",this.prompt_error="",this.prompt_busy=!1)}on_rename_action(e,t){t.preventDefault(),t.stopPropagation(),this.session_id&&(this.selected_item=e,this.prompt_kind="rename",this.prompt_value=e.name,this.prompt_error="",this.prompt_busy=!1)}close_prompt(){this.prompt_busy||(this.prompt_kind=null,this.prompt_value="",this.prompt_error="",this.promptInputEl=void 0)}async submit_prompt(){if(this.prompt_busy||!this.session_id)return;const e=this.prompt_kind,t=this.prompt_value.trim(),i=this.invalid_name(t);if(i)return void(this.prompt_error=i);const a=this.selected_item;if("rename"===e&&a&&t===a.name)this.close_prompt();else{this.prompt_busy=!0,this.prompt_error="",this.show_error=!1;try{if("mkdir"===e){const e=this.join_path(this.current_dir,t);this.status=`Creating ${t}...`,await this.run_op("create the folder",(t=>this.channel.send_sftp_mkdir(this.nodeId,this.session_id,e,t)))}else{if("rename"!==e||!a)return this.prompt_busy=!1,void this.close_prompt();{const e=this.item_path(a),i=this.join_path(a.path,t);this.status=`Renaming ${a.name}...`,await this.run_op("rename",(t=>this.channel.send_sftp_rename(this.nodeId,this.session_id,e,i,t)))}}this.prompt_busy=!1,this.prompt_kind=null,this.prompt_value="",this.promptInputEl=void 0,this.status="Connected",this.refresh_directory()}catch(e){this.prompt_busy=!1,this.prompt_error=this.error_text(e),this.status="Connected"}}}on_chmod_action(e,t){t.preventDefault(),t.stopPropagation(),this.session_id&&(this.selected_item=e,this.chmod_target=e,this.chmod_mode=4095&(e.attributes.permissions??0),this.chmod_error="",this.chmod_busy=!1)}close_chmod(){this.chmod_busy||(this.chmod_target=null,this.chmod_error="")}toggle_chmod_bit(e){this.chmod_busy||(this.chmod_mode=4095&(this.chmod_mode^e))}on_chmod_octal_input(e){const t=e.trim();/^[0-7]{1,4}$/.test(t)?(this.chmod_error="",this.chmod_mode=4095&parseInt(t,8)):this.chmod_error="Enter up to four octal digits, 0-7."}async submit_chmod(){const e=this.chmod_target;if(this.chmod_busy||!this.session_id||!e)return;const t=this.item_path(e),i=4095&this.chmod_mode;this.chmod_busy=!0,this.chmod_error="",this.show_error=!1,this.status=`Setting permissions on ${e.name}...`;try{await this.run_op("change permissions",(e=>this.channel.send_sftp_chmod(this.nodeId,this.session_id,t,i,e))),this.chmod_busy=!1,this.chmod_target=null,this.status="Connected",this.refresh_directory()}catch(e){this.chmod_busy=!1,this.chmod_error=this.error_text(e),this.status="Connected"}}async on_edit_action(e,t){if(t.preventDefault(),t.stopPropagation(),!this.session_id||"File"!==e.kind)return;const i=this.item_path(e);this.selected_item=e,this.show_editor=!0,this.editorPath=i,this.editor_name=e.name,this.editor_text="",this.editor_saved_text="",this.editor_error="",this.editor_confirm_discard=!1,this.editor_loaded=!1,this.editor_busy="loading",this.status=`Opening ${e.name}...`;try{const e=await this.run_op("open the file",(e=>this.channel.send_sftp_read_file(this.nodeId,this.session_id,i,e)),6e4);if("FileContents"!==e.result)throw Error("The agent answered without any file contents.");const t=this.decode_text(e.contents instanceof Uint8Array?e.contents:new Uint8Array(e.contents));this.editor_text=t,this.editor_saved_text=t,this.editor_loaded=!0,this.editor_busy="",this.status="Connected"}catch(e){this.editor_busy="",this.editor_error=this.error_text(e),this.status="Connected"}}decode_text(e){if(e.includes(0))throw Error("This looks like a binary file. Download it instead of editing it here.");try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{throw Error("This file is not valid UTF-8. Download it instead of editing it here.")}}editor_is_dirty(){return this.editor_loaded&&this.editor_text!==this.editor_saved_text}close_editor(e=!1){"saving"!==this.editor_busy&&(e||!this.editor_is_dirty()?(this.show_editor=!1,this.editor_confirm_discard=!1,this.editor_loaded=!1,this.editorPath="",this.editor_name="",this.editor_text="",this.editor_saved_text="",this.editor_error="",this.editor_busy="",this.editorTextEl=void 0):this.editor_confirm_discard=!0)}async save_editor(){if(this.editor_busy||!this.session_id||!this.editorPath)return;const e=this.editorPath,t=this.editor_text;this.editor_busy="saving",this.editor_error="",this.show_error=!1,this.status=`Saving ${this.editor_name}...`;try{await this.run_op("save the file",(i=>this.channel.send_sftp_write_file(this.nodeId,this.session_id,e,(new TextEncoder).encode(t),i)),6e4),this.editor_saved_text=t,this.editor_busy="",this.status="Connected",this.refresh_directory()}catch(e){this.editor_busy="",this.editor_error=this.error_text(e),this.status="Connected"}}toggle_sort(e){this.sort_key!==e?(this.sort_key=e,this.sort_asc=!0):this.sort_asc=!this.sort_asc}visible_listing(){const e=this.filter.trim().toLowerCase(),t=e?this.listing.filter((t=>t.name.toLowerCase().includes(e))):[...this.listing],i=this.sort_asc?1:-1;return t.sort(((e,t)=>{if(e.kind!==t.kind)return"Folder"===e.kind?-1:1;switch(this.sort_key){case"size":return i*((e.attributes.size??0)-(t.attributes.size??0));case"modified":return i*((e.attributes.modified??0)-(t.attributes.modified??0));default:return i*e.name.localeCompare(t.name,void 0,{numeric:!0,sensitivity:"base"})}}))}sort_indicator(e){return this.sort_key!==e?"":this.sort_asc?" ▲":" ▼"}on_listing_keydown(e){if(this.prompt_kind||this.chmod_target||this.show_editor||this.show_delete_modal)return;const t=this.selected_item;switch(e.key){case"Backspace":e.preventDefault(),this.go_to_parent_directory();break;case"F5":e.preventDefault(),this.refresh_directory();break;case"F2":t&&(e.preventDefault(),this.on_rename_action(t,e));break;case"Delete":t&&(e.preventDefault(),this.on_file_delete_action(t,e));break;case"Enter":t&&(e.preventDefault(),this.list_directory(t))}}on_modal_keydown(e,t){"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),t())}focus_once(e,t,i){e&&e!==t&&(i(e),requestAnimationFrame((()=>e.focus())))}open_upload_picker(){this.uploadInputEl?.click()}on_upload_selected(e){const t=e.target,i=t.files?.[0];i&&(this.upload_file(i),t.value="")}cancel_upload(){this.cancel_active_upload(),this.show_upload_modal=!1,this.upload_file_name="",this.upload_speed="--",this.status="Connected",this.refresh_directory()}cancel_download(){this.cancel_active_download(),this.show_download_modal=!1,this.download_file_name="",this.download_speed="--",this.status="Connected",this.refresh_directory()}is_selected(e){return!!this.selected_item&&this.selected_item.path===e.path&&this.selected_item.name===e.name}list_directory(e){if(!this.session_id)return void console.warn("No active session. Cannot list directory.");if("File"===e.kind)return console.warn("Cannot list directory of a file. Ignoring click."),void(this.selected_item=e);const t=this.item_path(e);t!==this.current_dir?(this.show_loader=!0,this.selected_item=null,this.channel.send_sftp_list_data(this.nodeId,this.session_id,t)):console.warn("Already in this directory. Ignoring click.")}format_size(e){if(void 0===e||Number.isNaN(e))return"-";if(e<1024)return e+" B";let t=e,i=-1;for(;t>=1024&&i<4;)t/=1024,i+=1;return`${t.toFixed(t>=10?1:2)} ${["KB","MB","GB","TB","PB"][i]}`}mode_type_to_char(e,t){switch(61440&e){case 49152:return"s";case 40960:return"l";case 32768:return"-";case 24576:return"b";case 16384:return"d";case 8192:return"c";case 4096:return"p";default:return"Folder"===t?"d":"-"}}format_permissions(e,t){if(null==e)return"-";if("string"==typeof e){const i=e.trim();return/^[bcdlps-][rwxStTs-]{9}$/.test(i)?i:/^[0-7]{3,4}$/.test(i)?this.format_permissions(parseInt(i,8),t):/^\d+$/.test(i)?this.format_permissions(parseInt(i,10),t):i||"-"}const i=e,a=this.mode_type_to_char(i,t),s=[256&i?"r":"-",128&i?"w":"-",64&i?"x":"-",32&i?"r":"-",16&i?"w":"-",8&i?"x":"-",4&i?"r":"-",2&i?"w":"-",1&i?"x":"-"];return 2048&i&&(s[2]="x"===s[2]?"s":"S"),1024&i&&(s[5]="x"===s[5]?"s":"S"),512&i&&(s[8]="x"===s[8]?"t":"T"),`${a}${s.join("")}`}render(){return s(o,{key:"9e2edc1a72c3a74b26feea2faa08b9f0a2e37a0c",class:{default:!this.max,max:this.max}},s("section",{key:"72fae8227792615a5452f9b01ec8230c2c10e2a9",class:"listing"},!this.hideHeader&&s("header",{key:"14632fcb4575678418132892308cfea1903fadab"},s("section",{key:"3ea3fb2cab9d4cdf36af3876235579562a7acbef",class:"title"},s("img",{key:"fd0badaae9b0d7b426ddece5faf7ea3515e9bbf0",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoNDYsIDE4NCwgMTM4KSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiCiAgICBjbGFzcz0ibHVjaWRlIGx1Y2lkZS10ZXJtaW5hbCB3LTMuNSBoLTMuNSB0ZXh0LXByaW1hcnkiPgogICAgPHBvbHlsaW5lIHBvaW50cz0iNCAxNyAxMCAxMSA0IDUiPjwvcG9seWxpbmU+CiAgICA8bGluZSB4MT0iMTIiIHgyPSIyMCIgeTE9IjE5IiB5Mj0iMTkiPjwvbGluZT4KPC9zdmc+Cg==",alt:"SFTP Client"}),s("div",{key:"4eece24a618c119861f5435eb3f1ae8a5bae4966",class:"text"},s("div",{key:"84b45196e1a1609451413cf8ea369b60cd7f5ec6",class:"name"},this.name),s("div",{key:"45da97e659ecbaa69e74d1789a1b7961b760a753",class:"description"},this.description))),s("section",{key:"9177dcc02b911e95870c5f55fc48f741895a0b75",class:"actions"},s("div",{key:"468f341eebf7569c2a1c4aeea09d56644e5b6161",class:"action",onClick:()=>this.toggle_max()},s("img",{key:"203b54e42cddc50bf068a49fa7f88c846ecaa2c9",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTE1LCAxMjMsIDE0MCkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtbWF4aW1pemUyIHctMyBoLTMiPgogICAgPHBvbHlsaW5lIHBvaW50cz0iMTUgMyAyMSAzIDIxIDkiPjwvcG9seWxpbmU+CiAgICA8cG9seWxpbmUgcG9pbnRzPSI5IDIxIDMgMjEgMyAxNSI+PC9wb2x5bGluZT4KICAgIDxsaW5lIHgxPSIyMSIgeDI9IjE0IiB5MT0iMyIgeTI9IjEwIj48L2xpbmU+CiAgICA8bGluZSB4MT0iMyIgeDI9IjEwIiB5MT0iMjEiIHkyPSIxNCI+PC9saW5lPgo8L3N2Zz4K",alt:"Maximize"})))),s("main",{key:"c0f757aaa07734199228e3dc520c98694bc6548d"},this.show_navigation&&s("nav",{key:"295440219080af5fa33566300fb1036998da399c",class:"navigation"},s("div",{key:"c9b63f04de675559d2e2bbb876115c63e00bfbd2",class:"breadcrumbs"},this.breadcrumbs.map(((e,t,i)=>s("span",{key:t,class:"breadcrumb-container"},s("span",{key:t,onClick:()=>this.list_breadcrumb(e.path),class:"breadcrumb"},e.label),t<i.length-1&&s("img",{class:"arrow",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIgogICAgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIKICAgIGNsYXNzPSJsdWNpZGUgbHVjaWRlLWNoZXZyb24tcmlnaHQgdy0zIGgtMyB0ZXh0LW11dGVkLWZvcmVncm91bmQvNTAgc2hyaW5rLTAiPgogICAgPHBhdGggZD0ibTkgMTggNi02LTYtNiI+PC9wYXRoPgo8L3N2Zz4K"}))))),s("section",{key:"325ccd4be07d61df1e16956b5818683feb70c52f",class:"actions","aria-label":"SFTP actions"},s("input",{key:"f75b4191b0718bd2234497b7168af9dc13a070d6",class:"filter",type:"search",autocorrect:"off",autocapitalize:"none",autoComplete:"off",placeholder:"Filter","aria-label":"Filter this directory",value:this.filter,onInput:e=>this.filter=e.target.value}),s("button",{key:"da64c4a88332d3efab6a6e03e8c16a8a1db96b43",type:"button",class:"action",onClick:()=>this.go_to_parent_directory(),title:"Go to parent directory","aria-label":"Go to parent directory"},s("img",{key:"309e0fdb89aa4d119a5193f1803ebdc117e55105",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtYXJyb3ctdXAgdy0zLjUgaC0zLjUiPgogICAgPHBhdGggZD0ibTUgMTIgNy03IDcgNyI+PC9wYXRoPgogICAgPHBhdGggZD0iTTEyIDE5VjUiPjwvcGF0aD4KPC9zdmc+Cg==",alt:"Go up"})),s("button",{key:"5f451e50801f10b88a3436515d792b1015bf48bb",type:"button",class:"action",onClick:()=>this.refresh_directory(),title:"Refresh","aria-label":"Refresh"},s("img",{key:"aa673b81504e65e78043c328f94d3a9dd02f696a",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtcmVmcmVzaC1jdyB3LTMuNSBoLTMuNSI+CiAgICA8cGF0aCBkPSJNMyAxMmE5IDkgMCAwIDEgOS05IDkuNzUgOS43NSAwIDAgMSA2Ljc0IDIuNzRMMjEgOCI+PC9wYXRoPgogICAgPHBhdGggZD0iTTIxIDN2NWgtNSI+PC9wYXRoPgogICAgPHBhdGggZD0iTTIxIDEyYTkgOSAwIDAgMS05IDkgOS43NSA5Ljc1IDAgMCAxLTYuNzQtMi43NEwzIDE2Ij48L3BhdGg+CiAgICA8cGF0aCBkPSJNOCAxNkgzdjUiPjwvcGF0aD4KPC9zdmc+Cg==",alt:"Refresh"})),s("button",{key:"963f5abf044c207f9e42babe9e029ac052521f36",type:"button",class:"action",onClick:()=>this.open_mkdir(),title:"New folder","aria-label":"New folder"},s("svg",{key:"d441f67a8b5d2944f95e934d60d680dc22ec7c6c",xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},s("path",{key:"9eec6695289a71b135dee4751217cd4b4810a276",d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"}),s("line",{key:"9a759bd7ac97c4e8ebf75c4d54e8f207999634c2",x1:"12",x2:"12",y1:"10",y2:"16"}),s("line",{key:"4591434cdbb6a7d3a1a0212409fe38e21e02a52e",x1:"9",x2:"15",y1:"13",y2:"13"}))),s("button",{key:"301d406858c2d9a4656a342b49e663e76a7f1970",type:"button",class:"action",onClick:()=>this.open_upload_picker(),title:"Upload","aria-label":"Upload"},s("img",{key:"36ff8480d3acf65282d6ef648349327eb3432237",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtdXBsb2FkIHctMy41IGgtMy41Ij4KICAgIDxwYXRoIGQ9Ik0yMSAxNXY0YTIgMiAwIDAgMS0yIDJINWEyIDIgMCAwIDEtMi0ydi00Ij48L3BhdGg+CiAgICA8cG9seWxpbmUgcG9pbnRzPSIxNyA4IDEyIDMgNyA4Ij48L3BvbHlsaW5lPgogICAgPGxpbmUgeDE9IjEyIiB4Mj0iMTIiIHkxPSIzIiB5Mj0iMTUiPjwvbGluZT4KPC9zdmc+Cg==",alt:"Upload"})),s("button",{key:"3fa19d5e17ef2e2a8fc926c8ba6994a4a30a1825",type:"button",class:"action disconnect",onClick:()=>this.disconnect_session(),title:"Disconnect","aria-label":"Disconnect"},"DISCONNECT"))),s("input",{key:"f5cf6cc13d4b760b538d630467972c8add2df490",type:"file",ref:e=>this.uploadInputEl=e,onChange:e=>this.on_upload_selected(e),style:{display:"none"}}),this.show_content&&s("div",{key:"d69a7009192adc292cf3ccf4de6a4f059b46fa0e",class:"content",tabindex:0,onKeyDown:e=>this.on_listing_keydown(e)},s("table",{key:"2f00d85024b3e4642925f488a34d228dd056a2ce"},s("thead",{key:"611091a29f97e218f5282e11c7c1accdc1be5732"},s("tr",{key:"5f0d04ff8a5009852af02472f4261b9a95733a3c"},s("th",{key:"6df9558b86b3d3161920d5f94e8df0cf47ee9c80",class:"sortable",onClick:()=>this.toggle_sort("name"),title:"Sort by name"},"Name",this.sort_indicator("name")),s("th",{key:"83384582ac59c07f65526cfc5fd1359b5a0cd912",class:"sortable",onClick:()=>this.toggle_sort("size"),title:"Sort by size"},"Size",this.sort_indicator("size")),s("th",{key:"cbc16eafd7fb17c9d79b5612502140bc9a16a3cb"},"Permissions"),s("th",{key:"25d802dd84a6cc3eda222d5a732e05010c405f31"},"Owner"),s("th",{key:"cf5f9df11baae69f664724c6a79df0a95a5189a8",class:"sortable",onClick:()=>this.toggle_sort("modified"),title:"Sort by modified date"},"Modified",this.sort_indicator("modified")),s("th",{key:"9c8b9515c81245656d89ea65ee091a70606c1a93",class:"action-col","aria-label":"Actions"}))),s("tbody",{key:"40f8ec5d38a0601af3520891c4a9d35b2da2c32f"},this.visible_listing().map(((e,t)=>s("tr",{key:t,class:{selected:this.is_selected(e)},onClick:()=>this.list_directory(e)},s("td",null,s("img","Folder"===e.kind?{class:"kind",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoNDYsIDE4NCwgMTM4KSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiCiAgICBjbGFzcz0ibHVjaWRlIGx1Y2lkZS1mb2xkZXIgdy0zLjUgaC0zLjUgdGV4dC1wcmltYXJ5IHNocmluay0wIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTIwIDIwYTIgMiAwIDAgMCAyLTJWOGEyIDIgMCAwIDAtMi0yaC03LjlhMiAyIDAgMCAxLTEuNjktLjlMOS42IDMuOUEyIDIgMCAwIDAgNy45MyAzSDRhMiAyIDAgMCAwLTIgMnYxM2EyIDIgMCAwIDAgMiAyWiI+PC9wYXRoPgo8L3N2Zz4K",alt:"Folder"}:{class:"kind",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTE1LCAxMjMsIDE0MCkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtZmlsZSB3LTMuNSBoLTMuNSB0ZXh0LW11dGVkLWZvcmVncm91bmQgc2hyaW5rLTAiPgogICAgPHBhdGggZD0iTTE1IDJINmEyIDIgMCAwIDAtMiAydjE2YTIgMiAwIDAgMCAyIDJoMTJhMiAyIDAgMCAwIDItMlY3WiI+PC9wYXRoPgogICAgPHBhdGggZD0iTTE0IDJ2NGEyIDIgMCAwIDAgMiAyaDQiPjwvcGF0aD4KPC9zdmc+Cg==",alt:"File"}),s("span",{class:"name "+e.kind.toLowerCase()},e.name)),s("td",null,"Folder"===e.kind?"-":this.format_size(e.attributes.size)),s("td",null,this.format_permissions(e.attributes.permissions,e.kind)),s("td",null,e.attributes.user??"-"),s("td",null,new Date(1e3*e.attributes.modified).toLocaleString()),s("td",{class:"action-col"},s("div",{class:"file-actions"},"File"===e.kind&&s("button",{type:"button",class:"file-action",onClick:t=>this.on_edit_action(e,t),title:"Edit","aria-label":"Edit "+e.name},s("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},s("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s("path",{d:"M18.5 2.5a2.12 2.12 0 0 1 3 3L12 15l-4 1 1-4Z"}))),"File"===e.kind&&s("button",{type:"button",class:"file-action",onClick:t=>this.on_file_row_action(e,t),title:"Download","aria-label":"Download "+e.name},s("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},s("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s("polyline",{points:"7 10 12 15 17 10"}),s("line",{x1:"12",x2:"12",y1:"15",y2:"3"}))),s("button",{type:"button",class:"file-action",onClick:t=>this.on_rename_action(e,t),title:"Rename","aria-label":"Rename "+e.name},s("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},s("path",{d:"M12 20h9"}),s("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"}))),s("button",{type:"button",class:"file-action",onClick:t=>this.on_chmod_action(e,t),title:"Permissions","aria-label":"Change permissions on "+e.name},s("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},s("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),s("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"}))),s("button",{type:"button",class:"file-action delete",onClick:t=>this.on_file_delete_action(e,t),title:"Delete","aria-label":"Delete "+e.name},s("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},s("polyline",{points:"3 6 5 6 21 6"}),s("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),s("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),s("line",{x1:"10",x2:"10",y1:"11",y2:"17"}),s("line",{x1:"14",x2:"14",y1:"11",y2:"17"})))))))),0===this.visible_listing().length&&s("tr",{key:"46a173ad6542c9ab315da2792ea9830f0086b683",class:"empty"},s("td",{key:"986924de123f9be62f89f869fca02cd195134080",colSpan:6},this.filter?`Nothing here matches "${this.filter}".`:"This directory is empty."))))),this.show_loader&&s("div",{key:"588f4ff57df18c993f8566711a2627bd69b03881",class:"loader"},"Loading..."),this.show_error&&s("div",{key:"816c8ca05f68291d784d4c86509c9478204f3449",class:"error"},this.error_message)),s("footer",{key:"6add74a0d5beb8de15a600d287d96dd69f87a646"},s("section",{key:"39b31ae22b9f6298b8991be47d5641c1de618ab7",class:"status"},this.status,this.selected_item&&s("span",{key:"6e3942b5471e240719dfaf66cb01763f162ff3f0",class:"selected-item"},this.selected_item.name)),s("section",{key:"cc7ab5a9a632da8fae266f9ae73f967083e3589f",class:"version"},this.version?"Version: "+this.version:""))),this.show_login_screen&&s("section",{key:"3e13e8c942f690d2e26c231c2403032af620f735",class:{creds:!0,blurred:this.show_login_screen}},s("form",{key:"7ddb982159a3470bfad44aea75973a2eb37bebcd",class:"auth",onSubmit:e=>{const t=new FormData(e.target);let i,a;this.show_login_screen_username&&(i=t.get("username")),this.show_login_screen_password&&(a=t.get("password")),this.channel.open_sftp_tunnel(this.nodeId,this.serviceId,i,a),this.show_login_screen_username=!1,this.show_login_screen_password=!1,this.show_login_screen=!1,this.show_loader=!0,e.stopPropagation(),e.preventDefault()}},s("div",{key:"036877a02034000a79836c0a0979def9163f8a1a",class:"title"},"SFTP Connection"),this.show_login_screen_username&&s("div",{key:"37830ddb769fe0491831700a90f3fc8bf71cf050"},s("label",{key:"0f6e3d70e34baae3342a57fceed657e59c8c05a4",htmlFor:"username"},"Username"),s("input",{key:"3ecb202b3ee015e8719c330edb06889f4f48a433",autocorrect:"off",autocapitalize:"none",autoComplete:"off",id:"username",name:"username",type:"text",placeholder:""})),this.show_login_screen_password&&s("div",{key:"092a40a9da1205ec6342069844135aea92b85c5a"},s("label",{key:"19e465136660c9d2c1ecd0bb02bd7f8a559e3e0b",htmlFor:"password"},"Password"),s("input",{key:"ab9a74273abc594fa9fd51a780c2586fb275b4b4",autocorrect:"off",autocapitalize:"none",autoComplete:"off",id:"password",name:"password",type:"password",placeholder:""})),s("div",{key:"c1596787c7fea135d203f831cb7432a6e803d488"},s("button",{key:"89314be80add42ba55f96ec01bf22848742ec179",type:"submit"},"Connect")))),this.show_upload_modal&&s("section",{key:"c8b08cf050947d1936c97caf46eacca93175db9f",class:{"upload-modal":!0,visible:this.show_upload_modal}},s("div",{key:"ccc745354525565cda06b6b6eb8253c557c59009",class:"upload-dialog",role:"dialog","aria-modal":"true","aria-label":"Upload progress"},s("div",{key:"d478b113fa655386998d93862fc53bf516eaf90b",class:"title"},"Uploading File"),s("div",{key:"35c85475b00efcf05097e1feae1313afde0d04af",class:"file-name",title:this.upload_file_name},this.upload_file_name),s("div",{key:"d5cb7df154d77dacdca48673b2f01e03729846b0",class:"progress-track",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":this.upload_progress},s("div",{key:"4a7c10979b37d06acdda30c0b8d04a2af3cf0e5a",class:"progress-fill",style:{width:this.upload_progress+"%"}})),s("div",{key:"c69da13c3bc15a9a36867cbb1a8d041780ffecca",class:"progress-meta"},s("div",{key:"000b027205a828e1257263e29b5a595ead0fe54a",class:"progress-speed"},this.upload_speed),s("div",{key:"8eda5c230e39343ffb10aa1bc64f70999d428c57",class:"progress-value"},this.format_percent(this.upload_progress))),s("button",{key:"b047fe324179b9f77f97f7bcf541c32e0903bad9",type:"button",class:{cancel:!0,finished:this.upload_finished},onClick:()=>this.cancel_upload()},this.upload_finished?"Close":"Cancel"))),this.show_download_modal&&s("section",{key:"fff5c3228be15048397b86a1457f63d4562c98f8",class:{"download-modal":!0,visible:this.show_download_modal}},s("div",{key:"8bbf7465cdb2b514b16c4982b3480b04aa5e1a6c",class:"download-dialog",role:"dialog","aria-modal":"true","aria-label":"Download progress"},s("div",{key:"dea4371acce3010cefdb14bbc3873d6cca1e308c",class:"title"},"Downloading File"),s("div",{key:"cffc4ad6e269108252db2bbb3b3f9678e88aed4b",class:"file-name",title:this.download_file_name},this.download_file_name),s("div",{key:"ec0fd7bbd72c2c1dcb55dffb39a8e550af9c54a6",class:"progress-track",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":this.download_progress},s("div",{key:"c899bcf67b523e9de0db76bc9163d192120fd61b",class:"progress-fill",style:{width:this.download_progress+"%"}})),s("div",{key:"14c343bb055ca7300f3b500bb9da06450f9338c8",class:"progress-meta"},s("div",{key:"6b030a95eb9b11d88a070dd8a8dc9f4a2d10302a",class:"progress-speed"},this.download_speed),s("div",{key:"0d8eb9884506e9bb7a31ea1ceedc0f3e3e74f9b8",class:"progress-value"},this.format_percent(this.download_progress))),s("button",{key:"4416377601c6655ba0e9385e6149dd461702439a",type:"button",class:{cancel:!0,finished:this.download_finished},onClick:()=>this.cancel_download()},this.download_finished?"Close":"Cancel"))),this.show_delete_modal&&s("section",{key:"803d5f9fc2096c44335380132eee7d6ee1c70c1f",class:{"delete-modal":!0,visible:this.show_delete_modal}},s("div",{key:"0f23cb5f9ed35b97accc994277c86eff46de74bd",class:"delete-dialog",role:"dialog","aria-modal":"true","aria-label":"Delete confirmation",tabindex:-1,onKeyDown:e=>this.on_modal_keydown(e,(()=>this.cancel_delete()))},s("div",{key:"6b64cac5732de2d5c091fea7ef1cd1b903b86c61",class:"title"},this.delete_is_dir?"Delete Folder":"Delete File"),s("div",{key:"f1b6592449d9697208c704dcaaeec83d4d40d852",class:"message"},this.delete_loading?this.delete_recursive?"Deleting the folder and everything in it...":"Deleting...":`Are you sure you want to delete this ${this.delete_is_dir?"folder":"file"}?`),s("div",{key:"a67f8bd35875e0477fcf3bbf9f075b10f9066f07",class:"file-name",title:this.delete_file_name},this.delete_file_name),this.delete_is_dir&&s("label",{key:"5e660c03c1df789bcdc4dba7a2adfe4887dd71ca",class:"checkline"},s("input",{key:"c28122496182d007ae2f99d9de79451c23dadef5",type:"checkbox",checked:this.delete_recursive,disabled:this.delete_loading,onChange:e=>this.delete_recursive=e.target.checked}),s("span",{key:"53539d4803c5358d26e181dc53fcc7f36ad62d6a"},"Delete everything inside it too")),!this.delete_is_dir||this.delete_recursive?null:s("div",{class:"hint"},"Without this, the remote refuses a folder that is not empty."),this.delete_error&&s("div",{key:"0773a1e6a26fa8dde7dba0d0ed00107d01782e2f",class:"dialog-error"},this.delete_error),this.delete_loading&&s("div",{key:"b1580f0825ec4f4b37f894fbd714f143a9515fd6",class:"delete-loader","aria-hidden":"true"},s("span",{key:"db549d437007182afdaddab37d8caec7b1c4a2c7",class:"spinner"})),s("div",{key:"040a4c6730ce5149737211fae9d67a3a290bdc5c",class:"modal-actions"},s("button",{key:"b742ccd04a3e119c446a2186081835fd6f67022d",type:"button",class:"btn secondary",onClick:()=>this.cancel_delete(),disabled:this.delete_loading},"Cancel"),s("button",{key:"4ce414e250ace86f93d24e399ca56014e56c7757",type:"button",class:"btn destructive",onClick:()=>this.confirm_delete(),disabled:this.delete_loading},this.delete_loading?"Deleting...":"Delete")))),this.prompt_kind&&s("section",{key:"d533b9ecb021dbb69766ba92e87d0b4279b047d4",class:"prompt-modal visible"},s("div",{key:"f7fbe0ee2323439da2c991046d90b1b6397ebee8",class:"prompt-dialog",role:"dialog","aria-modal":"true","aria-label":"mkdir"===this.prompt_kind?"New folder":"Rename",tabindex:-1,onKeyDown:e=>this.on_modal_keydown(e,(()=>this.close_prompt()))},s("div",{key:"36b154bda604336f8bbb7c46d7bb35b6afd6cec2",class:"title"},"mkdir"===this.prompt_kind?"New Folder":"Rename"),s("div",{key:"76b8027be289fcdba2867e1b06f05cab8481564d",class:"message"},"mkdir"===this.prompt_kind?"Create a folder in "+this.current_dir:"Give it a new name. Existing names are not overwritten."),s("form",{key:"8ec6e410dc6572de35ff6b2c81734fa48d74a4a8",onSubmit:e=>{e.preventDefault(),e.stopPropagation(),this.submit_prompt()}},s("input",{key:"0511fa8205057fe088be93781c23e283bc07739e",class:"dialog-input",type:"text",autocorrect:"off",autocapitalize:"none",autoComplete:"off",spellcheck:!1,"aria-label":"Name",disabled:this.prompt_busy,value:this.prompt_value,onInput:e=>this.prompt_value=e.target.value,ref:e=>this.focus_once(e,this.promptInputEl,(e=>this.promptInputEl=e))}),this.prompt_error&&s("div",{key:"2644600b1e015e02209309e1163e991acabad2e9",class:"dialog-error"},this.prompt_error),s("div",{key:"520937e554f3ff7839aad18fd0ed3c56f8a21680",class:"modal-actions"},s("button",{key:"e5a037f006c3f97e6227e672cff6cf3dc7282abb",type:"button",class:"btn secondary",onClick:()=>this.close_prompt(),disabled:this.prompt_busy},"Cancel"),s("button",{key:"b7883cc44b152c2c648f133eb5ffd7f5942d0aa4",type:"submit",class:"btn primary",disabled:this.prompt_busy},this.prompt_busy?"Working...":"mkdir"===this.prompt_kind?"Create":"Rename"))))),this.chmod_target&&s("section",{key:"e99ef709477024789821b76e1bbaa6497dcbc474",class:"prompt-modal visible"},s("div",{key:"1cec5818b817d089a9b4cda3b4ee514e7e9201a7",class:"prompt-dialog",role:"dialog","aria-modal":"true","aria-label":"Change permissions",tabindex:-1,onKeyDown:e=>this.on_modal_keydown(e,(()=>this.close_chmod()))},s("div",{key:"49c35a7228bbc6e9898c499904feb5fb525b2b5c",class:"title"},"Permissions"),s("div",{key:"814edc9c438d956bef13b14bc22733502168c340",class:"file-name",title:this.chmod_target.name},this.chmod_target.name),s("table",{key:"a4c1b45c1ee830599e7c08a9a44c69df1ac2b201",class:"perm-grid"},s("thead",{key:"99b953b4cf5f3a6aeff766d39b15222e74235a3c"},s("tr",{key:"49d3ae286989915aaca71ba43cb19db357064158"},s("th",{key:"3f3b7fcbeb1b713d29a874a111552f6ff95a811e","aria-label":"Class"}),s("th",{key:"6d18882102b71cb61be8ae93a946f62da7b555bc"},"Read"),s("th",{key:"44aed1177108307db4618680b5e7d28e248cdab6"},"Write"),s("th",{key:"d6056bed3aab4164768a010c369365c70e67bbbc"},"Execute"))),s("tbody",{key:"d54ecfe06cade301263977cf1f0a0ba9e3721b5c"},[{label:"Owner",read:256,write:128,exec:64},{label:"Group",read:32,write:16,exec:8},{label:"Other",read:4,write:2,exec:1}].map((e=>s("tr",{key:e.label},s("th",{scope:"row"},e.label),[e.read,e.write,e.exec].map((t=>s("td",{key:t},s("input",{type:"checkbox","aria-label":`${e.label} ${t}`,disabled:this.chmod_busy,checked:!!(this.chmod_mode&t),onChange:()=>this.toggle_chmod_bit(t)}))))))))),s("div",{key:"a124e9599de6b406d84ba9ffa3a56b3b993179ef",class:"perm-special"},[{label:"setuid",bit:2048},{label:"setgid",bit:1024},{label:"sticky",bit:512}].map((e=>s("label",{key:e.label,class:"checkline"},s("input",{type:"checkbox",disabled:this.chmod_busy,checked:!!(this.chmod_mode&e.bit),onChange:()=>this.toggle_chmod_bit(e.bit)}),s("span",null,e.label))))),s("div",{key:"05ab3c8451084b6acdf7ea0e45f71da0f913b08d",class:"perm-octal"},s("label",{key:"5cb748e079c869720361e56c4973eaea82a85bc0",htmlFor:"chmod-octal"},"Octal"),s("input",{key:"652571af51a36c975d8b7432923ef2ab80743480",id:"chmod-octal",class:"dialog-input",type:"text",autocorrect:"off",autocapitalize:"none",autoComplete:"off",spellcheck:!1,maxlength:4,disabled:this.chmod_busy,value:this.chmod_mode.toString(8).padStart(4,"0"),onInput:e=>this.on_chmod_octal_input(e.target.value)}),s("span",{key:"4a789c75be9a941d2adf8de68cfda043c19864cc",class:"perm-preview"},this.format_permissions(this.chmod_mode,this.chmod_target.kind))),this.chmod_error&&s("div",{key:"acb09c9d16146cc0466df1ea6394ff492604c397",class:"dialog-error"},this.chmod_error),s("div",{key:"46c5c4fc154529060b24e335dcd192ed6dc6f75d",class:"modal-actions"},s("button",{key:"2ad9fad876497e4d629c1911fbe29616853a2e59",type:"button",class:"btn secondary",onClick:()=>this.close_chmod(),disabled:this.chmod_busy},"Cancel"),s("button",{key:"c14f7edb08da6d2db078722438e8e06455a076c7",type:"button",class:"btn primary",onClick:()=>{this.submit_chmod()},disabled:this.chmod_busy},this.chmod_busy?"Applying...":"Apply")))),this.show_editor&&s("section",{key:"f040aeca04a6b02af3247c024271fbdc2564a0c4",class:"editor-modal visible"},s("div",{key:"6874ae8a526168be8c2c09ca3f8a1faa52b78027",class:"editor-dialog",role:"dialog","aria-modal":"true","aria-label":"Editing "+this.editor_name,tabindex:-1,onKeyDown:e=>{if((e.ctrlKey||e.metaKey)&&"s"===e.key)return e.preventDefault(),void this.save_editor();this.on_modal_keydown(e,(()=>this.close_editor()))}},s("div",{key:"421cbd1bfbde035049ed028c4d05083cc7d8f66f",class:"editor-head"},s("div",{key:"889adcf6e0187963964920b9750531c3fa06cd37",class:"title"},this.editor_name,this.editor_is_dirty()?" *":""),s("button",{key:"b14d28ca6a80c9a08277ff20bc0b38fc30ea3869",type:"button",class:"editor-close",onClick:()=>this.close_editor(),"aria-label":"Close editor",disabled:"saving"===this.editor_busy},"x")),"loading"===this.editor_busy?s("div",{class:"editor-loading"},"Loading..."):s("textarea",{class:"editor-text",spellcheck:!1,autocorrect:"off",autocapitalize:"none",autoComplete:"off","aria-label":"File contents",disabled:"saving"===this.editor_busy||!this.editor_loaded,value:this.editor_text,onInput:e=>this.editor_text=e.target.value,ref:e=>this.focus_once(e,this.editorTextEl,(e=>this.editorTextEl=e))}),this.editor_error&&s("div",{key:"e7c1db037e749fec8970ac2b2be2cb85cfcd85be",class:"dialog-error"},this.editor_error),this.editor_confirm_discard&&s("div",{key:"84ca6080e18c4334e87374126b82b816f318cb0d",class:"dialog-error"},"Unsaved changes. Close anyway?"),s("div",{key:"4515e164a418815eccfd9d54d8f96a076616f326",class:"modal-actions"},this.editor_confirm_discard?s("button",{type:"button",class:"btn destructive",onClick:()=>this.close_editor(!0)},"Discard"):s("button",{type:"button",class:"btn secondary",onClick:()=>this.close_editor(),disabled:"saving"===this.editor_busy},"Close"),s("button",{key:"b1e758ae6fd5de192135d617126c8c6939c62bde",type:"button",class:"btn primary",onClick:()=>{this.save_editor()},disabled:!!this.editor_busy||!this.editor_is_dirty()},"saving"===this.editor_busy?"Saving...":"Save")))))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}static get style(){return":host{--radius:0.375rem;--card:220 18% 10%;--border:220 15% 18%;--primary:160 60% 45%;--radius:0.375rem;--destructive:0 70% 50%;--muted:220 15% 13%;--muted-foreground:220 10% 50%;--primary-foreground:220 20% 7%;--scroll-track:220 16% 12%;--scroll-thumb:220 12% 34%;--scroll-thumb-hover:160 45% 44%;font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace;height:100%;width:100%;border:1px solid hsl(var(--border));background-color:hsl(var(--card));border-radius:var(--radius);overflow:hidden;display:flex;flex-direction:column;position:relative;container-type:inline-size;.listing{height:100%;display:flex;flex-direction:column;justify-content:space-between;min-height:0;header{height:30px;background:rgba(28, 31, 38, 0.6);border-bottom:1px solid hsl(var(--border));display:flex;align-items:center;justify-content:space-between;.actions{display:flex;align-items:center;.action{cursor:pointer;padding:4px;display:flex;align-items:center;z-index:1;img{height:14px;padding:4px;border-radius:4px}&:hover{background-color:hsl(var(--border) / 0.6)}}}.title{color:hsl(var(--primary));height:14px;padding:0 12px;display:flex;align-items:center;font-size:0.75rem;line-height:1rem;img{height:14px;margin-right:5px}.text{display:flex;flex-direction:row;justify-content:center;margin-top:2px;.name{margin-right:10px}.description{color:hsl(var(--muted-foreground))}}}}main{flex:1;display:flex;flex-direction:column;position:relative;min-height:0;overflow:hidden;.loader{color:hsl(var(--muted-foreground));font-size:13px;animation:pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;text-align:center;display:flex;align-items:center;justify-content:center;position:absolute;height:100%;width:100%;background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px)}.error{font-size:13px;text-align:center;color:hsl(var(--destructive));height:100%;display:flex;align-items:center;justify-content:center}.navigation{height:25px;padding:10px;font-size:0.75rem;line-height:1rem;background-color:hsl(var(--card));display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid hsl(var(--border));position:sticky;top:0;z-index:3;.breadcrumbs{display:flex;align-items:center;margin-right:10px;.breadcrumb-container{white-space:nowrap;.breadcrumb{color:hsl(var(--primary));margin-right:4px;cursor:pointer;&:after{margin-left:4px}&:hover{color:rgb(189, 219, 209)}&:last-child{margin-right:0;color:rgb(189, 219, 209);cursor:default}}}.arrow{height:12px;width:12px;opacity:0.6;top:2px;margin-right:4px;position:relative}}.actions{display:flex;align-items:center;gap:8px}.filter{height:1.5rem;width:110px;padding:0 6px;font:inherit;font-size:0.68rem;color:rgb(189, 219, 209);background-color:hsl(var(--muted));border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);outline:none;&::placeholder{color:hsl(var(--muted-foreground))}&:focus{border-color:hsl(var(--primary))}}.action{border:none;background:transparent;color:rgb(189, 219, 209);font-size:1.1rem;line-height:1;padding:2px 4px;border-radius:4px;cursor:pointer;&:hover{background-color:hsl(var(--border) / 0.6)}img{height:14px;width:14px;display:block}}.action.disconnect{color:#ff4d5f;font-size:0.65rem;letter-spacing:0.08em;padding:4px 8px;&:hover{color:#ff6b7a;background-color:hsl(var(--destructive) / 0.12)}}}.content{flex:1;min-height:0;outline:none;overflow:auto;font-size:0.75rem;line-height:1rem;scrollbar-width:thin;scrollbar-color:hsl(var(--scroll-thumb)) hsl(var(--scroll-track));&:focus-visible{box-shadow:inset 0 0 0 1px hsl(var(--primary) / 0.5)}&::-webkit-scrollbar{width:10px;height:10px}&::-webkit-scrollbar-track{background:hsl(var(--scroll-track))}&::-webkit-scrollbar-thumb{background:hsl(var(--scroll-thumb));border-radius:999px;border:2px solid hsl(var(--scroll-track))}&::-webkit-scrollbar-thumb:hover{background:hsl(var(--scroll-thumb-hover))}table{width:100%;border-collapse:separate;border-spacing:0;table-layout:auto;thead{background-color:hsl(var(--muted));border-bottom:1px solid hsl(var(--border));th.sortable{cursor:pointer;user-select:none;&:hover{color:hsl(var(--primary))}}th{padding:8px 10px;text-align:left;color:hsl(var(--muted-foreground));position:sticky;top:0;z-index:2;background-color:hsl(var(--muted));border-bottom:1px solid hsl(var(--border));line-height:0.95rem;&.action-col{width:58px;min-width:58px;padding:0 10px}&:first-child{width:30%;min-width:180px;max-width:195px}&:nth-child(2),&:nth-child(3),&:nth-child(4),&:nth-child(5){white-space:nowrap;width:1%}}}tbody{padding:10px 10px;tr.empty{cursor:default;td{color:hsl(var(--muted-foreground));text-align:center;padding:18px 8px}&:hover{background:transparent}}tr{border-bottom:1px solid hsl(var(--border) / 0.4);td{padding:10px 10px 9px;color:hsl(var(--muted-foreground));&:first-child{min-width:180px;max-width:195px;white-space:nowrap;.name{display:inline-block;max-width:calc(100% - 26px);overflow:hidden;text-overflow:ellipsis;vertical-align:middle}}&:nth-child(2),&:nth-child(3),&:nth-child(4),&:nth-child(5){white-space:nowrap}&.action-col{width:58px;min-width:58px;text-align:center;padding-left:1px;padding-right:1px;.file-actions{display:flex;align-items:center;justify-content:center;gap:8px}.file-action{border:none;background:transparent;color:hsl(var(--muted-foreground));width:16px;height:16px;border-radius:3px;cursor:pointer;opacity:0;visibility:hidden;pointer-events:none;transition:opacity 120ms ease;padding:0;svg{width:12px;height:12px;display:block;margin:0 auto}&:hover{color:hsl(var(--primary))}&.delete:hover{color:hsl(var(--destructive))}}}.name{&.file{color:rgb(189, 219, 209)}&.folder{color:hsl(var(--primary))}}.kind{height:14px;width:14px;margin-right:5px;top:3px;position:relative}}&:hover{cursor:pointer;background-color:hsl(var(--muted) / 0.4);td.action-col .file-action{opacity:1;visibility:visible;pointer-events:auto;color:hsl(var(--primary))}}&.selected{background-color:hsl(var(--primary) / 0.3);td.action-col .file-action{opacity:1;visibility:visible;pointer-events:auto}&:hover{background-color:hsl(var(--primary) / 0.4)}}}}}}}footer{height:25px;background:rgba(28, 31, 38, 0.6);border-top:1px solid hsl(var(--border));font-size:0.75rem;line-height:1rem;display:flex;align-items:center;justify-content:space-between;padding:0 10px;.status{font-size:0.65rem;color:hsl(var(--muted-foreground));.selected-item{margin-left:10px;color:hsl(var(--primary))}}.version{font-size:0.65rem;color:hsl(var(--muted-foreground))}}}.creds{position:absolute;top:0;left:0;height:100%;width:100%;display:flex;justify-content:center;align-items:center;;&.blurred{background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px)}.auth{display:flex;flex-direction:column;background:hsl(var(--card));position:relative;background-color:rgba(21, 24, 30, 0.95);border:1px solid hsl(var(--border));padding:30px;box-shadow:rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0.5) 0px 25px 50px -12px;border-radius:var(--radius);.title{margin-bottom:12px;color:hsl(var(--primary))}label{font-size:0.75rem;line-height:1rem;margin-bottom:1rem;color:hsl(var(--muted-foreground))}input{font-size:0.875rem;line-height:1.25rem;padding-top:0.5rem;padding-bottom:0.5rem;padding-left:0.75rem;padding-right:0.75rem;background-color:rgb(28, 31, 38);border-color:rgb(39, 44, 53);border-width:1px;border-radius:calc(var(--radius) - 2px);width:100%;margin-bottom:12px;color:rgb(189, 219, 209);box-sizing:border-box;&:focus{outline:none;border-color:hsl(var(--primary));box-shadow:0 0 0 1px hsl(var(--primary))}}button[type='submit']{margin-top:12px;width:100%;background-color:hsl(var(--primary));color:hsl(var(--primary-foreground));letter-spacing:0.05em;font-size:13px;font-weight:500;padding:0.5rem 1rem;border-radius:calc(var(--radius) - 2px);height:2rem;cursor:pointer;border:none;&:hover{background-color:hsl(var(--primary) / 0.9)}}}}.upload-modal,.download-modal,.delete-modal,.prompt-modal{position:absolute;inset:0;display:none;align-items:center;justify-content:center;background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px);z-index:6;&.visible{display:flex}.upload-dialog,.download-dialog,.delete-dialog,.prompt-dialog{width:min(360px, calc(100% - 24px));background-color:rgba(21, 24, 30, 0.96);border:1px solid hsl(var(--border));border-radius:var(--radius);padding:16px;box-shadow:rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0.5) 0px 25px 50px -12px;.title{color:hsl(var(--primary));font-size:0.8rem;margin-bottom:8px}.file-name{color:rgb(189, 219, 209);font-size:0.72rem;line-height:1rem;margin-bottom:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.progress-track{width:100%;height:10px;border-radius:999px;background-color:hsl(var(--muted));overflow:hidden;border:1px solid hsl(var(--border));.progress-fill{height:100%;width:0;background:linear-gradient(90deg, hsl(var(--primary) / 0.7), hsl(var(--primary)));transition:width 140ms ease}}.progress-meta{margin-top:8px;margin-bottom:12px;display:flex;align-items:center;justify-content:space-between;gap:10px}.progress-speed{color:hsl(var(--muted-foreground));font-size:0.75rem;font-variant-numeric:tabular-nums;line-height:1.4;text-align:left}.progress-value{color:hsl(var(--muted-foreground));font-size:0.75rem;font-variant-numeric:tabular-nums;line-height:1.4;text-align:right}.cancel{margin-top:14px;width:100%;height:2rem;border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);background:hsl(var(--muted));color:rgb(189, 219, 209);font-size:0.75rem;letter-spacing:0.03em;cursor:pointer;&:hover{border-color:hsl(var(--primary));color:hsl(var(--primary))}&.finished{background-color:hsl(var(--primary));border-color:hsl(var(--primary));color:hsl(var(--primary-foreground));&:hover{background-color:hsl(var(--primary) / 0.9);border-color:hsl(var(--primary) / 0.9);color:hsl(var(--primary-foreground))}}}.message{color:rgb(189, 219, 209);font-size:0.74rem;line-height:1rem;margin-bottom:8px}.modal-actions{margin-top:14px;display:grid;grid-template-columns:1fr 1fr;gap:8px;.btn{height:2rem;border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);font-size:0.75rem;letter-spacing:0.03em;cursor:pointer;&:disabled{opacity:0.65;cursor:not-allowed}}.btn.secondary{background:hsl(var(--muted));color:rgb(189, 219, 209);&:hover{border-color:hsl(var(--primary));color:hsl(var(--primary))}}.btn.destructive{background:hsl(var(--destructive));border-color:hsl(var(--destructive));color:white;&:hover{background:hsl(var(--destructive) / 0.9);border-color:hsl(var(--destructive) / 0.9)}}}.dialog-input{width:100%;box-sizing:border-box;height:2rem;padding:0 8px;font:inherit;font-size:0.75rem;color:rgb(189, 219, 209);background-color:hsl(var(--muted));border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);outline:none;&:focus{border-color:hsl(var(--primary))}&:disabled{opacity:0.65}}.dialog-error{margin-top:8px;font-size:0.7rem;line-height:0.95rem;color:#ff6b7a}.hint{margin-top:4px;font-size:0.66rem;line-height:0.9rem;color:hsl(var(--muted-foreground))}.checkline{margin-top:8px;display:flex;align-items:center;gap:6px;font-size:0.72rem;color:rgb(189, 219, 209);cursor:pointer;input{accent-color:hsl(var(--primary));margin:0}}.perm-grid{margin-top:10px;width:100%;border-collapse:collapse;font-size:0.68rem;th{color:hsl(var(--muted-foreground));font-weight:normal;text-align:center;padding:2px 0}th[scope='row']{text-align:left;color:rgb(189, 219, 209)}td{text-align:center;padding:2px 0}input{accent-color:hsl(var(--primary));margin:0}}.perm-special{margin-top:4px;display:flex;gap:12px;.checkline{margin-top:4px;font-size:0.66rem}}.perm-octal{margin-top:10px;display:flex;align-items:center;gap:8px;label{font-size:0.68rem;color:hsl(var(--muted-foreground))}.dialog-input{width:4.5rem;text-align:center;letter-spacing:0.1em}.perm-preview{font-size:0.7rem;color:hsl(var(--primary))}}.modal-actions .btn.primary{background:hsl(var(--primary));border-color:hsl(var(--primary));color:hsl(var(--primary-foreground));&:hover:not(:disabled){background:hsl(var(--primary) / 0.9);border-color:hsl(var(--primary) / 0.9)}}.delete-loader{margin-top:4px;display:flex;justify-content:center;.spinner{width:16px;height:16px;border:2px solid hsl(var(--muted-foreground) / 0.35);border-top-color:hsl(var(--primary));border-radius:50%;animation:spin 0.7s linear infinite}}}}.editor-modal{position:absolute;inset:0;display:none;align-items:center;justify-content:center;background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px);z-index:7;&.visible{display:flex}.editor-dialog{width:min(860px, calc(100% - 24px));height:min(620px, calc(100% - 24px));display:flex;flex-direction:column;background-color:rgba(21, 24, 30, 0.98);border:1px solid hsl(var(--border));border-radius:var(--radius);padding:16px;box-shadow:rgba(0, 0, 0, 0.5) 0px 25px 50px -12px;outline:none;.editor-head{display:flex;align-items:center;justify-content:space-between;gap:8px;.title{color:hsl(var(--primary));font-size:0.8rem;margin-bottom:8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.editor-close{border:none;background:transparent;color:hsl(var(--muted-foreground));font-size:0.85rem;line-height:1;padding:2px 6px;border-radius:4px;cursor:pointer;&:hover:not(:disabled){color:hsl(var(--primary));background-color:hsl(var(--border) / 0.6)}&:disabled{opacity:0.5;cursor:not-allowed}}}.editor-loading{flex:1;display:flex;align-items:center;justify-content:center;font-size:0.75rem;color:hsl(var(--muted-foreground))}.editor-text{flex:1;min-height:0;width:100%;box-sizing:border-box;resize:none;padding:10px;font:inherit;font-size:0.75rem;line-height:1.15rem;tab-size:4;white-space:pre;overflow:auto;color:rgb(189, 219, 209);background-color:hsl(var(--muted));border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);outline:none;&:focus{border-color:hsl(var(--primary) / 0.6)}&:disabled{opacity:0.65}}.dialog-error{margin-top:8px;font-size:0.7rem;line-height:0.95rem;color:#ff6b7a}.modal-actions{margin-top:14px;display:flex;justify-content:flex-end;gap:8px;.btn{height:2rem;min-width:6rem;border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);font-size:0.75rem;letter-spacing:0.03em;cursor:pointer;&:disabled{opacity:0.65;cursor:not-allowed}}.btn.secondary{background:hsl(var(--muted));color:rgb(189, 219, 209);&:hover:not(:disabled){border-color:hsl(var(--primary));color:hsl(var(--primary))}}.btn.destructive{background:hsl(var(--destructive));border-color:hsl(var(--destructive));color:white}.btn.primary{background:hsl(var(--primary));border-color:hsl(var(--primary));color:hsl(var(--primary-foreground));&:hover:not(:disabled){background:hsl(var(--primary) / 0.9);border-color:hsl(var(--primary) / 0.9)}}}}}}@keyframes spin{to{transform:rotate(360deg)}}:host(.max){height:100vh;width:100vw;position:fixed;top:0;left:0;z-index:9999}@container (max-width: 699px){:host .listing main .content table thead th:nth-child(4),:host .listing main .content table tbody td:nth-child(4){display:none}}@container (max-width: 635px){:host .listing main .content table thead th:nth-child(3),:host .listing main .content table tbody td:nth-child(3){display:none}}@container (max-width: 530px){:host .listing main .content table thead th:nth-child(5),:host .listing main .content table tbody td:nth-child(5){display:none}:host .listing footer .status{display:none}}@container (max-width: 370px){:host .listing main .content table thead th:nth-child(2),:host .listing main .content table tbody td:nth-child(2){display:none}:host .listing main .content table thead th:first-child,:host .listing main .content table tbody td:first-child{width:100%;min-width:0;max-width:none}:host .listing main .content table tbody td:first-child .name{max-width:100%}}@container (max-width: 295px){:host .listing main .content table tbody td:first-child .name{max-width:120px}}@container (max-width: 635px){:host .listing main .content table tbody tr td.action-col .file-action{opacity:1;visibility:visible;pointer-events:auto;width:36px;height:36px;border-radius:8px}:host .listing main .content table tbody tr td.action-col .file-action svg{width:17px;height:17px}:host .listing main .content table thead th.action-col,:host .listing main .content table tbody td.action-col{width:92px;min-width:92px}:host .listing main .content table tbody td.action-col .file-actions{gap:4px}:host .listing main .content table tbody tr:hover{background-color:transparent}:host .listing main .content table tbody tr.selected:hover{background-color:hsl(var(--primary) / 0.3)}:host .listing main .content table tbody td{padding:13px 10px 12px}:host .listing main .content table thead th{padding:12px 10px}:host .listing main .navigation{height:auto;min-height:44px;padding:6px 8px}:host .listing main .navigation .action{padding:10px;border-radius:8px}:host .listing main .navigation .action img{height:17px;width:17px}:host .listing main .navigation .action.disconnect{padding:10px 12px}:host .listing main .navigation .filter{height:2.25rem;font-size:16px;width:8rem}:host .listing header .actions .action{padding:8px}:host .listing header .actions .action img{height:17px}:host .modal .upload-dialog .cancel,:host .modal .download-dialog .cancel,:host .modal .delete-dialog .cancel,:host .modal .prompt-dialog .cancel,:host .modal .upload-dialog .modal-actions .btn,:host .modal .download-dialog .modal-actions .btn,:host .modal .delete-dialog .modal-actions .btn,:host .modal .prompt-dialog .modal-actions .btn{height:2.75rem}:host .modal .prompt-dialog .dialog-input,:host .auth input{height:2.5rem;font-size:16px}:host .modal .prompt-dialog .perm-grid input,:host .modal .prompt-dialog .perm-special input{width:20px;height:20px}:host .modal .prompt-dialog .perm-grid td,:host .modal .prompt-dialog .perm-grid th{padding:7px 0}}"}},[513,"phirepass-sftp-client",{name:[1],description:[1],hideHeader:[4,"hide-header"],serverHost:[1,"server-host"],serverPort:[2,"server-port"],allowInsecure:[4,"allow-insecure"],heartbeatInterval:[2,"heartbeat-interval"],nodeId:[1,"node-id"],serviceId:[1,"service-id"],token:[1],serverId:[1,"server-id"],channelFactory:[16],max:[32],show_login_screen:[32],show_login_screen_username:[32],show_error:[32],error_message:[32],show_login_screen_password:[32],show_navigation:[32],breadcrumbs:[32],current_dir:[32],listing:[32],show_content:[32],show_loader:[32],version:[32],status:[32],selected_item:[32],show_upload_modal:[32],upload_progress:[32],upload_file_name:[32],upload_speed:[32],upload_finished:[32],show_download_modal:[32],download_progress:[32],download_file_name:[32],download_speed:[32],download_finished:[32],show_delete_modal:[32],delete_file_name:[32],delete_loading:[32],delete_is_dir:[32],delete_recursive:[32],delete_error:[32],prompt_kind:[32],prompt_value:[32],prompt_error:[32],prompt_busy:[32],chmod_target:[32],chmod_mode:[32],chmod_error:[32],chmod_busy:[32],show_editor:[32],editor_name:[32],editor_text:[32],editor_saved_text:[32],editor_busy:[32],editor_error:[32],editor_confirm_discard:[32],editor_loaded:[32],filter:[32],sort_key:[32],sort_asc:[32],maximize:[64],minimize:[64]},void 0,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}]);function b(){"undefined"!=typeof customElements&&["phirepass-sftp-client"].forEach((t=>{"phirepass-sftp-client"===t&&(customElements.get(e(t))||customElements.define(e(t),h))}))}b();const p=h,g=b;export{p as PhirepassSftpClient,g as defineCustomElement}