phirepass-widgets 0.0.112 → 0.0.113

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 (89) hide show
  1. package/README.md +33 -0
  2. package/dist/cjs/{index-B8w6l0VL.js → index-CurErEK7.js} +101 -30
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/phirepass-downloader_3.cjs.entry.js +3696 -0
  5. package/dist/cjs/phirepass-rdp.cjs.entry.js +18 -6
  6. package/dist/cjs/phirepass-terminal.cjs.entry.js +6 -5
  7. package/dist/cjs/phirepass-widgets.cjs.js +3 -3
  8. package/dist/cjs/{protocol-COvteaUJ.js → protocol-DCBMfc2u.js} +557 -360
  9. package/dist/collection/collection-manifest.json +3 -1
  10. package/dist/collection/common/channel.js +21 -1
  11. package/dist/collection/common/fetch.js +40 -0
  12. package/dist/collection/components/phirepass-downloader/form.js +69 -0
  13. package/dist/collection/components/phirepass-downloader/format.js +105 -0
  14. package/dist/collection/components/phirepass-downloader/jobs.js +370 -0
  15. package/dist/collection/components/phirepass-downloader/phirepass-downloader.css +1109 -0
  16. package/dist/collection/components/phirepass-downloader/phirepass-downloader.js +1455 -0
  17. package/dist/collection/components/phirepass-downloader/source.js +106 -0
  18. package/dist/collection/components/phirepass-downloader/views/dialogs.js +34 -0
  19. package/dist/collection/components/phirepass-downloader/views/fetch-form.js +65 -0
  20. package/dist/collection/components/phirepass-downloader/views/icons.js +33 -0
  21. package/dist/collection/components/phirepass-downloader/views/job-row.js +91 -0
  22. package/dist/collection/components/phirepass-downloader/views/notices.js +15 -0
  23. package/dist/collection/components/phirepass-downloader/views/states.js +19 -0
  24. package/dist/collection/components/phirepass-media-player/phirepass-media-player.css +216 -0
  25. package/dist/collection/components/phirepass-media-player/phirepass-media-player.js +473 -0
  26. package/dist/collection/components/phirepass-media-player/player.js +94 -0
  27. package/dist/collection/components/phirepass-rdp/phirepass-rdp.js +36 -13
  28. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.css +122 -0
  29. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.fetch.js +35 -0
  30. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.js +181 -31
  31. package/dist/collection/components/phirepass-terminal/phirepass-terminal.js +2 -2
  32. package/dist/collection/phirepass-channel_bg.wasm +0 -0
  33. package/dist/collection/testing/fixtures.js +219 -0
  34. package/dist/collection/testing/mock-channel.js +410 -0
  35. package/dist/components/index.js +1 -1
  36. package/dist/components/p-C4cmk3bS.js +1 -0
  37. package/dist/components/p-CsYQJXY2.js +1 -0
  38. package/dist/components/p-D6Geq8Rn.js +1 -0
  39. package/dist/components/phirepass-downloader.d.ts +11 -0
  40. package/dist/components/phirepass-downloader.js +1 -0
  41. package/dist/components/phirepass-media-player.d.ts +11 -0
  42. package/dist/components/phirepass-media-player.js +1 -0
  43. package/dist/components/phirepass-rdp.js +1 -1
  44. package/dist/components/phirepass-sftp-client.js +1 -1
  45. package/dist/components/phirepass-terminal.js +2 -2
  46. package/dist/esm/{index-DGq2b7rM.js → index-B9qUl6FW.js} +101 -30
  47. package/dist/esm/loader.js +3 -3
  48. package/dist/esm/phirepass-downloader_3.entry.js +3692 -0
  49. package/dist/esm/phirepass-rdp.entry.js +18 -6
  50. package/dist/esm/phirepass-terminal.entry.js +6 -5
  51. package/dist/esm/phirepass-widgets.js +4 -4
  52. package/dist/esm/{protocol-Dur4cBX7.js → protocol-CsYQJXY2.js} +556 -359
  53. package/dist/phirepass-widgets/p-1b84c526.entry.js +1 -0
  54. package/dist/phirepass-widgets/{p-1fef5b5f.entry.js → p-41dd1ac9.entry.js} +2 -2
  55. package/dist/phirepass-widgets/p-614ab3de.entry.js +1 -0
  56. package/dist/phirepass-widgets/p-B9qUl6FW.js +3 -0
  57. package/dist/phirepass-widgets/p-CsYQJXY2.js +1 -0
  58. package/dist/phirepass-widgets/phirepass-channel_bg.wasm +0 -0
  59. package/dist/phirepass-widgets/phirepass-widgets.esm.js +1 -1
  60. package/dist/types/common/channel.d.ts +30 -0
  61. package/dist/types/common/fetch.d.ts +161 -0
  62. package/dist/types/components/phirepass-downloader/form.d.ts +54 -0
  63. package/dist/types/components/phirepass-downloader/format.d.ts +17 -0
  64. package/dist/types/components/phirepass-downloader/jobs.d.ts +115 -0
  65. package/dist/types/components/phirepass-downloader/phirepass-downloader.d.ts +231 -0
  66. package/dist/types/components/phirepass-downloader/source.d.ts +61 -0
  67. package/dist/types/components/phirepass-downloader/views/dialogs.d.ts +52 -0
  68. package/dist/types/components/phirepass-downloader/views/fetch-form.d.ts +31 -0
  69. package/dist/types/components/phirepass-downloader/views/icons.d.ts +5 -0
  70. package/dist/types/components/phirepass-downloader/views/job-row.d.ts +21 -0
  71. package/dist/types/components/phirepass-downloader/views/notices.d.ts +18 -0
  72. package/dist/types/components/phirepass-downloader/views/states.d.ts +38 -0
  73. package/dist/types/components/phirepass-media-player/phirepass-media-player.d.ts +67 -0
  74. package/dist/types/components/phirepass-media-player/player.d.ts +43 -0
  75. package/dist/types/components/phirepass-rdp/phirepass-rdp.d.ts +10 -0
  76. package/dist/types/components/phirepass-sftp-client/phirepass-sftp-client.d.ts +30 -0
  77. package/dist/types/components/phirepass-sftp-client/phirepass-sftp-client.fetch.d.ts +40 -0
  78. package/dist/types/components.d.ts +426 -34
  79. package/dist/types/stencil-public-runtime.d.ts +1 -1
  80. package/dist/types/testing/fixtures.d.ts +25 -0
  81. package/dist/types/testing/mock-channel.d.ts +132 -0
  82. package/package.json +26 -12
  83. package/dist/cjs/phirepass-sftp-client.cjs.entry.js +0 -1469
  84. package/dist/components/p-Dur4cBX7.js +0 -1
  85. package/dist/esm/phirepass-sftp-client.entry.js +0 -1467
  86. package/dist/phirepass-widgets/p-8eb3ec24.entry.js +0 -1
  87. package/dist/phirepass-widgets/p-9a1f9b9f.entry.js +0 -1
  88. package/dist/phirepass-widgets/p-DGq2b7rM.js +0 -3
  89. package/dist/phirepass-widgets/p-Dur4cBX7.js +0 -1
