phirepass-widgets 0.0.116 → 0.0.117

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 (26) hide show
  1. package/README.md +13 -12
  2. package/dist/cjs/{index-BCgmMoIq.js → index-DehquNXP.js} +1 -1
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/phirepass-downloader_3.cjs.entry.js +19 -8
  5. package/dist/cjs/phirepass-rdp.cjs.entry.js +1 -1
  6. package/dist/cjs/phirepass-terminal.cjs.entry.js +1 -1
  7. package/dist/cjs/phirepass-widgets.cjs.js +2 -2
  8. package/dist/collection/collection-manifest.json +1 -1
  9. package/dist/collection/components/phirepass-downloader/phirepass-downloader.js +18 -7
  10. package/dist/components/{p-5QoAejYG.js → p-B4kFfbHE.js} +1 -1
  11. package/dist/components/phirepass-downloader.js +1 -1
  12. package/dist/components/phirepass-sftp-client.js +1 -1
  13. package/dist/esm/{index-Dd9o0CbU.js → index-BinptKL7.js} +1 -1
  14. package/dist/esm/loader.js +2 -2
  15. package/dist/esm/phirepass-downloader_3.entry.js +19 -8
  16. package/dist/esm/phirepass-rdp.entry.js +1 -1
  17. package/dist/esm/phirepass-terminal.entry.js +1 -1
  18. package/dist/esm/phirepass-widgets.js +3 -3
  19. package/dist/phirepass-widgets/p-6a192c8d.entry.js +1 -0
  20. package/dist/phirepass-widgets/{p-c28a9257.entry.js → p-9e6f9220.entry.js} +4 -4
  21. package/dist/phirepass-widgets/{p-70a67e4d.entry.js → p-fe1ce8da.entry.js} +1 -1
  22. package/dist/phirepass-widgets/phirepass-widgets.esm.js +1 -1
  23. package/dist/types/components/phirepass-downloader/phirepass-downloader.d.ts +7 -0
  24. package/package.json +8 -8
  25. package/dist/phirepass-widgets/p-ab33f71f.entry.js +0 -1
  26. /package/dist/phirepass-widgets/{p-Dd9o0CbU.js → p-BinptKL7.js} +0 -0
@@ -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-5QoAejYG.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{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}
@@ -2,7 +2,7 @@ const NAMESPACE = 'phirepass-widgets';
2
2
  const BUILD = /* phirepass-widgets */ { hotModuleReplacement: false, hydratedSelectorName: "hydrated", lazyLoad: true, propChangeCallback: true, state: true, updatable: true};
3
3
 
4
4
  /*
5
- Stencil Client Platform v4.45.4 | MIT Licensed | https://stenciljs.com
5
+ Stencil Client Platform v4.45.5 | MIT Licensed | https://stenciljs.com
6
6
  */
7
7
 
8
8
 
@@ -1,5 +1,5 @@
1
- import { b as bootstrapLazy } from './index-Dd9o0CbU.js';
2
- export { s as setNonce } from './index-Dd9o0CbU.js';
1
+ import { b as bootstrapLazy } from './index-BinptKL7.js';
2
+ export { s as setNonce } from './index-BinptKL7.js';
3
3
  import { g as globalScripts } from './app-globals-DQuL1Twl.js';
4
4
 
