2 lines
16 KiB
JavaScript
2 lines
16 KiB
JavaScript
import{d as Ce,r as p,w as Ie,o as Ee,A as Me,c as d,m as Pe,a as n,b as Q,f as C,D as z,h as S,i as F,T as V,G as P,a9 as _e,a1 as Te,j as b,x as Be,B as f,J as D,Q as Se,u as Ae,q as c,t as $e}from"./index-DnbYEqLr.js";const Ne={class:"app-session-root"},je={class:"sticky top-0 z-10 flex items-center gap-3 border-b border-white/10 px-4 py-3 bg-black/60 backdrop-blur-md md:bg-transparent md:backdrop-blur-none"},Re={class:"flex-1 truncate text-sm font-medium text-white/90"},Le=["disabled"],Oe={key:0,class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},ze={key:1,class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Fe={key:2,class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Ve={key:0,class:"absolute right-0 top-full mt-1 w-48 bg-black/90 border border-white/10 rounded-lg backdrop-blur-xl shadow-2xl overflow-hidden z-50"},De={class:"relative flex-1 min-h-0 bg-black/40 overflow-hidden"},He={key:0,class:"absolute inset-0 z-10 flex items-center justify-center bg-black/40"},qe=["src"],Ke={key:0,class:"absolute inset-0 z-10 flex flex-col items-center justify-center"},Ue={class:"text-center px-8"},Ye={class:"text-white/50 text-sm mb-6"},Ge={key:1,class:"absolute inset-0 flex items-center justify-center"},We={class:"text-center px-8"},Je={class:"text-white/50 text-sm"},H="archipelago_app_display_mode",Z="archipelago_app_identity_",Xe=Ce({__name:"AppSession",props:{appIdProp:{}},emits:["close"],setup(ee,{emit:te}){const q=ee,A=te,v=b(()=>!!q.appIdProp),$=Ae(),_=Be(),y=p(null),I=p(null),N=p(null),h=p(!0),E=p(!1),w=p(!1),K=p(0),M=p(!1),g=p(!1);let r=null;const ne=new Set([]),i=p(localStorage.getItem(H)||"panel");function j(t){if(i.value==="fullscreen"&&document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),i.value=t,localStorage.setItem(H,t),g.value=!1,v.value&&t!=="panel"){const e=u.value;A("close"),_.push({name:"app-session",params:{appId:e}});return}if(!v.value&&t==="panel"){const e=u.value,o=Se();_.push({name:"apps"}).then(()=>{o.panelAppId=e});return}t==="fullscreen"&&y.value&&!document.fullscreenElement&&y.value.requestFullscreen().catch(()=>{})}const oe=b(()=>v.value?"app-session-backdrop-inline":"app-session-backdrop-overlay"),se=b(()=>{const t="app-session-panel glass-card";return v.value?`${t} app-session-inline`:i.value==="fullscreen"?`${t} app-session-fullscreen`:`${t} app-session-overlay`}),u=b(()=>q.appIdProp||$.params.appId),U={"bitcoin-knots":8334,"bitcoin-ui":8334,electrumx:50002,electrs:50002,"archy-electrs-ui":50002,"mempool-electrs":50002,"btcpay-server":23e3,lnd:8081,"archy-lnd-ui":8081,mempool:4080,"mempool-web":4080,"archy-mempool-web":4080,homeassistant:8123,grafana:3e3,searxng:8888,ollama:11434,onlyoffice:9980,penpot:9001,nextcloud:8085,vaultwarden:8082,jellyfin:8096,photoprism:2342,immich:2283,immich_server:2283,filebrowser:8083,"nginx-proxy-manager":81,portainer:9e3,"uptime-kuma":3001,tailscale:8240,fedimint:8175,"fedimint-gateway":8176,"nostr-rs-relay":18081,indeedhub:7777,dwn:3100,endurain:8080},le={},ae={"bitcoin-knots":"/app/bitcoin-ui/","bitcoin-ui":"/app/bitcoin-ui/",lnd:"/app/lnd/",electrumx:"/app/electrs/",electrs:"/app/electrs/","mempool-electrs":"/app/electrs/",mempool:"/app/mempool/","mempool-web":"/app/mempool/","archy-mempool-web":"/app/mempool/",fedimint:"/app/fedimint/","fedimint-gateway":"/app/fedimint-gateway/",jellyfin:"/app/jellyfin/",searxng:"/app/searxng/",filebrowser:"/app/filebrowser/",ollama:"/app/ollama/",onlyoffice:"/app/onlyoffice/",immich:"/app/immich/",immich_server:"/app/immich/",tailscale:"/app/tailscale/",endurain:"/app/endurain/",dwn:"/app/dwn/"},ie={botfights:"https://botfights.net",nwnn:"https://nwnn.l484.com","484-kitchen":"https://484.kitchen","call-the-operator":"https://cta.tx1138.com","syntropy-institute":"https://syntropy.institute","t-zero":"https://teeminuszero.net",nostrudel:"https://nostrudel.ninja"},re={"bitcoin-knots":"Bitcoin","btcpay-server":"BTCPay Server",indeedhub:"Indeehub",botfights:"BotFights","484-kitchen":"484 Kitchen","arch-presentation":"Presentation",homeassistant:"Home Assistant","uptime-kuma":"Uptime Kuma","nginx-proxy-manager":"Nginx Proxy Manager","nostr-rs-relay":"Nostr Relay","call-the-operator":"Call The Operator","syntropy-institute":"Syntropy Institute","t-zero":"T-Zero",nostrudel:"noStrudel"},R=b(()=>re[u.value]||u.value.replace(/-/g," ").replace(/\b\w/g,t=>t.toUpperCase())),ue=new Set(["btcpay-server","grafana","photoprism","homeassistant","vaultwarden","nextcloud","uptime-kuma","penpot"]),ce=b(()=>ue.has(u.value)),m=b(()=>{const t=u.value,e=ie[t];if(e)return e;const o=le[t];if(o)return`${window.location.origin}${o}`;if(t==="indeedhub"){const l=U[t];if(l){let s=`${window.location.protocol}//${window.location.hostname}:${l}`;const B=$.query.path;return B&&(s+=B),s}}if(window.location.protocol==="https:"){const l=ae[t];if(l)return`${window.location.origin}${l}`}const a=U[t];if(!a)return"";let x=`http://${window.location.hostname}:${a}`;const k=$.query.path;return k&&(x+=k),x});function pe(t){return t==="indeedhub"||t==="nostrudel"}function L(){try{const t=localStorage.getItem(Z+u.value);return t?JSON.parse(t):null}catch{return null}}function de(t){try{localStorage.setItem(Z+u.value,JSON.stringify(t))}catch{}}function me(t){M.value=!1,de(t),O(t)}async function O(t){try{const e=`archipelago-identity:${Date.now()}`,o=await f.call({method:"identity.sign",params:{id:t.id,message:e}});I.value?.contentWindow?.postMessage({type:"archipelago:identity",did:t.did,name:t.name,pubkey:t.pubkey,nostr_pubkey:t.nostr_pubkey||null,nostr_npub:t.nostr_npub||null,challenge:e,signature:o.signature},"*")}catch{}}function fe(){if(r&&(clearTimeout(r),r=null),h.value=!1,E.value=!1,setTimeout(()=>{try{const t=I.value?.contentDocument;if(t){const e=t.body;(!e||e.children.length===0&&e.innerText.trim()==="")&&(w.value=!0)}}catch{}},1e3),pe(u.value)){const t=L();t?O(t):M.value=!0}}function ve(){r&&(clearTimeout(r),r=null),h.value=!1,E.value=!1,w.value=!0}function he(){E.value=!0,h.value=!0,w.value=!1,K.value++,Y()}function Y(){r&&clearTimeout(r),r=setTimeout(()=>{h.value&&(h.value=!1,w.value=!0)},12e3)}function we(){m.value&&window.open(m.value,"_blank","noopener,noreferrer"),T()}function ke(){m.value&&window.open(m.value,"_blank","noopener,noreferrer")}function be(){try{I.value?.contentWindow?.history.back()}catch{}}function ye(){try{I.value?.contentWindow?.history.forward()}catch{}}function ge(){T()}function T(){document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),v.value?A("close"):_.push({name:"apps"})}function G(t){t.key==="Escape"&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):T(),t.preventDefault())}function W(t){g.value&&N.value&&!N.value.contains(t.target)&&(g.value=!1)}function J(){!document.fullscreenElement&&i.value==="fullscreen"&&(i.value="overlay",localStorage.setItem(H,"overlay"))}Ie(i,t=>{t==="fullscreen"&&y.value&&!document.fullscreenElement&&y.value.requestFullscreen().catch(()=>{})});function X(t){if(t.data?.type==="nostr-request"&&xe(t),t.data?.type==="archipelago:identity:request"){const e=L();e?O(e):M.value=!0}}async function xe(t){const{id:e,method:o,params:a}=t.data,x=t.source;if(!x)return;const k=L(),l=k?.id||null;console.log(`[NIP-07] ${o} identityId=${l} storedPubkey=${k?.nostr_pubkey?.slice(0,12)||"none"}`);try{let s;if(o==="getPublicKey")k?.nostr_pubkey?(s=k.nostr_pubkey,console.log("[NIP-07] getPublicKey from stored identity:",s.slice(0,12))):l?s=(await f.call({method:"identity.get",params:{id:l}})).nostr_pubkey:s=(await f.call({method:"node.nostr-pubkey"})).nostr_pubkey;else if(o==="signEvent")console.log(`[NIP-07] signEvent kind=${a.event?.kind} using identity=${l||"node-default"}`),l?s=await f.call({method:"identity.nostr-sign",params:{id:l,event:a.event}}):s=await f.call({method:"node.nostr-sign",params:{event:a.event}}),console.log("[NIP-07] signEvent OK");else if(o==="getRelays")s={};else if(o==="nip04.encrypt")s=(await f.call({method:"identity.nostr-encrypt-nip04",params:{id:l||void 0,pubkey:a.pubkey,plaintext:a.plaintext}})).ciphertext;else if(o==="nip04.decrypt")s=(await f.call({method:"identity.nostr-decrypt-nip04",params:{id:l||void 0,pubkey:a.pubkey,ciphertext:a.ciphertext}})).plaintext;else if(o==="nip44.encrypt")s=(await f.call({method:"identity.nostr-encrypt-nip44",params:{id:l||void 0,pubkey:a.pubkey,plaintext:a.plaintext}})).ciphertext;else if(o==="nip44.decrypt")s=(await f.call({method:"identity.nostr-decrypt-nip44",params:{id:l||void 0,pubkey:a.pubkey,ciphertext:a.ciphertext}})).plaintext;else throw new Error(`Unsupported NIP-07 method: ${o}`);x.postMessage({type:"nostr-response",id:e,result:s},"*")}catch(s){console.error(`[NIP-07] ${o} FAILED:`,s instanceof Error?s.message:s),x.postMessage({type:"nostr-response",id:e,error:s instanceof Error?s.message:"Unknown error"},"*")}}return Ee(()=>{if(ce.value&&m.value){window.open(m.value,"_blank","noopener,noreferrer"),v.value?A("close"):_.back();return}window.addEventListener("keydown",G,!0),window.addEventListener("message",X),document.addEventListener("click",W),document.addEventListener("fullscreenchange",J),ne.has(u.value)?(h.value=!1,w.value=!0):Y(),i.value==="fullscreen"&&requestAnimationFrame(()=>{y.value?.requestFullscreen().catch(()=>{})})}),Me(()=>{r&&clearTimeout(r),window.removeEventListener("keydown",G,!0),window.removeEventListener("message",X),document.removeEventListener("click",W),document.removeEventListener("fullscreenchange",J),document.fullscreenElement&&document.exitFullscreen().catch(()=>{})}),(t,e)=>(c(),d("div",Ne,[(c(),Pe(Te,{to:"body",disabled:v.value},[n("div",{class:C(oe.value),onClick:Q(ge,["self"])},[n("div",{ref_key:"sessionRef",ref:y,class:C(se.value),onClick:e[4]||(e[4]=Q(()=>{},["stop"]))},[n("div",je,[n("div",{class:"flex items-center gap-0.5"},[n("button",{class:"app-session-btn","aria-label":"Back",title:"Go back",onClick:be},[...e[6]||(e[6]=[n("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[n("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 19l-7-7 7-7"})],-1)])]),n("button",{class:"app-session-btn","aria-label":"Forward",title:"Go forward",onClick:ye},[...e[7]||(e[7]=[n("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[n("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"})],-1)])])]),n("span",Re,z(R.value),1),n("button",{class:"app-session-btn","aria-label":"Refresh",disabled:E.value,onClick:he},[(c(),d("svg",{class:C(["w-5 h-5 transition-transform duration-300",{"animate-spin":E.value}]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...e[8]||(e[8]=[n("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"},null,-1)])],2))],8,Le),n("div",{class:"relative",ref_key:"modeMenuRef",ref:N},[n("button",{class:"app-session-btn","aria-label":"Display mode",title:"Display mode",onClick:e[0]||(e[0]=o=>g.value=!g.value)},[i.value==="panel"?(c(),d("svg",Oe,[...e[9]||(e[9]=[n("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 3v18m12-18H3a1 1 0 00-1 1v16a1 1 0 001 1h18a1 1 0 001-1V4a1 1 0 00-1-1z"},null,-1)])])):i.value==="overlay"?(c(),d("svg",ze,[...e[10]||(e[10]=[n("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 5a1 1 0 011-1h14a1 1 0 011 1v14a1 1 0 01-1 1H5a1 1 0 01-1-1V5z"},null,-1)])])):(c(),d("svg",Fe,[...e[11]||(e[11]=[n("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5"},null,-1)])]))]),S(V,{name:"menu-fade"},{default:F(()=>[g.value?(c(),d("div",Ve,[n("button",{class:C(["mode-option",{"mode-option-active":i.value==="panel"}]),onClick:e[1]||(e[1]=o=>j("panel"))},[...e[12]||(e[12]=[n("svg",{class:"w-4 h-4 shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[n("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 3v18m12-18H3a1 1 0 00-1 1v16a1 1 0 001 1h18a1 1 0 001-1V4a1 1 0 00-1-1z"})],-1),n("span",null,"Right panel",-1)])],2),n("button",{class:C(["mode-option",{"mode-option-active":i.value==="overlay"}]),onClick:e[2]||(e[2]=o=>j("overlay"))},[...e[13]||(e[13]=[n("svg",{class:"w-4 h-4 shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[n("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 5a1 1 0 011-1h14a1 1 0 011 1v14a1 1 0 01-1 1H5a1 1 0 01-1-1V5z"})],-1),n("span",null,"Over whole app",-1)])],2),n("button",{class:C(["mode-option",{"mode-option-active":i.value==="fullscreen"}]),onClick:e[3]||(e[3]=o=>j("fullscreen"))},[...e[14]||(e[14]=[n("svg",{class:"w-4 h-4 shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[n("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5"})],-1),n("span",null,"Open fullscreen",-1)])],2)])):P("",!0)]),_:1})],512),n("button",{class:"app-session-btn","aria-label":"Open in new tab",title:"Open in new tab",onClick:ke},[...e[15]||(e[15]=[n("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[n("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})],-1)])]),n("button",{class:"app-session-btn","aria-label":"Close",onClick:T},[...e[16]||(e[16]=[n("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[n("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])]),e[17]||(e[17]=n("kbd",{class:"hidden sm:inline-flex px-2 py-1 text-xs text-white/50 bg-white/10 rounded"},"Esc",-1))]),n("div",De,[S(V,{name:"content-fade"},{default:F(()=>[h.value?(c(),d("div",He,[...e[18]||(e[18]=[n("svg",{class:"animate-spin h-8 w-8 text-blue-400",viewBox:"0 0 24 24",fill:"none"},[n("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),n("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})],-1)])])):P("",!0)]),_:1}),m.value&&!w.value?(c(),d("iframe",{ref_key:"iframeRef",ref:I,key:K.value,src:m.value,class:"absolute inset-0 w-full h-full border-0 iframe-scrollbar-hide",title:"App content",onLoad:fe,onError:ve},null,40,qe)):P("",!0),S(V,{name:"content-fade"},{default:F(()=>[w.value?(c(),d("div",Ke,[n("div",Ue,[e[22]||(e[22]=n("div",{class:"w-16 h-16 mx-auto mb-4 rounded-2xl bg-white/5 border border-white/10 flex items-center justify-center"},[n("svg",{class:"w-8 h-8 text-white/40",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[n("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})])],-1)),e[23]||(e[23]=n("h3",{class:"text-lg font-semibold text-white mb-2"},"This site blocks embedded viewing",-1)),n("p",Ye,[D(z(R.value)+" sets security headers that prevent iframe embedding.",1),e[19]||(e[19]=n("br",null,null,-1)),e[20]||(e[20]=D("Open it in a new browser tab instead.",-1))]),n("button",{onClick:we,class:"glass-button px-6 py-3 rounded-lg text-sm font-semibold inline-flex items-center gap-2"},[...e[21]||(e[21]=[n("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[n("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})],-1),D(" Open in new tab ",-1)])])])])):P("",!0)]),_:1}),m.value?P("",!0):(c(),d("div",Ge,[n("div",We,[e[24]||(e[24]=n("h3",{class:"text-lg font-semibold text-white mb-2"},"App not configured",-1)),n("p",Je,"No URL found for "+z(u.value),1)])]))])],2),S(_e,{show:M.value,"app-name":R.value,onSelect:me,onCancel:e[5]||(e[5]=o=>M.value=!1)},null,8,["show","app-name"])],2)],8,["disabled"]))]))}}),Ze=$e(Xe,[["__scopeId","data-v-6994c7f2"]]);export{Ze as default};
|