@@ -1 +1 @@
1
- function t(t,e,n){const l="undefined"!=typeof HTMLElement?HTMLElement.prototype:null;for(;t&&t!==l;){const l=Object.getOwnPropertyDescriptor(t,e);if(l&&(!n||l.get))return l;t=Object.getPrototypeOf(t)}}var e,n=(e,n)=>{var l;Object.entries(null!=(l=n.l.t)?l:{}).map((([l,[o]])=>{if(31&o||32&o){const o=e[l],s=t(Object.getPrototypeOf(e),l,!0)||Object.getOwnPropertyDescriptor(e,l);s&&Object.defineProperty(e,l,{get(){return s.get.call(this)},set(t){s.set.call(this,t)},configurable:!0,enumerable:!0}),n.o.has(l)?e[l]=n.o.get(l):void 0!==o&&(e[l]=o)}}))},l=t=>{if(t.__stencil__getHostRef)return t.__stencil__getHostRef()},o=(t,e)=>e in t,s=(t,e)=>(0,console.error)(t,e),i=new Map,r="undefined"!=typeof window?window:{},c=r.HTMLElement||class{},f={i:0,u:"",jmp:t=>t(),raf:t=>requestAnimationFrame(t),ael:(t,e,n,l)=>t.addEventListener(e,n,l),rel:(t,e,n,l)=>t.removeEventListener(e,n,l),ce:(t,e)=>new CustomEvent(t,e)},u=(()=>{try{return!!r.document.adoptedStyleSheets&&(new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync)}catch(t){}return!1})(),a=!!u&&(()=>!!r.document&&Object.getOwnPropertyDescriptor(r.document.adoptedStyleSheets,"length").writable)(),d=!1,p=[],h=[],m=()=>{var t;return(null==(t=r.document)?void 0:t.hidden)?$(v):f.raf(v)},b=(t,e)=>n=>{t.push(n),d||(d=!0,e&&4&f.i?$(v):m())},y=t=>{for(let e=0;e<t.length;e++)try{t[e](performance.now())}catch(t){s(t)}t.length=0},v=()=>{y(p),y(h),(d=p.length>0)&&m()},$=t=>Promise.resolve(void 0).then(t),g=b(h,!0),w=t=>{const e=new URL(t,f.u);return e.origin!==r.location.origin?e.href:e.pathname},j=t=>f.u=t;function O(){const t=this.attachShadow({mode:"open"});void 0===e&&(e=null),e&&(a?t.adoptedStyleSheets.push(e):t.adoptedStyleSheets=[...t.adoptedStyleSheets,e])}var S,k=new WeakMap,M=t=>"sc-"+t.p,E=t=>"object"==(t=typeof t)||"function"===t,A=(t,e,...n)=>{let l=null,o=null,i=!1,r=!1;const c=[],f=e=>{for(let n=0;n<e.length;n++)if(l=e[n],Array.isArray(l))f(l);else if(null!=l&&"boolean"!=typeof l){if(i="function"!=typeof t&&!E(l))l+="";else if("function"!=typeof t&&void 0===l.i){s("Invalid vNode child");continue}i&&r?c[c.length-1].h+=l:c.push(i?C(null,l):l),r=i}};if(f(n),e){e.key&&(o=e.key);{const t=e.className||e.class;t&&(e.class="object"!=typeof t?t:Object.keys(t).filter((e=>t[e])).join(" "))}}const u=C(t,null);return u.m=e,c.length>0&&(u.v=c),u.$=o,u},C=(t,e)=>({i:0,j:t,h:null!=e?e:null,O:null,v:null,m:null,$:null}),x={},N=t=>{if(!t)return;const e=Object.keys(t);if(0===e.length)return;let n=!1;for(const l of e){if(n)break;for(const e of t[l])if("string"==typeof e){n=!0;break}}if(!n)return t;const l={};for(const n of e)l[n]=t[n].map((t=>"string"==typeof t?{[t]:0}:t));return l},L=(t,e)=>null==t||E(t)?t:4&e?"false"!==t&&(""===t||!!t):2&e?"string"==typeof t?parseFloat(t):"number"==typeof t?t:NaN:1&e?t+"":t,_=(t,e)=>{const n=t;return{emit:t=>D(n,e,{bubbles:!0,composed:!0,cancelable:!0,detail:t})}},D=(t,e,n)=>{const l=f.ce(e,n);return t.dispatchEvent(l),l},H=(t,e,n,s,i,c)=>{if(n===s)return;let u=o(t,e),a=e.toLowerCase();if("class"===e){const e=t.classList,l=W(n);let o=W(s);e.remove(...l.filter((t=>t&&!o.includes(t)))),e.add(...o.filter((t=>t&&!l.includes(t))))}else if("style"===e){for(const e in n)s&&null!=s[e]||(e.includes("-")?t.style.removeProperty(e):t.style[e]="");for(const e in s)n&&s[e]===n[e]||(e.includes("-")?t.style.setProperty(e,s[e]):t.style[e]=s[e])}else if("key"===e);else if("ref"===e)s&&tt(s,t);else if(t.__lookupSetter__(e)||"o"!==e[0]||"n"!==e[1]){if("a"===e[0]&&e.startsWith("attr:")){const n=e.slice(5);let o;{const e=l(t);if(e&&e.l&&e.l.t){const t=e.l.t[n];t&&t[1]&&(o=t[1])}}return o||(o=n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()),void(null==s||!1===s?!1===s&&""!==t.getAttribute(o)||t.removeAttribute(o):t.setAttribute(o,!0===s?"":s))}if("p"===e[0]&&e.startsWith("prop:")){const n=e.slice(5);try{t[n]=s}catch(t){}return}{const l=E(s);if((u||l&&null!==s)&&!i)try{if(t.tagName.includes("-"))t[e]!==s&&(t[e]=s);else{const l=null==s?"":s;"list"===e?u=!1:null!=n&&t[e]===l||("function"==typeof t.__lookupSetter__(e)?t[e]=l:t.setAttribute(e,l))}}catch(t){}null==s||!1===s?(!1!==s||""===t.getAttribute(e)||4&c&&!R(e))&&t.removeAttribute(e):(!u||4&c||i)&&!l&&1===t.nodeType&&t.setAttribute(e,s=!0===s?"":s)}}else if(e="-"===e[2]?e.slice(3):o(r,a)?a.slice(2):a[2]+e.slice(3),n||s){const l=e.endsWith(F);e=e.replace(T,""),n&&f.rel(t,e,n,l),s&&f.ael(t,e,s,l)}},P=new Set(["draggable","contenteditable","spellcheck"]),R=t=>P.has(t)||t.startsWith("aria-"),U=/\s/,W=t=>("object"==typeof t&&t&&"baseVal"in t&&(t=t.baseVal),t&&"string"==typeof t?t.split(U):[]),F="Capture",T=RegExp(F+"$"),V=(t,e,n)=>{const l=11===e.O.nodeType&&e.O.host?e.O.host:e.O,o=t&&t.m||{},s=e.m||{};for(const t of q(Object.keys(o)))t in s||H(l,t,o[t],void 0,n,e.i);for(const t of q(Object.keys(s)))H(l,t,o[t],s[t],n,e.i)};function q(t){return t.includes("ref")?[...t.filter((t=>"ref"!==t)),"ref"]:t}var z=!1,I=!1,Y=[],Z=[],B=(t,e,n)=>{const l=e.v[n];let o,s,i=0;if(null!=l.h)o=l.O=r.document.createTextNode(l.h);else{if(I||(I="svg"===l.j),!r.document)throw Error("You are trying to render a Stencil component in an environment that doesn't support the DOM.");if(o=l.O=r.document.createElementNS(I?"http://www.w3.org/2000/svg":"http://www.w3.org/1999/xhtml",l.j),I&&"foreignObject"===l.j&&(I=!1),V(null,l,I),l.v){const e="template"===l.j?o.content:o;for(i=0;i<l.v.length;++i)s=B(t,l,i),s&&e.appendChild(s)}"svg"===l.j?I=!1:"foreignObject"===o.tagName&&(I=!0)}return o["s-hn"]=S,o},G=(t,e,n,l,o,s)=>{let i,r=t;for(r.shadowRoot&&r.tagName===S&&(r=r.shadowRoot),"template"===n.j&&(r=r.content);o<=s;++o)l[o]&&(i=B(null,n,o),i&&(l[o].O=i,et(r,i,e)))},J=(t,e,n)=>{for(let l=e;l<=n;++l){const e=t[l];if(e){const t=e.O;X(e),t&&t.remove()}}},K=(t,e,n=!1)=>t.j===e.j&&(n?(n&&!t.$&&e.$&&(t.$=e.$),!0):t.$===e.$),Q=(t,e,n=!1)=>{const l=e.O=t.O,o=t.v,s=e.v,i=e.j,r=e.h;null==r?(I="svg"===i||"foreignObject"!==i&&I,"slot"!==i||z||t.S!==e.S&&(e.O["s-sn"]=e.S||"",(t=>{f.i|=1;const e=t.closest(S.toLowerCase());if(null!=e){const n=Array.from(e.__childNodes||e.childNodes).find((t=>t["s-cr"])),l=Array.from(t.__childNodes||t.childNodes);for(const t of n?l.reverse():l)null!=t["s-sh"]&&(et(e,t,null!=n?n:null),t["s-sh"]=void 0)}f.i&=-2})(e.O.parentElement)),V(t,e,I),null!==o&&null!==s?((t,e,n,l,o=!1)=>{let s,i,r=0,c=0,f=0,u=0,a=e.length-1,d=e[0],p=e[a],h=l.length-1,m=l[0],b=l[h];const y="template"===n.j?t.content:t;for(;r<=a&&c<=h;)if(null==d)d=e[++r];else if(null==p)p=e[--a];else if(null==m)m=l[++c];else if(null==b)b=l[--h];else if(K(d,m,o))Q(d,m,o),d=e[++r],m=l[++c];else if(K(p,b,o))Q(p,b,o),p=e[--a],b=l[--h];else if(K(d,b,o))Q(d,b,o),et(y,d.O,p.O.nextSibling),d=e[++r],b=l[--h];else if(K(p,m,o))Q(p,m,o),et(y,p.O,d.O),p=e[--a],m=l[++c];else{for(f=-1,u=r;u<=a;++u)if(e[u]&&null!==e[u].$&&e[u].$===m.$){f=u;break}f>=0?(i=e[f],i.j!==m.j?s=B(e&&e[c],n,c):(Q(i,m,o),e[f]=void 0,s=i.O),m=l[++c]):(s=B(e&&e[c],n,c),m=l[++c]),s&&et(d.O.parentNode,s,d.O)}r>a?G(t,null==l[h+1]?null:l[h+1].O,n,l,c,h):c>h&&J(e,r,a)})(l,o,e,s,n):null!==s?(null!==t.h&&(l.textContent=""),G(l,null,e,s,0,s.length-1)):!n&&null!==o&&J(o,0,o.length-1),I&&"svg"===i&&(I=!1)):t.h!==r&&(l.data=r)},X=t=>{t.m&&t.m.ref&&Y.push((()=>t.m.ref(null))),t.v&&t.v.map(X)},tt=(t,e)=>{Z.push((()=>t(e)))},et=(t,e,n)=>null==t?void 0:t.insertBefore(e,n),nt=(t,e,n=!1)=>{const l=t.$hostElement$,o=t.l,s=t.k||C(null,null),i=(t=>t&&t.j===x)(e)?e:A(null,null,e);if(S=l.tagName,n&&i.m)for(const t of Object.keys(i.m))l.hasAttribute(t)&&!["key","ref","style","class"].includes(t)&&(i.m[t]=l[t]);i.j=null,i.i|=4,t.k=i,i.O=s.O=l.shadowRoot||l,z=!(!(1&o.i)||128&o.i),Q(s,i,n),Y.forEach((t=>t())),Y.length=0,Z.forEach((t=>t())),Z.length=0},lt=(t,e)=>{if(e&&!t.M&&e["s-p"]){const n=e["s-p"].push(new Promise((l=>t.M=()=>{e["s-p"].splice(n-1,1),l()})))}},ot=(t,e)=>{if(t.i|=16,4&t.i)return void(t.i|=512);lt(t,t.A);const n=()=>st(t,e);if(!e)return g(n);queueMicrotask((()=>{n()}))},st=(t,e)=>{const n=t.$hostElement$,l=n;if(!l)throw Error(`Can't render component <${n.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`);let o;return o=dt(l,e?"componentWillLoad":"componentWillUpdate",void 0,n),o=it(o,(()=>dt(l,"componentWillRender",void 0,n))),it(o,(()=>ct(t,l,e)))},it=(t,e)=>rt(t)?t.then(e).catch((t=>{console.error(t),e()})):e(),rt=t=>t instanceof Promise||t&&t.then&&"function"==typeof t.then,ct=async(t,e,n)=>{var l;const o=t.$hostElement$,s=o["s-rc"];n&&(t=>{const e=t.l,n=t.$hostElement$,l=e.i,o=((t,e)=>{var n,l,o;const s=M(e),c=i.get(s);if(!r.document)return s;if(t=11===t.nodeType?t:r.document,c)if("string"==typeof c){let o,i=k.get(t=t.head||t);if(i||k.set(t,i=new Set),!i.has(s)){o=r.document.createElement("style"),o.textContent=c;const d=null!=(n=f.C)?n:function(){var t,e,n;return null!=(n=null==(e=null==(t=r.document.head)?void 0:t.querySelector('meta[name="csp-nonce"]'))?void 0:e.getAttribute("content"))?n:void 0}();if(null!=d&&o.setAttribute("nonce",d),!(1&e.i))if("HEAD"===t.nodeName){const e=t.querySelectorAll("link[rel=preconnect]"),n=e.length>0?e[e.length-1].nextSibling:t.querySelector("style");t.insertBefore(o,(null==n?void 0:n.parentNode)===t?n:null)}else if("host"in t)if(u){const e=new(null!=(l=t.defaultView)?l:t.ownerDocument.defaultView).CSSStyleSheet;e.replaceSync(c),a?t.adoptedStyleSheets.unshift(e):t.adoptedStyleSheets=[e,...t.adoptedStyleSheets]}else{const e=t.querySelector("style");e?e.textContent=c+e.textContent:t.prepend(o)}else t.append(o);1&e.i&&t.insertBefore(o,null),4&e.i&&(o.textContent+="slot-fb{display:contents}slot-fb[hidden]{display:none}"),i&&i.add(s)}}else{let e=k.get(t);if(e||k.set(t,e=new Set),!e.has(s)){const n=null!=(o=t.defaultView)?o:t.ownerDocument.defaultView;let l;if(c.constructor===n.CSSStyleSheet)l=c;else{l=new n.CSSStyleSheet;for(let t=0;t<c.cssRules.length;t++)l.insertRule(c.cssRules[t].cssText,t)}a?t.adoptedStyleSheets.push(l):t.adoptedStyleSheets=[...t.adoptedStyleSheets,l],e.add(s)}}return s})(n.shadowRoot?n.shadowRoot:n.getRootNode(),e);10&l&&(n["s-sc"]=o,n.classList.add(o+"-h"))})(t);ft(t,e,o,n),s&&(s.map((t=>t())),o["s-rc"]=void 0);{const e=null!=(l=o["s-p"])?l:[],n=()=>ut(t);0===e.length?n():(Promise.all(e).then(n).catch(n),t.i|=4,e.length=0)}},ft=(t,e,n,l)=>{try{e=e.render(),t.i&=-17,t.i|=2,nt(t,e,l)}catch(e){s(e,t.$hostElement$)}return null},ut=t=>{const e=t.$hostElement$,n=e,l=t.A;dt(n,"componentDidRender",void 0,e),64&t.i?dt(n,"componentDidUpdate",void 0,e):(t.i|=64,pt(e),dt(n,"componentDidLoad",void 0,e),t.N(e),l||at()),t.M&&(t.M(),t.M=void 0),512&t.i&&$((()=>ot(t,!1))),t.i&=-517},at=()=>{$((()=>D(r,"appload",{detail:{namespace:"phirepass-widgets"}})))},dt=(t,e,n,l)=>{if(t&&t[e])try{return t[e](n)}catch(t){s(t,l)}},pt=t=>t.classList.add("hydrated"),ht=(t,e,n,o)=>{const i=l(t);if(!i)return;const r=t,c=i.o.get(e),f=i.i,u=r;if(!((n=L(n,o.t[e][0]))===c||Number.isNaN(c)&&Number.isNaN(n))){if(i.o.set(e,n),o.L){const t=o.L[e];t&&t.map((t=>{try{const[[l,o]]=Object.entries(t);(128&f||1&o)&&(u?u[l](n,c,e):i._.push((()=>{i.D[l](n,c,e)})))}catch(t){s(t,r)}}))}if(2&f){if(u.componentShouldUpdate&&!1===u.componentShouldUpdate(n,c,e)&&!(16&f))return;16&f||ot(i,!1)}}},mt=(e,n)=>{var o,s;const i=e.prototype;{e.watchers&&!n.L&&(n.L=N(e.watchers)),e.deserializers&&!n.H&&(n.H=e.deserializers),e.serializers&&!n.P&&(n.P=e.serializers);const r=Object.entries(null!=(o=n.t)?o:{});r.map((([e,[o]])=>{if(31&o||32&o){const{get:s,set:r}=t(i,e)||{};s&&(n.t[e][0]|=2048),r&&(n.t[e][0]|=4096),Object.defineProperty(i,e,{get(){return s?s.apply(this):((t,e)=>l(this).o.get(e))(0,e)},configurable:!0,enumerable:!0}),Object.defineProperty(i,e,{set(t){const s=l(this);if(s){if(r)return void 0===(32&o?this[e]:s.$hostElement$[e])&&s.o.get(e)&&(t=s.o.get(e)),r.call(this,L(t,o)),void ht(this,e,t=32&o?this[e]:s.$hostElement$[e],n);ht(this,e,t,n)}}})}}));{const t=new Map;i.attributeChangedCallback=function(e,o,s){f.jmp((()=>{var c;const f=t.get(e),u=l(this);if(this.hasOwnProperty(f),i.hasOwnProperty(f)&&"number"==typeof this[f]&&this[f]==s)return;if(null==f){const t=null==u?void 0:u.i;if(u&&t&&!(8&t)&&s!==o){const l=this,i=null==(c=n.L)?void 0:c[e];null==i||i.forEach((n=>{const[[i,r]]=Object.entries(n);null!=l[i]&&(128&t||1&r)&&l[i].call(l,s,o,e)}))}return}const a=r.find((([t])=>t===f)),d=4&(a?a[1][0]:0),p=d&&null===s&&void 0===this[f];d&&(s=null!==s&&"false"!==s);const h=this[f],m=Object.getOwnPropertyDescriptor(i,f);p||s==h||m.get&&!m.set||(this[f]=s)}))},e.observedAttributes=Array.from(new Set([...Object.keys(null!=(s=n.L)?s:{}),...r.filter((([t,e])=>31&e[0])).map((([e,n])=>{const l=n[1]||e;return t.set(l,e),l}))]))}}return e},bt=async(t,e,n)=>{let l;try{if(!(32&e.i)&&(e.i|=32,e.i&=-1025,l=t.constructor,customElements.whenDefined(t.localName).then((()=>e.i|=128)),l&&l.style)){let t;"string"==typeof l.style&&(t=l.style);const e=M(n);if(!i.has(e)){const l=()=>{};((t,e,n)=>{let l=i.get(t);u&&n?(l=l||new CSSStyleSheet,"string"==typeof l?l=e:l.replaceSync(e)):l=e,i.set(t,l)})(e,t,!!(1&n.i)),l()}}const o=e.A,s=()=>ot(e,!0);o&&o["s-rc"]?o["s-rc"].push(s):s()}catch(n){s(n,t),e.M&&(e.M(),e.M=void 0),!e.N||1024&e.i||e.N(t)}},yt=(t,e)=>{const o={i:e[0],p:e[1]};try{o.t=e[2],o.L=N(t.L),o.H=t.H,o.P=t.P;const s=t.prototype.connectedCallback,i=t.prototype.disconnectedCallback;return Object.assign(t.prototype,{__hasHostListenerAttached:!1,__registerHost(){((t,e)=>{const l={i:0,$hostElement$:t,l:e,o:new Map,R:new Map};l.U=new Promise((t=>l.N=t)),t["s-p"]=[],t["s-rc"]=[];const o=l;t.__stencil__getHostRef=()=>o,512&e.i&&n(t,l)})(this,o)},connectedCallback(){if(!this.__hasHostListenerAttached){if(!l(this))return;this.__hasHostListenerAttached=!0}(t=>{if(!(1&f.i)){const e=l(t);if(!e)return;const n=e.l,o=()=>{};if(1&e.i)(null==e?void 0:e.D)||(1024&e.i?setTimeout((()=>bt(t,e,n)),1e3):(null==e?void 0:e.U)&&e.U.then((()=>{})));else{e.i|=1;{let n=t;for(;n=n.parentNode||n.host;)if(n["s-p"]){lt(e,e.A=n);break}}n.t&&Object.entries(n.t).map((([e,[n]])=>{if(31&n&&Object.prototype.hasOwnProperty.call(t,e)){const n=t[e];delete t[e],t[e]=n}})),bt(t,e,n)}o()}})(this),s&&s.call(this)},disconnectedCallback(){(async t=>{k.has(t)&&k.delete(t),t.shadowRoot&&k.has(t.shadowRoot)&&k.delete(t.shadowRoot)})(this),i&&i.call(this)},__attachShadow(){if(this.shadowRoot){if("open"!==this.shadowRoot.mode)throw Error(`Unable to re-use existing shadow root for ${o.p}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`)}else O.call(this,o)}}),Object.defineProperty(t,"is",{value:o.p,configurable:!0}),mt(t,o)}catch(e){return s(e),t}},vt=t=>f.C=t,$t=t=>Object.assign(f,t),gt=new WeakMap;function wt(t,e){let n=gt.get(e);n||(n={i:0,l:{i:0,p:e.tagName},$hostElement$:e},gt.set(e,n)),nt(n,t)}function jt(t){return t}export{c as H,x as a,_ as c,w as getAssetPath,A as h,yt as p,wt as render,j as setAssetPath,vt as setNonce,$t as setPlatformOptions,jt as t}
1
+ function t(t,e,n){const l="undefined"!=typeof HTMLElement?HTMLElement.prototype:null;for(;t&&t!==l;){const l=Object.getOwnPropertyDescriptor(t,e);if(l&&(!n||l.get))return l;t=Object.getPrototypeOf(t)}}var e,n=(e,n)=>{var l;Object.entries(null!=(l=n.l.t)?l:{}).map((([l,[o]])=>{if(31&o||32&o){const o=e[l],s=t(Object.getPrototypeOf(e),l,!0)||Object.getOwnPropertyDescriptor(e,l);s&&Object.defineProperty(e,l,{get(){return s.get.call(this)},set(t){s.set.call(this,t)},configurable:!0,enumerable:!0}),n.o.has(l)?e[l]=n.o.get(l):void 0!==o&&(e[l]=o)}}))},l=t=>{if(t.__stencil__getHostRef)return t.__stencil__getHostRef()},o=(t,e)=>e in t,s=(t,e)=>(0,console.error)(t,e),i=new Map,r="http://www.w3.org/1999/xlink",c="undefined"!=typeof window?window:{},u=c.HTMLElement||class{},f={i:0,u:"",jmp:t=>t(),raf:t=>requestAnimationFrame(t),ael:(t,e,n,l)=>t.addEventListener(e,n,l),rel:(t,e,n,l)=>t.removeEventListener(e,n,l),ce:(t,e)=>new CustomEvent(t,e)},a=(()=>{try{return!!c.document.adoptedStyleSheets&&(new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync)}catch(t){}return!1})(),d=!!a&&(()=>!!c.document&&Object.getOwnPropertyDescriptor(c.document.adoptedStyleSheets,"length").writable)(),p=!1,h=[],m=[],v=()=>{var t;return(null==(t=c.document)?void 0:t.hidden)?setTimeout($,16):f.raf($)},b=(t,e)=>n=>{t.push(n),p||(p=!0,e&&4&f.i?g($):v())},y=t=>{for(let e=0;e<t.length;e++)try{t[e](performance.now())}catch(t){s(t)}t.length=0},$=()=>{y(h),y(m),(p=h.length>0)&&v()},g=t=>Promise.resolve(void 0).then(t),w=b(m,!0),j=t=>{const e=new URL(t,f.u);return e.origin!==c.location.origin?e.href:e.pathname},O=t=>f.u=t;function S(){const t=this.attachShadow({mode:"open"});void 0===e&&(e=null),e&&(d?t.adoptedStyleSheets.push(e):t.adoptedStyleSheets=[...t.adoptedStyleSheets,e])}var k,M=new WeakMap,E=t=>"sc-"+t.p,x=t=>"object"==(t=typeof t)||"function"===t,A=(t,e,...n)=>{let l=null,o=null,i=!1,r=!1;const c=[],u=e=>{for(let n=0;n<e.length;n++)if(l=e[n],Array.isArray(l))u(l);else if(null!=l&&"boolean"!=typeof l){if(i="function"!=typeof t&&!x(l))l+="";else if("function"!=typeof t&&void 0===l.i){s("Invalid vNode child");continue}i&&r?c[c.length-1].h+=l:c.push(i?C(null,l):l),r=i}};if(u(n),e){e.key&&(o=e.key);{const t=e.className||e.class;t&&(e.class="object"!=typeof t?t:Object.keys(t).filter((e=>t[e])).join(" "))}}if("function"==typeof t)return t(null===e?{}:e,c,L);const f=C(t,null);return f.m=e,c.length>0&&(f.v=c),f.$=o,f},C=(t,e)=>({i:0,j:t,h:null!=e?e:null,O:null,v:null,m:null,$:null}),N={},L={forEach:(t,e)=>t.map(_).forEach(e),map:(t,e)=>t.map(_).map(e).map(D)},_=t=>({vattrs:t.m,vchildren:t.v,vkey:t.$,vname:t.S,vtag:t.j,vtext:t.h}),D=t=>{if("function"==typeof t.vtag){const e={...t.vattrs};return t.vkey&&(e.key=t.vkey),t.vname&&(e.name=t.vname),A(t.vtag,e,...t.vchildren||[])}const e=C(t.vtag,t.vtext);return e.m=t.vattrs,e.v=t.vchildren,e.$=t.vkey,e.S=t.vname,e},H=t=>{if(!t)return;const e=Object.keys(t);if(0===e.length)return;let n=!1;for(const l of e){if(n)break;for(const e of t[l])if("string"==typeof e){n=!0;break}}if(!n)return t;const l={};for(const n of e)l[n]=t[n].map((t=>"string"==typeof t?{[t]:0}:t));return l},P=(t,e)=>null==t||x(t)?t:4&e?"false"!==t&&(""===t||!!t):2&e?"string"==typeof t?parseFloat(t):"number"==typeof t?t:NaN:1&e?t+"":t,R=(t,e)=>{const n=t;return{emit:t=>U(n,e,{bubbles:!0,composed:!0,cancelable:!0,detail:t})}},U=(t,e,n)=>{const l=f.ce(e,n);return t.dispatchEvent(l),l},W=(t,e,n,s,i,u)=>{if(n===s)return;let a=o(t,e),d=e.toLowerCase();if("class"===e){const e=t.classList,l=q(n);let o=q(s);{let t=l.filter((t=>t&&!o.includes(t)));e.remove(...t),e.add(...o.filter((t=>t&&!l.includes(t))))}}else if("style"===e){for(const e in n)s&&null!=s[e]||(e.includes("-")?t.style.removeProperty(e):t.style[e]="");for(const e in s)n&&s[e]===n[e]||(e.includes("-")?t.style.setProperty(e,s[e]):t.style[e]=s[e])}else if("key"===e);else if("ref"===e)s&&ot(s,t);else if(t.__lookupSetter__(e)||"o"!==e[0]||"n"!==e[1]){if("a"===e[0]&&e.startsWith("attr:")){const n=e.slice(5);let o;{const e=l(t);if(e&&e.l&&e.l.t){const t=e.l.t[n];t&&t[1]&&(o=t[1])}}return o||(o=n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()),void(null==s||!1===s?!1===s&&""!==t.getAttribute(o)||t.removeAttribute(o):t.setAttribute(o,!0===s?"":s))}if("p"===e[0]&&e.startsWith("prop:")){const n=e.slice(5);try{t[n]=s}catch(t){}return}{const l=x(s);if((a||l&&null!==s)&&!i)try{if(t.tagName.includes("-"))t[e]!==s&&(t[e]=s);else{const l=null==s?"":s;"list"===e?a=!1:null!=n&&t[e]===l||("function"==typeof t.__lookupSetter__(e)?t[e]=l:t.setAttribute(e,l))}}catch(t){}let o=!1;d!==(d=d.replace(/^xlink\:?/,""))&&(e=d,o=!0),null==s||!1===s?(!1!==s||""===t.getAttribute(e)||4&u&&!F(e))&&(o?t.removeAttributeNS(r,e):t.removeAttribute(e)):(!a||4&u||i)&&!l&&1===t.nodeType&&(s=!0===s?"":s,o?t.setAttributeNS(r,e,s):t.setAttribute(e,s))}}else if(e="-"===e[2]?e.slice(3):o(c,d)?d.slice(2):d[2]+e.slice(3),n||s){const l=e.endsWith(z);e=e.replace(I,""),n&&f.rel(t,e,n,l),s&&f.ael(t,e,s,l)}},T=new Set(["draggable","contenteditable","spellcheck"]),F=t=>T.has(t)||t.startsWith("aria-"),V=/\s/,q=t=>("object"==typeof t&&t&&"baseVal"in t&&(t=t.baseVal),t&&"string"==typeof t?t.split(V):[]),z="Capture",I=RegExp(z+"$"),Y=(t,e,n)=>{const l=11===e.O.nodeType&&e.O.host?e.O.host:e.O,o=t&&t.m||{},s=e.m||{};for(const t of Z(Object.keys(o)))t in s||W(l,t,o[t],void 0,n,e.i);for(const t of Z(Object.keys(s)))W(l,t,o[t],s[t],n,e.i)};function Z(t){return t.includes("ref")?[...t.filter((t=>"ref"!==t)),"ref"]:t}var B=!1,G=!1,J=[],K=[],Q=(t,e,n)=>{const l=e.v[n];let o,s,i=0;if(null!=l.h)o=l.O=c.document.createTextNode(l.h);else{if(G||(G="svg"===l.j),!c.document)throw Error("You are trying to render a Stencil component in an environment that doesn't support the DOM.");if(o=l.O=c.document.createElementNS(G?"http://www.w3.org/2000/svg":"http://www.w3.org/1999/xhtml",l.j),G&&"foreignObject"===l.j&&(G=!1),Y(null,l,G),l.v){const e="template"===l.j?o.content:o;for(i=0;i<l.v.length;++i)s=Q(t,l,i),s&&e.appendChild(s)}"svg"===l.j?G=!1:"foreignObject"===o.tagName&&(G=!0)}return o["s-hn"]=k,o},X=(t,e,n,l,o,s)=>{let i,r=t;for(r.shadowRoot&&r.tagName===k&&(r=r.shadowRoot),"template"===n.j&&(r=r.content);o<=s;++o)l[o]&&(i=Q(null,n,o),i&&(l[o].O=i,st(r,i,e)))},tt=(t,e,n)=>{for(let l=e;l<=n;++l){const e=t[l];if(e){const t=e.O;lt(e),t&&t.remove()}}},et=(t,e,n=!1)=>t.j===e.j&&(n?(n&&!t.$&&e.$&&(t.$=e.$),!0):t.$===e.$),nt=(t,e,n=!1)=>{const l=e.O=t.O,o=t.v,s=e.v,i=e.j,r=e.h;null==r?(G="svg"===i||"foreignObject"!==i&&G,"slot"!==i||B||t.S!==e.S&&(e.O["s-sn"]=e.S||"",(t=>{f.i|=1;const e=t.closest(k.toLowerCase());if(null!=e){const n=Array.from(e.__childNodes||e.childNodes).find((t=>t["s-cr"])),l=Array.from(t.__childNodes||t.childNodes);for(const t of n?l.reverse():l)null!=t["s-sh"]&&(st(e,t,null!=n?n:null),t["s-sh"]=void 0)}f.i&=-2})(e.O.parentElement)),Y(t,e,G),null!==o&&null!==s?((t,e,n,l,o=!1)=>{let s,i,r=0,c=0,u=0,f=0,a=e.length-1,d=e[0],p=e[a],h=l.length-1,m=l[0],v=l[h];const b="template"===n.j?t.content:t;for(;r<=a&&c<=h;)if(null==d)d=e[++r];else if(null==p)p=e[--a];else if(null==m)m=l[++c];else if(null==v)v=l[--h];else if(et(d,m,o))nt(d,m,o),d=e[++r],m=l[++c];else if(et(p,v,o))nt(p,v,o),p=e[--a],v=l[--h];else if(et(d,v,o))nt(d,v,o),st(b,d.O,p.O.nextSibling),d=e[++r],v=l[--h];else if(et(p,m,o))nt(p,m,o),st(b,p.O,d.O),p=e[--a],m=l[++c];else{for(u=-1,f=r;f<=a;++f)if(e[f]&&null!==e[f].$&&e[f].$===m.$){u=f;break}u>=0?(i=e[u],i.j!==m.j?s=Q(e&&e[c],n,c):(nt(i,m,o),e[u]=void 0,s=i.O),m=l[++c]):(s=Q(e&&e[c],n,c),m=l[++c]),s&&st(d.O.parentNode,s,d.O)}r>a?X(t,null==l[h+1]?null:l[h+1].O,n,l,c,h):c>h&&tt(e,r,a)})(l,o,e,s,n):null!==s?(null!==t.h&&(l.textContent=""),X(l,null,e,s,0,s.length-1)):!n&&null!==o&&tt(o,0,o.length-1),G&&"svg"===i&&(G=!1)):t.h!==r&&(l.data=r)},lt=t=>{t.m&&t.m.ref&&J.push((()=>t.m.ref(null))),t.v&&t.v.map(lt)},ot=(t,e)=>{K.push((()=>t(e)))},st=(t,e,n)=>null==t?void 0:t.insertBefore(e,n),it=(t,e,n=!1)=>{const l=t.$hostElement$,o=t.l,s=t.k||C(null,null),i=(t=>t&&t.j===N)(e)?e:A(null,null,e);if(k=l.tagName,o.M&&(i.m=i.m||{},o.M.forEach((([t,e])=>{i.m[e]=l[t]}))),n&&i.m)for(const t of Object.keys(i.m))l.hasAttribute(t)&&!["key","ref","style","class"].includes(t)&&(i.m[t]=l[t]);i.j=null,i.i|=4,t.k=i,i.O=s.O=l.shadowRoot||l,B=!(!(1&o.i)||128&o.i),nt(s,i,n),J.forEach((t=>t())),J.length=0,K.forEach((t=>t())),K.length=0},rt=(t,e)=>{if(e&&!t.A&&e["s-p"]){const n=e["s-p"].push(new Promise((l=>t.A=()=>{e["s-p"].splice(n-1,1),l()})))}},ct=(t,e)=>{if(t.i|=16,4&t.i)return void(t.i|=512);rt(t,t.C);const n=()=>ut(t,e);if(!e)return w(n);queueMicrotask((()=>{n()}))},ut=(t,e)=>{const n=t.$hostElement$,l=n;if(!l)throw Error(`Can't render component <${n.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`);let o;return o=vt(l,e?"componentWillLoad":"componentWillUpdate",void 0,n),o=ft(o,(()=>vt(l,"componentWillRender",void 0,n))),ft(o,(()=>dt(t,l,e)))},ft=(t,e)=>at(t)?t.then(e).catch((t=>{console.error(t),e()})):e(),at=t=>t instanceof Promise||t&&t.then&&"function"==typeof t.then,dt=async(t,e,n)=>{var l;const o=t.$hostElement$,s=o["s-rc"];n&&(t=>{const e=t.l,n=t.$hostElement$,l=e.i,o=((t,e)=>{var n,l,o;const s=E(e),r=i.get(s);if(!c.document)return s;if(t=11===t.nodeType?t:c.document,r)if("string"==typeof r){let o,i=M.get(t=t.head||t);if(i||M.set(t,i=new Set),!i.has(s)){o=c.document.createElement("style"),o.textContent=r;const u=null!=(n=f.N)?n:function(){var t,e,n;return null!=(n=null==(e=null==(t=c.document.head)?void 0:t.querySelector('meta[name="csp-nonce"]'))?void 0:e.getAttribute("content"))?n:void 0}();if(null!=u&&o.setAttribute("nonce",u),!(1&e.i))if("HEAD"===t.nodeName){const e=t.querySelectorAll("link[rel=preconnect]"),n=e.length>0?e[e.length-1].nextSibling:t.querySelector("style");t.insertBefore(o,(null==n?void 0:n.parentNode)===t?n:null)}else if("host"in t)if(a){const e=new(null!=(l=t.defaultView)?l:t.ownerDocument.defaultView).CSSStyleSheet;e.replaceSync(r),d?t.adoptedStyleSheets.unshift(e):t.adoptedStyleSheets=[e,...t.adoptedStyleSheets]}else{const e=t.querySelector("style");e?e.textContent=r+e.textContent:t.prepend(o)}else t.append(o);1&e.i&&t.insertBefore(o,null),4&e.i&&(o.textContent+="slot-fb{display:contents}slot-fb[hidden]{display:none}"),i&&i.add(s)}}else{let e=M.get(t);if(e||M.set(t,e=new Set),!e.has(s)){const n=null!=(o=t.defaultView)?o:t.ownerDocument.defaultView;let l;if(r.constructor===n.CSSStyleSheet)l=r;else{l=new n.CSSStyleSheet;for(let t=0;t<r.cssRules.length;t++)l.insertRule(r.cssRules[t].cssText,t)}d?t.adoptedStyleSheets.push(l):t.adoptedStyleSheets=[...t.adoptedStyleSheets,l],e.add(s)}}return s})(n.shadowRoot?n.shadowRoot:n.getRootNode(),e);10&l&&(n["s-sc"]=o,n.classList.add(o+"-h"))})(t);pt(t,e,o,n),s&&(s.map((t=>t())),o["s-rc"]=void 0);{const e=null!=(l=o["s-p"])?l:[],n=()=>ht(t);0===e.length?n():(Promise.all(e).then(n).catch(n),t.i|=4,e.length=0)}},pt=(t,e,n,l)=>{try{e=e.render(),t.i&=-17,t.i|=2,it(t,e,l)}catch(e){s(e,t.$hostElement$)}return null},ht=t=>{const e=t.$hostElement$,n=e,l=t.C;vt(n,"componentDidRender",void 0,e),64&t.i?vt(n,"componentDidUpdate",void 0,e):(t.i|=64,bt(e),vt(n,"componentDidLoad",void 0,e),t.L(e),l||mt()),t.A&&(t.A(),t.A=void 0),512&t.i&&g((()=>ct(t,!1))),t.i&=-517},mt=()=>{g((()=>U(c,"appload",{detail:{namespace:"phirepass-widgets"}})))},vt=(t,e,n,l)=>{if(t&&t[e])try{return t[e](n)}catch(t){s(t,l)}},bt=t=>t.classList.add("hydrated"),yt=(t,e,n,o)=>{const i=l(t);if(!i)return;const r=t,c=i.o.get(e),u=i.i,f=r;if(!((n=P(n,o.t[e][0]))===c||Number.isNaN(c)&&Number.isNaN(n))){if(i.o.set(e,n),o._){const t=o._[e];t&&t.map((t=>{try{const[[l,o]]=Object.entries(t);(128&u||1&o)&&(f?f[l](n,c,e):i.D.push((()=>{i.H[l](n,c,e)})))}catch(t){s(t,r)}}))}if(2&u){if(f.componentShouldUpdate&&!1===f.componentShouldUpdate(n,c,e)&&!(16&u))return;16&u||ct(i,!1)}}},$t=(e,n)=>{var o,s;const i=e.prototype;{e.watchers&&!n._&&(n._=H(e.watchers)),e.deserializers&&!n.P&&(n.P=e.deserializers),e.serializers&&!n.R&&(n.R=e.serializers);const r=Object.entries(null!=(o=n.t)?o:{});r.map((([e,[o]])=>{if(31&o||32&o){const{get:s,set:r}=t(i,e)||{};s&&(n.t[e][0]|=2048),r&&(n.t[e][0]|=4096),Object.defineProperty(i,e,{get(){return s?s.apply(this):((t,e)=>l(this).o.get(e))(0,e)},configurable:!0,enumerable:!0}),Object.defineProperty(i,e,{set(t){const s=l(this);if(s){if(r)return void 0===(32&o?this[e]:s.$hostElement$[e])&&s.o.get(e)&&(t=s.o.get(e)),r.call(this,P(t,o)),void yt(this,e,t=32&o?this[e]:s.$hostElement$[e],n);yt(this,e,t,n)}}})}}));{const t=new Map;i.attributeChangedCallback=function(e,o,s){f.jmp((()=>{var c;const u=t.get(e),f=l(this);if(this.hasOwnProperty(u),i.hasOwnProperty(u)&&"number"==typeof this[u]&&this[u]==s)return;if(null==u){const t=null==f?void 0:f.i;if(f&&t&&!(8&t)&&s!==o){const l=this,i=null==(c=n._)?void 0:c[e];null==i||i.forEach((n=>{const[[i,r]]=Object.entries(n);null!=(null==l?void 0:l[i])&&(128&t||1&r)&&l[i].call(l,s,o,e)}))}return}const a=r.find((([t])=>t===u)),d=a?a[1][0]:0,p=4&d;if(512&d&&8&d&&!x(this[u])&&(t=>null==t||!1===t?null:!0===t?"":t+"")(this[u])===s)return;const h=p&&null===s&&void 0===this[u];p&&(s=null!==s&&"false"!==s);const m=Object.getOwnPropertyDescriptor(i,u);h||s===this[u]||null==s&&null==this[u]||m.get&&!m.set||(this[u]=s)}))},e.observedAttributes=Array.from(new Set([...Object.keys(null!=(s=n._)?s:{}),...r.filter((([t,e])=>31&e[0])).map((([e,l])=>{var o;const s=l[1]||e;return t.set(s,e),512&l[0]&&(null==(o=n.M)||o.push([e,s])),s}))]))}}return e},gt=async(t,e,n)=>{let l;try{if(!(32&e.i)&&(e.i|=32,e.i&=-1025,l=t.constructor,customElements.whenDefined(t.localName).then((()=>e.i|=128)),l&&l.style)){let t;"string"==typeof l.style&&(t=l.style);const e=E(n);if(!i.has(e)){const l=()=>{};((t,e,n)=>{let l=i.get(t);a&&n?(l=l||new CSSStyleSheet,"string"==typeof l?l=e:l.replaceSync(e)):l=e,i.set(t,l)})(e,t,!!(1&n.i)),l()}}const o=e.C,s=()=>ct(e,!0);o&&o["s-rc"]?o["s-rc"].push(s):s()}catch(n){s(n,t),e.A&&(e.A(),e.A=void 0),!e.L||1024&e.i||e.L(t)}},wt=(t,e)=>{const o={i:e[0],p:e[1]};try{o.t=e[2],o._=H(t._),o.P=t.P,o.R=t.R,o.M=[];const s=t.prototype.connectedCallback,i=t.prototype.disconnectedCallback;return Object.assign(t.prototype,{__hasHostListenerAttached:!1,__registerHost(){((t,e)=>{const l={i:0,$hostElement$:t,l:e,o:new Map,U:new Map};l.W=new Promise((t=>l.L=t)),t["s-p"]=[],t["s-rc"]=[];const o=l;t.__stencil__getHostRef=()=>o,512&e.i&&n(t,l)})(this,o)},connectedCallback(){if(!this.__hasHostListenerAttached){if(!l(this))return;this.__hasHostListenerAttached=!0}(t=>{if(!(1&f.i)){const e=l(t);if(!e)return;const n=e.l,o=()=>{};if(1&e.i)(null==e?void 0:e.H)||(1024&e.i?setTimeout((()=>gt(t,e,n)),1e3):(null==e?void 0:e.W)&&e.W.then((()=>{})));else{e.i|=1;{let n=t;for(;n=n.parentNode||n.host;)if(n["s-p"]){rt(e,e.C=n);break}}n.t&&Object.entries(n.t).map((([e,[n]])=>{if(31&n&&Object.prototype.hasOwnProperty.call(t,e)){const n=t[e];delete t[e],t[e]=n}})),gt(t,e,n)}o()}})(this),s&&s.call(this)},disconnectedCallback(){(async t=>{M.has(t)&&M.delete(t),t.shadowRoot&&M.has(t.shadowRoot)&&M.delete(t.shadowRoot)})(this),i&&i.call(this)},__attachShadow(){if(this.shadowRoot){if("open"!==this.shadowRoot.mode)throw Error(`Unable to re-use existing shadow root for ${o.p}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`)}else S.call(this,o)}}),Object.defineProperty(t,"is",{value:o.p,configurable:!0}),$t(t,o)}catch(e){return s(e),t}},jt=t=>f.N=t,Ot=t=>Object.assign(f,t),St=new WeakMap;function kt(t,e){let n=St.get(e);n||(n={i:0,l:{i:0,p:e.tagName},$hostElement$:e},St.set(e,n)),it(n,t)}function Mt(t){return t}export{u as H,N as a,R as c,j as getAssetPath,A as h,wt as p,kt as render,O as setAssetPath,jt as setNonce,Ot as setPlatformOptions,Mt as t}
@@ -0,0 +1 @@
1
+ import{h as t,t as a,p as e,H as s,c as i,a as n}from"./index.js";const r=["B","KB","MB","GB","TB"];function o(t){if(null==t||!Number.isFinite(t)||t<0)return"—";let a=t,e=0;for(;a>=1e3&&e<r.length-1;)a/=1e3,e++;if(0===e)return`${Math.round(a)} B`;const s=a>=100?0:a>=10?1:e>=3?2:1,i=a.toFixed(s);return`${s?i.replace(/\.?0+$/,""):i} ${r[e]}`}function h(t,a="↓"){return!t||t<=0?"":`${a} ${o(t)}/s`}function d(t){const a=Math.max(0,Math.round(t));if(a<60)return`${a}s`;const e=Math.floor(a/60);if(e<10){const t=a%60;return t?`${e}m ${t}s`:`${e}m`}if(e<60)return`${e}m`;const s=Math.floor(e/60),i=e%60;return s<24?i?`${s}h ${i}m`:`${s}h`:`${Math.floor(s/24)}d ${s%24}h`}function l(t,a,e){return!a||!e||e<=0||t>=a?"":`${d((a-t)/e)} left`}function c(t,a){if(!a||a<=0)return"";const e=Math.min(100,t/a*100);return e>=100?"100%":`${e.toFixed(1)}%`}function p(t,a){return!a||a<=0?0:Math.max(0,Math.min(100,t/a*100))}function u(t){if(!Number.isFinite(t)||t<0)return"0:00";const a=Math.floor(t),e=Math.floor(a/3600),s=Math.floor(a%3600/60),i=String(a%60).padStart(2,"0");return e?`${e}:${String(s).padStart(2,"0")}:${i}`:`${s}:${i}`}const g={fetch:()=>[t("path",{d:"M17.5 19a4.5 4.5 0 1 0-1.4-8.8A6 6 0 0 0 4.3 12.7 4 4 0 0 0 6 19.9"}),t("path",{d:"M12 12v8"}),t("path",{d:"m8.5 16.5 3.5 3.5 3.5-3.5"})],magnet:()=>[t("path",{d:"M6 3v8a6 6 0 0 0 12 0V3"}),t("path",{d:"M6 7h4M14 7h4"}),t("path",{d:"M10 3v8a2 2 0 0 0 4 0V3"})],globe:()=>[t("circle",{cx:"12",cy:"12",r:"9"}),t("path",{d:"M3 12h18M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18"})],torrent:()=>[t("path",{d:"M6 3h8l4 4v14H6z"}),t("path",{d:"M14 3v4h4"}),t("path",{d:"M9.5 11.5 12 14l2.5-2.5M12 14v3"})],node:()=>[t("rect",{x:"3",y:"4",width:"18",height:"7",rx:"1.5"}),t("rect",{x:"3",y:"13",width:"18",height:"7",rx:"1.5"}),t("path",{d:"M7 7.5h.01M7 16.5h.01"})],x:()=>[t("path",{d:"M6 6l12 12M18 6 6 18"})],retry:()=>[t("path",{d:"M3 12a9 9 0 0 0 15.4 6.4L21 16"}),t("path",{d:"M21 21v-5h-5"}),t("path",{d:"M21 12A9 9 0 0 0 5.6 5.6L3 8"}),t("path",{d:"M3 3v5h5"})],check:()=>[t("circle",{cx:"12",cy:"12",r:"9.5"}),t("path",{d:"m8 12.5 2.7 2.7L16.5 9.5"})],locate:()=>[t("path",{d:"M3 6.5A1.5 1.5 0 0 1 4.5 5h4.6l2 2h8.4A1.5 1.5 0 0 1 21 8.5v9a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 17.5z"}),t("path",{d:"m11 13 2 2 3-3"})],file:()=>[t("path",{d:"M6 3h8l4 4v14H6z"}),t("path",{d:"M14 3v4h4"})],folder:()=>[t("path",{d:"M3 6.5A1.5 1.5 0 0 1 4.5 5h4.6l2 2h8.4A1.5 1.5 0 0 1 21 8.5v9a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 17.5z"})],warn:()=>[t("path",{d:"M12 3 2.5 20h19z"}),t("path",{d:"M12 10v4.5"}),t("path",{d:"M12 17.5v.01"})],trash:()=>[t("path",{d:"M3 6h18"}),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"})],chevron:()=>[t("path",{d:"m6 9 6 6 6-6"})],up:()=>[t("path",{d:"m6 15 6-6 6 6"})],cast:()=>[t("path",{d:"M3 8V6a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-5"}),t("path",{d:"M3 12a8 8 0 0 1 8 8"}),t("path",{d:"M3 16a4 4 0 0 1 4 4"}),t("path",{d:"M3 20h.01"})],lock:()=>[t("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2"}),t("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})],signal:()=>[t("path",{d:"M2 20h.01M7 20v-4M12 20v-8M17 20V8M22 4v16"})],plus:()=>[t("path",{d:"M12 5v14M5 12h14"})]},f={pause:()=>[t("rect",{x:"6",y:"5",width:"4",height:"14",rx:"1"}),t("rect",{x:"14",y:"5",width:"4",height:"14",rx:"1"})],play:()=>[t("path",{d:"M7 5v14l12-7z"})]},m=({name:a,size:e=16,label:s})=>{const i=f[a];return t("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:i?"currentColor":"none",stroke:i?"none":"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":s?void 0:"true",role:s?"img":void 0,"aria-label":s},(i??g[a])?.()??null)},b={mp4:"video/mp4",m4v:"video/mp4",webm:"video/webm",mkv:"video/x-matroska",mov:"video/quicktime",mp3:"audio/mpeg",m4a:"audio/mp4",flac:"audio/flac",ogg:"audio/ogg",oga:"audio/ogg",opus:"audio/ogg",wav:"audio/wav"};function y(t){return b[function(t){const a=/\.([a-z0-9]+)$/i.exec(t);return a?a[1].toLowerCase():""}(t)]??"application/octet-stream"}function v(t,a){return function(t,a){return!(!Number.isFinite(a)||a<=0)&&(t>=.95*a||a-t<=120)}(t,a)?"clear":t<30?"skip":"save"}const x="phirepass.player.position.",w={async get(t){try{const a=window.localStorage.getItem(x+t);if(!a)return null;const e=JSON.parse(a);return"number"==typeof e?.secs?e:null}catch{return null}},async set(t,a,e){try{window.localStorage.setItem(x+t,JSON.stringify({secs:a,duration:e,at:Date.now()}))}catch{}},async clear(t){try{window.localStorage.removeItem(x+t)}catch{}}},M=e(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.playerClose=i(this,"phirepassPlayerClose")}get el(){return this}media;lastSave=0;resumeAt=0;everPlayed=!1;positionPrompted=!1;availabilityId;onRemoteConnect=()=>this.phase="casting";onRemoteDisconnect=()=>{"casting"===this.phase&&(this.phase=this.everPlayed?"playing":"buffering")};src;name;mime;status;ready;positionStore;positionKey;remotePlayback;castDevice;playerClose;phase="buffering";stored=null;castAvailable=!1;currentTime=0;duration=0;get store(){return this.positionStore??w}get audio(){return(this.mime??y(this.name)).startsWith("audio/")}async componentWillLoad(){if(this.positionKey){const t=await this.store.get(this.positionKey).catch((()=>null));t&&"save"===v(t.secs,t.duration)&&(this.stored=t,this.positionPrompted=!0,this.phase="prompt")}}componentDidLoad(){this.watchRemote()}disconnectedCallback(){this.savePosition(!0);const t=this.remote();t&&(t.removeEventListener("connect",this.onRemoteConnect),t.removeEventListener("disconnect",this.onRemoteDisconnect),void 0!==this.availabilityId&&t.cancelWatchAvailability(this.availabilityId).catch((()=>{})))}onSrc(){this.everPlayed=!1,this.phase="buffering"}async close(){await this.savePosition(!0),this.media?.pause?.(),this.playerClose.emit()}remote(){return this.remotePlayback??this.media?.remote}async watchRemote(){const t=this.remote();if(t&&!this.audio){t.addEventListener("connect",this.onRemoteConnect),t.addEventListener("disconnect",this.onRemoteDisconnect),"connected"===t.state&&(this.phase="casting");try{this.availabilityId=await t.watchAvailability((t=>this.castAvailable=t))}catch{this.castAvailable=!0}}}async savePosition(t=!1){const a=this.media;if(!a||!this.positionKey||!this.everPlayed)return;const e=Date.now();if(!t&&e-this.lastSave<1e4)return;this.lastSave=e;const s=v(a.currentTime,a.duration);"save"===s?await this.store.set(this.positionKey,a.currentTime,a.duration).catch((()=>{})):"clear"===s&&await(this.store.clear?.(this.positionKey).catch((()=>{})))}startAt(t){this.stored=null,this.phase="buffering",this.resumeAt=t;const a=this.media;a&&(t>0&&(a.currentTime=t),a.play?.()?.catch?.((()=>{})))}retry(){const t=this.media,a=t?.currentTime||this.resumeAt;this.phase="buffering",t&&(t.load?.(),this.startAt(a))}onError(){const t=this.media?.error?.code;this.phase=2===t?"stopped":"unsupported"}bindMedia(t){t&&t!==this.media&&(this.media=t)}renderStage(){switch(this.phase){case"prompt":return t("div",{class:"stage-msg","data-phase":"prompt"},t("b",null,"Resume from ",u(this.stored.secs),"?"),t("span",null,"You stopped here on ",function(t){const a=new Date(t);return`${a.getDate()} ${a.toLocaleString("en-GB",{month:"short"})}`}(this.stored.at),". ",u(this.stored.duration)," in total."),t("div",{class:"row"},t("button",{type:"button",class:"btn",onClick:()=>this.startAt(0)},"Start over"),t("button",{type:"button",class:"btn pri",onClick:()=>this.startAt(this.stored.secs)},"Resume")));case"buffering":return t("div",{class:"stage-msg overlay-msg","data-phase":"buffering"},t("span",{class:"spin","aria-hidden":"true"}),t("b",null,"Buffering"),void 0!==this.ready&&t("span",null,o(this.ready)," ready from the start"));case"waiting":return t("div",{class:"stage-msg overlay-msg","data-phase":"waiting"},t("span",{class:"spin","aria-hidden":"true"}),t("b",null,"Waiting for this part to download"),t("span",null,"You skipped ahead of what the node has. Playback resumes by itself."));case"unsupported":return t("div",{class:"stage-msg","data-phase":"unsupported"},t(m,{name:"warn",size:28}),t("b",null,"This browser cannot play this format"),t("span",null,"The download is not affected. Download the file to play it in another app."),t("a",{class:"btn pri",href:this.src,download:this.name},"Download file"));case"stopped":return t("div",{class:"stage-msg","data-phase":"stopped"},t(m,{name:"signal",size:28}),t("b",null,"Playback stopped"),t("span",null,"The connection to the node was lost."),t("button",{type:"button",class:"btn pri",onClick:()=>this.retry()},"Try again"));case"casting":return t("div",{class:"stage-msg","data-phase":"casting"},t(m,{name:"cast",size:28}),t("b",null,"Playing on ",this.castDevice??"your TV"),t("span",null,"The TV reads the file from the node. You can close this tab."),t("span",{class:"clock"},u(this.currentTime)," / ",u(this.duration)),t("button",{type:"button",class:"btn",onClick:()=>{this.remote()?.prompt().catch((()=>{}))}},"Stop casting"));default:return null}}render(){const a=this.audio,e=function(t,a){const e=a??y(t);return"video/x-matroska"===e?"TVs cannot play MKV files. Download it and play it with VLC.":"video/quicktime"===e?"TVs cannot play MOV files.":null}(this.name,this.mime),s="function"==typeof this.media?.webkitShowPlaybackTargetPicker,i={ref:t=>this.bindMedia(t),src:this.src,controls:!0,preload:"prompt"===this.phase?"metadata":"auto",autoplay:!this.positionPrompted,playsInline:!0,class:{hidden:"prompt"===this.phase||"unsupported"===this.phase||"stopped"===this.phase||"casting"===this.phase},onCanPlay:()=>{"buffering"!==this.phase&&"waiting"!==this.phase||(this.phase="playing")},onPlaying:()=>{this.everPlayed=!0,"casting"!==this.phase&&(this.phase="playing")},onWaiting:()=>{"playing"===this.phase&&(this.phase=this.everPlayed?"waiting":"buffering")},onTimeUpdate:t=>{this.currentTime=t.target.currentTime,this.savePosition()},onDurationChange:t=>this.duration=t.target.duration||0,onPause:()=>{this.savePosition(!0)},onError:()=>this.onError()};return t(n,{key:"941b4e81590e1144fc0bd424f4a5156ca047624d",class:{audio:a}},t("header",{key:"c1866c6dce284c49a17918c6d0e86d132ea9824a",class:"bar"},t("span",{key:"645cf1ec23df722e4b479e2d0b9f78aad9c339f1",class:"nm",title:this.name},this.name),this.status&&t("span",{key:"db77564456be6b4b52b78c709041924b97b930fc",class:"pill"},this.status),t("span",{key:"4f3203babb8f002bf3b783947a01ff6b06cfdb13",class:"sp"}),!a&&(this.castAvailable||e)&&t("button",{key:"3174885867db39af25d328d1bf69879e2e9e5ea5",type:"button",class:"ib",disabled:!!e,title:e??"Cast","aria-label":e?`Cast unavailable: ${e}`:"Cast",onClick:()=>{this.remote()?.prompt().catch((()=>{}))}},t(m,{key:"c36b4847aa20e6b37da23b8b124bc5a679fcfdf1",name:"cast",size:15})),!a&&s&&t("button",{key:"7f1932ac452b57518c608e4723329dac0b9c5698",type:"button",class:"ib",title:"AirPlay","aria-label":"AirPlay",onClick:()=>this.media.webkitShowPlaybackTargetPicker()},t(m,{key:"6814c32ae5b0276260164131f7d017ce24c5063d",name:"cast",size:15})),t("button",{key:"dfcf1c345b01bd30f8274e637e03a0a7e97a0bb8",type:"button",class:"ib","aria-label":"Close player",title:"Close",onClick:()=>{this.close()}},t(m,{key:"2d056a662ae56d4e70ff90cd08ab05cb6c2cf386",name:"x",size:14}))),t("div",{key:"bd610362589f488b395081ae4d12b06da92e8372",class:{stage:!0,audio:a},"data-phase":this.phase},t(a?"audio":"video",{...i}),this.renderStage()))}static get watchers(){return{src:[{onSrc:0}]}}static get style(){return":host{--card:220 18% 10%;--bg:216 18% 7%;--border:220 15% 18%;--primary:160 60% 45%;--primary-foreground:220 20% 7%;--muted:220 15% 13%;--muted-foreground:215 10% 52%;--foreground:210 20% 90%;--amber:38 75% 55%;display:flex;flex-direction:column;background:hsl(var(--card));color:hsl(var(--foreground));border:1px solid hsl(var(--border));border-radius:8px;overflow:hidden;font-family:ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;font-size:13px;line-height:1.45;box-shadow:0 20px 50px -10px rgba(0, 0, 0, 0.7)}*{box-sizing:border-box}button,a.btn{font:inherit;color:inherit;cursor:pointer}:focus-visible{outline:2px solid hsl(var(--primary));outline-offset:2px}.bar{display:flex;align-items:center;gap:8px;padding:8px 10px;border-bottom:1px solid hsl(var(--border));min-width:0}.nm{font-family:ui-monospace, SFMono-Regular, Menlo, monospace;font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.pill{font-size:10px;font-weight:600;text-transform:uppercase;letter-spacing:0.05em;padding:2px 7px;border-radius:3px;white-space:nowrap;background:hsl(var(--primary) / 0.18);color:hsl(var(--primary));flex:none}.sp{flex:1}.ib{width:28px;height:28px;display:inline-grid;place-items:center;border-radius:4px;border:1px solid transparent;background:transparent;color:hsl(var(--muted-foreground));padding:0;flex:none}.ib:hover:not(:disabled){background:hsl(var(--muted));color:hsl(var(--foreground))}.ib:disabled{opacity:0.4;cursor:not-allowed}.btn{border-radius:4px;padding:7px 14px;font-size:12px;font-weight:600;border:1px solid hsl(var(--border));background:hsl(var(--muted));text-decoration:none;display:inline-flex;align-items:center}.btn.pri{background:hsl(var(--primary));border-color:hsl(var(--primary));color:hsl(var(--primary-foreground))}.stage{position:relative;background:#000;min-height:220px;display:grid}.stage.audio{min-height:0;background:hsl(var(--bg));padding:14px}.stage>video,.stage>audio{grid-area:1 / 1;width:100%;max-height:70vh;display:block}.stage>audio{align-self:center}.stage>.hidden{visibility:hidden}.stage-msg{grid-area:1 / 1;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:8px;padding:22px;z-index:1}.stage.audio .stage-msg{padding:8px}.overlay-msg{background:rgba(0, 0, 0, 0.55);pointer-events:none}.stage-msg>svg{color:hsl(var(--amber))}.stage-msg[data-phase='casting']>svg{color:hsl(var(--primary))}.stage-msg b{font-size:14px;font-weight:600}.stage-msg span{color:hsl(var(--muted-foreground));font-size:12px;max-width:44ch}.stage-msg .clock{font-family:ui-monospace, SFMono-Regular, Menlo, monospace;font-variant-numeric:tabular-nums}.stage-msg .row{display:flex;gap:8px;margin-top:4px}.spin{width:26px;height:26px;border-radius:50%;border:3px solid hsl(var(--border));border-top-color:hsl(var(--primary));animation:spin 1s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion: reduce){.spin{animation:none}}"}},[513,"phirepass-media-player",{src:[1],name:[1],mime:[1],status:[1],ready:[2],positionStore:[16],positionKey:[1,"position-key"],remotePlayback:[16],castDevice:[1,"cast-device"],phase:[32],stored:[32],castAvailable:[32],currentTime:[32],duration:[32],close:[64]},void 0,{src:[{onSrc:0}]}]);function k(){"undefined"!=typeof customElements&&["phirepass-media-player"].forEach((t=>{"phirepass-media-player"===t&&(customElements.get(a(t))||customElements.define(a(t),M))}))}k();export{m as I,M as P,o as a,d as b,h as c,k as d,l as e,c as f,u as g,p}
@@ -0,0 +1 @@
1
+ class t{__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,s.unregister(this),t}free(){const t=this.__destroy_into_raw();T.__wbg_channel_free(t,0)}authenticate(t,n,e){const r=+(y(e)?Number.MAX_SAFE_INTEGER:e>>>0);let c,o,i,s;try{c=v(t,T.__wbindgen_export,T.__wbindgen_export2),o=F,i=v(n,T.__wbindgen_export,T.__wbindgen_export2),s=F}catch(t){throw i&&T.__wbindgen_export3(i,1*s,1),c&&T.__wbindgen_export3(c,1*o,1),t}T.channel_authenticate(this.__wbg_ptr,c,o,i,s,r)}connect(){T.channel_connect(this.__wbg_ptr)}create_service(t,n,e,r,c,o,i,s,_){const u=+c,a=+(y(_)?Number.MAX_SAFE_INTEGER:_>>>0);let f,b,l,d,h,w,g,p,m,R,A,N,S,O;try{f=v(t,T.__wbindgen_export,T.__wbindgen_export2),b=F,l=v(n,T.__wbindgen_export,T.__wbindgen_export2),d=F,h=y(e)?0:v(e,T.__wbindgen_export,T.__wbindgen_export2),w=F,g=v(r,T.__wbindgen_export,T.__wbindgen_export2),p=F,m=y(o)?0:v(o,T.__wbindgen_export,T.__wbindgen_export2),R=F,A=y(i)?0:v(i,T.__wbindgen_export,T.__wbindgen_export2),N=F,S=y(s)?0:v(s,T.__wbindgen_export,T.__wbindgen_export2),O=F}catch(t){throw S&&T.__wbindgen_export3(S,1*O,1),A&&T.__wbindgen_export3(A,1*N,1),m&&T.__wbindgen_export3(m,1*R,1),g&&T.__wbindgen_export3(g,1*p,1),h&&T.__wbindgen_export3(h,1*w,1),l&&T.__wbindgen_export3(l,1*d,1),f&&T.__wbindgen_export3(f,1*b,1),t}T.channel_create_service(this.__wbg_ptr,f,b,l,d,h,w,g,p,u,m,R,A,N,S,O,a)}delete_service(t,n,e){const r=+(y(e)?Number.MAX_SAFE_INTEGER:e>>>0);let c,o,i,s;try{c=v(t,T.__wbindgen_export,T.__wbindgen_export2),o=F,i=v(n,T.__wbindgen_export,T.__wbindgen_export2),s=F}catch(t){throw i&&T.__wbindgen_export3(i,1*s,1),c&&T.__wbindgen_export3(c,1*o,1),t}T.channel_delete_service(this.__wbg_ptr,c,o,i,s,r)}disconnect(){T.channel_disconnect(this.__wbg_ptr)}is_connected(){return 0!==T.channel_is_connected(this.__wbg_ptr)}is_disconnected(){return 0!==T.channel_is_disconnected(this.__wbg_ptr)}constructor(t,n,e){let r,c,o,i,_,u;try{r=v(t,T.__wbindgen_export,T.__wbindgen_export2),c=F,o=v(n,T.__wbindgen_export,T.__wbindgen_export2),i=F,_=y(e)?0:v(e,T.__wbindgen_export,T.__wbindgen_export2),u=F}catch(t){throw _&&T.__wbindgen_export3(_,1*u,1),o&&T.__wbindgen_export3(o,1*i,1),r&&T.__wbindgen_export3(r,1*c,1),t}const a=T.channel_new(r,c,o,i,_,u);return this.__wbg_ptr=a,s.register(this,this.__wbg_ptr,this),this}on_connection_close(t){T.channel_on_connection_close(this.__wbg_ptr,y(t)?0:_(t))}on_connection_error(t){T.channel_on_connection_error(this.__wbg_ptr,y(t)?0:_(t))}on_connection_message(t){T.channel_on_connection_message(this.__wbg_ptr,y(t)?0:_(t))}on_connection_open(t){T.channel_on_connection_open(this.__wbg_ptr,y(t)?0:_(t))}on_protocol_message(t){T.channel_on_protocol_message(this.__wbg_ptr,y(t)?0:_(t))}on_protocol_message_type(t,n){const e=v(t,T.__wbindgen_export,T.__wbindgen_export2);T.channel_on_protocol_message_type(this.__wbg_ptr,e,F,y(n)?0:_(n))}open_rdp_tunnel(t,n,e,r,c){const o=+(y(c)?Number.MAX_SAFE_INTEGER:c>>>0);let i,s,_,u,a,f,b,l;try{i=v(t,T.__wbindgen_export,T.__wbindgen_export2),s=F,_=v(n,T.__wbindgen_export,T.__wbindgen_export2),u=F,a=y(e)?0:v(e,T.__wbindgen_export,T.__wbindgen_export2),f=F,b=y(r)?0:v(r,T.__wbindgen_export,T.__wbindgen_export2),l=F}catch(t){throw b&&T.__wbindgen_export3(b,1*l,1),a&&T.__wbindgen_export3(a,1*f,1),_&&T.__wbindgen_export3(_,1*u,1),i&&T.__wbindgen_export3(i,1*s,1),t}T.channel_open_rdp_tunnel(this.__wbg_ptr,i,s,_,u,a,f,b,l,o)}open_sftp_tunnel(t,n,e,r,c){const o=+(y(c)?Number.MAX_SAFE_INTEGER:c>>>0);let i,s,_,u,a,f,b,l;try{i=v(t,T.__wbindgen_export,T.__wbindgen_export2),s=F,_=v(n,T.__wbindgen_export,T.__wbindgen_export2),u=F,a=y(e)?0:v(e,T.__wbindgen_export,T.__wbindgen_export2),f=F,b=y(r)?0:v(r,T.__wbindgen_export,T.__wbindgen_export2),l=F}catch(t){throw b&&T.__wbindgen_export3(b,1*l,1),a&&T.__wbindgen_export3(a,1*f,1),_&&T.__wbindgen_export3(_,1*u,1),i&&T.__wbindgen_export3(i,1*s,1),t}T.channel_open_sftp_tunnel(this.__wbg_ptr,i,s,_,u,a,f,b,l,o)}open_ssh_tunnel(t,n,e,r,c){const o=+(y(c)?Number.MAX_SAFE_INTEGER:c>>>0);let i,s,_,u,a,f,b,l;try{i=v(t,T.__wbindgen_export,T.__wbindgen_export2),s=F,_=v(n,T.__wbindgen_export,T.__wbindgen_export2),u=F,a=y(e)?0:v(e,T.__wbindgen_export,T.__wbindgen_export2),f=F,b=y(r)?0:v(r,T.__wbindgen_export,T.__wbindgen_export2),l=F}catch(t){throw b&&T.__wbindgen_export3(b,1*l,1),a&&T.__wbindgen_export3(a,1*f,1),_&&T.__wbindgen_export3(_,1*u,1),i&&T.__wbindgen_export3(i,1*s,1),t}T.channel_open_ssh_tunnel(this.__wbg_ptr,i,s,_,u,a,f,b,l,o)}send_sftp_chmod(t,n,e,r,c){const o=+n,i=+r,s=+(y(c)?Number.MAX_SAFE_INTEGER:c>>>0);let _,u,a,f;try{_=v(t,T.__wbindgen_export,T.__wbindgen_export2),u=F,a=v(e,T.__wbindgen_export,T.__wbindgen_export2),f=F}catch(t){throw a&&T.__wbindgen_export3(a,1*f,1),_&&T.__wbindgen_export3(_,1*u,1),t}T.channel_send_sftp_chmod(this.__wbg_ptr,_,u,o,a,f,i,s)}send_sftp_delete(t,n,e,r,c){const o=+n,i=+(y(c)?Number.MAX_SAFE_INTEGER:c>>>0);let s,_,u,a,f,b;try{s=v(t,T.__wbindgen_export,T.__wbindgen_export2),_=F,u=v(e,T.__wbindgen_export,T.__wbindgen_export2),a=F,f=v(r,T.__wbindgen_export,T.__wbindgen_export2),b=F}catch(t){throw f&&T.__wbindgen_export3(f,1*b,1),u&&T.__wbindgen_export3(u,1*a,1),s&&T.__wbindgen_export3(s,1*_,1),t}T.channel_send_sftp_delete(this.__wbg_ptr,s,_,o,u,a,f,b,i)}send_sftp_download_ack(t,n,e,r){const c=+n,o=+e,i=+r,s=v(t,T.__wbindgen_export,T.__wbindgen_export2);T.channel_send_sftp_download_ack(this.__wbg_ptr,s,F,c,o,i)}send_sftp_download_chunk(t,n,e,r,c){const o=+n,i=+e,s=+r,_=+(y(c)?Number.MAX_SAFE_INTEGER:c>>>0),u=v(t,T.__wbindgen_export,T.__wbindgen_export2);T.channel_send_sftp_download_chunk(this.__wbg_ptr,u,F,o,i,s,_)}send_sftp_download_start(t,n,e,r,c){const o=+n,i=+(y(c)?Number.MAX_SAFE_INTEGER:c>>>0);let s,_,u,a,f,b;try{s=v(t,T.__wbindgen_export,T.__wbindgen_export2),_=F,u=v(e,T.__wbindgen_export,T.__wbindgen_export2),a=F,f=v(r,T.__wbindgen_export,T.__wbindgen_export2),b=F}catch(t){throw f&&T.__wbindgen_export3(f,1*b,1),u&&T.__wbindgen_export3(u,1*a,1),s&&T.__wbindgen_export3(s,1*_,1),t}T.channel_send_sftp_download_start(this.__wbg_ptr,s,_,o,u,a,f,b,i)}send_sftp_list_data(t,n,e,r){const c=+n,o=+(y(r)?Number.MAX_SAFE_INTEGER:r>>>0);let i,s,_,u;try{i=v(t,T.__wbindgen_export,T.__wbindgen_export2),s=F,_=v(e,T.__wbindgen_export,T.__wbindgen_export2),u=F}catch(t){throw _&&T.__wbindgen_export3(_,1*u,1),i&&T.__wbindgen_export3(i,1*s,1),t}T.channel_send_sftp_list_data(this.__wbg_ptr,i,s,c,_,u,o)}send_sftp_mkdir(t,n,e,r){const c=+n,o=+(y(r)?Number.MAX_SAFE_INTEGER:r>>>0);let i,s,_,u;try{i=v(t,T.__wbindgen_export,T.__wbindgen_export2),s=F,_=v(e,T.__wbindgen_export,T.__wbindgen_export2),u=F}catch(t){throw _&&T.__wbindgen_export3(_,1*u,1),i&&T.__wbindgen_export3(i,1*s,1),t}T.channel_send_sftp_mkdir(this.__wbg_ptr,i,s,c,_,u,o)}send_sftp_read_file(t,n,e,r){const c=+n,o=+(y(r)?Number.MAX_SAFE_INTEGER:r>>>0);let i,s,_,u;try{i=v(t,T.__wbindgen_export,T.__wbindgen_export2),s=F,_=v(e,T.__wbindgen_export,T.__wbindgen_export2),u=F}catch(t){throw _&&T.__wbindgen_export3(_,1*u,1),i&&T.__wbindgen_export3(i,1*s,1),t}T.channel_send_sftp_read_file(this.__wbg_ptr,i,s,c,_,u,o)}send_sftp_remove(t,n,e,r,c){const o=+n,i=+r,s=+(y(c)?Number.MAX_SAFE_INTEGER:c>>>0);let _,u,a,f;try{_=v(t,T.__wbindgen_export,T.__wbindgen_export2),u=F,a=v(e,T.__wbindgen_export,T.__wbindgen_export2),f=F}catch(t){throw a&&T.__wbindgen_export3(a,1*f,1),_&&T.__wbindgen_export3(_,1*u,1),t}T.channel_send_sftp_remove(this.__wbg_ptr,_,u,o,a,f,i,s)}send_sftp_rename(t,n,e,r,c){const o=+n,i=+(y(c)?Number.MAX_SAFE_INTEGER:c>>>0);let s,_,u,a,f,b;try{s=v(t,T.__wbindgen_export,T.__wbindgen_export2),_=F,u=v(e,T.__wbindgen_export,T.__wbindgen_export2),a=F,f=v(r,T.__wbindgen_export,T.__wbindgen_export2),b=F}catch(t){throw f&&T.__wbindgen_export3(f,1*b,1),u&&T.__wbindgen_export3(u,1*a,1),s&&T.__wbindgen_export3(s,1*_,1),t}T.channel_send_sftp_rename(this.__wbg_ptr,s,_,o,u,a,f,b,i)}send_sftp_upload_chunk(t,n,e,r,c,o,i){const s=+n,_=+e,u=+r,a=+c,f=+(y(i)?Number.MAX_SAFE_INTEGER:i>>>0);let b,l,d,h;try{b=v(t,T.__wbindgen_export,T.__wbindgen_export2),l=F,d=m(o,T.__wbindgen_export),h=F}catch(t){throw d&&T.__wbindgen_export3(d,1*h,1),b&&T.__wbindgen_export3(b,1*l,1),t}T.channel_send_sftp_upload_chunk(this.__wbg_ptr,b,l,s,_,u,a,d,h,f)}send_sftp_upload_start(t,n,e,r,c,o,i){const s=+n,_=+c,u=BigInt.asIntN(64,o),a=+(y(i)?Number.MAX_SAFE_INTEGER:i>>>0);let f,b,l,d,h,w;try{f=v(t,T.__wbindgen_export,T.__wbindgen_export2),b=F,l=v(e,T.__wbindgen_export,T.__wbindgen_export2),d=F,h=v(r,T.__wbindgen_export,T.__wbindgen_export2),w=F}catch(t){throw h&&T.__wbindgen_export3(h,1*w,1),l&&T.__wbindgen_export3(l,1*d,1),f&&T.__wbindgen_export3(f,1*b,1),t}T.channel_send_sftp_upload_start(this.__wbg_ptr,f,b,s,l,d,h,w,_,u,a)}send_sftp_write_file(t,n,e,r,c){const o=+n,i=+(y(c)?Number.MAX_SAFE_INTEGER:c>>>0);let s,_,u,a,f,b;try{s=v(t,T.__wbindgen_export,T.__wbindgen_export2),_=F,u=v(e,T.__wbindgen_export,T.__wbindgen_export2),a=F,f=m(r,T.__wbindgen_export),b=F}catch(t){throw f&&T.__wbindgen_export3(f,1*b,1),u&&T.__wbindgen_export3(u,1*a,1),s&&T.__wbindgen_export3(s,1*_,1),t}T.channel_send_sftp_write_file(this.__wbg_ptr,s,_,o,u,a,f,b,i)}send_ssh_terminal_resize(t,n,e,r,c,o){const i=+n,s=+e,_=+r,u=+c,a=+o,f=v(t,T.__wbindgen_export,T.__wbindgen_export2);T.channel_send_ssh_terminal_resize(this.__wbg_ptr,f,F,i,s,_,u,a)}send_ssh_tunnel_data(t,n,e){const r=+n;let c,o,i,s;try{c=v(t,T.__wbindgen_export,T.__wbindgen_export2),o=F,i=v(e,T.__wbindgen_export,T.__wbindgen_export2),s=F}catch(t){throw i&&T.__wbindgen_export3(i,1*s,1),c&&T.__wbindgen_export3(c,1*o,1),t}T.channel_send_ssh_tunnel_data(this.__wbg_ptr,c,o,r,i,s)}start_heartbeat(t){T.channel_start_heartbeat(this.__wbg_ptr,t)}stop_heartbeat(){T.channel_stop_heartbeat(this.__wbg_ptr)}update_service(t,n,e,r,c,o,i,s,_,u){const a=+o,f=+(y(u)?Number.MAX_SAFE_INTEGER:u>>>0);let b,l,d,h,w,g,p,m,R,A,N,S,O,P,U,j;try{b=v(t,T.__wbindgen_export,T.__wbindgen_export2),l=F,d=v(n,T.__wbindgen_export,T.__wbindgen_export2),h=F,w=v(e,T.__wbindgen_export,T.__wbindgen_export2),g=F,p=y(r)?0:v(r,T.__wbindgen_export,T.__wbindgen_export2),m=F,R=v(c,T.__wbindgen_export,T.__wbindgen_export2),A=F,N=y(i)?0:v(i,T.__wbindgen_export,T.__wbindgen_export2),S=F,O=y(s)?0:v(s,T.__wbindgen_export,T.__wbindgen_export2),P=F,U=y(_)?0:v(_,T.__wbindgen_export,T.__wbindgen_export2),j=F}catch(t){throw U&&T.__wbindgen_export3(U,1*j,1),O&&T.__wbindgen_export3(O,1*P,1),N&&T.__wbindgen_export3(N,1*S,1),R&&T.__wbindgen_export3(R,1*A,1),p&&T.__wbindgen_export3(p,1*m,1),w&&T.__wbindgen_export3(w,1*g,1),d&&T.__wbindgen_export3(d,1*h,1),b&&T.__wbindgen_export3(b,1*l,1),t}T.channel_update_service(this.__wbg_ptr,b,l,d,h,w,g,p,m,R,A,a,N,S,O,P,U,j,f)}}Symbol.dispose&&(t.prototype[Symbol.dispose]=t.prototype.free);const n=Object.freeze({Generic:0,0:"Generic",Authentication:10,10:"Authentication",RequiresUsername:100,100:"RequiresUsername",RequiresPassword:110,110:"RequiresPassword",RequiresUsernamePassword:120,120:"RequiresUsernamePassword"});function e(t,n){T.__wasm_bindgen_func_elem_67(t,n)}function r(t,n,e){T.__wasm_bindgen_func_elem_63(t,n,e)}function c(t,n,e){T.__wasm_bindgen_func_elem_63_37(t,n,e)}function o(t,n,e){T.__wasm_bindgen_func_elem_63_38(t,n,e)}const i=["blob","arraybuffer"],s="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>T.__wbg_channel_free(t,1)));function _(t){const n=T.__wbindgen_export5();return T.__wbindgen_externrefs.set(n,t),n}const u="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>T.__wbindgen_export6(t.a,t.b)));function a(t){switch(typeof t){case"number":case"boolean":case"undefined":return`${t}`;case"string":return JSON.stringify(t);case"bigint":return`${t}n`;case"symbol":return void 0!==t.description?`Symbol(${t.description})`:"Symbol";case"function":return"string"==typeof t.name&&""!==t.name?`Function(${t.name})`:"Function";case"object":{if(null===t)return"null";if(Array.isArray(t))return"["+Array.from(t,a).join(", ")+"]";if(t instanceof Error)return`${t.name}: ${t.message}\n${t.stack}`;const n=toString.call(t),e=/\[object ([^\]]+)\]/.exec(n)?.[1];if(void 0===e)return n;if("Object"===e)try{return"Object("+JSON.stringify(t)+")"}catch(t){return"Object"}return e}}}function f(t,n){return t>>>=0,w().subarray(t/1,t/1+n)}let b=null;function l(){return(null===b||!0===b.buffer.detached||void 0===b.buffer.detached&&b.buffer!==T.memory.buffer)&&(b=new DataView(T.memory.buffer)),b}function d(t,n){return t>>>=0,e=w().subarray(t,t+n),N+=e.length,N>=A&&(R=new TextDecoder("utf-8",{ignoreBOM:!0}),R.decode(),N=e.length),R.decode(e);var e}let h=null;function w(){return null!==h&&0!==h.byteLength||(h=new Uint8Array(T.memory.buffer)),h}function g(t,n){try{return t.apply(this,n)}catch(t){const n=_(t);T.__wbindgen_export4(n)}}function y(t){return null==t}function p(t,n,e){const r={a:t,b:n,cnt:1},c=(...t)=>{r.cnt++;const n=r.a;r.a=0;try{return e(n,r.b,...t)}finally{r.a=n,c._wbg_cb_unref()}};return c._wbg_cb_unref=()=>{0==--r.cnt&&(T.__wbindgen_export6(r.a,r.b),r.a=0,u.unregister(r))},u.register(c,r,r),c}function m(t,n){const e=n(1*t.length,1)>>>0;return w().set(t,e/1),F=t.length,e}function v(t,n,e){if(void 0===e){const e=S.encode(t),r=n(e.length,1)>>>0;return w().subarray(r,r+e.length).set(e),F=e.length,r}let r=t.length,c=n(r,1)>>>0;const o=w();let i=0;for(;i<r;i++){const n=t.charCodeAt(i);if(n>127)break;o[c+i]=n}if(i!==r){0!==i&&(t=t.slice(i)),c=e(c,r,r=i+3*t.length,1)>>>0;const n=w().subarray(c+i,c+r);i+=S.encodeInto(t,n).written,c=e(c,r,i,1)>>>0}return F=i,c}let R=new TextDecoder("utf-8",{ignoreBOM:!0});R.decode();const A=2146435072;let N=0;const S=new TextEncoder;"encodeInto"in S||(S.encodeInto=function(t,n){const e=S.encode(t);return n.set(e),{read:t.length,written:e.length}});let T,O,F=0;async function P(t){return void 0!==T?T:(void 0===O&&(O=async function(t){void 0!==t&&(Object.getPrototypeOf(t)===Object.prototype?({module_or_path:t}=t):console.warn("using deprecated parameters for the initialization function; pass a single object instead")),void 0===t&&(t=new URL("phirepass-channel_bg.wasm",import.meta.url));const n=function(){const t={__proto__:null,__wbg_Error_208446807d0d1e30:function(t,n){return Error(d(t,n))},__wbg_String_8564e559799eccda:function(t,n){const e=v(String(n),T.__wbindgen_export,T.__wbindgen_export2),r=F;l().setInt32(4+(t>>>0),r,!0),l().setInt32(0+(t>>>0),e,!0)},__wbg___wbindgen_debug_string_f249a2a76caa9a55:function(t,n){const e=v(a(n),T.__wbindgen_export,T.__wbindgen_export2),r=F;l().setInt32(4+(t>>>0),r,!0),l().setInt32(0+(t>>>0),e,!0)},__wbg___wbindgen_string_get_7ce8eee7fd327545:function(t,n){const e="string"==typeof n?n:void 0;var r=y(e)?0:v(e,T.__wbindgen_export,T.__wbindgen_export2),c=F;l().setInt32(4+(t>>>0),c,!0),l().setInt32(0+(t>>>0),r,!0)},__wbg___wbindgen_throw_4c88d8bf264fd984:function(t,n){throw new Error(d(t,n))},__wbg__wbg_cb_unref_09736879a3f67559:function(t){t._wbg_cb_unref()},__wbg_call_40b008ba32f73991:function(){return g((function(t,n){return t.call(n)}),arguments)},__wbg_call_a410eb4b59ed5965:function(){return g((function(t,n,e){return t.call(n,e)}),arguments)},__wbg_call_fc92fee6137d452d:function(){return g((function(t,n,e,r){return t.call(n,e,r)}),arguments)},__wbg_clearInterval_26ba580547547579:function(t){return clearInterval(t)},__wbg_close_5ee9c5fe4e8754a4:function(){return g((function(t){t.close()}),arguments)},__wbg_data_c7e5e8500f1bca2f:function(t){return t.data},__wbg_from_eac91875c8a5ffa4:function(t){return Array.from(t)},__wbg_getRandomValues_5d8c030b527203a6:function(){return g((function(t,n){globalThis.crypto.getRandomValues(f(t,n))}),arguments)},__wbg_get_2080c49015e35254:function(){return g((function(t,n){return Reflect.get(t,n)}),arguments)},__wbg_info_2b8ee6588e4c6072:function(t,n){console.info(d(t,n))},__wbg_instanceof_ArrayBuffer_12cdaa4161423e6b:function(t){let n;try{n=t instanceof ArrayBuffer}catch(t){n=!1}return n},__wbg_length_186163212ffe79c3:function(t){return t.length},__wbg_new_13de428334042d26:function(t){return new Uint8Array(t)},__wbg_new_37eb45aaf5eeb820:function(){return new Array},__wbg_new_cd4348290afae586:function(){return new Object},__wbg_new_with_str_sequence_75b26d88172889d0:function(){return g((function(t,n,e){return new WebSocket(d(t,n),e)}),arguments)},__wbg_prototypesetcall_13162965d1fe7aa3:function(t,n,e){Uint8Array.prototype.set.call(f(t,n),e)},__wbg_push_c9f4893fc209f768:function(t,n){return t.push(n)},__wbg_readyState_039bc047141a5f6d:function(t){return t.readyState},__wbg_send_d83d0891cf698779:function(){return g((function(t,n,e){t.send(f(n,e))}),arguments)},__wbg_setInterval_d933acbf2578adfa:function(){return g((function(t,n){return setInterval(t,n)}),arguments)},__wbg_set_binaryType_d5b4dafd0f127fb2:function(t,n){t.binaryType=i[n]},__wbg_set_d2d33b52458e984a:function(t,n,e){t[n>>>0]=e},__wbg_set_e4b9a833d288759a:function(t,n,e){t[n]=e},__wbg_set_onclose_078935cf8d0fb024:function(t,n){t.onclose=n},__wbg_set_onerror_f7f089f7f059501c:function(t,n){t.onerror=n},__wbg_set_onmessage_26abc49cfa5f9ffc:function(t,n){t.onmessage=n},__wbg_set_onopen_757be120cc7b1ea6:function(t,n){t.onopen=n},__wbg_warn_b0df9a9e7105e74b:function(t,n){console.warn(d(t,n))},__wbindgen_generic_0000000000000001:function(t,n){return p(t,n,r)},__wbindgen_generic_0000000000000002:function(t,n){return p(t,n,c)},__wbindgen_generic_0000000000000003:function(t,n){return p(t,n,o)},__wbindgen_generic_0000000000000004:function(t,n){return p(t,n,e)},__wbindgen_generic_0000000000000005:function(t){return t},__wbindgen_generic_0000000000000006:function(t,n){return f(t,n)},__wbindgen_generic_0000000000000007:function(t,n){return d(t,n)},__wbindgen_generic_0000000000000008:function(t){return BigInt.asUintN(64,t)},__wbindgen_init_externref_table:function(){const t=T.__wbindgen_externrefs;t.set(0,void 0),t.set(1024,void 0),t.set(1025,null),t.set(1026,!0),t.set(1027,!1)}};return{__proto__:null,"./phirepass-channel_bg.js":t}}();("string"==typeof t||"function"==typeof Request&&t instanceof Request||"function"==typeof URL&&t instanceof URL)&&(t=fetch(t));const{instance:s}=await async function(t,n){if("function"==typeof Response&&t instanceof Response){if(!t.ok)throw new Error(`failed to fetch Wasm: ${t.status} ${t.statusText} fetching '${t.url}'`);if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(t,n)}catch(n){if(!function(t){switch(t){case"basic":case"cors":case"default":return!0}return!1}(t.type)||"application/wasm"===t.headers.get("Content-Type"))throw n;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",n)}const e=await t.arrayBuffer();return await WebAssembly.instantiate(e,n)}{const e=await WebAssembly.instantiate(t,n);return e instanceof WebAssembly.Instance?{instance:e,module:t}:e}}(await t,n);return function(t){return T=t.exports,b=null,h=null,T.__wbindgen_start(),T}(s)}(t),O.catch((()=>{O=void 0}))),O)}var U,j,k;!function(t){t.Error="Error",t.AuthSuccess="AuthSuccess",t.TunnelOpened="TunnelOpened",t.TunnelClosed="TunnelClosed",t.TunnelData="TunnelData",t.RDPAuthorized="RDPAuthorized",t.SFTPListItems="SFTPListItems",t.SFTPDownloadStartResponse="SFTPDownloadStartResponse",t.SFTPDownloadChunk="SFTPDownloadChunk",t.SFTPUploadStartResponse="SFTPUploadStartResponse",t.SFTPUploadChunkAck="SFTPUploadChunkAck",t.SFTPOpResult="SFTPOpResult"}(U||(U={})),function(t){t[t.Username=0]="Username",t[t.Password=1]="Password",t[t.Default=2]="Default"}(j||(j={})),function(t){t.Disconnected="disconnected",t.Connected="connected",t.Error="error"}(k||(k={}));export{t as C,n as E,j as I,U as P,P as _,k as a}
@@ -0,0 +1 @@
1
+ import{h as e,t,p as n,H as o,c as s,a as i}from"./index.js";import{_ as r,C as a,P as l,E as d}from"./p-CsYQJXY2.js";import{f as h,a as c,b as p,c as u,e as f,g as b,I as g,p as m,d as w}from"./p-C4cmk3bS.js";const v=["send_download_start","send_download_stop","send_download_resume","send_download_set_order","send_download_delete","send_download_subscribe","send_download_where"];function x(e){return!(!e||"object"!=typeof e)&&v.every((t=>"function"==typeof e[t]))}const y=1073741824,k=new Set(["DownloadProgress","DownloadAccepted","DownloadWhereAnswer","DownloadCaps","DownloadFoldersAnswer"]);function C(e){return k.has(e.type)}const S=new Set(["host","content-length","range","if-range","transfer-encoding","connection","keep-alive","proxy-authenticate","proxy-authorization","te","trailer","upgrade"]);function $(e){const t=e.trim();if(!t)return{kind:"empty"};if(/^magnet:\?/i.test(t)){const e=t.slice(t.indexOf("?")+1),n=new URLSearchParams(e),o=n.getAll("xt").find((e=>/^urn:btih:/i.test(e)));if(!o)return{kind:"invalid"};const s=o.slice(9),i=n.get("dn")?.trim();return{kind:"magnet",uri:t,infoHash:s,...i?{name:i}:{}}}let n;try{n=new URL(t)}catch{return{kind:"invalid"}}if("http:"!==n.protocol&&"https:"!==n.protocol)return{kind:"invalid"};if(!n.hostname)return{kind:"invalid"};if(n.username||n.password)return{kind:"invalid"};const o="https:"===n.protocol?"HTTPS":"HTTP",s=function(e){const t=e.split("/").filter(Boolean),n=t[t.length-1]??"";try{return decodeURIComponent(n)}catch{return n}}(n.pathname)||"download";return{kind:/\.torrent$/i.test(n.pathname)?"torrent-url":"http",url:t,host:n.hostname,name:s,scheme:o}}function D(e){switch(e.mode){case"none":return{auth:null};case"basic":return e.username?{auth:{Basic:{username:e.username,password:e.password}}}:{auth:null,error:"Enter a username."};case"bearer":return e.token.trim()?{auth:{Bearer:{token:e.token.trim()}}}:{auth:null,error:"Enter a token."};case"header":{const t=e.headerName.trim();return/^[A-Za-z0-9!#$%&'*+.^_`|~-]+$/.test(t)?S.has(t.toLowerCase())?{auth:null,error:`${t} cannot be set here.`}:{auth:{Header:{name:t,value:e.headerValue}}}:{auth:null,error:"Enter a valid header name."}}}}const z={text:"",saveAs:"",torrent:null,order:null,auth:{mode:"none",username:"",password:"",token:"",headerName:"",headerValue:""},authOpen:!1};function F(e,t,n){const o=e.torrent?{kind:"empty"}:$(e.text),s=!!e.torrent||"magnet"===o.kind,i=s&&!!t&&!t.torrents,r="http"===o.kind||"torrent-url"===o.kind;let a=null;"too-large"===e.torrent?.error?a={tone:"err",title:"Too large",body:"A .torrent file can be up to 2 MB. Use its magnet link instead."}:"not-torrent"===e.torrent?.error?a={tone:"err",title:"Not a .torrent",body:"Choose a file that ends in .torrent."}:"invalid"===o.kind?a={tone:"err",title:"Not a link",body:"Use http://, https:// or magnet:"}:i&&(a={tone:"warn",title:"Torrents are off",body:"This node only allows ordinary links. Its owner can allow torrents in the node's settings."});const l=D(e.auth),d=s&&!i,h=n&&!!t&&(r||"magnet"===o.kind||!!e.torrent&&!e.torrent.error&&!!e.torrent.contents)&&!a&&(!d||null!==e.order)&&(!r||!e.authOpen||!l.error);let c;return r?c=e.saveAs.trim()||o.name:"magnet"===o.kind&&(c=o.name),{detected:o,isTorrent:s,needsOrder:d,showSaveAs:"http"===o.kind,showAuth:r,note:a,canStart:h,askedName:c,authError:r&&e.authOpen&&(e.auth.username||e.auth.token||e.auth.headerName||e.auth.headerValue)?l.error:void 0}}const _=new Set(["Completed","Seeding"]);function P(e){return _.has(e)}const T=new Set(["Queued","Scheduled","Resolving","FetchingMetadata","Downloading","Verifying","Paused","Stopped","Unknown"]);function I(e){return["Queued","Scheduled","Resolving","FetchingMetadata","Downloading","Verifying","Paused"].includes(e.state)}function R(e){return("Completed"===e.state||"Cancelled"===e.state)&&!e.deleting}const N={Downloading:0,Verifying:1,FetchingMetadata:2,Resolving:3,Paused:4,Queued:5,Scheduled:6,Retrying:7,Stopped:8,Seeding:9,Completed:10,Cancelled:11,Deleted:12,Unknown:13};function A(e){const t=e.filter(I),n=t.reduce(((e,t)=>e+(t.down_bps||0)),0),o=t.filter((e=>e.total_bytes)),s=o.reduce(((e,t)=>e+t.done_bytes),0),i=o.reduce(((e,t)=>e+(t.total_bytes??0)),0);return{active:t.length,downBps:n,done:s,total:i,percent:i?s/i*100:null}}const j=/\.(mp4|m4v|webm|mkv|mov|mp3|m4a|flac|ogg|oga|opus|wav)$/i;function O(e){return j.test(e)}function M(e){const t=function(e){const t=e.files.filter((e=>e.media||O(e.name)));return t.length?t.reduce(((e,t)=>t.size>e.size?t:e)):!e.files.length&&O(e.name)?{index:0,name:e.name,size:e.total_bytes??0,done_bytes:e.done_bytes,media:!0,ready_from_start:e.in_order?e.done_bytes:0}:null}(e);return!t||e.deleting?{play:!1,file:null,switchToInOrder:!1}:P(e.state)?{play:!0,file:t,switchToInOrder:!1}:["Downloading","Verifying","Paused","Stopped","Retrying"].includes(e.state)&&t.size?e.in_order?{play:!0,file:t,switchToInOrder:!1}:{play:!1,file:null,switchToInOrder:"Torrent"===e.kind}:{play:!1,file:null,switchToInOrder:!1}}function B(...e){const t=e.filter((e=>!!e)).join("/").replace(/\/{2,}/g,"/");return t.length>1?t.replace(/\/+$/,""):t}function U(e){return B(e.dest_root,e.sub_dir)}function E(e,t,n){return e.agent_supported?"Organisation"===e.lock?{id:"blocked",title:"Blocked",body:`Your organisation does not allow downloads on ${t}.`,secondary:"An owner or admin of the organisation can change this under Organisation → Downloads."}:e.http?"NoFolder"===e.lock?{id:"no-folder",title:"No download folder",body:"The download folder on this node is missing or can't be written.",secondary:"Someone who can configure the node can pick another one.",action:n?"Open node settings":void 0}:null:{id:"off",title:"Downloads are off",body:`Downloads are turned off for ${t}.`,secondary:n?"You can turn them on in the node's settings.":"Ask the node's owner to turn them on.",action:n?"Open node settings":void 0}:{id:"too-old",title:"Too old",body:`${t} runs an agent that cannot download. Update the agent on that machine, then try again.`}}const V=({label:t,onClose:n,wide:o},s)=>e("div",{class:"overlay",onClick:e=>{e.target===e.currentTarget&&n()}},e("div",{class:{modal:!0,wide:!!o},role:"dialog","aria-modal":"true","aria-label":t,tabindex:-1,onKeyDown:e=>{"Escape"===e.key&&(e.stopPropagation(),n())}},s)),Q=({cancel:t,confirm:n,danger:o,onCancel:s,onConfirm:i})=>e("div",{class:"dlg-f"},e("button",{type:"button",class:"btn",onClick:s},t),e("button",{type:"button",class:{btn:!0,pri:!o,dng:!!o},onClick:i},n)),W=({row:t,discard:n,onDiscard:o,...s})=>e(V,{label:"Stop this download?",onClose:s.onCancel},e("div",{class:"dlg"},e("h4",null,"Stop this download?"),e("div",{class:"filechip"},e(g,{name:"file",size:20}),e("div",null,e("b",null,t.name),e("span",null,t.total_bytes?`${c(t.done_bytes)} of ${c(t.total_bytes)} downloaded`:`${c(t.done_bytes)} downloaded`))),e("label",{class:"checkline"},e("input",{type:"checkbox",checked:n,onChange:e=>o(e.target.checked)}),e("span",null,"Also delete the part already downloaded",e("span",{class:"hint block"},"Leave this off and Resume continues from here."))),e(Q,{cancel:"Keep downloading",confirm:"Stop download",danger:!0,...s}))),q=({row:t,deleteFile:n,onDeleteFile:o,nodeName:s,...i})=>{const r=P(t.state),a=t.files.length>1?`${t.files.length} files · ${c(t.total_bytes??t.done_bytes)}`:c(t.total_bytes??t.done_bytes);return e(V,{label:"Delete this download?",onClose:i.onCancel},e("div",{class:"dlg"},e("h4",null,"Delete this download?"),e("div",{class:"filechip"},e(g,{name:"file",size:20}),e("div",null,e("b",null,t.name),e("span",null,"Seeding"===t.state?"Seeding · ":"",a," in ",U(t)))),"Seeding"===t.state&&e("p",{class:"dtx"},s," stops sharing it with peers."),r?e("label",{class:"checkline"},e("input",{type:"checkbox",checked:n,onChange:e=>o(e.target.checked)}),e("span",null,"Also delete the files",e("span",{class:"hint block"},"Off: the files stay in ",U(t)," and only the download is removed."))):e("p",{class:"dtx"},"The part already downloaded is deleted."),e(Q,{cancel:"Cancel",confirm:"Delete",danger:!0,...i})))},L=({row:t,...n})=>e(V,{label:"Switch to fastest?",onClose:n.onCancel},e("div",{class:"dlg"},e("h4",null,"Switch to fastest?"),e("p",{class:"dtx"},e("b",null,t.name)," is playing. Fastest downloads pieces in any order, so playback stops until it finishes or you switch back."),e(Q,{cancel:"Keep in order",confirm:"Switch and stop playback",danger:!0,...n}))),H=({nodeName:t,dontAsk:n,onDontAsk:o,...s})=>e(V,{label:`Start a torrent on ${t}?`,onClose:s.onCancel},e("div",{class:"dlg"},e("h4",null,"Start a torrent on ",t,"?"),e("div",{class:"note warn"},e(g,{name:"warn",size:14}),e("div",null,"The node will connect to public peers. They can see its internet address, and it uploads to them while it downloads.")),e("p",{class:"dtx"},"When it finishes, ",t," keeps sharing it with other peers until you delete it."),e("label",{class:"checkline"},e("input",{type:"checkbox",checked:n,onChange:e=>o(e.target.checked)}),e("span",null,"Do not ask again on this browser")),e(Q,{cancel:"Cancel",confirm:"Start torrent",...s}))),K=({reason:t,onClose:n})=>e(V,{label:"Not enough space",onClose:n},e("div",{class:"dlg"},e("h4",null,"Not enough space"),e("p",{class:"dtx"},t),e("div",{class:"dlg-f"},e("button",{type:"button",class:"btn pri",onClick:n},"OK")))),Y=t=>e(V,{label:"Save downloads to",onClose:t.onCancel,wide:!0},e("div",{class:"dlg"},e("h4",null,"Save downloads to"),e("nav",{class:"crumbs","aria-label":"Folder"},e("button",{type:"button",class:"lnk",onClick:()=>t.onUp(0)},t.root),t.path.map(((n,o)=>[e("span",{class:"sep"},"/"),e("button",{type:"button",class:"lnk",onClick:()=>t.onUp(o+1)},n)]))),e("div",{class:"folders",role:"list"},null===t.folders&&e("div",{class:"muted"},"Loading…"),0===t.folders?.length&&e("div",{class:"muted"},"No folders here."),t.folders?.map((n=>e("button",{type:"button",class:"folder-row",role:"listitem",onClick:()=>t.onOpen(n)},e(g,{name:"folder",size:14}),e("span",null,n))))),t.error&&e("div",{class:"note err"},t.error),null!==t.newName&&e("input",{class:"inp",type:"text","aria-label":"New folder name",placeholder:"New folder name",value:t.newName,onInput:e=>t.onNewName(e.target.value)}),e("p",{class:"hint"},"Folders only, and only inside the node's download folder. A new folder is created by the node when the first download lands in it."),e("div",{class:"dlg-f"},e("button",{type:"button",class:"btn left",onClick:()=>t.onNewName(null===t.newName?"":null)},e(g,{name:"plus",size:12})," New folder"),e("button",{type:"button",class:"btn",onClick:t.onCancel},"Cancel"),e("button",{type:"button",class:"btn pri",disabled:null!==t.newName&&!/^[^/\\\0]+$/.test(t.newName.trim()),onClick:t.onSave},"Save here")))),X=({note:t})=>e("div",{class:`note ${t.tone}`,role:"err"===t.tone?"alert":"status"},e(g,{name:"warn",size:14}),e("div",null,e("b",null,t.title)," ",t.body));function J({model:t}){const n=t.detected;return"http"===n.kind||"torrent-url"===n.kind?e("div",{class:"detect","data-kind":n.kind},e("span",{class:"pill meta"},"torrent-url"===n.kind?".torrent link":n.scheme),e("span",{class:"host"},n.host)):"magnet"===n.kind?e("div",{class:"detect","data-kind":"magnet"},e("span",{class:"pill meta"},"Magnet"),e("span",{class:"host"},n.name??"name arrives with the metadata")):e("div",{class:"detect"})}const Z=({auth:t,onChange:n})=>{const o=n,s=(n,s,i="text")=>e("label",{class:"fld"},e("span",null,n),e("input",{class:"inp",type:i,autocomplete:"off",spellcheck:!1,value:t[s],onInput:e=>o({[s]:e.target.value})}));return e("div",{class:"auth"},e("div",{class:"seg",role:"radiogroup","aria-label":"Login for the link"},[["none","No login"],["basic","Username and password"],["bearer","Bearer token"],["header","Custom header"]].map((([n,s])=>e("label",{class:{on:t.mode===n}},e("input",{type:"radio",name:"auth-mode",checked:t.mode===n,onChange:()=>o({mode:n})}),s)))),"basic"===t.mode&&[s("Username","username"),s("Password","password","password")],"bearer"===t.mode&&s("Token","token","password"),"header"===t.mode&&[s("Header name","headerName"),s("Value","headerValue","password")],"none"!==t.mode&&e("p",{class:"hint"},"Sent only to this link's own site, and dropped if it redirects elsewhere. The node seals it and deletes it when the download finishes."))},G=({order:t,onChange:n})=>e("fieldset",{class:"order"},e("legend",null,"How should it download? (required for torrents)"),e("label",{class:{opt:!0,on:"in"===t}},e("input",{type:"radio",name:"order",value:"in",checked:"in"===t,onChange:()=>n("in")}),e("span",null,e("b",null,"In order")," · watch while it downloads, a little slower")),e("label",{class:{opt:!0,on:"fast"===t}},e("input",{type:"radio",name:"order",value:"fast",checked:"fast"===t,onChange:()=>n("fast")}),e("span",null,e("b",null,"Fastest")," · any order; switch to in order later if you want to watch"))),ee=t=>{const{form:n,model:o,caps:s}=t;let i;const r=!!s?.torrents,a="dialog"===t.layout,l=e("input",{type:"file",accept:".torrent,application/x-bittorrent",class:"hidden-input",ref:e=>i=e,onChange:e=>{const n=e.target,o=n.files?.[0];o&&t.onPickTorrent(o),n.value=""}}),d=n.torrent?e("div",{class:{filechip:!0,bad:!!n.torrent.error}},e(g,{name:"torrent",size:20}),e("div",null,e("b",null,n.torrent.name),e("span",null,c(n.torrent.size)," · from this computer")),e("button",{type:"button",class:"ib","aria-label":"Remove the .torrent file",title:"Remove",onClick:()=>t.onChange({torrent:null,order:null})},e(g,{name:"x",size:14}))):e("div",{class:"fld"},e("label",{htmlFor:"fetch-link"},"Link or magnet"),e("div",{class:"inline-row"},e("input",{id:"fetch-link",class:"inp",type:"text",inputMode:"url",autocomplete:"off",autocapitalize:"none",spellcheck:!1,placeholder:"https://… or magnet:?xt=…",value:n.text,disabled:t.starting,onInput:e=>t.onChange({text:e.target.value}),onKeyDown:e=>{"Enter"===e.key&&o.canStart&&(e.preventDefault(),t.onStart())}}),!a&&r&&e("button",{type:"button",class:"btn",onClick:()=>i?.click()},".torrent…"),!a&&e("button",{type:"button",class:"btn pri",disabled:!o.canStart||t.starting,onClick:()=>t.onStart()},t.starting?"Starting…":"Download")),e(J,{model:o}));return e("form",{class:{"fetch-form":!0,[t.layout]:!0},onSubmit:e=>{e.preventDefault(),o.canStart&&t.onStart()},onDragOver:e=>r&&e.preventDefault(),onDrop:e=>r&&(e=>{e.preventDefault();const n=e.dataTransfer?.files?.[0];n&&t.onPickTorrent(n)})(e)},a&&e("div",{class:"dlg-h"},e(g,{name:"fetch"}),e("h4",null,t.title)),l,d,o.note&&e(X,{note:o.note}),t.refusal&&e(X,{note:t.refusal}),o.showSaveAs&&e("div",{class:"fld"},e("label",{htmlFor:"fetch-save-as"},"Save as"),e("input",{id:"fetch-save-as",class:"inp",type:"text",autocomplete:"off",spellcheck:!1,placeholder:o.askedName,value:n.saveAs,disabled:t.starting,onInput:e=>t.onChange({saveAs:e.target.value})}),e("span",{class:"hint"},"Taken from the server's filename when it sends one. An existing file is never overwritten; the new one gets “(1)” added.")),o.showAuth&&e("div",{class:"login"},e("button",{type:"button",class:"lnk","aria-expanded":n.authOpen?"true":"false",onClick:()=>t.onChange({authOpen:!n.authOpen})},e(g,{name:n.authOpen?"up":"chevron",size:12})," This link needs a login"),n.authOpen&&e(Z,{auth:n.auth,onChange:t.onAuth}),o.authError&&e("span",{class:"hint err",role:"alert"},o.authError)),o.needsOrder&&e(G,{order:n.order,onChange:e=>t.onChange({order:e})}),("http"===o.detected.kind||"torrent-url"===o.detected.kind)&&e("p",{class:"hint"},"A link always downloads in order, so you can watch while it arrives."),a&&r&&!n.torrent&&[e("div",{class:"or"},"or"),e("button",{type:"button",class:"drop",onClick:()=>i?.click()},e(g,{name:"torrent",size:22}),e("span",null,e("b",null,"Choose a .torrent file")," or drop it here",e("br",null),e("span",{class:"hint"},"Up to 2 MB, read in the browser and sent to the node")))],t.destination&&e("div",{class:"fld"},a&&e("label",null,"Destination"),e("div",{class:"dest-row"},e("div",{class:"dest",title:t.destination.path},e(g,{name:"folder",size:14}),e("span",null,t.destination.path)),t.onChooseFolder&&e("button",{type:"button",class:"btn",onClick:()=>t.onChooseFolder?.()},"Choose folder…")),t.destination.hint&&e("span",{class:"hint where"},t.destination.hint)),a&&e("div",{class:"dlg-f"},e("button",{type:"button",class:"btn",onClick:()=>t.onCancel?.()},"Cancel"),e("button",{type:"submit",class:"btn pri",disabled:!o.canStart||t.starting},t.starting?"Starting…":"Start download")))};function te(e){return"FetchingMetadata"===e.state||"Resolving"===e.state?"bar indet":"Retrying"===e.state||"Paused"===e.state?"bar moving":"Stopped"===e.state||"Queued"===e.state||"Scheduled"===e.state||e.deleting?"bar paused":"Cancelled"===e.state?"bar fail":"Seeding"===e.state?"bar seed":"bar"}const ne=({icon:t,label:n,onClick:o,primary:s})=>e("button",{type:"button",class:{ib:!0,new:!!s},title:n,"aria-label":n,onClick:o},e(g,{name:t,size:14})),oe=({row:t,actions:n,running:o,source:s,compact:i})=>{const{icon:r,tone:a}=function(e){return"Torrent"===e.kind?{icon:e.name.startsWith("magnet:")?"magnet":"torrent",tone:"t"}:"Node"===e.kind?{icon:"node",tone:"n"}:{icon:"globe",tone:"h"}}(t),l=function(e){if(e.deleting)return{text:"Deleting…",tone:"ps"};if(e.waitingForNode)return{text:"Waiting for the node",tone:"q"};switch(e.state){case"Queued":return{text:"Queued",tone:"q"};case"Scheduled":return{text:"Scheduled",tone:"q"};case"Resolving":return{text:"Connecting",tone:"meta"};case"FetchingMetadata":return{text:"Fetching metadata",tone:"meta"};case"Downloading":return{text:"Downloading",tone:"dl"};case"Verifying":return{text:"Checking pieces",tone:"meta"};case"Paused":return{text:"DiskFull"===e.pause_reason?"Paused · disk almost full":"Paused",tone:"mv"};case"Retrying":return{text:"Retrying",tone:"mv"};case"Seeding":return{text:"Seeding",tone:"sd"};case"Completed":return{text:"Completed",tone:"ok"};case"Stopped":return{text:"Stopped",tone:"ps"};case"Cancelled":return{text:"Cancelled",tone:"err"};default:return{text:e.state,tone:"ps"}}}(t),d=function(e){return"Torrent"===e.kind&&["Downloading","Verifying","Paused"].includes(e.state)?e.in_order?"In order":"Fastest":null}(t),w=M(t),v=function(e,t={}){const n=t.now??Date.now(),o=h(e.done_bytes,e.total_bytes),s=e.total_bytes?`${c(e.done_bytes)} of ${c(e.total_bytes)}`:e.done_bytes?c(e.done_bytes):"",i=[],r=(e,t={})=>e&&i.push({text:e,...t});if(e.deleting)return r("Waiting for the node to confirm"),i;if(e.waitingForNode)return r("Starts when the node reports in"),r("It keeps going after you close this tab"),i;switch(e.state){case"Queued":r("Waiting for a free slot"),t.running&&r(`${t.running} ${1===t.running?"is":"are"} running`);break;case"Scheduled":r("Waits for the download window"),e.next_attempt_at&&e.next_attempt_at>n&&r(`starts in ${p((e.next_attempt_at-n)/1e3)}`);break;case"Resolving":r(t.source?`Contacting ${t.source}`:"Contacting the server");break;case"FetchingMetadata":r("Asking peers for the torrent info"),r(`${e.peers} ${1===e.peers?"peer":"peers"}`),r(b((n-e.started_at)/1e3));break;case"Downloading":r(o,{strong:!0}),r(s),r(u(e.down_bps)),"Torrent"===e.kind&&(r(u(e.up_bps,"↑")),r(`${e.peers} ${1===e.peers?"peer":"peers"}`)),r(f(e.done_bytes,e.total_bytes,e.down_bps)),e.restarted_from_zero&&r("The file changed on the server, so it started over"),t.source&&r(t.source);break;case"Verifying":r(o,{strong:!0}),r("Checking downloaded pieces after a restart"),r(`${c(e.done_bytes)} already on disk`);break;case"Paused":"DiskFull"===e.pause_reason?(r(e.reason??"Free space is below the floor"),r("Resumes by itself when there is room")):(r(o,{strong:!0}),r("Outside the download window"),r("Resumes by itself"));break;case"Retrying":r(e.retry_reason??e.reason??"Something went wrong",{error:!0}),r(`attempt ${e.attempt}`),e.next_attempt_at&&r(e.next_attempt_at>n?`Next try in ${p((e.next_attempt_at-n)/1e3)}`:"Trying again now"),e.done_bytes&&r(`${c(e.done_bytes)} kept`);break;case"Seeding":r(u(e.up_bps,"↑")),r(`${c(e.up_total)} uploaded`),r(`${e.peers} ${1===e.peers?"peer":"peers"}`),e.seeding_since&&r(`seeding for ${p((n-e.seeding_since)/1e3).replace(/ \d+[hm]$/,"")}, until you delete it`);break;case"Completed":if(r("100%",{strong:!0}),r(e.files.length>1?`${e.files.length} files · ${c(e.total_bytes??e.done_bytes)}`:c(e.total_bytes??e.done_bytes)),e.finished_at&&e.started_at){const t=(e.finished_at-e.started_at)/1e3;r(`took ${p(t)}`),t>0&&(e.total_bytes??e.done_bytes)&&r(`avg ${c((e.total_bytes??e.done_bytes)/t)}/s`)}break;case"Stopped":r(o,{strong:!0}),r(e.reason??"Stopped by you"),r("Resume continues from here");break;case"Cancelled":r(e.reason??"Stopped and its part deleted",{error:!!e.reason}),r("Resume starts from zero")}return i}(t,{running:o,source:s}),x="Completed"===t.state||"Seeding"===t.state?100:m(t.done_bytes,t.total_bytes),y=[];if(!t.deleting)switch(w.play&&y.push(e(ne,{icon:"play",label:P(t.state)?"Play":"Play while downloading",primary:!0,onClick:()=>n.play(t)})),t.state){case"Downloading":case"Verifying":case"Resolving":case"FetchingMetadata":case"Queued":"Downloading"!==t.state&&"Verifying"!==t.state||y.push(e(ne,{icon:"pause",label:"Pause",onClick:()=>n.pause(t)})),y.push(e(ne,{icon:"x",label:"Stop",onClick:()=>n.stop(t)}));break;case"Scheduled":case"Paused":"Scheduled"!==t.state&&"Window"!==t.pause_reason||y.push(e(ne,{icon:"play",label:"Start now",onClick:()=>n.resume(t,!0)})),y.push(e(ne,{icon:"x",label:"Stop",onClick:()=>n.stop(t)}));break;case"Retrying":y.push(e(ne,{icon:"retry",label:"Try now",onClick:()=>n.resume(t)})),y.push(e(ne,{icon:"x",label:"Stop",onClick:()=>n.stop(t)}));break;case"Stopped":y.push(e(ne,{icon:"play",label:"Resume",onClick:()=>n.resume(t)})),y.push(e(ne,{icon:"trash",label:"Delete",onClick:()=>n.remove(t)}));break;case"Seeding":y.push(e(ne,{icon:"pause",label:"Pause seeding",onClick:()=>n.pause(t)})),y.push(e(ne,{icon:"locate",label:"Show in folder",onClick:()=>n.showInFolder(t)})),y.push(e(ne,{icon:"trash",label:"Delete",onClick:()=>n.remove(t)}));break;case"Completed":y.push(e(ne,{icon:"locate",label:"Show in folder",onClick:()=>n.showInFolder(t)})),y.push(e(ne,{icon:"x",label:"Remove from list",onClick:()=>n.remove(t)}));break;case"Cancelled":y.push(e(ne,{icon:"retry",label:"Start again",onClick:()=>n.resume(t)})),y.push(e(ne,{icon:"x",label:"Remove from list",onClick:()=>n.remove(t)}))}return e("div",{key:t.download_id,class:{job:!0,compact:!!i},"data-state":t.deleting?"Deleting":t.state,"data-id":t.download_id,role:"listitem","aria-label":`${t.name}, ${l.text}`},e("span",{class:`kind ${a}`},e(g,{name:r,size:15})),e("div",{class:"title"},e("span",{class:"nm",title:t.name},t.name),e("span",{class:`pill ${l.tone}`},l.text),d&&e("span",{class:"pill meta"},d)),e("div",{class:"acts"},y),e("div",{class:te(t),role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(x),"aria-label":`${t.name} progress`},e("i",{style:{width:`${x}%`}})),e("div",{class:"stats"},v.map((t=>t.strong?e("b",null,t.text):e("span",{class:{err:!!t.error}},t.text))),!w.play&&w.switchToInOrder&&e("button",{type:"button",class:"lnk inline",onClick:()=>n.setOrder(t,!0)},"Switch to in order to watch"),w.play&&"Torrent"===t.kind&&t.in_order&&!P(t.state)&&e("button",{type:"button",class:"lnk inline",onClick:()=>n.setOrder(t,!1)},"Switch to fastest")))},se={started:"fetch",queued:"fetch",stuck:"warn",renamed:"file",completed:"check",error:"warn"},ie=({notices:t,onDismiss:n})=>t.length?e("div",{class:"toasts","aria-live":"polite"},t.map((t=>e("div",{class:{toast:!0,bad:"stuck"===t.kind||"error"===t.kind},"data-notice":t.kind,key:t.id},e(g,{name:se[t.kind],size:18}),e("div",{class:"t"},e("b",null,t.title),e("span",{title:t.detail},t.detail)),t.action&&e("button",{type:"button",class:"btn",onClick:()=>{t.action.run(),n(t.id)}},t.action.label),e("button",{type:"button",class:"ib","aria-label":"Dismiss",onClick:()=>n(t.id)},e(g,{name:"x",size:12})))))):null,re=({icon:t,title:n,body:o,action:s})=>e("div",{class:"empty",role:"status"},e(g,{name:t,size:28}),e("b",null,n),e("span",null,o),s&&e("button",{type:"button",class:"btn pri",onClick:s.onClick},s.label)),ae=()=>e(re,{icon:"fetch",title:"No downloads yet",body:"Press Fetch and paste a link. Downloads keep running after you close this tab, and they show here when you come back."}),le=({nodeName:t,folder:n})=>e(re,{icon:"fetch",title:"Nothing downloading",body:`Paste a link above. It downloads onto ${t}${n?`, into ${n}`:""}.`}),de=({onSignIn:t})=>e(re,{icon:"lock",title:"Sign in to PhirePass",body:"Your downloads are tied to your account and the nodes you can reach.",action:{label:"Sign in",onClick:t}}),he=({nodeName:t,onRetry:n})=>e(re,{icon:"signal",title:`Can't reach ${t}`,body:"If the machine is still running, its downloads carry on. They will show here when it reconnects.",action:n?{label:"Try again",onClick:n}:void 0}),ce=()=>e(re,{icon:"warn",title:"Downloads are not available here",body:"This page's connection library is too old to start downloads. Reload after the site updates."}),pe=()=>e("div",{class:"empty",role:"status"},e("span",{class:"spin","aria-hidden":"true"}),e("span",null,"Loading downloads…")),ue=({blocker:t,onAction:n,onClose:o})=>e("div",{class:"blocker","data-blocker":t.id},e("div",{class:"note "+("off"===t.id?"info":"warn"),role:"status"},e(g,{name:"off"===t.id?"fetch":"warn",size:14}),e("div",null,e("b",null,t.title)," ",t.body)),t.secondary&&e("p",{class:"hint"},t.secondary),(o||t.action&&n)&&e("div",{class:"dlg-f"},o&&e("button",{type:"button",class:"btn",onClick:o},"Close"),t.action&&n&&e("button",{type:"button",class:"btn pri",onClick:n},t.action))),fe="phirepass.downloader.torrent-ack",be=n(class extends o{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.fetchCompleted=s(this,"phirepassFetchCompleted"),this.play=s(this,"phirepassPlay"),this.activeCount=s(this,"phirepassActiveCount"),this.showInFolder=s(this,"phirepassShowInFolder"),this.openNodeSettings=s(this,"phirepassOpenNodeSettings"),this.signIn=s(this,"phirepassSignIn")}get el(){return this}ownChannel=!1;msgId=y;noticeId=1;seenNotices=new Set;torrentAcked=function(){try{return"1"===window.localStorage.getItem(fe)}catch{return!1}}();noticeTimers=new Map;whereMsgId;nodeId;nodeLabel;token;channel;connected=!1;channelFactory;browsingService;browsingPath;compact=!1;streamBase;canConfigure=!1;inlinePlayer=!0;serverHost="phirepass.com";serverPort=443;serverId;allowInsecure=!1;heartbeatInterval=3e4;fetchCompleted;play;activeCount;showInFolder;openNodeSettings;signIn;connection="connecting";caps=null;jobs={};tab="active";drawerOpen=!1;dialogOpen=!1;unread=0;form=z;where=null;starting=null;refusal=null;confirm=null;notices=[];subDir=null;picker=null;player=null;get name(){return this.nodeLabel||this.nodeId}get ch(){return this.channel??this.ownedChannel}ownedChannel;async componentWillLoad(){this.channel?this.adoptChannel():await this.openOwnChannel()}disconnectedCallback(){this.noticeTimers.forEach((e=>window.clearTimeout(e))),this.noticeTimers.clear(),this.starting?.silence&&window.clearTimeout(this.starting.silence),this.ownChannel&&this.ownedChannel&&(this.ownedChannel.stop_heartbeat(),this.ownedChannel.disconnect())}onChannel(){this.channel&&this.adoptChannel()}onConnected(e,t){this.channel&&(e&&!t?this.subscribe():!e&&t&&(this.connection="unreachable"))}onBrowsing(){this.where=null,this.dialogOpen&&this.askWhere()}onNode(e,t){e!==t&&(this.jobs={},this.caps=null,this.where=null,this.channel?this.connected&&this.subscribe():this.ownedChannel&&(this.ownedChannel.disconnect(),this.openOwnChannel()))}adoptChannel(){this.ownChannel=!1,x(this.channel)?(this.connection="connecting",this.connected&&this.subscribe()):this.connection="unsupported"}endpoint(){return`${this.allowInsecure?"ws":"wss"}://${this.serverHost}${!this.allowInsecure&&443===this.serverPort||this.allowInsecure&&80===this.serverPort?"":`:${this.serverPort}`}/api/web/ws`}defaultStreamBase(){return`${this.allowInsecure?"http":"https"}://${this.serverHost}${!this.allowInsecure&&443===this.serverPort||this.allowInsecure&&80===this.serverPort?"":`:${this.serverPort}`}`}async openOwnChannel(){if(this.ownChannel=!0,!this.token)return void(this.connection="signed-out");if(!this.nodeId)return;this.channelFactory||await r();const e=this.channelFactory?this.channelFactory(this.endpoint(),this.nodeId,this.serverId):this.serverId?new a(this.endpoint(),this.nodeId,this.serverId):new a(this.endpoint(),this.nodeId);this.ownedChannel=e,x(e)?(e.on_connection_open((()=>e.authenticate(this.token,this.nodeId))),e.on_connection_close((()=>{"signed-out"!==this.connection&&(this.connection="unreachable")})),e.on_connection_error((()=>{"signed-out"!==this.connection&&(this.connection="unreachable")})),e.on_connection_message((()=>{})),e.on_protocol_message((e=>this.dispatch(e.data.web))),this.connection="connecting",e.connect()):this.connection="unsupported"}reconnect(){this.ownChannel?(this.ownedChannel?.disconnect(),this.openOwnChannel()):this.connected&&this.subscribe()}async receive(e){this.dispatch(e.data.web)}dispatch(e){if(e.type===l.AuthSuccess)return this.ownedChannel?.start_heartbeat(Math.max(3e4,this.heartbeatInterval)),void this.subscribe();if(e.type!==l.Error){if(C(e))switch(e.type){case"DownloadCaps":e.node_id===this.nodeId&&(this.caps=e.caps,this.connection="ready");break;case"DownloadProgress":e.node_id===this.nodeId&&this.onProgress(e.job);break;case"DownloadAccepted":this.onAccepted(e.msg_id,e.download_id);break;case"DownloadWhereAnswer":e.msg_id===this.whereMsgId&&(this.where={saves_to:e.saves_to,mapped:e.mapped});break;case"DownloadFoldersAnswer":this.picker&&e.msg_id===this.picker.msgId&&(this.picker={...this.picker,folders:[...e.folders].sort(((e,t)=>e.localeCompare(t)))})}}else this.handleError(e)}handleError(e){if(void 0!==e.msg_id&&e.msg_id===this.starting?.msgId)return this.clearStarting(),void(this.refusal={tone:"err",title:"Refused",body:e.message||"The server refused this download."});this.picker&&e.msg_id===this.picker.msgId?this.picker={...this.picker,folders:[],error:e.message}:void 0!==e.msg_id&&e.msg_id>=y?this.notify("error","That did not work",e.message||"The server refused it."):this.ownChannel&&e.kind===d.Authentication&&(this.connection="signed-out")}subscribe(){const e=this.ch;x(e)?(this.jobs={},e.send_download_subscribe({Node:this.nodeId}),this.dialogOpen&&this.askWhere()):this.connection="unsupported"}onProgress(e){const t=this.jobs[e.download_id],{jobs:n,completed:o}=function(e,t){const n=e[t.download_id];if("Deleted"===t.state){if(!n)return{jobs:e,first:!1};const{[t.download_id]:o,...s}=e;return{jobs:s,first:!1}}return{jobs:{...e,[t.download_id]:{...t,deleting:n?.deleting}},completed:n&&!P(n.state)&&P(t.state)?t:void 0,first:!n}}(this.jobs,e);this.jobs=n,this.emitCount(),this.starting?.downloadId!==e.download_id||t||this.onFirstProgress(e),o&&(this.fetchCompleted.emit({download_id:e.download_id,dest_root:e.dest_root,sub_dir:e.sub_dir,name:e.name}),!this.drawerOpen&&this.compact&&this.unread++,this.notify("completed","Download complete",`${e.name} → ${U(e)}`,{label:"Show",run:()=>this.showInFolder.emit({path:U(e),name:e.name})}));const s=this.jobs[e.download_id];s&&function(e,t=3600){return"Retrying"===e.state&&function(e,t=3600){let n=0;for(let o=0;o<e;o++)n+=Math.min(10*2**o,t);return n}(e.attempt,t)>=86400}(s)&&!this.seenNotices.has(`stuck:${e.download_id}`)&&(this.seenNotices.add(`stuck:${e.download_id}`),this.notify("stuck","Still retrying after a day",`${e.name} · ${e.retry_reason??"no answer"}`,{label:"Show",run:()=>this.showRetrying()},!0))}onAccepted(e,t){if(!this.starting||this.starting.msgId!==e)return;if(this.jobs[t])return void this.onFirstProgress(this.jobs[t]);const n=window.setTimeout((()=>this.nodeSilent(t)),8e3);this.starting={...this.starting,downloadId:t,silence:n}}nodeSilent(e){if(this.starting?.downloadId!==e||this.jobs[e])return;const t=this.starting.askedName??"Download",n=Date.now(),o={download_id:e,kind:"Unknown",name:t,dest_root:this.where?.saves_to??this.caps?.folder??"",sub_dir:null,state:"Queued",done_bytes:0,total_bytes:null,down_bps:0,up_bps:0,peers:0,in_order:!0,started_at:n,finished_at:null,reason:null,requested_by:null,files:[],up_total:0,pause_reason:null,seeding_since:null,info_hash:null,retry_reason:null,attempt:0,next_attempt_at:null,restarted_from_zero:!1,waitingForNode:!0};this.jobs={...this.jobs,[e]:o},this.clearStarting(),this.closeDialog(!0),this.notify("queued",`Waiting for ${this.name}`,`${t} starts when the node reports in.`)}onFirstProgress(e){const t=this.starting?.askedName;if(this.clearStarting(),"Cancelled"!==e.state){if(this.closeDialog(!0),"Queued"===e.state){const e=Object.values(this.jobs).filter((e=>"Downloading"===e.state)).length;this.notify("queued","Added to the queue",`${e} ${1===e?"download is":"downloads are"} already running on this node`)}else this.notify("started","Download started",`${e.name} → ${U(e)}`);(function(e,t){return!!e&&e!==t&&/ \(\d+\)(\.[^.]*)?$/.test(t)})(t,e.name)&&this.notify("renamed",`Saved as ${e.name}`,`A file named ${t} was already in ${U(e)}`)}else{const t=e.reason??"The node refused this download.";!function(e){return!!e&&/not enough (disk )?space|disk (is )?full|needs [\d.]+ ?[kmgt]?b\b.*\bfree\b/i.test(e)}(t)?!this.dialogOpen&&this.compact||(this.refusal={tone:"err",title:"Refused",body:t}):this.confirm={kind:"space",reason:t}}}clearStarting(){this.starting?.silence&&window.clearTimeout(this.starting.silence),this.starting=null}emitCount(){this.activeCount.emit({n:Object.values(this.jobs).filter(I).length})}notify(e,t,n,o,s=!1){const i=this.noticeId++;this.notices=[...this.notices.slice(-2),{id:i,kind:e,title:t,detail:n,action:o,sticky:s}],s||this.noticeTimers.set(i,window.setTimeout((()=>this.dismiss(i)),6e3))}dismiss(e){const t=this.noticeTimers.get(e);t&&(window.clearTimeout(t),this.noticeTimers.delete(e)),this.notices=this.notices.filter((t=>t.id!==e))}showRetrying(){this.tab="retrying",this.drawerOpen=!0}async openFetch(e){void 0!==e&&e!==this.browsingPath&&(this.browsingPath=e),this.drawerOpen=!0,this.unread=0,this.dialogOpen=!0,this.refusal=null,this.askWhere()}async toggleDrawer(e){this.drawerOpen=e??!this.drawerOpen,this.drawerOpen&&(this.unread=0)}async jobForPath(e){const t=Object.values(this.jobs).find((t=>!P(t.state)&&"Cancelled"!==t.state&&function(e){return`${B(U(e),e.name)}.phirepass-part`}(t)===e));return t?{download_id:t.download_id,name:t.name}:null}async deleteDownload(e,t=!1){const n=this.jobs[e];n&&this.sendDelete(n,t)}async torrentPathFor(e){const t=this.caps?.folder;if(!t||!this.caps?.torrents||!/\.torrent$/i.test(e)||E(this.caps,this.name,this.canConfigure))return null;const n=t.endsWith("/")?t:`${t}/`;return e.startsWith(n)?e.slice(n.length):null}async startTorrentPath(e,t=!1){const n=await this.torrentPathFor(e),o=this.ch;if(null===n||!x(o))return!1;const s=this.nextMsgId();this.starting={msgId:s,askedName:n.split("/").pop()?.replace(/\.torrent$/i,"")};const i=n.includes("/")?n.slice(0,n.lastIndexOf("/")):null;return o.send_download_start(this.nodeId,{TorrentPath:{path:n}},i,null,t,{source_auth:null,ignore_window:!1},s),this.drawerOpen=!0,!0}nextMsgId(){return this.msgId=this.msgId>=4294967280?y:this.msgId+1,this.msgId}browsing(){return this.compact&&this.browsingService&&this.browsingPath?{service_id:this.browsingService,path:this.browsingPath}:null}askWhere(){const e=this.browsing(),t=this.ch;e&&x(t)&&"ready"===this.connection&&(this.whereMsgId=this.nextMsgId(),t.send_download_where(this.nodeId,e,this.whereMsgId))}destination(){if(this.browsing())return this.where?this.where.mapped?{path:this.where.saves_to}:{path:this.where.saves_to,hint:`This folder is outside ${this.name}'s download folder. The file will be saved to ${this.where.saves_to}.`}:{path:this.browsingPath,hint:"Asking the node where this lands…"};const e=this.caps?.folder;return e?{path:B(e,this.subDir)}:null}formReady(){return!(this.starting||"ready"!==this.connection||this.browsing()&&!this.where)}async pickTorrent(e){const t=function(e){const t=function(e){return/\.torrent$/i.test(e.name)?e.size>2097152?{ok:!1,reason:"too-large"}:{ok:!0}:{ok:!1,reason:"not-torrent"}}(e);return t.ok?{name:e.name,size:e.size}:{name:e.name,size:e.size,error:t.reason}}(e);t.error||(t.contents=new Uint8Array(await e.arrayBuffer())),this.form={...this.form,torrent:t,text:"",order:null},this.refusal=null}start(e=!1){const t=F(this.form,this.caps,this.formReady()),n=function(e){const t={source_auth:null,ignore_window:!1};if(e.torrent)return!e.torrent.contents||e.torrent.error?null:{source:{TorrentFile:{name:e.torrent.name,contents:e.torrent.contents}},inOrder:"in"===e.order,options:t};const n=$(e.text);if("magnet"===n.kind)return{source:{Magnet:{uri:n.uri}},inOrder:"in"===e.order,options:t};if("http"===n.kind||"torrent-url"===n.kind){const o=e.authOpen?D(e.auth):{auth:null};if("error"in o&&o.error)return null;const s=e.saveAs.trim();return{source:{Http:{url:n.url,save_as:s||null}},inOrder:!0,options:{...t,source_auth:o.auth}}}return null}(this.form),o=this.ch;if(!t.canStart||!n||!x(o))return;if(t.isTorrent&&!this.torrentAcked&&!e)return void(this.confirm={kind:"torrent",dontAsk:!1});const s=this.nextMsgId(),i=t.askedName??(this.form.torrent?this.form.torrent.name.replace(/\.torrent$/i,""):"magnet"===t.detected.kind?function(e){const t=/urn:btih:([a-z0-9]+)/i.exec(e);if(!t)return e.length>40?`${e.slice(0,37)}…`:e;const n=t[1];return`magnet:?xt=urn:btih:${n.slice(0,4)}…${n.slice(-4)}`}(t.detected.uri):void 0);this.starting={msgId:s,askedName:i},this.refusal=null;const r=this.browsing();o.send_download_start(this.nodeId,n.source,r?null:this.subDir,r,n.inOrder,n.options,s)}closeDialog(e=!1){this.dialogOpen=!1,this.refusal=null,e&&(this.form=z,this.drawerOpen=!0)}sendStop(e,t){const n=this.ch;x(n)&&n.send_download_stop(e.download_id,t,this.nextMsgId())}sendDelete(e,t){const n=this.ch;x(n)&&(n.send_download_delete(e.download_id,t,this.nextMsgId()),this.jobs={...this.jobs,[e.download_id]:{...e,deleting:!0}})}actions={play:e=>this.playRow(e),pause:e=>this.sendStop(e,!1),resume:(e,t=!1)=>{const n=this.ch;x(n)&&n.send_download_resume(e.download_id,t,this.nextMsgId())},stop:e=>this.confirm={kind:"stop",row:e,discard:!1},remove:e=>{"Completed"===e.state||"Seeding"===e.state||"Stopped"===e.state?this.confirm={kind:"delete",row:e,deleteFile:!1}:this.sendDelete(e,!1)},setOrder:(e,t)=>{t||this.player?.downloadId!==e.download_id?this.sendOrder(e,t):this.confirm={kind:"fastest",row:e}},showInFolder:e=>this.showInFolder.emit({path:U(e),name:e.name})};sendOrder(e,t){const n=this.ch;x(n)&&n.send_download_set_order(e.download_id,t,this.nextMsgId())}playRow(e){const t=M(e);if(!t.play||!t.file)return;const n=(o=this.streamBase||this.defaultStreamBase(),s=this.nodeId,i=e.download_id,r=t.file.index,`${o.replace(/\/+$/,"")}/api/web/stream/${encodeURIComponent(s)}/${encodeURIComponent(i)}/${r}`);var o,s,i,r;!this.play.emit({src:n,name:t.file.name,downloadId:e.download_id}).defaultPrevented&&this.inlinePlayer&&(this.player={src:n,name:t.file.name,downloadId:e.download_id})}clearFinished(){Object.values(this.jobs).filter(R).forEach((e=>this.sendDelete(e,!1)))}canPickFolder(){return!!this.caps?.folder&&"function"==typeof this.ch?.send_download_folders}listFolders(e){const t=this.nextMsgId();this.picker={path:e,folders:null,msgId:t,newName:null},this.ch?.send_download_folders?.(this.nodeId,e.length?e.join("/"):null,t)}savePicker(){if(!this.picker)return;const e=[...this.picker.path],t=this.picker.newName?.trim();t&&e.push(t),this.subDir=e.length?e.join("/"):null,this.picker=null}renderConfirm(){const t=this.confirm;if(!t)return null;const n=()=>this.confirm=null;switch(t.kind){case"stop":return e(W,{row:t.row,discard:t.discard,onDiscard:e=>this.confirm={...t,discard:e},onCancel:n,onConfirm:()=>{this.sendStop(t.row,t.discard),this.confirm=null}});case"delete":return e(q,{row:t.row,nodeName:this.name,deleteFile:t.deleteFile,onDeleteFile:e=>this.confirm={...t,deleteFile:e},onCancel:n,onConfirm:()=>{this.sendDelete(t.row,t.deleteFile),this.confirm=null}});case"fastest":return e(L,{row:t.row,onCancel:n,onConfirm:()=>{this.player=null,this.sendOrder(t.row,!1),this.confirm=null}});case"torrent":return e(H,{nodeName:this.name,dontAsk:t.dontAsk,onDontAsk:e=>this.confirm={...t,dontAsk:e},onCancel:n,onConfirm:()=>{t.dontAsk&&(function(){try{window.localStorage.setItem(fe,"1")}catch{}}(),this.torrentAcked=!0),this.confirm=null,this.start(!0)}});case"space":return e(K,{reason:t.reason,onClose:n})}}renderForm(t){const n=this.caps?E(this.caps,this.name,this.canConfigure):null,o=()=>this.openNodeSettings.emit({nodeId:this.nodeId});if(n)return"dialog"===t?e("div",{class:"dlg"},e("div",{class:"dlg-h"},e(g,{name:"fetch"}),e("h4",null,"Fetch into this folder")),e(ue,{blocker:n,onAction:o,onClose:()=>this.closeDialog()})):e(ue,{blocker:n,onAction:o});const s=F(this.form,this.caps,this.formReady());return e(ee,{form:this.form,model:s,caps:this.caps,layout:t,title:this.browsing()?"Fetch into this folder":"Add download",destination:"dialog"===t||this.browsing()?this.destination():null,starting:!!this.starting,refusal:this.refusal,onChange:e=>{this.form={...this.form,...e},("text"in e||"torrent"in e)&&(this.refusal=null)},onAuth:e=>this.form={...this.form,auth:{...this.form.auth,...e}},onPickTorrent:e=>{this.pickTorrent(e)},onStart:()=>this.start(),onCancel:()=>this.closeDialog()})}renderRows(t){const n=t.filter((e=>"Downloading"===e.state)).length;return e("div",{class:"jobs",role:"list"},function(e){return[...e].sort(((e,t)=>N[e.state]-N[t.state]||(t.finished_at??t.started_at)-(e.finished_at??e.started_at)))}(t).map((t=>e(oe,{row:t,actions:this.actions,running:n,compact:this.compact}))))}renderStatus(){switch(this.connection){case"unsupported":return e(ce,null);case"signed-out":return e(de,{onSignIn:()=>this.signIn.emit()});case"unreachable":return e(he,{nodeName:this.name,onRetry:()=>this.reconnect()});case"connecting":return e(pe,null);default:return null}}renderCompact(){const t=Object.values(this.jobs),n=A(t),o=this.renderStatus();if("unsupported"===this.connection)return null;const s=t.some(R),i=!this.drawerOpen&&(n.active>0||this.unread>0),r=[`${n.active} active`,null===n.percent||this.drawerOpen?"":`${Math.round(n.percent)}%`,u(n.downBps)].filter(Boolean).join(" · ");return[this.drawerOpen&&e("section",{class:"drawer","aria-label":"Transfers"},e("div",{class:"drawer-h"},e("h4",null,"Transfers"),e("span",{class:"sum"},r),e("span",{class:"sp"}),s&&e("button",{type:"button",class:"lnk",onClick:()=>this.clearFinished()},"Clear finished"),e("button",{type:"button",class:"ib","aria-label":"Collapse transfers",title:"Collapse",onClick:()=>this.drawerOpen=!1},e(g,{name:"chevron",size:12}))),e("div",{class:"drawer-b"},o??(t.length?this.renderRows(t):e(ae,null)))),i&&e("button",{type:"button",class:"strip","aria-label":"Show transfers",onClick:()=>this.toggleDrawer(!0)},e("h4",null,"Transfers"),e("span",{class:"bar"},e("i",{style:{width:`${n.percent??0}%`}})),e("span",{class:"sum"},this.unread&&!n.active?`${this.unread} finished`:r),e(g,{name:"up",size:12})),this.dialogOpen&&e(V,{label:"Fetch into this folder",onClose:()=>this.closeDialog()},o&&"ready"!==this.connection?e("div",{class:"dlg"},o,e("div",{class:"dlg-f"},e("button",{type:"button",class:"btn",onClick:()=>this.closeDialog()},"Close"))):this.renderForm("dialog"))]}renderStandalone(){const t=this.renderStatus(),n=Object.values(this.jobs),o={active:[],finished:[],retrying:[]};n.forEach((e=>{return o[(t=e,"Retrying"===t.state?"retrying":T.has(t.state)?"active":"finished")].push(e);var t}));const s=A(n),i=o[this.tab],r=this.caps?.folder?B(this.caps.folder,this.subDir):null;return e("section",{class:"standalone"},e("header",{class:"sa-head"},e("div",{class:"sa-title"},e("h3",null,"Downloads"),e("span",{class:"node"},this.name),s.downBps>0&&e("span",{class:"sum"},u(s.downBps))),r&&e("span",{class:"saving"},"saving to ",e("code",null,r),this.caps&&this.caps.folder_free_bytes>0&&e("span",{class:"free"}," · ",c(this.caps.folder_free_bytes)," free"))),t??[e("div",{class:"sa-add"},this.renderForm("inline"),r&&!E(this.caps,this.name,this.canConfigure)&&e("div",{class:"sa-dest"},e("span",{class:"dest"},e(g,{name:"folder",size:14}),e("span",null,r)),this.canPickFolder()&&e("button",{type:"button",class:"btn",onClick:()=>this.listFolders(this.subDir?this.subDir.split("/"):[])},"Choose folder…"))),e("div",{class:"tabs",role:"tablist","aria-label":"Downloads"},[["active","Active"],["finished","Finished"],["retrying","Retrying"]].map((([t,n])=>e("button",{type:"button",role:"tab","aria-selected":this.tab===t?"true":"false",class:{on:this.tab===t},onClick:()=>this.tab=t},n,e("b",null,o[t].length))))),"finished"===this.tab&&o.finished.length>0&&e("div",{class:"tab-h"},e("span",null,o.finished.length," finished"),o.finished.some(R)&&e("button",{type:"button",class:"lnk",onClick:()=>this.clearFinished()},"Clear finished")),i.length?this.renderRows(i):0===n.length?e(le,{nodeName:this.name,folder:r}):e("div",{class:"muted pad"},"retrying"===this.tab?"Nothing is retrying.":"finished"===this.tab?"Nothing has finished yet.":"Nothing is running.")])}render(){return e(i,{key:"6a7316df730c5bc4bc588f7d05e19033d98a9d0a",class:{compact:this.compact,standalone:!this.compact}},this.compact?this.renderCompact():this.renderStandalone(),this.renderConfirm(),this.picker&&e(Y,{key:"412dc8107ea30420f022a49f188ea020eabd46f5",root:this.caps?.folder??"",path:this.picker.path,folders:this.picker.folders,error:this.picker.error,newName:this.picker.newName,onOpen:e=>this.listFolders([...this.picker.path,e]),onUp:e=>this.listFolders(this.picker.path.slice(0,e)),onNewName:e=>this.picker={...this.picker,newName:e},onCancel:()=>this.picker=null,onSave:()=>this.savePicker()}),this.player&&e("div",{key:"61bc6c3ab32346d87c0ed02280182fdae234eb71",class:"overlay player"},e("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})),e(ie,{key:"fa27f16c8f72435939e51b48d92b6f10b0535d80",notices:this.notices,onDismiss:e=>this.dismiss(e)}))}playerRow(){return this.player?this.jobs[this.player.downloadId]:void 0}playerStatus(){const e=this.playerRow();if(!e)return this.player?"On the node":void 0;if(P(e.state))return"On the node";const t=e.total_bytes?` · ${(e.done_bytes/e.total_bytes*100).toFixed(1)}%`:"";return`${"Downloading"===e.state?"Downloading":e.state}${t}`}playerReady(){const e=this.playerRow();if(!e||P(e.state))return;const t=M(e);return t.file?.ready_from_start}static get watchers(){return{channel:[{onChannel:0}],connected:[{onConnected:0}],browsingPath:[{onBrowsing:0}],browsingService:[{onBrowsing:0}],nodeId:[{onNode:0}]}}static get style(){return":host{--card:220 18% 10%;--bg:216 18% 7%;--border:220 15% 18%;--primary:160 60% 45%;--primary-foreground:220 20% 7%;--destructive:0 70% 50%;--muted:220 15% 13%;--muted-foreground:215 10% 52%;--foreground:210 20% 90%;--amber:38 75% 55%;--blue:206 72% 63%;--radius:0.375rem;display:block;color:hsl(var(--foreground));font-family:ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;font-size:13px;line-height:1.45;container-type:inline-size}:host(.standalone){position:relative;height:100%;background:hsl(var(--card));border:1px solid hsl(var(--border));border-radius:var(--radius);overflow:auto}:host(.compact){flex:none}*{box-sizing:border-box}button{font:inherit;color:inherit;cursor:pointer}button:disabled{cursor:not-allowed}:focus-visible{outline:2px solid hsl(var(--primary));outline-offset:2px}.hidden-input{display:none}.mono,code,.stats,.sum,.inp,.dest,.detect .host{font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace}code{font-size:12px}.muted{color:hsl(var(--muted-foreground))}.pad{padding:18px 14px}.ib{width:28px;height:28px;display:inline-grid;place-items:center;border-radius:4px;border:1px solid transparent;background:transparent;color:hsl(var(--muted-foreground));flex:none;padding:0}.ib:hover:not(:disabled){background:hsl(var(--muted));color:hsl(var(--foreground))}.ib:disabled{opacity:0.4}.ib.new{color:hsl(var(--primary));border-color:hsl(var(--primary) / 0.55);background:hsl(var(--primary) / 0.12)}.btn{border-radius:4px;padding:7px 14px;font-size:12px;font-weight:600;border:1px solid hsl(var(--border));background:hsl(var(--muted));white-space:nowrap;display:inline-flex;align-items:center;gap:6px;text-decoration:none;color:hsl(var(--foreground))}.btn:hover:not(:disabled){border-color:hsl(var(--muted-foreground))}.btn.pri{background:hsl(var(--primary));border-color:hsl(var(--primary));color:hsl(var(--primary-foreground))}.btn.dng{background:hsl(var(--destructive));border-color:hsl(var(--destructive));color:#fff}.btn:disabled{opacity:0.45}.lnk{background:none;border:0;color:hsl(var(--muted-foreground));font-size:11px;padding:2px 4px;display:inline-flex;align-items:center;gap:4px}.lnk:hover{color:hsl(var(--foreground))}.lnk.inline{color:hsl(var(--primary));padding:0}.pill{font-size:10px;font-weight:600;text-transform:uppercase;letter-spacing:0.05em;padding:2px 7px;border-radius:3px;white-space:nowrap;flex:none}.pill.dl{background:hsl(var(--primary) / 0.18);color:hsl(var(--primary))}.pill.meta,.pill.sd{background:hsl(var(--blue) / 0.18);color:hsl(var(--blue))}.pill.mv{background:hsl(var(--amber) / 0.18);color:hsl(var(--amber))}.pill.ok{background:hsl(var(--primary));color:hsl(var(--primary-foreground))}.pill.err{background:hsl(var(--destructive) / 0.2);color:hsl(var(--destructive))}.pill.ps,.pill.q{background:hsl(var(--muted));color:hsl(var(--muted-foreground))}.bar{display:block;height:5px;border-radius:3px;background:hsl(var(--muted));overflow:hidden;position:relative}.bar i{display:block;height:100%;background:hsl(var(--primary));border-radius:3px;transition:width 0.6s linear}.bar.indet i{width:30% !important;animation:slide 1.3s ease-in-out infinite;background:hsl(var(--blue))}.bar.paused i{background:hsl(var(--muted-foreground))}.bar.fail i{background:hsl(var(--destructive))}.bar.moving i{background:hsl(var(--amber))}.bar.seed i{background:hsl(var(--blue))}@keyframes slide{0%{transform:translateX(-100%)}100%{transform:translateX(340%)}}.jobs{display:flex;flex-direction:column}.job{display:grid;grid-template-columns:28px minmax(0, 1fr) auto;gap:4px 10px;padding:10px 12px;border-bottom:1px solid hsl(var(--border) / 0.6);align-items:center}.job:last-child{border-bottom:0}.job .kind{grid-row:span 3;align-self:start;width:28px;height:28px;border-radius:6px;display:grid;place-items:center;background:hsl(var(--muted));color:hsl(var(--muted-foreground))}.job .kind.t{color:hsl(var(--blue))}.job .kind.h{color:hsl(var(--primary))}.job .kind.n{color:hsl(var(--amber))}.job .title{display:flex;gap:8px;align-items:center;min-width:0}.job .title .nm{font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.job .acts{display:flex;gap:2px;grid-row:1;grid-column:3}.job .bar,.job .stats{grid-column:2 / 4}.stats{display:flex;flex-wrap:wrap;gap:4px 14px;font-size:11px;color:hsl(var(--muted-foreground));font-variant-numeric:tabular-nums}.stats b{color:hsl(var(--foreground));font-weight:500}.stats .err{color:hsl(var(--destructive))}.job[data-state='Deleting']{opacity:0.6}.drawer{border-top:1px solid hsl(var(--border));background:hsl(var(--bg));display:flex;flex-direction:column;max-height:min(46vh, 380px)}.drawer-h{display:flex;align-items:center;gap:10px;padding:6px 12px;border-bottom:1px solid hsl(var(--border));flex:none}.drawer-h h4,.strip h4{margin:0;font-size:12px;font-weight:600;letter-spacing:0.04em;text-transform:uppercase}.sum{color:hsl(var(--muted-foreground));font-size:11px;font-variant-numeric:tabular-nums}.sp{flex:1}.drawer-b{overflow:auto;min-height:0}.strip{display:flex;align-items:center;gap:10px;padding:7px 12px;border:0;border-top:1px solid hsl(var(--border));background:hsl(var(--bg));width:100%;text-align:left}.strip .bar{flex:1 1 120px}.overlay{position:absolute;inset:0;background:rgba(5, 7, 9, 0.6);display:grid;place-items:center;padding:14px;z-index:20}:host(.standalone) .overlay{position:fixed}.modal{width:min(100%, 420px);max-height:100%;overflow:auto;background:hsl(var(--card));border:1px solid hsl(var(--border));border-radius:8px;box-shadow:0 20px 50px -10px rgba(0, 0, 0, 0.7)}.modal.wide{width:min(100%, 480px)}.dlg,.fetch-form.dialog{padding:16px;display:flex;flex-direction:column;gap:14px}.dlg h4,.dlg-h h4{margin:0;font-size:14px;font-weight:600}.dlg-h{display:flex;align-items:center;gap:10px;color:hsl(var(--primary))}.dlg-h h4{color:hsl(var(--foreground))}.dlg-f{display:flex;justify-content:flex-end;gap:8px;flex-wrap:wrap}.dlg-f .left{margin-right:auto}.dtx{margin:0;font-size:13px}.hint{font-size:11px;color:hsl(var(--muted-foreground));margin:0}.hint.block{display:block;margin-top:2px}.hint.err{color:hsl(var(--destructive))}.hint.where{color:hsl(var(--amber))}.fld{display:flex;flex-direction:column;gap:6px;min-width:0}.fld>label,.fld>span:first-child,legend{font-size:11px;text-transform:uppercase;letter-spacing:0.05em;color:hsl(var(--muted-foreground))}.inp{width:100%;min-width:0;background:hsl(var(--muted));border:1px solid hsl(var(--border));border-radius:4px;color:hsl(var(--foreground));padding:8px 10px;font-size:12px}.inp:focus{outline:none;border-color:hsl(var(--primary))}.inline-row{display:flex;gap:8px;align-items:stretch}.detect{display:flex;align-items:center;gap:8px;font-size:12px;color:hsl(var(--muted-foreground));min-height:20px;min-width:0}.detect .host{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.note{display:flex;gap:8px;align-items:flex-start;font-size:12px;line-height:1.45;padding:8px 10px;border-radius:4px;border:1px solid hsl(var(--border));background:hsl(var(--muted))}.note svg{flex:none;margin-top:2px}.note.err{border-color:hsl(var(--destructive) / 0.5)}.note.err svg{color:hsl(var(--destructive))}.note.warn{border-color:hsl(var(--amber) / 0.5)}.note.warn svg{color:hsl(var(--amber))}.note.info svg{color:hsl(var(--primary))}.or{display:flex;align-items:center;gap:10px;color:hsl(var(--muted-foreground));font-size:11px;text-transform:uppercase;letter-spacing:0.06em}.or::before,.or::after{content:'';flex:1;height:1px;background:hsl(var(--border))}.drop{border:1px dashed hsl(var(--border));border-radius:6px;padding:14px;display:flex;align-items:center;gap:12px;color:hsl(var(--muted-foreground));font-size:12px;background:transparent;text-align:left}.drop svg{color:hsl(var(--blue));flex:none}.drop b{color:hsl(var(--foreground));font-weight:500}.filechip{display:flex;gap:10px;align-items:center;padding:10px;border:1px solid hsl(var(--border));border-radius:4px;background:hsl(var(--muted))}.filechip>svg{color:hsl(var(--blue));flex:none}.filechip>div{flex:1;min-width:0}.filechip b{display:block;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.filechip span{color:hsl(var(--muted-foreground));font-size:11px}.filechip.bad{border-color:hsl(var(--destructive) / 0.55)}.filechip.bad>svg{color:hsl(var(--destructive))}.dest-row,.sa-dest{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.dest{display:flex;align-items:center;gap:8px;background:hsl(var(--bg));border:1px solid hsl(var(--border));border-radius:4px;padding:7px 10px;font-size:12px;min-width:0;flex:1 1 200px}.dest span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dest svg{color:hsl(var(--primary));flex:none}fieldset.order{border:0;margin:0;padding:0;display:flex;flex-direction:column;gap:6px}fieldset.order legend{margin-bottom:6px}.opt{display:flex;gap:8px;align-items:flex-start;padding:8px 10px;border:1px solid hsl(var(--border));border-radius:4px;font-size:12px;cursor:pointer}.opt.on{border-color:hsl(var(--primary));background:hsl(var(--primary) / 0.08)}.opt input,.checkline input,.seg input{accent-color:hsl(var(--primary));margin:2px 0 0}.checkline{display:flex;gap:8px;align-items:flex-start;font-size:12px;cursor:pointer}.login{display:flex;flex-direction:column;gap:8px}.login>.lnk{align-self:flex-start;padding-left:0}.auth{display:flex;flex-direction:column;gap:10px;padding:10px;border:1px solid hsl(var(--border));border-radius:4px}.seg{display:flex;flex-wrap:wrap;gap:6px}.seg label{display:flex;gap:6px;align-items:center;font-size:11px;padding:4px 8px;border:1px solid hsl(var(--border));border-radius:999px;cursor:pointer}.seg label.on{border-color:hsl(var(--primary));color:hsl(var(--primary))}.seg input{margin:0}.crumbs{display:flex;flex-wrap:wrap;align-items:center;gap:2px;font-family:ui-monospace, SFMono-Regular, Menlo, monospace}.crumbs .lnk{font-size:12px}.crumbs .sep{color:hsl(var(--muted-foreground))}.folders{display:flex;flex-direction:column;border:1px solid hsl(var(--border));border-radius:4px;max-height:220px;overflow:auto}.folders .muted{padding:10px}.folder-row{display:flex;align-items:center;gap:8px;padding:7px 10px;border:0;border-bottom:1px solid hsl(var(--border) / 0.6);background:transparent;text-align:left;font-family:ui-monospace, SFMono-Regular, Menlo, monospace;font-size:12px}.folder-row:hover{background:hsl(var(--muted))}.folder-row svg{color:hsl(var(--primary))}.blocker{display:flex;flex-direction:column;gap:10px}.empty{display:flex;flex-direction:column;align-items:center;text-align:center;gap:8px;padding:30px 20px}.empty>svg{color:hsl(var(--muted-foreground))}.empty b{font-size:14px;font-weight:600}.empty span{color:hsl(var(--muted-foreground));font-size:12px;max-width:44ch}.spin{width:22px;height:22px;border-radius:50%;border:3px solid hsl(var(--border));border-top-color:hsl(var(--primary));animation:spin 1s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.standalone{display:flex;flex-direction:column;min-height:100%}.sa-head{padding:14px 16px 10px;display:flex;flex-direction:column;gap:4px}.sa-title{display:flex;align-items:baseline;gap:10px;flex-wrap:wrap}.sa-title h3{margin:0;font-size:16px;font-weight:600}.sa-title .node{color:hsl(var(--muted-foreground))}.saving{font-size:12px;color:hsl(var(--muted-foreground))}.sa-add{padding:0 16px 14px;display:flex;flex-direction:column;gap:10px;border-bottom:1px solid hsl(var(--border))}.fetch-form.inline{display:flex;flex-direction:column;gap:10px}.tabs{display:flex;gap:4px;padding:0 10px;border-bottom:1px solid hsl(var(--border));overflow-x:auto}.tabs button{padding:9px 10px;font-size:12px;color:hsl(var(--muted-foreground));border:0;border-bottom:2px solid transparent;background:none;white-space:nowrap}.tabs button.on{color:hsl(var(--foreground));border-bottom-color:hsl(var(--primary))}.tabs b{font-family:ui-monospace, SFMono-Regular, Menlo, monospace;font-weight:500;color:hsl(var(--muted-foreground));margin-left:6px}.tab-h{display:flex;justify-content:space-between;align-items:center;padding:8px 12px;font-size:12px;color:hsl(var(--muted-foreground));border-bottom:1px solid hsl(var(--border) / 0.6)}.toasts{position:absolute;left:12px;right:12px;bottom:12px;display:flex;flex-direction:column;gap:8px;z-index:30;pointer-events:none;align-items:flex-end}:host(.standalone) .toasts{position:sticky;margin:12px}.toast{pointer-events:auto;display:flex;gap:10px;align-items:center;padding:10px 12px;background:hsl(var(--bg));border:1px solid hsl(var(--primary) / 0.5);border-radius:6px;width:min(100%, 420px);box-shadow:0 12px 30px -12px rgba(0, 0, 0, 0.7)}.toast>svg{color:hsl(var(--primary));flex:none}.toast.bad{border-color:hsl(var(--destructive) / 0.55)}.toast.bad>svg{color:hsl(var(--destructive))}.toast .t{flex:1;min-width:0}.toast .t b{display:block;font-weight:600}.toast .t span{color:hsl(var(--muted-foreground));font-family:ui-monospace, SFMono-Regular, Menlo, monospace;font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block}.overlay.player{padding:10px}.overlay.player phirepass-media-player{width:min(100%, 880px)}@container (max-width: 480px){.job{padding:9px 10px}.job .title .pill.meta{display:none}.inline-row{flex-wrap:wrap}.inline-row .inp{flex-basis:100%}.inline-row .btn.pri{flex:1;justify-content:center}.stats{gap:2px 10px}}@media (prefers-reduced-motion: reduce){.bar i{transition:none}.bar.indet i{animation:none;width:100% !important;opacity:0.5}.spin{animation:none}}"}},[513,"phirepass-downloader",{nodeId:[1,"node-id"],nodeLabel:[1,"node-label"],token:[1],channel:[16],connected:[4],channelFactory:[16],browsingService:[1,"browsing-service"],browsingPath:[1025,"browsing-path"],compact:[516],streamBase:[1,"stream-base"],canConfigure:[4,"can-configure"],inlinePlayer:[4,"inline-player"],serverHost:[1,"server-host"],serverPort:[2,"server-port"],serverId:[1,"server-id"],allowInsecure:[4,"allow-insecure"],heartbeatInterval:[2,"heartbeat-interval"],connection:[32],caps:[32],jobs:[32],tab:[32],drawerOpen:[32],dialogOpen:[32],unread:[32],form:[32],where:[32],starting:[32],refusal:[32],confirm:[32],notices:[32],subDir:[32],picker:[32],player:[32],receive:[64],openFetch:[64],toggleDrawer:[64],jobForPath:[64],deleteDownload:[64],torrentPathFor:[64],startTorrentPath:[64]},void 0,{channel:[{onChannel:0}],connected:[{onConnected:0}],browsingPath:[{onBrowsing:0}],browsingService:[{onBrowsing:0}],nodeId:[{onNode:0}]}]);function ge(){"undefined"!=typeof customElements&&["phirepass-downloader","phirepass-media-player"].forEach((e=>{switch(e){case"phirepass-downloader":customElements.get(t(e))||customElements.define(t(e),be);break;case"phirepass-media-player":customElements.get(t(e))||w()}}))}ge();export{y as D,be as P,ge as d,C as i,x as s}
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface PhirepassDownloader extends Components.PhirepassDownloader, HTMLElement {}
4
+ export const PhirepassDownloader: {
5
+ prototype: PhirepassDownloader;
6
+ new (): PhirepassDownloader;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1 @@
1
+ import{P as o,d as s}from"./p-D6Geq8Rn.js";const p=o,r=s;export{p as PhirepassDownloader,r as defineCustomElement}
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface PhirepassMediaPlayer extends Components.PhirepassMediaPlayer, HTMLElement {}
4
+ export const PhirepassMediaPlayer: {
5
+ prototype: PhirepassMediaPlayer;
6
+ new (): PhirepassMediaPlayer;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1 @@
1
+ import{P as o,d as s}from"./p-C4cmk3bS.js";const m=o,p=s;export{m as PhirepassMediaPlayer,p as defineCustomElement}
@@ -1 +1 @@
1
- import{t,p as e,H as s,c as i,h as o,a as n}from"./index.js";import{_ as r,C as h,a,P as c}from"./p-Dur4cBX7.js";const d=200;function u(t){return!Number.isFinite(t)||t<=0?d:Math.min(8192,Math.max(d,Math.floor(t)))}function l(t){return t-t%2}function p(t){const e=t.getBoundingClientRect();return function(t,e){return{width:l(u(t)),height:l(u(e))}}(e.width,e.height)}class m{onResize;debounceMs;observer;handle;reported;constructor(t,e=250){this.onResize=t,this.debounceMs=e}observe(t,e){this.disconnect(),this.reported=e,this.report(p(t)),"undefined"!=typeof ResizeObserver&&(this.observer=new ResizeObserver((()=>{clearTimeout(this.handle),this.handle=setTimeout((()=>this.report(p(t))),this.debounceMs)})),this.observer.observe(t))}disconnect(){clearTimeout(this.handle),this.handle=void 0,this.observer?.disconnect(),this.observer=void 0,this.reported=void 0}report(t){(function(t,e){return!!t&&!!e&&t.width===e.width&&t.height===e.height})(t,this.reported)||(this.reported=t,this.onResize(t))}}function f(){return navigator.keyboard}function b(){return"function"==typeof f()?.lock}function y(t){return document.fullscreenElement===t}function w(t){return document.fullscreenElement?.contains(t)??!1}function g(){if(b())try{f().unlock()}catch(t){console.warn("Failed to release the keyboard lock:",t)}}const v=e(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.connectionStateChanged=i(this,"connectionStateChanged")}channel;containerEl;ironEl;userInteraction;viewport;domReady=!1;runtimeReady=!1;connected=!1;disposed=!1;session_id;onFullscreenChange=()=>this.sync_keyboard_lock();credentials;credentialsPrompt=!1;statusMessage;usernameBuffer="";passwordBuffer="";get el(){return this}serverHost="phirepass.com";serverPort=443;allowInsecure=!1;heartbeatInterval=3e4;nodeId;serviceId;token;username;password;destination;scale="fit";dynamicResize=!0;captureKeyboard=!0;clipboard=!0;onNodeIdChange(t,e){this.reset_session_state(),this.channel&&this.channel.is_connected()&&this.close_comms(),t&&(this.open_comms(),this.channel.connect())}serverId;onServerIdChange(t,e){this.onNodeIdChange(this.nodeId,this.nodeId)}connectionStateChanged;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}`}async connectedCallback(){document.addEventListener("fullscreenchange",this.onFullscreenChange),this.disposed=!1,await r(),this.open_comms(),this.runtimeReady=!0,this.nodeId?this.try_connect():console.warn("Prop node_id is not set. Cannot connect to RDP.")}componentDidLoad(){this.domReady=!0,this.try_connect()}async disconnectedCallback(){document.removeEventListener("fullscreenchange",this.onFullscreenChange),this.disposed=!0,this.session_id=void 0,this.connected=!1,this.domReady=!1,this.runtimeReady=!1,this.close_comms()}async toggleFullscreen(){const t=await async function(t){try{return y(t)?(await document.exitFullscreen(),!1):(await t.requestFullscreen({navigationUI:"hide"}),!0)}catch(e){return console.warn("Failed to change the fullscreen state of the RDP session:",e),y(t)}}(this.el);return this.focus_desktop(),t}async keyboardLockSupported(){return b()}async focusDesktop(){this.focus_desktop()}async sendCtrlAltDel(){return!!this.userInteraction&&(this.userInteraction.ctrlAltDel(),this.focus_desktop(),!0)}async sendMetaKey(){return!!this.userInteraction&&(this.userInteraction.metaKey(),this.focus_desktop(),!0)}try_connect(){!this.connected&&this.domReady&&this.runtimeReady&&this.containerEl&&this.channel&&this.connect()}connect(){this.connected=!0,this.channel.connect()}open_comms(){this.channel=this.serverId?new h(this.create_web_socket_endpoint()+"/api/web/ws",this.nodeId,this.serverId):new h(this.create_web_socket_endpoint()+"/api/web/ws",this.nodeId),this.channel.on_connection_open((()=>{this.connectionStateChanged.emit([a.Connected]),this.channel.authenticate(this.token,this.nodeId)})),this.channel.on_connection_close((()=>{this.connectionStateChanged.emit([a.Disconnected]),this.teardown_client()})),this.channel.on_connection_error((t=>{this.connectionStateChanged.emit([a.Error,t])})),this.channel.on_connection_message((()=>{})),this.channel.on_protocol_message((t=>{const{web:e}=t.data;switch(e.type){case c.Error:this.handle_error(e);break;case c.AuthSuccess:this.handle_auth_success(e);break;case c.RDPAuthorized:this.handle_rdp_authorized(e);break;case c.TunnelClosed:this.handle_tunnel_closed(e);break;default:console.warn("Unknown protocol message type:",e)}}))}close_comms(){this.teardown_client(),this.channel&&(this.channel.stop_heartbeat(),this.channel.disconnect())}reset_session_state(){this.session_id=void 0,this.credentials=void 0,this.credentialsPrompt=!1,this.usernameBuffer="",this.passwordBuffer="",this.statusMessage=void 0}handle_auth_success(t){if(this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.username&&this.password)return this.credentials={username:this.username,password:this.password},void this.request_tunnel();this.credentialsPrompt=!0}request_tunnel(){this.credentials&&(this.statusMessage=void 0,this.channel.open_rdp_tunnel(this.nodeId,this.serviceId,this.credentials.username,this.credentials.password))}async handle_rdp_authorized(t){this.session_id=t.sid,this.statusMessage="Connecting…";const[e]=await Promise.all([import("@devolutions/iron-remote-desktop-rdp"),import("@devolutions/iron-remote-desktop")]);if(this.disposed||!this.containerEl||this.session_id!==t.sid)return;if(await e.init("info"),this.disposed||!this.containerEl||this.session_id!==t.sid)return;const s=document.createElement("iron-remote-desktop");s.module=e.Backend,s.scale=this.scale,s.flexcenter=!0,s.verbose=!1;const i=[e.enableCredssp(!0)];this.dynamicResize&&i.push(e.displayControl(!0)),s.addEventListener("ready",(e=>{this.start_session(e.detail.irgUserInteraction,t.ticket,i)})),this.ironEl=s,this.mount_client(s)}mount_client(t){this.el.appendChild(t)}async start_session(t,e,s){this.userInteraction=t,this.clipboard||t.setEnableClipboard(!1),t.onWarningCallback((t=>{console.warn("The remote desktop client reported a problem:",t)}));const i=t.configBuilder().withUsername(this.credentials?.username??"").withPassword(this.credentials?.password??"").withDestination(this.destination??this.nodeId).withProxyAddress(`${this.create_web_socket_endpoint()}/api/web/rdp/${this.nodeId}`).withAuthToken(e);for(const t of s)i.withExtension(t);let o;this.dynamicResize&&(o=function(t){const e=t.getBoundingClientRect();if(Number.isFinite(e.width)&&Number.isFinite(e.height)&&!(e.width<d||e.height<d))return{width:l(Math.min(Math.floor(e.width),4096)),height:l(Math.min(Math.floor(e.height),4096))}}(this.el),o&&i.withDesktopSize(o));try{const e=await t.connect(i.build());if(this.disposed)return this.shutdown_session(t),void await e.run();t.setVisibility(!0),this.statusMessage=void 0,this.focus_desktop(),this.sync_keyboard_lock();const s=e.run();this.start_viewport_sync(o);const n=await s;this.statusMessage=n.reason()}catch(t){const e=this.describe_error(t);this.statusMessage=e,this.connectionStateChanged.emit([a.Error,t])}}start_viewport_sync(t){this.dynamicResize&&(this.viewport=new m((t=>this.resize_desktop(t))),this.viewport.observe(this.el,t))}stop_viewport_sync(){this.viewport?.disconnect(),this.viewport=void 0}resize_desktop(t){try{this.userInteraction?.resize(t.width,t.height)}catch(t){console.warn("The remote host would not resize its desktop:",t)}}focus_desktop(){!function(t){t?.focus({preventScroll:!0})}(this.ironEl)}async sync_keyboard_lock(){this.captureKeyboard&&w(this.el)?(await async function(t){if(b()&&w(t))try{await f().lock()}catch(t){console.warn("Failed to lock the keyboard for the RDP session:",t)}}(this.el),this.focus_desktop()):g()}describe_error(t){return t&&"function"==typeof t.backtrace?t.backtrace():t instanceof Error?t.message:"Connection failed."}handle_tunnel_closed(t){this.session_id=void 0,this.statusMessage=this.statusMessage??"Connection closed.",this.teardown_client(),this.close_comms()}handle_error(t){this.statusMessage=t.message,this.connectionStateChanged.emit([a.Error,t])}shutdown_session(t){try{t.shutdown()}catch(t){console.warn("Failed to shut the RDP session down cleanly:",t)}}teardown_client(){this.stop_viewport_sync(),g(),this.userInteraction&&(this.shutdown_session(this.userInteraction),this.userInteraction=void 0),this.ironEl?.remove(),this.ironEl=void 0,this.credentialsPrompt=!1,this.usernameBuffer="",this.passwordBuffer=""}submit_credentials(t){t.preventDefault(),this.credentialsPrompt=!1,this.credentials={username:this.usernameBuffer,password:this.passwordBuffer},this.usernameBuffer="",this.passwordBuffer="",this.request_tunnel()}render(){return o(n,{key:"56354df7bd0d3f01fcd5ff65ca5618ceb6af1b91"},o("div",{key:"446dc83e41a29c3bc2c341a26092ed3581565967",class:"screen",ref:t=>this.containerEl=t},o("slot",{key:"2beafc92d81662dfac5c7b41356f6c6c802643b9"})),this.credentialsPrompt&&o("form",{key:"dcc29b21fba03bb97526ec3d1cf5a1fb51b483e9",class:"prompt",onSubmit:t=>this.submit_credentials(t)},o("label",{key:"b5a3e302089b2282aedbdbefd4fb5eaca7c34455",htmlFor:"rdp-username"},"Username"),o("input",{key:"3bd1c902a6bc41bc7e69c16258cac78035a949bd",id:"rdp-username",type:"text",autocomplete:"off",autofocus:!0,onInput:t=>this.usernameBuffer=t.target.value}),o("label",{key:"2defe12d73b609cbad27c06447c3c3221ff3e5aa",htmlFor:"rdp-password"},"Password"),o("input",{key:"55935891f24f0c1db71a14c42b2fc7a96c0c0ba6",id:"rdp-password",type:"password",autocomplete:"off",onInput:t=>this.passwordBuffer=t.target.value}),o("button",{key:"83439c0e8756001c7042fc3b6754889d62a8eada",type:"submit"},"Connect")),this.statusMessage&&!this.credentialsPrompt&&o("div",{key:"294262625f44a3f45d54bcd492875a9b6fd03219",class:"status"},this.statusMessage))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}static get style(){return':host{display:block;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden;position:relative;background:#0b1021;container-type:inline-size}.screen{width:100%;height:100%;display:flex}::slotted(iron-remote-desktop){display:block;flex:1 1 auto;min-width:0;min-height:0;width:100%;height:100%}:host(:fullscreen){width:100vw;height:100vh;background:#000}.prompt{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:0.5rem;background:rgba(11, 16, 33, 0.92);color:#e2e8f0;font-family:"Berkeley Mono", "Fira Code", "SFMono-Regular", Menlo, monospace;font-size:0.875rem}.prompt input{padding:0.5rem 0.75rem;border:1px solid #334155;border-radius:0.375rem;background:#0f172a;color:inherit;font:inherit;min-width:16rem}.prompt input:focus{outline:2px solid #67e8f9;outline-offset:1px}.prompt button{margin-top:0.5rem;padding:0.5rem 1.25rem;border:0;border-radius:0.375rem;background:#67e8f9;color:#0b1021;font:inherit;font-weight:600;cursor:pointer}.status{position:absolute;inset-inline:0;bottom:0;padding:0.5rem 0.75rem;background:rgba(11, 16, 33, 0.92);color:#e2e8f0;font-family:"Berkeley Mono", "Fira Code", "SFMono-Regular", Menlo, monospace;font-size:0.8125rem;text-align:center}@container (max-width: 640px){.prompt{padding:1rem;gap:0.4rem}.prompt input{min-width:0;width:100%;max-width:22rem;font-size:16px;padding:0.625rem 0.75rem}.prompt button{width:100%;max-width:22rem;padding:0.75rem 1.25rem}.status{font-size:0.75rem;padding:0.5rem;padding-bottom:calc(0.5rem + env(safe-area-inset-bottom))}}'}},[769,"phirepass-rdp",{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],username:[1],password:[1],destination:[1],scale:[1],dynamicResize:[4,"dynamic-resize"],captureKeyboard:[4,"capture-keyboard"],clipboard:[4],serverId:[1,"server-id"],credentialsPrompt:[32],statusMessage:[32],toggleFullscreen:[64],keyboardLockSupported:[64],focusDesktop:[64],sendCtrlAltDel:[64],sendMetaKey:[64]},void 0,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}]);function k(){"undefined"!=typeof customElements&&["phirepass-rdp"].forEach((e=>{"phirepass-rdp"===e&&(customElements.get(t(e))||customElements.define(t(e),v))}))}k();const _=v,I=k;export{_ as PhirepassRdp,I as defineCustomElement}
1
+ import{t,p as e,H as s,c as i,h as o,a as n}from"./index.js";import{_ as r,C as h,a,P as c}from"./p-CsYQJXY2.js";const d=200;function l(t){return!Number.isFinite(t)||t<=0?d:Math.min(8192,Math.max(d,Math.floor(t)))}function u(t){return t-t%2}function p(t){const e=t.getBoundingClientRect();return function(t,e){return{width:u(l(t)),height:u(l(e))}}(e.width,e.height)}class m{onResize;debounceMs;observer;handle;reported;constructor(t,e=250){this.onResize=t,this.debounceMs=e}observe(t,e){this.disconnect(),this.reported=e,this.report(p(t)),"undefined"!=typeof ResizeObserver&&(this.observer=new ResizeObserver((()=>{clearTimeout(this.handle),this.handle=setTimeout((()=>this.report(p(t))),this.debounceMs)})),this.observer.observe(t))}disconnect(){clearTimeout(this.handle),this.handle=void 0,this.observer?.disconnect(),this.observer=void 0,this.reported=void 0}report(t){(function(t,e){return!!t&&!!e&&t.width===e.width&&t.height===e.height})(t,this.reported)||(this.reported=t,this.onResize(t))}}function f(){return navigator.keyboard}function b(){return"function"==typeof f()?.lock}function y(t){return document.fullscreenElement===t}function w(t){return document.fullscreenElement?.contains(t)??!1}function g(){if(b())try{f().unlock()}catch(t){console.warn("Failed to release the keyboard lock:",t)}}const v=e(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.connectionStateChanged=i(this,"connectionStateChanged")}channel;containerEl;ironEl;userInteraction;viewport;domReady=!1;runtimeReady=!1;connected=!1;disposed=!1;session_id;onFullscreenChange=()=>this.sync_keyboard_lock();credentials;credentialsPrompt=!1;statusMessage;usernameBuffer="";passwordBuffer="";get el(){return this}serverHost="phirepass.com";serverPort=443;allowInsecure=!1;heartbeatInterval=3e4;nodeId;serviceId;token;username;password;destination;scale="fit";dynamicResize=!0;captureKeyboard=!0;clipboard=!0;onNodeIdChange(t,e){this.reset_session_state(),this.channel&&this.channel.is_connected()&&this.close_comms(),t&&(this.open_comms(),this.channel.connect())}serverId;channelFactory;onServerIdChange(t,e){this.onNodeIdChange(this.nodeId,this.nodeId)}connectionStateChanged;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}`}async connectedCallback(){document.addEventListener("fullscreenchange",this.onFullscreenChange),this.disposed=!1,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 RDP.")}componentDidLoad(){this.domReady=!0,this.try_connect()}async disconnectedCallback(){document.removeEventListener("fullscreenchange",this.onFullscreenChange),this.disposed=!0,this.session_id=void 0,this.connected=!1,this.domReady=!1,this.runtimeReady=!1,this.close_comms()}async toggleFullscreen(){const t=await async function(t){try{return y(t)?(await document.exitFullscreen(),!1):(await t.requestFullscreen({navigationUI:"hide"}),!0)}catch(e){return console.warn("Failed to change the fullscreen state of the RDP session:",e),y(t)}}(this.el);return this.focus_desktop(),t}async keyboardLockSupported(){return b()}async focusDesktop(){this.focus_desktop()}async sendCtrlAltDel(){return!!this.userInteraction&&(this.userInteraction.ctrlAltDel(),this.focus_desktop(),!0)}async sendMetaKey(){return!!this.userInteraction&&(this.userInteraction.metaKey(),this.focus_desktop(),!0)}try_connect(){!this.connected&&this.domReady&&this.runtimeReady&&this.containerEl&&this.channel&&this.connect()}connect(){this.connected=!0,this.channel.connect()}open_comms(){this.channel=this.channelFactory?this.channelFactory(this.create_web_socket_endpoint()+"/api/web/ws",this.nodeId,this.serverId||void 0):this.serverId?new h(this.create_web_socket_endpoint()+"/api/web/ws",this.nodeId,this.serverId):new h(this.create_web_socket_endpoint()+"/api/web/ws",this.nodeId),this.channel.on_connection_open((()=>{this.connectionStateChanged.emit([a.Connected]),this.channel.authenticate(this.token,this.nodeId)})),this.channel.on_connection_close((()=>{this.connectionStateChanged.emit([a.Disconnected]),this.teardown_client()})),this.channel.on_connection_error((t=>{this.connectionStateChanged.emit([a.Error,t])})),this.channel.on_connection_message((()=>{})),this.channel.on_protocol_message((t=>{const{web:e}=t.data;switch(e.type){case c.Error:this.handle_error(e);break;case c.AuthSuccess:this.handle_auth_success(e);break;case c.RDPAuthorized:this.handle_rdp_authorized(e);break;case c.TunnelClosed:this.handle_tunnel_closed(e);break;default:console.warn("Unknown protocol message type:",e)}}))}close_comms(){this.teardown_client(),this.channel&&(this.channel.stop_heartbeat(),this.channel.disconnect())}reset_session_state(){this.session_id=void 0,this.credentials=void 0,this.credentialsPrompt=!1,this.usernameBuffer="",this.passwordBuffer="",this.statusMessage=void 0}handle_auth_success(t){if(this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.username&&this.password)return this.credentials={username:this.username,password:this.password},void this.request_tunnel();this.credentialsPrompt=!0}request_tunnel(){this.credentials&&(this.statusMessage=void 0,this.channel.open_rdp_tunnel(this.nodeId,this.serviceId,this.credentials.username,this.credentials.password))}async handle_rdp_authorized(t){this.session_id=t.sid,this.statusMessage="Connecting…";const[e]=await Promise.all([import("@devolutions/iron-remote-desktop-rdp"),import("@devolutions/iron-remote-desktop")]);if(this.disposed||!this.containerEl||this.session_id!==t.sid)return;if(await e.init("info"),this.disposed||!this.containerEl||this.session_id!==t.sid)return;const s=document.createElement("iron-remote-desktop");s.module=e.Backend,s.scale=this.scale,s.flexcenter=!0,s.verbose=!1;const i=[e.enableCredssp(!0)];this.dynamicResize&&i.push(e.displayControl(!0)),s.addEventListener("ready",(e=>{this.start_session(e.detail.irgUserInteraction,t.ticket,i)})),this.ironEl=s,this.mount_client(s)}mount_client(t){this.el.appendChild(t)}async start_session(t,e,s){this.userInteraction=t,this.clipboard||t.setEnableClipboard(!1),t.onWarningCallback((t=>{console.warn("The remote desktop client reported a problem:",t)}));const i=t.configBuilder().withUsername(this.credentials?.username??"").withPassword(this.credentials?.password??"").withDestination(this.destination??this.nodeId).withProxyAddress(`${this.create_web_socket_endpoint()}/api/web/rdp/${this.nodeId}`).withAuthToken(e);for(const t of s)i.withExtension(t);let o;this.dynamicResize&&(o=function(t){const e=t.getBoundingClientRect();if(Number.isFinite(e.width)&&Number.isFinite(e.height)&&!(e.width<d||e.height<d))return{width:u(Math.min(Math.floor(e.width),4096)),height:u(Math.min(Math.floor(e.height),4096))}}(this.el),o&&i.withDesktopSize(o));try{const e=await t.connect(i.build());if(this.disposed)return this.shutdown_session(t),void await e.run();t.setVisibility(!0),this.statusMessage=void 0,this.focus_desktop(),this.sync_keyboard_lock();const s=e.run();this.start_viewport_sync(o);const n=await s;this.statusMessage=n.reason()}catch(t){const e=this.describe_error(t);this.statusMessage=e,this.connectionStateChanged.emit([a.Error,t])}}start_viewport_sync(t){this.dynamicResize&&(this.viewport=new m((t=>this.resize_desktop(t))),this.viewport.observe(this.el,t))}stop_viewport_sync(){this.viewport?.disconnect(),this.viewport=void 0}resize_desktop(t){try{this.userInteraction?.resize(t.width,t.height)}catch(t){console.warn("The remote host would not resize its desktop:",t)}}focus_desktop(){!function(t){t?.focus({preventScroll:!0})}(this.ironEl)}async sync_keyboard_lock(){this.captureKeyboard&&w(this.el)?(await async function(t){if(b()&&w(t))try{await f().lock()}catch(t){console.warn("Failed to lock the keyboard for the RDP session:",t)}}(this.el),this.focus_desktop()):g()}describe_error(t){return t&&"function"==typeof t.backtrace?t.backtrace():t instanceof Error?t.message:"Connection failed."}handle_tunnel_closed(t){this.session_id=void 0,this.statusMessage=this.statusMessage??"Connection closed.",this.teardown_client(),this.close_comms()}handle_error(t){this.statusMessage=t.message,this.connectionStateChanged.emit([a.Error,t])}shutdown_session(t){try{t.shutdown()}catch(t){console.warn("Failed to shut the RDP session down cleanly:",t)}}teardown_client(){this.stop_viewport_sync(),g(),this.userInteraction&&(this.shutdown_session(this.userInteraction),this.userInteraction=void 0),this.ironEl?.remove(),this.ironEl=void 0,this.credentialsPrompt=!1,this.usernameBuffer="",this.passwordBuffer=""}submit_credentials(t){t.preventDefault(),this.credentialsPrompt=!1,this.credentials={username:this.usernameBuffer,password:this.passwordBuffer},this.usernameBuffer="",this.passwordBuffer="",this.request_tunnel()}render(){return o(n,{key:"04896084a5e914a9e2a184ee7b560f4978da9bfd"},o("div",{key:"db5d3d0d4351aeb868ffe6956b86f22b62775e4b",class:"screen",ref:t=>this.containerEl=t},o("slot",{key:"efafd5d8b1437687713aff0425c050413593d162"})),this.credentialsPrompt&&o("form",{key:"ad6079b6db1d71e8eb60bef71cd808be22b7387c",class:"prompt",onSubmit:t=>this.submit_credentials(t)},o("label",{key:"b976c7a3c01e4983fac39e1ef027e4307a6654c7",htmlFor:"rdp-username"},"Username"),o("input",{key:"3a90a73a446015d708eaebec6a7d9bc1703ae5d0",id:"rdp-username",type:"text",autocomplete:"off",autofocus:!0,onInput:t=>this.usernameBuffer=t.target.value}),o("label",{key:"eaf13aa5fe39e4576de052b15c85e6b60be466cb",htmlFor:"rdp-password"},"Password"),o("input",{key:"d53ec8c48b7826b011a07bcb57b7ae1fbe30160f",id:"rdp-password",type:"password",autocomplete:"off",onInput:t=>this.passwordBuffer=t.target.value}),o("button",{key:"d1616e75c1f37a853ec793a25ffc8919544c16d2",type:"submit"},"Connect")),this.statusMessage&&!this.credentialsPrompt&&o("div",{key:"8e6deb9e32f0c416bf85666847f10e095f40e210",class:"status"},this.statusMessage))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}static get style(){return':host{display:block;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden;position:relative;background:#0b1021;container-type:inline-size}.screen{width:100%;height:100%;display:flex}::slotted(iron-remote-desktop){display:block;flex:1 1 auto;min-width:0;min-height:0;width:100%;height:100%}:host(:fullscreen){width:100vw;height:100vh;background:#000}.prompt{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:0.5rem;background:rgba(11, 16, 33, 0.92);color:#e2e8f0;font-family:"Berkeley Mono", "Fira Code", "SFMono-Regular", Menlo, monospace;font-size:0.875rem}.prompt input{padding:0.5rem 0.75rem;border:1px solid #334155;border-radius:0.375rem;background:#0f172a;color:inherit;font:inherit;min-width:16rem}.prompt input:focus{outline:2px solid #67e8f9;outline-offset:1px}.prompt button{margin-top:0.5rem;padding:0.5rem 1.25rem;border:0;border-radius:0.375rem;background:#67e8f9;color:#0b1021;font:inherit;font-weight:600;cursor:pointer}.status{position:absolute;inset-inline:0;bottom:0;padding:0.5rem 0.75rem;background:rgba(11, 16, 33, 0.92);color:#e2e8f0;font-family:"Berkeley Mono", "Fira Code", "SFMono-Regular", Menlo, monospace;font-size:0.8125rem;text-align:center}@container (max-width: 640px){.prompt{padding:1rem;gap:0.4rem}.prompt input{min-width:0;width:100%;max-width:22rem;font-size:16px;padding:0.625rem 0.75rem}.prompt button{width:100%;max-width:22rem;padding:0.75rem 1.25rem}.status{font-size:0.75rem;padding:0.5rem;padding-bottom:calc(0.5rem + env(safe-area-inset-bottom))}}'}},[769,"phirepass-rdp",{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],username:[1],password:[1],destination:[1],scale:[1],dynamicResize:[4,"dynamic-resize"],captureKeyboard:[4,"capture-keyboard"],clipboard:[4],serverId:[1,"server-id"],channelFactory:[16],credentialsPrompt:[32],statusMessage:[32],toggleFullscreen:[64],keyboardLockSupported:[64],focusDesktop:[64],sendCtrlAltDel:[64],sendMetaKey:[64]},void 0,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}]);function k(){"undefined"!=typeof customElements&&["phirepass-rdp"].forEach((e=>{"phirepass-rdp"===e&&(customElements.get(t(e))||customElements.define(t(e),v))}))}k();const _=v,I=k;export{_ as PhirepassRdp,I as defineCustomElement}