5
5
  const defineCustomElements = async (win, options) => {
@@ -1,4 +1,4 @@
1
- import { h, r as registerInstance, c as createEvent, g as getElement, H as Host } from './index-Dd9o0CbU.js';
1
+ import { h, r as registerInstance, c as createEvent, g as getElement, H as Host } from './index-BinptKL7.js';
2
2
  import { _ as __wbg_init, C as Channel, P as ProtocolMessageType, E as ErrorType, a as ConnectionState } from './protocol-BekUePpu.js';
3
3
 
4
4
  const DOWNLOAD_METHODS = [
@@ -1630,6 +1630,15 @@ const PhirepassDownloader = class {
1630
1630
  this.picker = null;
1631
1631
  }
1632
1632
  // ---------------------------------------------------------------- render
1633
+ /**
1634
+ * The dialog's state as it is now, not as it was when the dialog last rendered.
1635
+ * Handlers run between a state change and the re-render it schedules (tick a box,
1636
+ * then click confirm before the frame), so reading `c` from the render closure
1637
+ * would act on the stale value.
1638
+ */
1639
+ latest(c) {
1640
+ return this.confirm?.kind === c.kind ? this.confirm : c;
1641
+ }
1633
1642
  renderConfirm() {
1634
1643
  const c = this.confirm;
1635
1644
  if (!c) {
@@ -1638,13 +1647,15 @@ const PhirepassDownloader = class {
1638
1647
  const cancel = () => (this.confirm = null);
1639
1648
  switch (c.kind) {
1640
1649
  case 'stop':
1641
- return (h(ConfirmStop, { row: c.row, discard: c.discard, onDiscard: discard => (this.confirm = { ...c, discard }), onCancel: cancel, onConfirm: () => {
1642
- this.sendStop(c.row, c.discard);
1650
+ return (h(ConfirmStop, { row: c.row, discard: c.discard, onDiscard: discard => (this.confirm = { ...this.latest(c), discard }), onCancel: cancel, onConfirm: () => {
1651
+ const cur = this.latest(c);
1652
+ this.sendStop(cur.row, cur.discard);
1643
1653
  this.confirm = null;
1644
1654
  } }));
1645
1655
  case 'delete':
1646
- return (h(ConfirmDelete, { row: c.row, nodeName: this.name, deleteFile: c.deleteFile, onDeleteFile: deleteFile => (this.confirm = { ...c, deleteFile }), onCancel: cancel, onConfirm: () => {
1647
- this.sendDelete(c.row, c.deleteFile);
1656
+ return (h(ConfirmDelete, { row: c.row, nodeName: this.name, deleteFile: c.deleteFile, onDeleteFile: deleteFile => (this.confirm = { ...this.latest(c), deleteFile }), onCancel: cancel, onConfirm: () => {
1657
+ const cur = this.latest(c);
1658
+ this.sendDelete(cur.row, cur.deleteFile);
1648
1659
  this.confirm = null;
1649
1660
  } }));
1650
1661
  case 'fastest':
@@ -1654,8 +1665,8 @@ const PhirepassDownloader = class {
1654
1665
  this.confirm = null;
1655
1666
  } }));
1656
1667
  case 'torrent':
1657
- return (h(ConfirmTorrent, { nodeName: this.name, dontAsk: c.dontAsk, onDontAsk: dontAsk => (this.confirm = { ...c, dontAsk }), onCancel: cancel, onConfirm: () => {
1658
- if (c.dontAsk) {
1668
+ return (h(ConfirmTorrent, { nodeName: this.name, dontAsk: c.dontAsk, onDontAsk: dontAsk => (this.confirm = { ...this.latest(c), dontAsk }), onCancel: cancel, onConfirm: () => {
1669
+ if (this.latest(c).dontAsk) {
1659
1670
  writeTorrentAck();
1660
1671
  this.torrentAcked = true;
1661
1672
  }
@@ -1734,7 +1745,7 @@ const PhirepassDownloader = class {
1734
1745
  ]));
1735
1746
  }
1736
1747
  render() {
1737
- return (h(Host, { key: '6a7316df730c5bc4bc588f7d05e19033d98a9d0a', class: { compact: this.compact, standalone: !this.compact } }, this.compact ? this.renderCompact() : this.renderStandalone(), this.renderConfirm(), this.picker && (h(FolderPicker, { key: '412dc8107ea30420f022a49f188ea020eabd46f5', root: this.caps?.folder ?? '', path: this.picker.path, folders: this.picker.folders, error: this.picker.error, newName: this.picker.newName, onOpen: name => this.listFolders([...this.picker.path, name]), onUp: depth => this.listFolders(this.picker.path.slice(0, depth)), onNewName: newName => (this.picker = { ...this.picker, newName }), onCancel: () => (this.picker = null), onSave: () => this.savePicker() })), this.player && (h("div", { key: '61bc6c3ab32346d87c0ed02280182fdae234eb71', class: "overlay player" }, h("phirepass-media-player", { key: '59d99ac6289a146ba106e9cb8682d5f7b4383e26', src: this.player.src, name: this.player.name, status: this.playerStatus(), ready: this.playerReady(), positionKey: `dl:${this.player.downloadId}`, onPhirepassPlayerClose: () => (this.player = null) }))), h(Notices, { key: 'fa27f16c8f72435939e51b48d92b6f10b0535d80', notices: this.notices, onDismiss: id => this.dismiss(id) })));
1748
+ return (h(Host, { key: 'b7f751d7107ff8f00d791e5c54f4261e2d7cd580', class: { compact: this.compact, standalone: !this.compact } }, this.compact ? this.renderCompact() : this.renderStandalone(), this.renderConfirm(), this.picker && (h(FolderPicker, { key: '538f0f433863e0fbd79a8e66c0b7a45c93a8bd28', root: this.caps?.folder ?? '', path: this.picker.path, folders: this.picker.folders, error: this.picker.error, newName: this.picker.newName, onOpen: name => this.listFolders([...this.picker.path, name]), onUp: depth => this.listFolders(this.picker.path.slice(0, depth)), onNewName: newName => (this.picker = { ...this.picker, newName }), onCancel: () => (this.picker = null), onSave: () => this.savePicker() })), this.player && (h("div", { key: 'b9d3ade696c6079d6a2e3bc2206c19a6bdd7d640', class: "overlay player" }, h("phirepass-media-player", { key: 'c5fa1244ea9766ff37d08478dbc2d096430f2081', src: this.player.src, name: this.player.name, status: this.playerStatus(), ready: this.playerReady(), positionKey: `dl:${this.player.downloadId}`, onPhirepassPlayerClose: () => (this.player = null) }))), h(Notices, { key: '34a34a810001815a890a0995aab44f29f34aab61', notices: this.notices, onDismiss: id => this.dismiss(id) })));
1738
1749
  }
1739
1750
  playerRow() {
1740
1751
  return this.player ? this.jobs[this.player.downloadId] : undefined;
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, c as createEvent, g as getElement, h, H as Host } from './index-Dd9o0CbU.js';
1
+ import { r as registerInstance, c as createEvent, g as getElement, h, H as Host } from './index-BinptKL7.js';
2
2
  import { _ as __wbg_init, C as Channel, a as ConnectionState, P as ProtocolMessageType } from './protocol-BekUePpu.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, c as createEvent, g as getElement, h as h$1, H as Host } from './index-Dd9o0CbU.js';
1
+ import { r as registerInstance, c as createEvent, g as getElement, h as h$1, H as Host } from './index-BinptKL7.js';
2
2
  import { I as InputMode, _ as __wbg_init, C as Channel, a as ConnectionState, P as ProtocolMessageType, E as ErrorType } from './protocol-BekUePpu.js';
3
3
 
4
4
  /**
@@ -1,9 +1,9 @@
1
- import { p as promiseResolve, b as bootstrapLazy } from './index-Dd9o0CbU.js';
2
- export { s as setNonce } from './index-Dd9o0CbU.js';
1
+ import { p as promiseResolve, b as bootstrapLazy } from './index-BinptKL7.js';
2
+ export { s as setNonce } from './index-BinptKL7.js';
3
3
  import { g as globalScripts } from './app-globals-DQuL1Twl.js';
4
4
 
5
5
  /*
6
- Stencil Client Patch Browser v4.45.4 | MIT Licensed | https://stenciljs.com
6
+ Stencil Client Patch Browser v4.45.5 | MIT Licensed | https://stenciljs.com
7
7
  */
8
8
 
9
9
  var patchBrowser = () => {