chirkle 0.4.1 → 0.5.4
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.
- package/README.md +38 -202
- package/bin/release/darwin-amd64/chirkle-server +2 -2
- package/bin/release/darwin-arm64/chirkle-server +0 -0
- package/bin/release/linux-amd64/chirkle-server +0 -0
- package/bin/release/linux-arm64/chirkle-server +0 -0
- package/package.json +17 -5
- package/pb_hooks/federation/inbox.js +2 -0
- package/pb_hooks/federation/messages.js +40 -2
- package/pb_hooks/federation/worker.js +7 -3
- package/pb_hooks/lib/collections.js +5 -3
- package/pb_hooks/lib/files.js +36 -0
- package/pb_hooks/lib/handles.js +24 -2
- package/pb_hooks/lib/http.js +2 -2
- package/pb_hooks/lib/inbox.js +6 -5
- package/pb_hooks/lib/media.js +16 -3
- package/pb_hooks/lib/messages.js +16 -6
- package/pb_hooks/lib/pins.js +199 -0
- package/pb_hooks/lib/rooms.js +4 -0
- package/pb_hooks/lib/users.js +33 -2
- package/pb_hooks/main.pb.js +17 -3
- package/pb_hooks/telegram/inbound.js +187 -16
- package/pb_hooks/telegram/links.js +12 -1
- package/pb_hooks/telegram/outbound.js +153 -12
- package/pb_hooks/telegram/worker.js +3 -1
- package/pb_migrations/1760000057_reactions_seen.js +17 -0
- package/pb_migrations/1760000058_users_kind_public.js +20 -0
- package/pb_migrations/1760000059_telegram_media_edits.js +37 -0
- package/pb_migrations/1760000060_pins.js +23 -0
- package/pb_public/assets/{access-UK3L54NR.js → access-23A7N3OD.js} +2 -2
- package/pb_public/assets/access-23A7N3OD.js.br +0 -0
- package/pb_public/assets/access-23A7N3OD.js.gz +0 -0
- package/pb_public/assets/access-XGNXIUR5.css +2 -0
- package/pb_public/assets/access-XGNXIUR5.css.br +0 -0
- package/pb_public/assets/access-XGNXIUR5.css.gz +0 -0
- package/pb_public/assets/access-XGNXIUR5.css.map +7 -0
- package/pb_public/assets/account-EBCPOLWT.css +2 -0
- package/pb_public/assets/account-EBCPOLWT.css.br +0 -0
- package/pb_public/assets/account-EBCPOLWT.css.gz +0 -0
- package/pb_public/assets/account-EBCPOLWT.css.map +7 -0
- package/pb_public/assets/account-api-J6A6IYVX.js.br +0 -0
- package/pb_public/assets/account-api-J6A6IYVX.js.gz +0 -0
- package/pb_public/assets/app-A7HBI65K.js +3 -0
- package/pb_public/assets/app-A7HBI65K.js.br +0 -0
- package/pb_public/assets/app-A7HBI65K.js.gz +0 -0
- package/pb_public/assets/app-A7HBI65K.js.map +7 -0
- package/pb_public/assets/app-HMWQXURS.css +2 -0
- package/pb_public/assets/app-HMWQXURS.css.br +0 -0
- package/pb_public/assets/app-HMWQXURS.css.gz +0 -0
- package/pb_public/assets/app-HMWQXURS.css.map +7 -0
- package/pb_public/assets/chunk-AG73QNUN.js.br +0 -0
- package/pb_public/assets/chunk-AG73QNUN.js.gz +0 -0
- package/pb_public/assets/chunk-DC4TJ7HF.js +2 -0
- package/pb_public/assets/chunk-DC4TJ7HF.js.br +0 -0
- package/pb_public/assets/chunk-DC4TJ7HF.js.gz +0 -0
- package/pb_public/assets/chunk-DC4TJ7HF.js.map +7 -0
- package/pb_public/assets/chunk-DCLJRQ53.js.br +0 -0
- package/pb_public/assets/chunk-DCLJRQ53.js.gz +0 -0
- package/pb_public/assets/chunk-RPCBA7VF.js.br +0 -0
- package/pb_public/assets/chunk-RPCBA7VF.js.gz +0 -0
- package/pb_public/assets/chunk-RYZHXNLF.js +2 -0
- package/pb_public/assets/chunk-RYZHXNLF.js.br +0 -0
- package/pb_public/assets/chunk-RYZHXNLF.js.gz +0 -0
- package/pb_public/assets/chunk-RYZHXNLF.js.map +7 -0
- package/pb_public/assets/chunk-SM542ZXL.js +2 -0
- package/pb_public/assets/chunk-SM542ZXL.js.br +0 -0
- package/pb_public/assets/chunk-SM542ZXL.js.gz +0 -0
- package/pb_public/assets/chunk-SM542ZXL.js.map +7 -0
- package/pb_public/assets/chunk-SZMAZMR4.js +2 -0
- package/pb_public/assets/chunk-SZMAZMR4.js.br +0 -0
- package/pb_public/assets/chunk-SZMAZMR4.js.gz +0 -0
- package/pb_public/assets/chunk-SZMAZMR4.js.map +7 -0
- package/pb_public/assets/chunk-UZDXAORM.js.br +0 -0
- package/pb_public/assets/chunk-UZDXAORM.js.gz +0 -0
- package/pb_public/assets/chunk-VSHXXDW4.js +2 -0
- package/pb_public/assets/chunk-VSHXXDW4.js.br +0 -0
- package/pb_public/assets/chunk-VSHXXDW4.js.gz +0 -0
- package/pb_public/assets/chunk-VSHXXDW4.js.map +7 -0
- package/pb_public/assets/chunk-VTOUI25E.js.br +0 -0
- package/pb_public/assets/chunk-VTOUI25E.js.gz +0 -0
- package/pb_public/assets/chunk-WDXT4S4J.js +2 -0
- package/pb_public/assets/chunk-WDXT4S4J.js.br +0 -0
- package/pb_public/assets/chunk-WDXT4S4J.js.gz +0 -0
- package/pb_public/assets/chunk-WDXT4S4J.js.map +7 -0
- package/pb_public/assets/collections-FZB6G4W4.css +2 -0
- package/pb_public/assets/collections-FZB6G4W4.css.br +0 -0
- package/pb_public/assets/collections-FZB6G4W4.css.gz +0 -0
- package/pb_public/assets/collections-FZB6G4W4.css.map +7 -0
- package/pb_public/assets/emoji-IHRUMGCY.css +2 -0
- package/pb_public/assets/emoji-IHRUMGCY.css.br +0 -0
- package/pb_public/assets/emoji-IHRUMGCY.css.gz +0 -0
- package/pb_public/assets/emoji-IHRUMGCY.css.map +7 -0
- package/pb_public/assets/{emoji-picker-K6JTK2GV.js → emoji-picker-K4DOKYL3.js} +2 -2
- package/pb_public/assets/emoji-picker-K4DOKYL3.js.br +0 -0
- package/pb_public/assets/emoji-picker-K4DOKYL3.js.gz +0 -0
- package/pb_public/assets/{emoji-picker-K6JTK2GV.js.map → emoji-picker-K4DOKYL3.js.map} +2 -2
- package/pb_public/assets/forward-OR7S3EHR.js +2 -0
- package/pb_public/assets/forward-OR7S3EHR.js.br +0 -0
- package/pb_public/assets/forward-OR7S3EHR.js.gz +0 -0
- package/pb_public/assets/forward-OR7S3EHR.js.map +7 -0
- package/pb_public/assets/inbox-2AXY3INA.css +2 -0
- package/pb_public/assets/inbox-2AXY3INA.css.br +0 -0
- package/pb_public/assets/inbox-2AXY3INA.css.gz +0 -0
- package/pb_public/assets/inbox-2AXY3INA.css.map +7 -0
- package/pb_public/assets/{inbox-CLMYESNI.js → inbox-A46J7ZU2.js} +2 -2
- package/pb_public/assets/inbox-A46J7ZU2.js.br +0 -0
- package/pb_public/assets/inbox-A46J7ZU2.js.gz +0 -0
- package/pb_public/assets/{inbox-CLMYESNI.js.map → inbox-A46J7ZU2.js.map} +2 -2
- package/pb_public/assets/{invite-OGT5E2MZ.js → invite-VGT2DI2L.js} +2 -2
- package/pb_public/assets/invite-VGT2DI2L.js.br +0 -0
- package/pb_public/assets/invite-VGT2DI2L.js.gz +0 -0
- package/pb_public/assets/invite-api-7G7XPXQW.js.br +0 -0
- package/pb_public/assets/invite-api-7G7XPXQW.js.gz +0 -0
- package/pb_public/assets/lazy-OVEJT5CP.js +2 -0
- package/pb_public/assets/lazy-OVEJT5CP.js.br +0 -0
- package/pb_public/assets/lazy-OVEJT5CP.js.gz +0 -0
- package/pb_public/assets/lazy-OVEJT5CP.js.map +7 -0
- package/pb_public/assets/{login-TK6K4WGB.js → login-TN6R7N2U.js} +2 -2
- package/pb_public/assets/login-TN6R7N2U.js.br +0 -0
- package/pb_public/assets/login-TN6R7N2U.js.gz +0 -0
- package/pb_public/assets/media-BCKZQR2R.css +2 -0
- package/pb_public/assets/media-BCKZQR2R.css.br +0 -0
- package/pb_public/assets/media-BCKZQR2R.css.gz +0 -0
- package/pb_public/assets/media-BCKZQR2R.css.map +7 -0
- package/pb_public/assets/{media-WZ4653L5.js → media-VCJWBQJZ.js} +2 -2
- package/pb_public/assets/media-VCJWBQJZ.js.br +0 -0
- package/pb_public/assets/media-VCJWBQJZ.js.gz +0 -0
- package/pb_public/assets/{mention-suggest-ODJD2IC5.js → mention-suggest-K3UUHR4D.js} +2 -2
- package/pb_public/assets/mention-suggest-K3UUHR4D.js.br +0 -0
- package/pb_public/assets/mention-suggest-K3UUHR4D.js.gz +0 -0
- package/pb_public/assets/notify-EPDM772N.js.br +0 -0
- package/pb_public/assets/notify-EPDM772N.js.gz +0 -0
- package/pb_public/assets/pins-DSUFB5EW.css +2 -0
- package/pb_public/assets/pins-DSUFB5EW.css.br +0 -0
- package/pb_public/assets/pins-DSUFB5EW.css.gz +0 -0
- package/pb_public/assets/pins-DSUFB5EW.css.map +7 -0
- package/pb_public/assets/pins-XWBYZN4P.js +2 -0
- package/pb_public/assets/pins-XWBYZN4P.js.br +0 -0
- package/pb_public/assets/pins-XWBYZN4P.js.gz +0 -0
- package/pb_public/assets/pins-XWBYZN4P.js.map +7 -0
- package/pb_public/assets/profile-NQ6QCQIB.js +2 -0
- package/pb_public/assets/profile-NQ6QCQIB.js.br +0 -0
- package/pb_public/assets/profile-NQ6QCQIB.js.gz +0 -0
- package/pb_public/assets/profile-NQ6QCQIB.js.map +7 -0
- package/pb_public/assets/rooms-forms-NYMPXVUQ.js +2 -0
- package/pb_public/assets/rooms-forms-NYMPXVUQ.js.br +0 -0
- package/pb_public/assets/rooms-forms-NYMPXVUQ.js.gz +0 -0
- package/pb_public/assets/rooms-forms-NYMPXVUQ.js.map +7 -0
- package/pb_public/assets/search-HOPAWIMQ.js +2 -0
- package/pb_public/assets/search-HOPAWIMQ.js.br +0 -0
- package/pb_public/assets/search-HOPAWIMQ.js.gz +0 -0
- package/pb_public/assets/search-HOPAWIMQ.js.map +7 -0
- package/pb_public/assets/sidebar-forms-ETSRVSPY.css +2 -0
- package/pb_public/assets/sidebar-forms-ETSRVSPY.css.br +0 -0
- package/pb_public/assets/sidebar-forms-ETSRVSPY.css.gz +0 -0
- package/pb_public/assets/sidebar-forms-ETSRVSPY.css.map +7 -0
- package/pb_public/assets/stats-5GSWDHZI.css +2 -0
- package/pb_public/assets/stats-5GSWDHZI.css.br +0 -0
- package/pb_public/assets/stats-5GSWDHZI.css.gz +0 -0
- package/pb_public/assets/stats-5GSWDHZI.css.map +7 -0
- package/pb_public/assets/{stats-GTO2H6PG.js → stats-Y3LIXAZR.js} +2 -2
- package/pb_public/assets/stats-Y3LIXAZR.js.br +0 -0
- package/pb_public/assets/stats-Y3LIXAZR.js.gz +0 -0
- package/pb_public/assets/stats-Y3LIXAZR.js.map +7 -0
- package/pb_public/assets/switcher-TFSO45KV.js.br +0 -0
- package/pb_public/assets/switcher-TFSO45KV.js.gz +0 -0
- package/pb_public/assets/user-search-GUNMIBSB.js +2 -0
- package/pb_public/assets/user-search-GUNMIBSB.js.br +0 -0
- package/pb_public/assets/user-search-GUNMIBSB.js.gz +0 -0
- package/pb_public/assets/{viewer-2Y5FJBW4.js → viewer-BHKVAADP.js} +2 -2
- package/pb_public/assets/viewer-BHKVAADP.js.br +0 -0
- package/pb_public/assets/viewer-BHKVAADP.js.gz +0 -0
- package/pb_public/assets/viewer-JBZU46HP.css +2 -0
- package/pb_public/assets/viewer-JBZU46HP.css.br +0 -0
- package/pb_public/assets/viewer-JBZU46HP.css.gz +0 -0
- package/pb_public/assets/{viewer-P7GYCBYM.css.map → viewer-JBZU46HP.css.map} +2 -2
- package/pb_public/index.html +9 -8
- package/pb_public/stats.html +3 -3
- package/scripts/service.mjs +1 -1
- package/scripts/start.mjs +2 -1
- package/pb_public/assets/access-GPRLOZOO.css +0 -2
- package/pb_public/assets/access-GPRLOZOO.css.map +0 -7
- package/pb_public/assets/account-CT2BVMAX.css +0 -2
- package/pb_public/assets/account-CT2BVMAX.css.map +0 -7
- package/pb_public/assets/app-HB3NZHQ2.js +0 -3
- package/pb_public/assets/app-HB3NZHQ2.js.map +0 -7
- package/pb_public/assets/app-XJ73EU5O.css +0 -2
- package/pb_public/assets/app-XJ73EU5O.css.map +0 -7
- package/pb_public/assets/chunk-56ACD3V5.js +0 -2
- package/pb_public/assets/chunk-56ACD3V5.js.map +0 -7
- package/pb_public/assets/chunk-DZC4SY4M.js +0 -2
- package/pb_public/assets/chunk-DZC4SY4M.js.map +0 -7
- package/pb_public/assets/chunk-N2OFGBCZ.js +0 -2
- package/pb_public/assets/chunk-N2OFGBCZ.js.map +0 -7
- package/pb_public/assets/chunk-OKIIBH7O.js +0 -2
- package/pb_public/assets/chunk-OKIIBH7O.js.map +0 -7
- package/pb_public/assets/chunk-WR25F7FU.js +0 -2
- package/pb_public/assets/chunk-WR25F7FU.js.map +0 -7
- package/pb_public/assets/collections-DHJEOLHW.css +0 -2
- package/pb_public/assets/collections-DHJEOLHW.css.map +0 -7
- package/pb_public/assets/emoji-WWNPWCF3.css +0 -2
- package/pb_public/assets/emoji-WWNPWCF3.css.map +0 -7
- package/pb_public/assets/forward-267HRNPY.js +0 -2
- package/pb_public/assets/forward-267HRNPY.js.map +0 -7
- package/pb_public/assets/inbox-3FSOPY2T.css +0 -2
- package/pb_public/assets/inbox-3FSOPY2T.css.map +0 -7
- package/pb_public/assets/lazy-H3KIJVB5.js +0 -2
- package/pb_public/assets/lazy-H3KIJVB5.js.map +0 -7
- package/pb_public/assets/media-7TCBG7WM.css +0 -2
- package/pb_public/assets/media-7TCBG7WM.css.map +0 -7
- package/pb_public/assets/profile-3R6S5QYS.js +0 -2
- package/pb_public/assets/profile-3R6S5QYS.js.map +0 -7
- package/pb_public/assets/search-WCHOGAJQ.js +0 -2
- package/pb_public/assets/search-WCHOGAJQ.js.map +0 -7
- package/pb_public/assets/stats-A2TBRUI6.css +0 -2
- package/pb_public/assets/stats-A2TBRUI6.css.map +0 -7
- package/pb_public/assets/stats-GTO2H6PG.js.map +0 -7
- package/pb_public/assets/user-search-3HQOCQWL.js +0 -2
- package/pb_public/assets/viewer-P7GYCBYM.css +0 -2
- /package/pb_public/assets/{access-UK3L54NR.js.map → access-23A7N3OD.js.map} +0 -0
- /package/pb_public/assets/{invite-OGT5E2MZ.js.map → invite-VGT2DI2L.js.map} +0 -0
- /package/pb_public/assets/{login-TK6K4WGB.js.map → login-TN6R7N2U.js.map} +0 -0
- /package/pb_public/assets/{media-WZ4653L5.js.map → media-VCJWBQJZ.js.map} +0 -0
- /package/pb_public/assets/{mention-suggest-ODJD2IC5.js.map → mention-suggest-K3UUHR4D.js.map} +0 -0
- /package/pb_public/assets/{user-search-3HQOCQWL.js.map → user-search-GUNMIBSB.js.map} +0 -0
- /package/pb_public/assets/{viewer-2Y5FJBW4.js.map → viewer-BHKVAADP.js.map} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as i}from"./chunk-VTOUI25E.js";var ne="/api/collections/collections/records",P=n=>JSON.stringify(n),Pe="id,collection,file,name,video,poster,created";function R(n){return{get:(e,r)=>n.request(`${ne}/${e}`,{query:{expand:"owner",fields:"id,name,public,owner,items,expand.owner.name"},signal:r}),create:(e,r,o)=>n.request(ne,{method:"POST",body:{owner:e,name:r,public:o},query:{fields:"id"}}),update:(e,r)=>n.request(`${ne}/${e}`,{method:"PATCH",body:r,query:{fields:"name,public"}}),remove:e=>n.request(`${ne}/${e}`,{method:"DELETE"}),async items(e,r,o,d=!1){let p=d?">":"<",g=r?` && (created ${p} ${P(r.created)} || (created = ${P(r.created)} && id ${p} ${P(r.id)}))`:"",x={filter:`collection = ${P(e)}${g}`,sort:"-created,-id",perPage:61,skipTotal:!0,fields:Pe},{items:u}=await n.request("/api/collections/collection_items/records",{query:x,signal:o});return{items:u.slice(0,60),more:u.length>60}},async idsSince(e,r,o){let d=new Set,p=`collection = ${P(e)} && (created > ${P(r.created)} || (created = ${P(r.created)} && id >= ${P(r.id)}))`;for(let g=1;;g++){let x={filter:p,sort:"-created,-id",page:g,perPage:1e3,skipTotal:!0,fields:"id"},{items:u}=await n.request("/api/collections/collection_items/records",{query:x,signal:o});for(let T of u)d.add(T.id);if(u.length<1e3)return d}},save:(e,r)=>n.request("/api/chat/items",{method:"POST",body:{collection:e,...r}}),upload:(e,r,o)=>n.request("/api/chat/items",{method:"POST",body:{collection:e,file:r},onUpload:o}),unsave:e=>n.request(`/api/chat/items/${e}`,{method:"DELETE"}),savedIn:(e,r)=>n.request("/api/chat/saved",{query:e,signal:r}),follow:(e,r)=>n.request("/api/chat/subs",{method:"POST",body:{collection:e,on:r}})}}async function Re(n,e,r){let{id:o}=await R(n.api).create(n.me()?.id??"",e,r);return n.service.refresh(),o}var ae=n=>`${n} ${n===1?"item":"items"}`,Ce=(n,e)=>`Delete \u201C${n}\u201D${e?` and its ${ae(e)}`:""}? This can't be undone.`;var le=null;function G(){return le??=new Promise(n=>{let r=i("link",{rel:"stylesheet",href:"/assets/collections-FZB6G4W4.css",on:{load:()=>n(),error:()=>{r.remove(),le=null,n()}}});document.head.append(r)}),le}var xe=/\.(jpe?g|png|gif|webp|avif|mp4|m4v|webm|mov|ogv)$/i,Ee=".jpg,.jpeg,.png,.gif,.webp,.avif,.mp4,.m4v,.webm,.mov,.ogv",ye=20*1024*1024,N=n=>n.list()??{mine:[],subs:[]};function ce(n,e){return new Promise(r=>{let o=()=>{d(),clearTimeout(p),r()},d=n.watch(o),p=setTimeout(o,e)})}function V(n){let e=n;return e?.status===0?"Can't reach the server. Check your connection.":Object.values(e?.fields??{})[0]||e?.message||"Something went wrong."}var D=()=>i("span",{class:"ci","aria-hidden":"true"}),Se=new Intl.DateTimeFormat(void 0,{month:"long",year:"numeric"}),Te=n=>new Date(n.replace(" ","T"));function de(n){let{id:e,created:r,file:o,name:d}=n;return{id:e,room:"",author:"",text:"",created:r,updated:r,edited_at:"",deleted:!1,files:[o],file_names:{[o]:d}}}function oe(n,e,r){if(e.video&&!e.poster)return null;let o=i("img",{src:e.video?n.api.itemPosterUrl(e):n.api.itemUrl(e,"240x240"),alt:"",loading:"lazy",decoding:"async"});return e.video&&o.addEventListener("error",()=>o.remove(),{signal:r}),o}function z(n,e,r){let o=[],d=!1,p=null;return{items:o,get done(){return d},next(){return d?Promise.resolve([]):(p??=R(n.api).items(e,o.at(-1),r).then(g=>(p=null,d=!g.more,o.push(...g.items),g.items),g=>{throw p=null,g}),p)}}}var me=null;async function ie(n){me?.();let e=R(n.api),r=new AbortController,{signal:o}=r;n.signal.addEventListener("abort",()=>A(),{signal:o});let d=i("h2",{id:"coll-save-title"},[D()," Save to collection"]),p=i("ul",{class:"coll-choices"}),g=i("p",{class:"coll-status",role:"status"},"Loading\u2026"),x=i("input",{placeholder:"New collection","aria-label":"New collection name",autocomplete:"off"}),u=i("form",{class:"coll-new-form",on:{submit:async b=>{if(b.preventDefault(),!!x.value.trim())try{let a=(await e.create(n.me()?.id??"",x.value,!1)).id;x.value="",await M(a,!0)}catch(a){g.textContent=V(a)}}},signal:o},[x,i("button",{type:"submit"},"Create")]),T=i("dialog",{class:"coll-dialog coll-save","aria-labelledby":d.id},[i("header",{class:"media-bar"},[d,i("button",{type:"button",class:"icon-button ic i-x","aria-label":"Close",on:{click:()=>A()},signal:o})]),i("div",{class:"coll-body"},[p,g,u])]),E={},y=new Map;async function M(b,a){y.set(b,a),g.textContent=a?"Saving\u2026":"Removing\u2026",h();try{a?E[b]=(await e.save(b,n.from)).id:E[b]&&(await e.unsave(E[b]),delete E[b]),g.textContent=a?"Saved.":"Removed.",n.service.refresh()}catch(C){C.status===409?E=await e.savedIn(n.from,o).catch(()=>E):g.textContent=V(C)}y.delete(b),h()}function h(){let b=N(n).mine;p.replaceChildren(...b.map(a=>{let C=i("input",{type:"checkbox",checked:y.get(a.id)??!!E[a.id],disabled:y.has(a.id)});return C.addEventListener("change",()=>{M(a.id,C.checked)},{signal:o}),i("li",{"aria-busy":y.has(a.id)?"true":"false"},i("label",{},[C," ",a.name,i("span",{class:"coll-meta"},a.public?" \xB7 Public: anyone can see it":" \xB7 Private"),y.has(a.id)?i("span",{class:"coll-spin","aria-hidden":"true"}):null]))})),!b.length&&g.textContent===""&&(g.textContent="You have no collections yet. Make one:")}function A(){o.aborted||(r.abort(),me=null,T.open&&T.close(),T.remove(),n.opener.setAttribute("aria-expanded","false"),n.opener.focus())}if(me=A,T.addEventListener("close",()=>A(),{signal:o}),o.addEventListener("abort",n.watch(h),{once:!0}),await G(),!o.aborted){document.body.append(T),T.showModal(),n.opener.setAttribute("aria-expanded","true");try{E=await e.savedIn(n.from,o),g.textContent=""}catch(b){if(o.aborted)return;g.textContent=V(b)}h(),(p.querySelector("input")??x).focus()}}async function He(n,e){let{api:r,signal:o,id:d}=e,p=R(r),[,g]=await Promise.all([G(),p.get(d,o).catch(()=>null),(async()=>{e.me()&&!e.list()&&await ce(e,2e3)})()]);if(o.aborted)return;function x(){n.replaceChildren(i("section",{class:"collection not-found"},[i("h1",{},[D()," This collection doesn't exist."]),i("p",{},["It may be private, or deleted. ",i("a",{href:"/"},"Back to rooms")])]))}if(!g)return x();let u=g,T=e.me(),E=!!T&&u.owner===T.id,y=g.expand?.owner?.name??"",M=N(e).subs.find(t=>t.id===d)?.seen_at??"",h=z(e,d,o),A=i("h1",{id:"coll-title"}),b=i("p",{class:"coll-meta"}),a=i("div",{class:"coll-actions"}),C=i("p",{class:"coll-notice",role:"status"}),Y=i("p",{class:"coll-new",hidden:!0}),L=i("div",{class:"media-grid coll-grid"}),O=i("p",{class:"media-status",role:"status"});n.replaceChildren(i("section",{class:"collection","aria-labelledby":"coll-title"},[i("header",{class:`coll-head t${d.charCodeAt(0)%4}`},[i("a",{href:"/",class:"back ic i-back","aria-label":"Back to rooms"}),A,b,a,C]),Y,L,O]));let H=(t,s)=>{C.textContent=`${t} ${V(s)}`},_=(t,s,l="")=>i("button",{type:"button",class:l,on:{click:()=>{s()}},signal:o},t),B=()=>E?"Nothing here yet. Upload images and videos, or save them from the chat.":"Nothing here yet.",$=[],k=0,c=!1,S=[],U=i("input",{type:"file",multiple:!0,accept:Ee,hidden:!0,on:{change:()=>{se([...U.files??[]]),U.value=""}},signal:o});function se(t){for(let s of t)xe.test(s.name)?s.size>ye?S.push(`${s.name}: larger than 20 MB`):$.push(s):S.push(`${s.name}: not an image or video`);if(!c){if(!$.length)return ue();c=!0,(async()=>{for(;$.length&&!o.aborted;){let s=$[0],l=`Uploading ${k+1} of ${k+$.length}\u2026`;C.textContent=l;try{await p.upload(d,s,f=>C.textContent=`${l} ${Math.round(f*100)}%`)}catch(f){if(f.status===429){C.textContent="Waiting for the server\u2026",await new Promise(m=>setTimeout(m,1e4));continue}S.push(`${s.name}: ${V(f)}`)}$.shift(),k++,e.service.refresh()}k=0,c=!1,ue()})()}}function ue(){C.textContent=S.length?`Couldn't upload ${S.join("; ")}`:"",S=[]}let X=!1,j="",J="";function Q(){X=!1,J="",F()}async function pe(t){try{return u={...u,...await p.update(d,t)},C.textContent="",e.service.refresh(),Q(),!0}catch(s){return H("Couldn't save.",s),!1}}function Le(){X=!0,j="Rename";let t=i("input",{value:u.name,"aria-label":"Collection name",autocomplete:"off"}),s=i("form",{class:"coll-rename",on:{submit:l=>{l.preventDefault(),pe({name:t.value})},keydown:l=>l.key==="Escape"&&Q()},signal:o},[t,i("button",{type:"submit"},"Save"),_("Cancel",Q,"link")]);a.replaceChildren(s),t.focus(),t.select()}function _e(){X=!0,j="Delete",a.replaceChildren(i("span",{},Ce(u.name,u.items)),_("Delete collection",async()=>{try{await p.remove(d),e.service.refresh(),e.navigate("/")}catch(t){H("Couldn't delete it.",t)}},"danger"),_("Cancel",Q,"link")),a.querySelector("button")?.focus()}function F(){if(o.aborted)return;A.replaceChildren(D()," ",u.name),b.textContent=[E?"Yours":y&&`By ${y}`,u.public?"Public":"Private",ae(u.items)].filter(Boolean).join(" \xB7 ");let t=N(e).subs.some(m=>m.id===d),s=[u.public,t].join();if(X||s===J)return;J=s;let l=[...a.children].findIndex(m=>m.contains(document.activeElement));if(E)a.replaceChildren(_("Upload",()=>U.click()),_("Rename",Le),_(u.public?"Make private":"Make public",()=>pe({public:!u.public})),_("Delete",_e,"danger"));else if(T&&(u.public||t)){let m=_(t?"Unsubscribe":"Subscribe",async()=>{m.disabled=!0;try{await p.follow(d,!t),e.service.refresh(),await ce(e,1e3)}catch(w){H(t?"unsubscribe":"subscribe",w)}J="",F()});m.setAttribute("aria-pressed",String(t)),a.replaceChildren(m)}else a.replaceChildren();let f=[...a.children];l>=0&&(f.find(m=>j&&m.textContent===j)??f[l])?.focus(),j=""}if(F(),E){n.firstElementChild.append(U);let t=s=>s.dataTransfer?.types.includes("Files");n.addEventListener("dragover",s=>t(s)&&s.preventDefault(),{signal:o}),n.addEventListener("drop",s=>{t(s)&&(s.preventDefault(),se([...s.dataTransfer?.files??[]]))},{signal:o}),document.addEventListener("paste",s=>{let l=[...s.clipboardData?.files??[]];!l.length||document.querySelector("dialog[open]")||(s.preventDefault(),se(l))},{signal:o})}let W="";function re(){if(!W||document.visibilityState!=="visible"||!N(e).subs.some(s=>s.id===d))return;let t=W;W="",queueMicrotask(()=>o.aborted||e.service.seen(d,t))}document.addEventListener("visibilitychange",re,{signal:o});let fe=()=>[...N(e).mine,...N(e).subs].find(t=>t.id===d),q=fe();function Ie(){let t=fe();t?(u={...u,name:t.name,public:t.public,items:t.items},q&&t.last_added!==q.last_added&&ke(),q&&t.items<q.items+(t.last_added!==q.last_added?1:0)&&Ne(),t.new&&(W=t.last_added,re())):q&&p.get(d,o).then(s=>{u={...u,...s},F()},s=>s.status===404&&x()),q=t,F()}o.addEventListener("abort",e.watch(Ie),{once:!0});let K="",Z=0;function ge(t,s=!1){let l=Se.format(Te(t.created)),f=s||!!M&&t.created>M;f&&!s&&Z++;let m=`${t.name}${t.video?", video":""}${f?", new":""}`,w=i("button",{type:"button",class:"media-tile","aria-label":m,title:t.name,on:{click:()=>{Me(t,w)}},signal:o},[oe(e,t,o),t.video&&i("span",{class:"att-play","aria-hidden":"true"})]),v=i("div",{class:`coll-cell${f?" new":""}`,dataset:{item:t.id}},[w]);if(T){let I=i("button",{type:"button",class:"att-save","aria-label":`Save ${t.name} to collection`,title:"Save to collection",on:{click:()=>ie({...e,from:{item:t.id},opener:I})},signal:o},D());v.append(I)}E&&v.append(i("button",{type:"button",class:"coll-remove","aria-label":`Remove ${t.name} from the collection`,title:"Remove from collection",on:{click:()=>{Ae(t,v)}},signal:o},"\xD7")),s?L.firstElementChild?.textContent===l?L.firstElementChild.after(v):(L.prepend(i("h2",{},l),v),K||=l):(l!==K&&L.append(i("h2",{},l)),K=l,L.append(v))}async function Ae(t,s){try{await p.unsave(t.id)}catch(w){return H("Couldn't remove it.",w)}let l=[...L.querySelectorAll(".coll-cell")],f=l.indexOf(s),m=l[f+1]??l[f-1];he(t),u={...u,items:Math.max(0,u.items-1)},F(),(m?.querySelector(".coll-remove")??a.querySelector("button"))?.focus(),e.service.refresh()}function he(t){let s=h.items.indexOf(t);if(s<0)return;h.items.splice(s,1);let l=[...L.querySelectorAll(".coll-cell")].find(f=>f.dataset.item===t.id);if(l){let[f,m]=[l.previousElementSibling,l.nextElementSibling];l.contains(document.activeElement)&&(m?.querySelector("button")??a.querySelector("button"))?.focus(),l.remove(),f?.tagName==="H2"&&(!m||m.tagName==="H2")&&(f.remove(),m||(K=""))}h.done&&!h.items.length&&(O.textContent=B())}let be=0;async function Ne(){let t=++be,s=[...h.items],l=s.at(-1),f=l&&await p.idsSince(d,l,o).catch(()=>null);if(!(!f||t!==be||o.aborted))for(let m of s.filter(w=>!f.has(w.id)))he(m)}async function ee(){let t=h;if(!t.done){O.textContent="Loading\u2026";try{let s=await t.next();if(o.aborted||t!==h)return;for(let l of s)ge(l);O.textContent=t.done&&!t.items.length?B():""}catch{if(o.aborted||t!==h)return;te.unobserve(O),O.replaceChildren("Couldn't load the collection. ",_("Retry",()=>{ee()},"link"));return}te.unobserve(O),t.done||te.observe(O)}}function ve(){return h=z(e,d,o),L.replaceChildren(),K="",ee()}async function ke(){let t=h.items[0];if(!t)return ve();let s=await p.items(d,t,o,!0).catch(()=>null);if(!s||o.aborted)return;if(s.more)return ve();let l=new Set(h.items.map(m=>m.id)),f=s.items.filter(m=>!l.has(m.id));h.items.unshift(...f);for(let m of f.reverse())ge(m,!0);f.length&&(O.textContent="")}async function Me(t,s){let f=[...h.items].reverse().map(w=>({message:de(w),file:w.file,video:w.video})),m=h;try{let{openViewer:w}=await import("./viewer-BHKVAADP.js");if(o.aborted)return;await w({images:f,start:f.findIndex(v=>v.message.id===t.id),more:[!m.done,!1],page:async v=>({messages:(v?await m.next():[]).map(de).reverse(),done:!v||m.done}),media:v=>[{message:v,file:v.files[0],video:m.items.find(I=>I.id===v.id)?.video??!1}],name:(v,I)=>v.file_names?.[I]??I,when:v=>`Added ${e.when(v.created)}`,fileUrl:(v,I)=>r.itemUrl({id:v.id,file:I}),...T?{onSave:(v,I,$e)=>ie({...e,from:{item:v.id},opener:$e})}:{},opener:s,follow:()=>{},signal:o})}catch{window.open(r.itemUrl(t),"_blank","noopener")}}let te=new IntersectionObserver(t=>t.some(s=>s.isIntersecting)&&void ee(),{rootMargin:"400px"});o.addEventListener("abort",()=>te.disconnect(),{once:!0}),await ee(),!o.aborted&&(Z&&(Y.hidden=!1,Y.textContent=`${Z>=60?"60+":Z} new since your last visit`),W=h.items[0]?.created??"",re())}var we=(n,e)=>`${n} picked${e?" (the most a message takes)":""}`,Oe=(n,e)=>`${n}${e?", video":""}`;async function Ue(n){let e=new AbortController,{signal:r}=e;n.signal.addEventListener("abort",()=>k(),{signal:r});let{mine:o,subs:d}=N(n),p=[...o,...d],g=i("h2",{id:"coll-pick-title"},[D()," Attach from collections"]),x=p[0]?.id??"",u=p.map(c=>i("button",{type:"button",class:"coll-chip","aria-pressed":String(c.id===x),on:{click:S=>_(c.id,S.currentTarget)},signal:r},c.owner?`${c.name} \xB7 ${c.owner.name}`:c.name)),T=i("div",{class:"coll-chips",role:"group","aria-label":"Collection"},u),E=i("div",{class:"media-grid coll-grid"}),y=i("p",{class:"media-status",role:"status"}),M=i("span",{class:"coll-count","aria-live":"polite"}),h=i("button",{type:"button",disabled:!0,on:{click:()=>$()},signal:r},"Attach"),A=i("div",{class:"coll-body"},[E,y]),b=i("dialog",{class:"coll-dialog coll-pick","aria-labelledby":g.id},[i("header",{class:"media-bar"},[g,i("button",{type:"button",class:"icon-button ic i-x","aria-label":"Close",on:{click:()=>k()},signal:r})]),p.length?T:null,A,i("footer",{class:"coll-foot"},[M,h])]),a=new Map,C=z(n,"",r);function Y(){M.textContent=a.size?we(a.size,a.size>=n.max):n.max?"":"The message has all the files it can take.",h.disabled=!a.size,h.textContent=a.size?`Attach ${a.size}`:"Attach"}function L(c){let S=i("button",{type:"button",class:"media-tile","aria-label":Oe(c.name,c.video),title:c.name,"aria-pressed":String(a.has(c.id)),on:{click:()=>{a.has(c.id)?a.delete(c.id):a.size<n.max&&a.set(c.id,c),S.setAttribute("aria-pressed",String(a.has(c.id))),Y()}},signal:r},[oe(n,c,r),c.video&&i("span",{class:"att-play","aria-hidden":"true"})]);return S}async function O(){if(C.done||!x)return;let c=C;y.textContent="Loading\u2026";try{let S=await c.next();if(r.aborted||c!==C)return;E.append(...S.map(L)),y.textContent=c.done&&!c.items.length?"Nothing in this collection yet.":""}catch{if(r.aborted||c!==C)return;B.unobserve(y),y.replaceChildren("Couldn't load the collection. ",i("button",{type:"button",class:"link",on:{click:()=>{O()}},signal:r},"Retry"));return}B.unobserve(y),c.done||B.observe(y)}function H(){C=z(n,x,r),E.replaceChildren(),O()}function _(c,S){if(c!==x){x=c;for(let U of u)U.setAttribute("aria-pressed",String(U===S));S.scrollIntoView({block:"nearest",inline:"nearest"}),H()}}let B=new IntersectionObserver(c=>c.some(S=>S.isIntersecting)&&void O(),{root:A,rootMargin:"400px"});function $(){let c=[...a.values()];k(),c.length&&n.onPick(c)}function k(){r.aborted||(e.abort(),B.disconnect(),b.open&&b.close(),b.remove(),n.opener.focus())}if(b.addEventListener("close",()=>k(),{signal:r}),await G(),!r.aborted){if(document.body.append(b),b.showModal(),Y(),!p.length){y.textContent="You have no collections yet. Save images and videos from the chat to one first.";return}H(),u[0]?.focus()}}export{Re as createCollection,He as mountCollection,Ue as openPicker,ie as openSave};
|
|
2
|
+
//# sourceMappingURL=lazy-OVEJT5CP.js.map
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../web/src/views/collection/calls.ts", "../../web/src/views/collection/create.ts", "../../web/src/strings/collection-page.ts", "../../web/src/views/collection/shared.ts", "../../web/src/views/collection/save.ts", "../../web/src/views/collection/page.ts", "../../web/src/strings/collection-picker.ts", "../../web/src/views/collection/picker.ts"],
|
|
4
|
+
"sourcesContent": ["// The collections' requests (\u00A731), through Api.request: app.js doesn't carry them. ITEM_FIELDS is shared/contract.json's\n// (tests/unit/contract.test.ts).\n\nimport type { Api } from \"../../api.ts\";\nimport type { CollectionItem } from \"../../lib/types.ts\";\n\n/** What a collection's page shows of it. */\nexport interface Meta {\n id: string;\n name: string;\n public: boolean;\n owner: string;\n items: number;\n}\n\n/** A message's file (the one that has it: a forward's original, \u00A721.3), or an item. */\nexport type From = { message: string; file: string } | { item: string };\n\n/** A collection's page of items, as the media grid's (\u00A730.2). */\nexport const PAGE = 60;\n\nexport const RECORDS = \"/api/collections/collections/records\";\n\n/** A value in a records filter (ids and dates here), quoted and escaped. */\nexport const lit = (v: string) => JSON.stringify(v);\n\n/** What a page of items asks for (shared/contract.json). */\nexport const ITEM_FIELDS = \"id,collection,file,name,video,poster,created\";\n\n/** The requests of the page, the menu and the picker. */\nexport function calls(api: Api) {\n return {\n /** The collection, with its owner's name (guests can't look users up). */\n get: (id: string, signal: AbortSignal) =>\n api.request<Meta & { expand?: { owner?: { name: string } } }>(`${RECORDS}/${id}`, {\n query: { expand: \"owner\", fields: \"id,name,public,owner,items,expand.owner.name\" },\n signal,\n }),\n create: (owner: string, name: string, isPublic: boolean) =>\n api.request<{ id: string }>(RECORDS, { method: \"POST\", body: { owner, name, public: isPublic }, query: { fields: \"id\" } }),\n update: (id: string, body: { name?: string; public?: boolean }) =>\n api.request<Pick<Meta, \"name\" | \"public\">>(`${RECORDS}/${id}`, { method: \"PATCH\", body, query: { fields: \"name,public\" } }),\n remove: (id: string) => api.request(`${RECORDS}/${id}`, { method: \"DELETE\" }),\n /**\n * A page of a collection's items, newest first: older than `after` (the oldest shown), or the newest; with\n * `newer`, those added after `after` (the newest shown).\n */\n async items(collection: string, after: CollectionItem | undefined, signal: AbortSignal, newer = false) {\n const op = newer ? \">\" : \"<\";\n const cursor = after\n ? ` && (created ${op} ${lit(after.created)} || (created = ${lit(after.created)} && id ${op} ${lit(after.id)}))`\n : \"\";\n const query = {\n filter: `collection = ${lit(collection)}${cursor}`,\n sort: \"-created,-id\",\n perPage: PAGE + 1,\n skipTotal: true,\n fields: ITEM_FIELDS,\n };\n const { items } = await api.request<{ items: CollectionItem[] }>(\"/api/collections/collection_items/records\", { query, signal });\n return { items: items.slice(0, PAGE), more: items.length > PAGE };\n },\n /** The ids of a collection's items from `oldest` on (it included): which of those shown are still there. */\n async idsSince(collection: string, oldest: CollectionItem, signal: AbortSignal) {\n const ids = new Set<string>();\n const filter = `collection = ${lit(collection)} && (created > ${lit(oldest.created)} || (created = ${lit(oldest.created)} && id >= ${lit(oldest.id)}))`;\n for (let page = 1; ; page++) {\n const query = { filter, sort: \"-created,-id\", page, perPage: 1000, skipTotal: true, fields: \"id\" };\n const { items } = await api.request<{ items: { id: string }[] }>(\"/api/collections/collection_items/records\", { query, signal });\n for (const x of items) ids.add(x.id);\n if (items.length < 1000) return ids;\n }\n },\n /** A copy of a message's file or of an item in a collection of yours. 409: it is in there already. */\n save: (collection: string, from: From) =>\n api.request<CollectionItem>(\"/api/chat/items\", { method: \"POST\", body: { collection, ...from } }),\n /** An image or video of your own, uploaded straight into a collection of yours. */\n upload: (collection: string, file: File, onUpload: (fraction: number) => void) =>\n api.request<CollectionItem>(\"/api/chat/items\", { method: \"POST\", body: { collection, file }, onUpload }),\n unsave: (item: string) => api.request(`/api/chat/items/${item}`, { method: \"DELETE\" }),\n /** Your collections that have the file already: collection id \u2192 item id. */\n savedIn: (from: From, signal: AbortSignal) => api.request<Record<string, string>>(\"/api/chat/saved\", { query: from, signal }),\n follow: (collection: string, on: boolean) => api.request(\"/api/chat/subs\", { method: \"POST\", body: { collection, on } }),\n };\n}\n", "// A new collection (\u00A731), from the sidebar's inline form (views/rooms.ts): made, and the list asked for again.\n\nimport { calls } from \"./calls.ts\";\nimport type { Base } from \"./shared.ts\";\n\n/** Makes a collection of yours; resolves to its id. */\nexport async function createCollection(o: Pick<Base, \"api\" | \"service\" | \"me\">, name: string, isPublic: boolean): Promise<string> {\n const { id } = await calls(o.api).create(o.me()?.id ?? \"\", name, isPublic);\n o.service.refresh();\n return id;\n}\n", "// The user-facing text of views/collection/page.ts (docs/REFACTOR.md item 56): one module per source file, so a lazy\n// screen's text stays in its own chunk. Copy changes here; a translation would replace these.\n\nexport const BACK_TO_ROOMS = \"Back to rooms\";\nexport const IT_MAY_BE_PRIVATE_OR_DELETED = \"It may be private, or deleted. \";\nexport const COULDNT_SAVE = \"Couldn't save.\";\nexport const COULDNT_DELETE_IT = \"Couldn't delete it.\";\nexport const COULDNT_REMOVE_IT = \"Couldn't remove it.\";\nexport const NOTHING_HERE_YET = \"Nothing here yet.\";\nexport const NOTHING_HERE_YET_UPLOAD_IMAGES_AND = \"Nothing here yet. Upload images and videos, or save them from the chat.\";\nexport const uploadingOf = (n: string | number, total: string | number) => `Uploading ${n} of ${total}\u2026`;\nexport const WAITING_FOR_THE_SERVER = \"Waiting for the server\u2026\";\nexport const couldntUpload = (files: string | number) => `Couldn't upload ${files}`;\nexport const RENAME = \"Rename\";\nexport const COLLECTION_NAME = \"Collection name\";\nexport const CANCEL = \"Cancel\";\nexport const SAVE = \"Save\";\nexport const DELETE = \"Delete\";\nexport const DELETE_COLLECTION = \"Delete collection\";\nexport const PRIVATE = \"Private\";\nexport const PUBLIC = \"Public\";\nexport const by = (ownerName: string | number) => `By ${ownerName}`;\nexport const YOURS = \"Yours\";\nexport const UPLOAD = \"Upload\";\nexport const MAKE_PUBLIC = \"Make public\";\nexport const MAKE_PRIVATE = \"Make private\";\nexport const SUBSCRIBE = \"Subscribe\";\nexport const UNSUBSCRIBE = \"Unsubscribe\";\nexport const saveToCollection = (name: string | number) => `Save ${name} to collection`;\nexport const SAVE_TO_COLLECTION = \"Save to collection\";\nexport const removeFromTheCollection = (name: string | number) => `Remove ${name} from the collection`;\nexport const REMOVE_FROM_COLLECTION = \"Remove from collection\";\nexport const LOADING = \"Loading\u2026\";\nexport const COULDNT_LOAD_THE_COLLECTION = \"Couldn't load the collection. \";\nexport const RETRY = \"Retry\";\nexport const added = (when: string | number) => `Added ${when}`;\nexport const THIS_COLLECTION_DOESNT_EXIST = \" This collection doesn't exist.\";\nexport const notAnImageOrVideo = (name: string | number) => `${name}: not an image or video`;\nexport const largerThan20Mb = (name: string | number) => `${name}: larger than 20 MB`;\nexport const items = (n: number) => `${n} ${n === 1 ? \"item\" : \"items\"}`;\nexport const deleteCollection = (name: string, n: number) => `Delete \u201C${name}\u201D${n ? ` and its ${items(n)}` : \"\"}? This can't be undone.`;\nexport const newSinceYourLastVisit = (n: string | number) => `${n} new since your last visit`;\n", "// What the collections' chunk (lazy.ts) shares between its parts: the options every part gets, the stylesheet, and the\n// helpers for tiles, pages of items and errors.\n\nimport type { Api } from \"../../api.ts\";\nimport type { CollectionsService } from \"../../collections.ts\";\nimport { h } from \"../../dom.ts\";\nimport type { CollectionItem, Collections, Message, User } from \"../../lib/types.ts\";\nimport * as S from \"../../strings/collection-shared.ts\";\nimport { calls } from \"./calls.ts\";\n\n/** The stylesheet's URL, set by the build (scripts/lib/build-utils.mjs). */\ndeclare const COLLECTIONS_CSS: string;\n\nexport interface Base {\n api: Api;\n service: CollectionsService;\n me: () => User | null;\n /** Yours and those you follow, as the store has them: null until they are loaded. */\n list: () => Collections | null;\n /** Call `fn` when they change; returns the unsubscribe. */\n watch: (fn: () => void) => () => void;\n /** When an item was added, for the viewer. */\n when: (created: string) => string;\n signal: AbortSignal;\n}\n\nlet stylesheet: Promise<void> | null = null;\nexport function loadStylesheet(): Promise<void> {\n stylesheet ??= new Promise((resolve) => {\n const failed = () => {\n link.remove();\n stylesheet = null;\n resolve();\n };\n const link = h(\"link\", { rel: \"stylesheet\", href: COLLECTIONS_CSS, on: { load: () => resolve(), error: failed } });\n document.head.append(link);\n });\n return stylesheet;\n}\n\n/** What can be uploaded into a collection: the images and videos of lib/files.ts (not imported: app.js has it), at most 20 MB. */\nexport const MEDIA = /\\.(jpe?g|png|gif|webp|avif|mp4|m4v|webm|mov|ogv)$/i;\nexport const ACCEPT = \".jpg,.jpeg,.png,.gif,.webp,.avif,.mp4,.m4v,.webm,.mov,.ogv\";\nexport const MAX_BYTES = 20 * 1024 * 1024;\n\n/** Yours and those you follow (none until they are loaded). */\nexport const lists = (o: Base): Collections => o.list() ?? { mine: [], subs: [] };\n\n/** The next change of the collections in the store, or `ms` without one. */\nexport function changed(o: Base, ms: number): Promise<void> {\n return new Promise((resolve) => {\n const done = () => {\n off();\n clearTimeout(timer);\n resolve();\n };\n const off = o.watch(done);\n const timer = setTimeout(done, ms);\n });\n}\n\n/** Why a request failed, in words: the server's reason for a field when it gave one. */\nexport function reason(e: unknown): string {\n const err = e as { fields?: Record<string, string>; message?: string; status?: number };\n if (err?.status === 0) return \"Can't reach the server. Check your connection.\";\n return Object.values(err?.fields ?? {})[0] || err?.message || \"Something went wrong.\";\n}\n\nexport const icon = () => h(\"span\", { class: \"ci\", \"aria-hidden\": \"true\" });\nexport const monthOf = new Intl.DateTimeFormat(undefined, { month: \"long\", year: \"numeric\" });\nexport const dateOf = (created: string) => new Date(created.replace(\" \", \"T\"));\n\n/** An item as the viewer takes it: a message of its own with one file. */\nexport function asMessage(it: CollectionItem): Message {\n const { id, created, file, name } = it;\n return {\n id,\n room: \"\",\n author: \"\",\n text: \"\",\n created,\n updated: created,\n edited_at: \"\",\n deleted: false,\n files: [file],\n file_names: { [file]: name },\n };\n}\n\n/** A square tile's picture: the grid thumbnail, a video's poster, or nothing (a plain tile with the play badge). */\nexport function picture(b: Base, it: CollectionItem, signal: AbortSignal): HTMLImageElement | null {\n if (it.video && !it.poster) return null;\n const img = h(\"img\", {\n src: it.video ? b.api.itemPosterUrl(it) : b.api.itemUrl(it, \"240x240\"),\n alt: \"\",\n loading: \"lazy\",\n decoding: \"async\",\n });\n // A poster that fails leaves the plain tile.\n if (it.video) img.addEventListener(\"error\", () => img.remove(), { signal });\n return img;\n}\n\n/** A collection's items a page at a time, newest first. */\nexport function pager(b: Base, collection: string, signal: AbortSignal) {\n const items: CollectionItem[] = [];\n let done = false;\n let loading: Promise<CollectionItem[]> | null = null;\n return {\n items,\n get done() {\n return done;\n },\n /** The next page (the same one while it loads); rejects when it fails. */\n next(): Promise<CollectionItem[]> {\n if (done) return Promise.resolve([]);\n loading ??= calls(b.api)\n .items(collection, items.at(-1), signal)\n .then(\n (page: { items: CollectionItem[]; more: boolean }) => {\n loading = null;\n done = !page.more;\n items.push(...page.items);\n return page.items;\n },\n (e: unknown) => {\n loading = null;\n throw e;\n },\n );\n return loading!;\n },\n };\n}\n", "// The save menu (\u00A731): which of your collections have a file; tick to add, untick to take out, or make a new one.\n\nimport { h } from \"../../dom.ts\";\nimport type { Collection } from \"../../lib/types.ts\";\nimport * as S from \"../../strings/collection-save.ts\";\nimport type { From } from \"./calls.ts\";\nimport { calls } from \"./calls.ts\";\nimport { type Base, icon, lists, loadStylesheet, reason } from \"./shared.ts\";\n\nexport interface SaveOptions extends Base {\n from: From;\n /** Gets focus back on close. */\n opener: HTMLElement;\n}\n\n/** One save menu at a time. */\nlet saving: (() => void) | null = null;\n\nexport async function openSave(o: SaveOptions): Promise<void> {\n saving?.();\n const call = calls(o.api);\n const scope = new AbortController();\n const { signal } = scope;\n o.signal.addEventListener(\"abort\", () => close(), { signal });\n const title = h(\"h2\", { id: \"coll-save-title\" }, [icon(), \" Save to collection\"]);\n const list = h(\"ul\", { class: \"coll-choices\" });\n const status = h(\"p\", { class: \"coll-status\", role: \"status\" }, \"Loading\u2026\");\n const input = h(\"input\", { placeholder: \"New collection\", \"aria-label\": \"New collection name\", autocomplete: \"off\" });\n const form = h(\n \"form\",\n {\n class: \"coll-new-form\",\n on: {\n submit: async (e) => {\n e.preventDefault();\n if (!input.value.trim()) return;\n try {\n const id = (await call.create(o.me()?.id ?? \"\", input.value, false)).id;\n input.value = \"\";\n await toggle(id, true);\n } catch (err) {\n status.textContent = reason(err);\n }\n },\n },\n signal,\n },\n [input, h(\"button\", { type: \"submit\" }, \"Create\")],\n );\n const dialog = h(\"dialog\", { class: \"coll-dialog coll-save\", \"aria-labelledby\": title.id }, [\n h(\"header\", { class: \"media-bar\" }, [\n title,\n h(\"button\", { type: \"button\", class: \"icon-button ic i-x\", \"aria-label\": \"Close\", on: { click: () => close() }, signal }),\n ]),\n h(\"div\", { class: \"coll-body\" }, [list, status, form]),\n ]);\n /** Collection id \u2192 the item there (ticked). */\n let saved: Record<string, string> = {};\n /** Collection id \u2192 ticked or unticked, while that is saving. */\n const busy = new Map<string, boolean>();\n\n async function toggle(id: string, on: boolean) {\n busy.set(id, on);\n status.textContent = on ? \"Saving\u2026\" : \"Removing\u2026\";\n render();\n try {\n if (on) saved[id] = (await call.save(id, o.from)).id;\n else if (saved[id]) {\n await call.unsave(saved[id]);\n delete saved[id];\n }\n status.textContent = on ? \"Saved.\" : \"Removed.\";\n o.service.refresh();\n } catch (e) {\n // In there already (another tab): it is ticked.\n if ((e as { status?: number }).status === 409) saved = await call.savedIn(o.from, signal).catch(() => saved);\n else status.textContent = reason(e);\n }\n busy.delete(id);\n render();\n }\n\n function render() {\n const mine = lists(o).mine;\n list.replaceChildren(\n ...mine.map((c: Collection) => {\n const box = h(\"input\", { type: \"checkbox\", checked: busy.get(c.id) ?? !!saved[c.id], disabled: busy.has(c.id) });\n box.addEventListener(\"change\", () => void toggle(c.id, box.checked), { signal });\n // Saving copies the file on the server, which can take a while: a spinner on the row until it is done.\n return h(\n \"li\",\n { \"aria-busy\": busy.has(c.id) ? \"true\" : \"false\" },\n h(\"label\", {}, [\n box,\n \" \",\n c.name,\n h(\"span\", { class: \"coll-meta\" }, c.public ? \" \u00B7 Public: anyone can see it\" : \" \u00B7 Private\"),\n busy.has(c.id) ? h(\"span\", { class: \"coll-spin\", \"aria-hidden\": \"true\" }) : null,\n ]),\n );\n }),\n );\n if (!mine.length && status.textContent === \"\") status.textContent = \"You have no collections yet. Make one:\";\n }\n\n function close() {\n if (signal.aborted) return;\n scope.abort();\n saving = null;\n if (dialog.open) dialog.close();\n dialog.remove();\n o.opener.setAttribute(\"aria-expanded\", \"false\");\n o.opener.focus();\n }\n saving = close;\n dialog.addEventListener(\"close\", () => close(), { signal });\n signal.addEventListener(\"abort\", o.watch(render), { once: true });\n\n await loadStylesheet();\n if (signal.aborted) return;\n document.body.append(dialog);\n dialog.showModal();\n o.opener.setAttribute(\"aria-expanded\", \"true\");\n try {\n saved = await call.savedIn(o.from, signal);\n status.textContent = \"\";\n } catch (e) {\n if (signal.aborted) return;\n status.textContent = reason(e);\n }\n render();\n (list.querySelector(\"input\") ?? input).focus();\n}\n", "// A collection's page (/c/:id, \u00A731): its items as a grid like the media grid's, newest first under month headings, what\n// is new since you last looked highlighted.\n\nimport { h } from \"../../dom.ts\";\nimport type { CollectionItem, Message } from \"../../lib/types.ts\";\nimport * as S from \"../../strings/collection-page.ts\";\nimport type { ViewerImage } from \"../room/viewer.ts\";\nimport { calls, type Meta } from \"./calls.ts\";\nimport { openSave } from \"./save.ts\";\nimport {\n ACCEPT,\n asMessage,\n type Base,\n changed,\n dateOf,\n icon,\n lists,\n loadStylesheet,\n MAX_BYTES,\n MEDIA,\n monthOf,\n pager,\n picture,\n reason,\n} from \"./shared.ts\";\n\nexport interface PageOptions extends Base {\n id: string;\n navigate: (path: string) => void;\n}\n\nexport async function mountCollection(root: HTMLElement, o: PageOptions): Promise<void> {\n const { api, signal, id } = o;\n const call = calls(api);\n const [, meta] = await Promise.all([\n loadStylesheet(),\n call.get(id, signal).catch(() => null),\n (async () => {\n // Your subscription's `seen_at` decides what is new: wait for the store to have it (just after a reload).\n if (o.me() && !o.list()) {\n await changed(o, 2000);\n }\n })(),\n ]);\n if (signal.aborted) return;\n /** Not there (any more), or not yours to see. */\n function gone() {\n root.replaceChildren(\n h(\"section\", { class: \"collection not-found\" }, [\n h(\"h1\", {}, [icon(), \" This collection doesn't exist.\"]),\n h(\"p\", {}, [\"It may be private, or deleted. \", h(\"a\", { href: \"/\" }, \"Back to rooms\")]),\n ]),\n );\n }\n if (!meta) return gone();\n let info: Meta = meta;\n const me = o.me();\n const mine = !!me && info.owner === me.id;\n const ownerName = meta.expand?.owner?.name ?? \"\";\n const seenAt = lists(o).subs.find((c) => c.id === id)?.seen_at ?? \"\";\n let pages = pager(o, id, signal);\n\n const heading = h(\"h1\", { id: \"coll-title\" });\n const metaLine = h(\"p\", { class: \"coll-meta\" });\n const actions = h(\"div\", { class: \"coll-actions\" });\n const notice = h(\"p\", { class: \"coll-notice\", role: \"status\" });\n const newLine = h(\"p\", { class: \"coll-new\", hidden: true });\n const grid = h(\"div\", { class: \"media-grid coll-grid\" });\n const status = h(\"p\", { class: \"media-status\", role: \"status\" });\n root.replaceChildren(\n h(\"section\", { class: \"collection\", \"aria-labelledby\": \"coll-title\" }, [\n // The tile's tint is the sidebar row's (t0..t3, views/rooms.ts).\n h(\"header\", { class: `coll-head t${id.charCodeAt(0) % 4}` }, [\n h(\"a\", { href: \"/\", class: \"back ic i-back\", \"aria-label\": \"Back to rooms\" }),\n heading,\n metaLine,\n actions,\n notice,\n ]),\n newLine,\n grid,\n status,\n ]),\n );\n\n const fail = (what: string, e: unknown) => {\n notice.textContent = `${what} ${reason(e)}`;\n };\n const btn = (label: string, run: () => unknown, cls = \"\") =>\n h(\"button\", { type: \"button\", class: cls, on: { click: () => void run() }, signal }, label);\n const empty = () => (mine ? \"Nothing here yet. Upload images and videos, or save them from the chat.\" : \"Nothing here yet.\");\n\n /** Files waiting to be uploaded (the owner's), one at a time; each comes in at the top once the store hears of it. */\n const queue: File[] = [];\n let sent = 0;\n let busy = false;\n let failed: string[] = [];\n const picker = h(\"input\", {\n type: \"file\",\n multiple: true,\n accept: ACCEPT,\n hidden: true,\n on: {\n change: () => {\n upload([...(picker.files ?? [])]);\n picker.value = \"\";\n },\n },\n signal,\n });\n function upload(files: File[]) {\n for (const f of files) {\n if (!MEDIA.test(f.name)) failed.push(`${f.name}: not an image or video`);\n else if (f.size > MAX_BYTES) failed.push(`${f.name}: larger than 20 MB`);\n else queue.push(f);\n }\n if (busy) return;\n if (!queue.length) return report();\n busy = true;\n void (async () => {\n while (queue.length && !signal.aborted) {\n const f = queue[0]!;\n const at = `Uploading ${sent + 1} of ${sent + queue.length}\u2026`;\n notice.textContent = at;\n try {\n await call.upload(id, f, (x) => (notice.textContent = `${at} ${Math.round(x * 100)}%`));\n } catch (e) {\n // Too many at once (the server's rate limit): wait, then the same one again.\n if ((e as { status?: number }).status === 429) {\n notice.textContent = \"Waiting for the server\u2026\";\n await new Promise((r) => setTimeout(r, 10_000));\n continue;\n }\n failed.push(`${f.name}: ${reason(e)}`);\n }\n queue.shift();\n sent++;\n o.service.refresh();\n }\n sent = 0;\n busy = false;\n report();\n })();\n }\n /** After an upload: what didn't go, or nothing. */\n function report() {\n notice.textContent = failed.length ? `Couldn't upload ${failed.join(\"; \")}` : \"\";\n failed = [];\n }\n\n /** Renaming or confirming a delete: the actions stay as they are while the store changes. */\n let editing = false;\n /** The button that was pressed to edit (Rename or Delete): it gets focus back. */\n let back = \"\";\n /** What the actions were drawn for: they are drawn again only when that changes, so focus stays. */\n let drawn = \"\";\n function doneEditing() {\n editing = false;\n drawn = \"\";\n renderHead();\n }\n\n /** Saved: true. Refused: the reason is shown, and whatever was being edited stays. */\n async function change(patch: { name?: string; public?: boolean }): Promise<boolean> {\n try {\n info = { ...info, ...(await call.update(id, patch)) };\n notice.textContent = \"\";\n o.service.refresh();\n doneEditing();\n return true;\n } catch (e) {\n fail(\"Couldn't save.\", e);\n return false;\n }\n }\n\n function renameForm() {\n editing = true;\n back = \"Rename\";\n const input = h(\"input\", { value: info.name, \"aria-label\": \"Collection name\", autocomplete: \"off\" });\n const form = h(\n \"form\",\n {\n class: \"coll-rename\",\n on: {\n submit: (e) => {\n e.preventDefault();\n void change({ name: input.value });\n },\n keydown: (e) => e.key === \"Escape\" && doneEditing(),\n },\n signal,\n },\n [input, h(\"button\", { type: \"submit\" }, \"Save\"), btn(\"Cancel\", doneEditing, \"link\")],\n );\n actions.replaceChildren(form);\n input.focus();\n input.select();\n }\n\n function confirmDelete() {\n editing = true;\n back = \"Delete\";\n actions.replaceChildren(\n h(\"span\", {}, S.deleteCollection(info.name, info.items)),\n btn(\n \"Delete collection\",\n async () => {\n try {\n await call.remove(id);\n o.service.refresh();\n o.navigate(\"/\");\n } catch (e) {\n fail(\"Couldn't delete it.\", e);\n }\n },\n \"danger\",\n ),\n btn(\"Cancel\", doneEditing, \"link\"),\n );\n actions.querySelector(\"button\")?.focus();\n }\n\n function renderHead() {\n if (signal.aborted) return;\n heading.replaceChildren(icon(), \" \", info.name);\n metaLine.textContent = [mine ? \"Yours\" : ownerName && `By ${ownerName}`, info.public ? \"Public\" : \"Private\", S.items(info.items)]\n .filter(Boolean)\n .join(\" \u00B7 \");\n const following = lists(o).subs.some((c) => c.id === id);\n const key = [info.public, following].join();\n if (editing || key === drawn) return;\n drawn = key;\n const focused = [...actions.children].findIndex((c) => c.contains(document.activeElement));\n if (mine) {\n actions.replaceChildren(\n btn(\"Upload\", () => picker.click()),\n btn(\"Rename\", renameForm),\n btn(info.public ? \"Make private\" : \"Make public\", () => change({ public: !info.public })),\n btn(\"Delete\", confirmDelete, \"danger\"),\n );\n } else if (me && (info.public || following)) {\n const b = btn(following ? \"Unsubscribe\" : \"Subscribe\", async () => {\n b.disabled = true;\n try {\n await call.follow(id, !following);\n o.service.refresh();\n await changed(o, 1000);\n } catch (e) {\n fail(following ? \"unsubscribe\" : \"subscribe\", e);\n }\n drawn = \"\";\n renderHead();\n });\n b.setAttribute(\"aria-pressed\", String(following));\n actions.replaceChildren(b);\n } else actions.replaceChildren();\n const kids = [...actions.children] as HTMLElement[];\n if (focused >= 0) (kids.find((c) => back && c.textContent === back) ?? kids[focused])?.focus();\n back = \"\";\n }\n renderHead();\n if (mine) {\n root.firstElementChild!.append(picker);\n const files = (e: DragEvent) => e.dataTransfer?.types.includes(\"Files\");\n root.addEventListener(\"dragover\", (e) => files(e) && e.preventDefault(), { signal });\n root.addEventListener(\n \"drop\",\n (e) => {\n if (!files(e)) return;\n e.preventDefault();\n upload([...(e.dataTransfer?.files ?? [])]);\n },\n { signal },\n );\n // Pasted (Ctrl+V) anywhere on the page, unless a dialog (the viewer, a menu's) is open over it.\n document.addEventListener(\n \"paste\",\n (e) => {\n const pasted = [...(e.clipboardData?.files ?? [])];\n if (!pasted.length || document.querySelector(\"dialog[open]\")) return;\n e.preventDefault();\n upload(pasted);\n },\n { signal },\n );\n }\n\n /** The newest item's `created` (or the collection's last_added), to send as seen once the tab is visible. */\n let unseen = \"\";\n function markSeen() {\n if (!unseen || document.visibilityState !== \"visible\" || !lists(o).subs.some((c) => c.id === id)) return;\n const at = unseen;\n unseen = \"\";\n // Not while the store is telling its listeners of a change: the badge goes with the next one.\n queueMicrotask(() => signal.aborted || o.service.seen(id, at));\n }\n document.addEventListener(\"visibilitychange\", markSeen, { signal });\n\n /** The collection as the store has it (yours, or followed), last time: what changed since. */\n const listed = () => [...lists(o).mine, ...lists(o).subs].find((c) => c.id === id);\n let last = listed();\n function follow() {\n const c = listed();\n if (c) {\n info = { ...info, name: c.name, public: c.public, items: c.items };\n if (last && c.last_added !== last.last_added) void newer();\n // Some may have been taken out (the save menu, another tab): the gone ones leave the grid.\n if (last && c.items < last.items + (c.last_added !== last.last_added ? 1 : 0)) void prune();\n if (c.new) {\n unseen = c.last_added;\n markSeen();\n }\n } else if (last) {\n // Gone from the list: made private, deleted, or no longer followed.\n void call.get(id, signal).then(\n (m) => {\n info = { ...info, ...m };\n renderHead();\n },\n (e: { status?: number }) => e.status === 404 && gone(),\n );\n }\n last = c;\n renderHead();\n }\n signal.addEventListener(\"abort\", o.watch(follow), { once: true });\n\n let month = \"\";\n let fresh = 0;\n /** An item's cell, at the end (a page of older ones) or at the top (`added`: new while the page is open). */\n function add(it: CollectionItem, added = false) {\n const mo = monthOf.format(dateOf(it.created));\n const isNew = added || (!!seenAt && it.created > seenAt);\n if (isNew && !added) fresh++;\n const label = `${it.name}${it.video ? \", video\" : \"\"}${isNew ? \", new\" : \"\"}`;\n const tile = h(\n \"button\",\n {\n type: \"button\",\n class: \"media-tile\",\n \"aria-label\": label,\n title: it.name,\n on: { click: () => void open(it, tile) },\n signal,\n },\n [picture(o, it, signal), it.video && h(\"span\", { class: \"att-play\", \"aria-hidden\": \"true\" })],\n );\n const cell = h(\"div\", { class: `coll-cell${isNew ? \" new\" : \"\"}`, dataset: { item: it.id } }, [tile]);\n if (me) {\n const save: HTMLButtonElement = h(\n \"button\",\n {\n type: \"button\",\n class: \"att-save\",\n \"aria-label\": `Save ${it.name} to collection`,\n title: \"Save to collection\",\n on: { click: () => openSave({ ...o, from: { item: it.id }, opener: save }) },\n signal,\n },\n icon(),\n );\n cell.append(save);\n }\n if (mine) {\n cell.append(\n h(\n \"button\",\n {\n type: \"button\",\n class: \"coll-remove\",\n \"aria-label\": `Remove ${it.name} from the collection`,\n title: \"Remove from collection\",\n on: { click: () => void remove(it, cell) },\n signal,\n },\n \"\u00D7\",\n ),\n );\n }\n if (!added) {\n if (mo !== month) grid.append(h(\"h2\", {}, mo));\n month = mo;\n grid.append(cell);\n } else if (grid.firstElementChild?.textContent === mo) grid.firstElementChild.after(cell);\n else {\n grid.prepend(h(\"h2\", {}, mo), cell);\n month ||= mo;\n }\n }\n\n async function remove(it: CollectionItem, cell: HTMLElement) {\n try {\n await call.unsave(it.id);\n } catch (e) {\n return fail(\"Couldn't remove it.\", e);\n }\n const cells = [...grid.querySelectorAll(\".coll-cell\")];\n const at = cells.indexOf(cell);\n const to = cells[at + 1] ?? cells[at - 1];\n drop(it);\n info = { ...info, items: Math.max(0, info.items - 1) };\n renderHead();\n // Focus stays in the grid (the next one's Remove), or goes to the actions once it is empty.\n (to?.querySelector<HTMLElement>(\".coll-remove\") ?? actions.querySelector(\"button\"))?.focus();\n o.service.refresh();\n }\n\n /** An item no longer in the collection: its cell goes, and its month's heading when it was the last of it. */\n function drop(it: CollectionItem) {\n const at = pages.items.indexOf(it);\n if (at < 0) return;\n pages.items.splice(at, 1);\n const cell = [...grid.querySelectorAll<HTMLElement>(\".coll-cell\")].find((c) => c.dataset.item === it.id);\n if (cell) {\n const [before, after] = [cell.previousElementSibling, cell.nextElementSibling];\n if (cell.contains(document.activeElement)) (after?.querySelector<HTMLElement>(\"button\") ?? actions.querySelector(\"button\"))?.focus();\n cell.remove();\n if (before?.tagName === \"H2\" && (!after || after.tagName === \"H2\")) {\n before.remove();\n if (!after) month = \"\";\n }\n }\n if (pages.done && !pages.items.length) status.textContent = empty();\n }\n\n /** Taken out elsewhere (the save menu, another tab): those shown that are gone go from the grid. */\n let pruned = 0;\n async function prune() {\n const seq = ++pruned;\n const shown = [...pages.items];\n const oldest = shown.at(-1);\n const ids = oldest && (await call.idsSince(id, oldest, signal).catch(() => null));\n if (!ids || seq !== pruned || signal.aborted) return;\n for (const it of shown.filter((x) => !ids.has(x.id))) drop(it);\n }\n\n async function more() {\n const p = pages;\n if (p.done) return;\n status.textContent = \"Loading\u2026\";\n try {\n const page = await p.next();\n if (signal.aborted || p !== pages) return;\n for (const it of page) add(it);\n status.textContent = p.done && !p.items.length ? empty() : \"\";\n } catch {\n if (signal.aborted || p !== pages) return;\n seen.unobserve(status);\n status.replaceChildren(\n \"Couldn't load the collection. \",\n btn(\"Retry\", () => void more(), \"link\"),\n );\n return;\n }\n seen.unobserve(status);\n if (!p.done) seen.observe(status);\n }\n\n /** From the start again (the page was empty, or more was added than a page holds). */\n function reset() {\n pages = pager(o, id, signal);\n grid.replaceChildren();\n month = \"\";\n return more();\n }\n\n /** Items added while the page is open: at the top, marked new. */\n async function newer() {\n const top = pages.items[0];\n if (!top) return reset();\n const got = await call.items(id, top, signal, true).catch(() => null);\n if (!got || signal.aborted) return;\n if (got.more) return reset();\n const shown = new Set(pages.items.map((x) => x.id));\n const added = got.items.filter((x) => !shown.has(x.id));\n pages.items.unshift(...added);\n for (const it of added.reverse()) add(it, true);\n if (added.length) status.textContent = \"\";\n }\n\n async function open(it: CollectionItem, opener: HTMLElement) {\n const images = (): ViewerImage[] => [...pages.items].reverse().map((x) => ({ message: asMessage(x), file: x.file, video: x.video }));\n const all = images();\n const p = pages;\n try {\n const { openViewer } = await import(\"../room/viewer.ts\");\n if (signal.aborted) return;\n await openViewer({\n images: all,\n start: all.findIndex((x) => x.message.id === it.id),\n more: [!p.done, false],\n page: async (older) => {\n const got = older ? await p.next() : [];\n return { messages: got.map(asMessage).reverse(), done: !older || p.done };\n },\n media: (m) => [{ message: m, file: m.files![0]!, video: p.items.find((x) => x.id === m.id)?.video ?? false }],\n name: (m, f) => m.file_names?.[f] ?? f,\n when: (m) => `Added ${o.when(m.created)}`,\n fileUrl: (m, f) => api.itemUrl({ id: m.id, file: f }),\n ...(me ? { onSave: (m: Message, _f: string, b: HTMLElement) => openSave({ ...o, from: { item: m.id }, opener: b }) } : {}),\n opener,\n follow: () => {},\n signal,\n });\n } catch {\n window.open(api.itemUrl(it), \"_blank\", \"noopener\");\n }\n }\n\n const seen = new IntersectionObserver((es) => es.some((e) => e.isIntersecting) && void more(), { rootMargin: \"400px\" });\n signal.addEventListener(\"abort\", () => seen.disconnect(), { once: true });\n await more();\n if (signal.aborted) return;\n if (fresh) {\n newLine.hidden = false;\n newLine.textContent = `${fresh >= 60 ? \"60+\" : fresh} new since your last visit`;\n }\n // Seen once it is on screen in a visible tab: the sidebar's count goes.\n unseen = pages.items[0]?.created ?? \"\";\n markSeen();\n}\n", "// The user-facing text of views/collection/picker.ts (docs/REFACTOR.md item 56): one module per source file, so a lazy\n// screen's text stays in its own chunk. Copy changes here; a translation would replace these.\n\nexport const COLLECTION = \"Collection\";\nexport const ATTACH = \"Attach\";\nexport const CLOSE = \"Close\";\nexport const THE_MESSAGE_HAS_ALL_THE_FILES = \"The message has all the files it can take.\";\nexport const attach = (pickedSize: string | number) => `Attach ${pickedSize}`;\nexport const LOADING = \"Loading\u2026\";\nexport const NOTHING_IN_THIS_COLLECTION_YET = \"Nothing in this collection yet.\";\nexport const COULDNT_LOAD_THE_COLLECTION = \"Couldn't load the collection. \";\nexport const RETRY = \"Retry\";\nexport const YOU_HAVE_NO_COLLECTIONS_YET_SAVE = \"You have no collections yet. Save images and videos from the chat to one first.\";\nexport const ATTACH_FROM_COLLECTIONS = \" Attach from collections\";\nexport const picked = (n: number, full: boolean) => `${n} picked${full ? \" (the most a message takes)\" : \"\"}`;\nexport const tile = (name: string, video: boolean) => `${name}${video ? \", video\" : \"\"}`;\n", "// The picker the composer opens (\u00A731): items of your collections and those you follow, to attach.\n\nimport { h } from \"../../dom.ts\";\nimport type { CollectionItem } from \"../../lib/types.ts\";\nimport * as S from \"../../strings/collection-picker.ts\";\nimport { type Base, icon, lists, loadStylesheet, pager, picture } from \"./shared.ts\";\n\nexport interface PickOptions extends Base {\n /** At most this many may be picked (what the message still has room for). */\n max: number;\n /** Attach these (Attach was pressed). */\n onPick: (items: CollectionItem[]) => void;\n opener: HTMLElement;\n}\n\nexport async function openPicker(o: PickOptions): Promise<void> {\n const scope = new AbortController();\n const { signal } = scope;\n o.signal.addEventListener(\"abort\", () => close(), { signal });\n const { mine, subs } = lists(o);\n const all = [...mine, ...subs];\n const title = h(\"h2\", { id: \"coll-pick-title\" }, [icon(), \" Attach from collections\"]);\n /** The collection shown: a row of chips, as the app's. */\n let chosen = all[0]?.id ?? \"\";\n const chips = all.map((c) =>\n h(\n \"button\",\n {\n type: \"button\",\n class: \"coll-chip\",\n \"aria-pressed\": String(c.id === chosen),\n on: { click: (e: Event) => choose(c.id, e.currentTarget as HTMLElement) },\n signal,\n },\n c.owner ? `${c.name} \u00B7 ${c.owner.name}` : c.name,\n ),\n );\n const row = h(\"div\", { class: \"coll-chips\", role: \"group\", \"aria-label\": \"Collection\" }, chips);\n const grid = h(\"div\", { class: \"media-grid coll-grid\" });\n const status = h(\"p\", { class: \"media-status\", role: \"status\" });\n const count = h(\"span\", { class: \"coll-count\", \"aria-live\": \"polite\" });\n const attach = h(\"button\", { type: \"button\", disabled: true, on: { click: () => done() }, signal }, \"Attach\");\n const body = h(\"div\", { class: \"coll-body\" }, [grid, status]);\n const dialog = h(\"dialog\", { class: \"coll-dialog coll-pick\", \"aria-labelledby\": title.id }, [\n h(\"header\", { class: \"media-bar\" }, [\n title,\n h(\"button\", { type: \"button\", class: \"icon-button ic i-x\", \"aria-label\": \"Close\", on: { click: () => close() }, signal }),\n ]),\n all.length ? row : null,\n body,\n h(\"footer\", { class: \"coll-foot\" }, [count, attach]),\n ]);\n /** Picked, in the order they were. */\n const picked = new Map<string, CollectionItem>();\n let pages = pager(o, \"\", signal);\n\n function update() {\n count.textContent = picked.size ? S.picked(picked.size, picked.size >= o.max) : o.max ? \"\" : \"The message has all the files it can take.\";\n attach.disabled = !picked.size;\n attach.textContent = picked.size ? `Attach ${picked.size}` : \"Attach\";\n }\n\n function tile(it: CollectionItem) {\n const b: HTMLButtonElement = h(\n \"button\",\n {\n type: \"button\",\n class: \"media-tile\",\n \"aria-label\": S.tile(it.name, it.video),\n title: it.name,\n \"aria-pressed\": String(picked.has(it.id)),\n on: {\n click: () => {\n if (picked.has(it.id)) picked.delete(it.id);\n else if (picked.size < o.max) picked.set(it.id, it);\n b.setAttribute(\"aria-pressed\", String(picked.has(it.id)));\n update();\n },\n },\n signal,\n },\n [picture(o, it, signal), it.video && h(\"span\", { class: \"att-play\", \"aria-hidden\": \"true\" })],\n );\n return b;\n }\n\n async function more() {\n if (pages.done || !chosen) return;\n const p = pages;\n status.textContent = \"Loading\u2026\";\n try {\n const got = await p.next();\n if (signal.aborted || p !== pages) return;\n grid.append(...got.map(tile));\n status.textContent = p.done && !p.items.length ? \"Nothing in this collection yet.\" : \"\";\n } catch {\n if (signal.aborted || p !== pages) return;\n seen.unobserve(status);\n status.replaceChildren(\n \"Couldn't load the collection. \",\n h(\"button\", { type: \"button\", class: \"link\", on: { click: () => void more() }, signal }, \"Retry\"),\n );\n return;\n }\n seen.unobserve(status);\n if (!p.done) seen.observe(status);\n }\n\n function show() {\n pages = pager(o, chosen, signal);\n grid.replaceChildren();\n void more();\n }\n\n function choose(id: string, chip: HTMLElement) {\n if (id === chosen) return;\n chosen = id;\n for (const c of chips) c.setAttribute(\"aria-pressed\", String(c === chip));\n chip.scrollIntoView({ block: \"nearest\", inline: \"nearest\" });\n show();\n }\n const seen = new IntersectionObserver((es) => es.some((e) => e.isIntersecting) && void more(), { root: body, rootMargin: \"400px\" });\n\n function done() {\n const items = [...picked.values()];\n close();\n if (items.length) o.onPick(items);\n }\n\n function close() {\n if (signal.aborted) return;\n scope.abort();\n seen.disconnect();\n if (dialog.open) dialog.close();\n dialog.remove();\n o.opener.focus();\n }\n dialog.addEventListener(\"close\", () => close(), { signal });\n\n await loadStylesheet();\n if (signal.aborted) return;\n document.body.append(dialog);\n dialog.showModal();\n update();\n if (!all.length) {\n status.textContent = \"You have no collections yet. Save images and videos from the chat to one first.\";\n return;\n }\n show();\n chips[0]?.focus();\n}\n"],
|
|
5
|
+
"mappings": "wCAqBO,IAAMA,GAAU,uCAGVC,EAAOC,GAAc,KAAK,UAAUA,CAAC,EAGrCC,GAAc,+CAGpB,SAASC,EAAMC,EAAU,CAC9B,MAAO,CAEL,IAAK,CAACC,EAAYC,IAChBF,EAAI,QAA0D,GAAGL,EAAO,IAAIM,CAAE,GAAI,CAChF,MAAO,CAAE,OAAQ,QAAS,OAAQ,8CAA+C,EACjF,OAAAC,CACF,CAAC,EACH,OAAQ,CAACC,EAAeC,EAAcC,IACpCL,EAAI,QAAwBL,GAAS,CAAE,OAAQ,OAAQ,KAAM,CAAE,MAAAQ,EAAO,KAAAC,EAAM,OAAQC,CAAS,EAAG,MAAO,CAAE,OAAQ,IAAK,CAAE,CAAC,EAC3H,OAAQ,CAACJ,EAAYK,IACnBN,EAAI,QAA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,QAIX,IAHA,SAAS,KAAK,OAAOoB,CAAM,EAC3BA,EAAO,UAAU,EACjBI,EAAO,EACH,CAACnB,EAAI,OAAQ,CACfU,EAAO,YAAc,kFACrB,MACF,CACAkB,EAAK,EACLvB,EAAM,CAAC,GAAG,MAAM,EAClB",
|
|
6
|
+
"names": ["RECORDS", "lit", "v", "ITEM_FIELDS", "calls", "api", "id", "signal", "owner", "name", "isPublic", "body", "collection", "after", "newer", "op", "cursor", "query", "items", "oldest", "ids", "filter", "page", "x", "from", "file", "onUpload", "item", "on", "createCollection", "o", "name", "isPublic", "id", "calls", "items", "deleteCollection", "name", "n", "stylesheet", "loadStylesheet", "resolve", "link", "h", "MEDIA", "ACCEPT", "MAX_BYTES", "lists", "o", "changed", "ms", "done", "off", "timer", "reason", "e", "err", "icon", "monthOf", "dateOf", "created", "asMessage", "it", "id", "file", "name", "picture", "b", "signal", "img", "pager", "collection", "items", "loading", "calls", "page", "saving", "openSave", "o", "call", "calls", "scope", "signal", "close", "title", "h", "icon", "list", "status", "input", "form", "e", "id", "toggle", "err", "reason", "dialog", "saved", "busy", "on", "render", "mine", "lists", "c", "box", "loadStylesheet", "mountCollection", "root", "o", "api", "signal", "id", "call", "calls", "meta", "loadStylesheet", "changed", "gone", "h", "icon", "info", "me", "mine", "ownerName", "seenAt", "lists", "c", "pages", "pager", "heading", "metaLine", "actions", "notice", "newLine", "grid", "status", "fail", "what", "e", "reason", "btn", "label", "run", "cls", "empty", "queue", "sent", "busy", "failed", "picker", "ACCEPT", "upload", "files", "f", "MEDIA", "MAX_BYTES", "report", "at", "x", "r", "editing", "back", "drawn", "doneEditing", "renderHead", "change", "patch", "renameForm", "input", "form", "confirmDelete", "deleteCollection", "items", "following", "key", "focused", "b", "kids", "pasted", "unseen", "markSeen", "listed", "last", "follow", "newer", "prune", "m", "month", "fresh", "add", "it", "added", "mo", "monthOf", "dateOf", "isNew", "tile", "open", "picture", "cell", "save", "openSave", "remove", "cells", "to", "drop", "before", "after", "pruned", "seq", "shown", "oldest", "ids", "more", "p", "page", "seen", "reset", "top", "got", "opener", "all", "asMessage", "openViewer", "older", "_f", "es", "picked", "full", "tile", "name", "video", "openPicker", "o", "scope", "signal", "close", "mine", "subs", "lists", "all", "title", "h", "icon", "chosen", "chips", "e", "choose", "row", "grid", "status", "count", "attach", "done", "body", "dialog", "picked", "pages", "pager", "update", "tile", "it", "b", "picture", "more", "p", "got", "seen", "show", "id", "chip", "c", "es", "items", "loadStylesheet"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{q as G}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=login-
|
|
1
|
+
import{q as G}from"./chunk-SM542ZXL.js";import"./chunk-RPCBA7VF.js";import{a as m,b as $}from"./chunk-UZDXAORM.js";import{g as P,j as u,k as F,l as A}from"./chunk-DC4TJ7HF.js";import"./chunk-SZMAZMR4.js";import{a as o,b as W,c as v}from"./chunk-VTOUI25E.js";var Y=()=>({login:[{name:"email",label:"Email",type:"email",autocomplete:"email"},{name:"password",label:"Password",type:"password",autocomplete:"current-password"}],forgot:[{name:"email",label:"Email",type:"email",autocomplete:"email"}],reset:[{name:"password",label:"New password",type:"password",autocomplete:"new-password",extra:{minlength:m.passwordMin}}],signup:[{name:"name",label:"Display name",type:"text",autocomplete:"nickname"},{name:"email",label:"Email",type:"email",autocomplete:"email"},{name:"password",label:"Password",type:"password",autocomplete:"new-password",extra:{minlength:m.passwordMin}}]}),q={name:"invite_code",label:"Invite code",type:"text",autocomplete:"off"},I={login:"Log in",signup:"Sign up",forgot:"Reset password",reset:"Set a new password"},U=["login","signup"],J={forgot:"Send link",reset:"Set password"},j=()=>({forgot:"Enter your account's email, and we'll send you a link to set a new password.",reset:`At least ${m.passwordMin} characters. Every device logged in to this account is logged out.`});function X(a){try{let f=JSON.parse(atob(a.split(".")[1].replace(/-/g,"+").replace(/_/g,"/")));return typeof f.email=="string"?f.email:""}catch{return""}}function se(a){let f=Y(),N=j(),d=null,e=a.mode??"login",p=!1,L="",h="",s={name:"",email:"",password:"",invite_code:""},w=()=>a.store?.get().site??P,x=i=>i==="signup"&&w().inviteOnly?[...f.signup,q]:f[i],R=()=>{},B=W("login"),S;function r(i={}){d?.abort(),d=new AbortController;let{signal:t}=d,l=n=>()=>{e=n,h="",r()},c=U.map(n=>o("button",{type:"button",role:"tab","aria-selected":String(n===e),on:{click:()=>{n!==e&&(e=n,r())}},signal:t},I[n])),y=o("button",{type:"submit",class:"primary",disabled:p},J[e]??I[e]),E=e==="login"&&w().passwordReset?o("button",{type:"button",class:"link auth-forgot",on:{click:l("forgot")},signal:t},"Forgot password?"):null,k=x(e).map(n=>{let g=`${B}-${n.name}`,M=`${g}-error`,D=i.fields?.[n.name];return o("div",{class:"field"},[o("label",{for:g},n.label),o("input",{id:g,name:n.name,type:n.type,autocomplete:n.autocomplete,required:!0,value:s[n.name],"aria-invalid":D?"true":null,"aria-describedby":M,...n.extra,on:{input:V=>s[n.name]=V.target.value},signal:t}),o("p",{id:M,class:"field-error"},D??"")])}),b=o("form",{class:"auth-form","aria-label":I[e],on:{submit:n=>{n.preventDefault();for(let g of x(e))s[g.name]=b.elements.namedItem(g.name).value;H(y)}},signal:t},[N[e]?o("p",{class:"auth-hint"},N[e]):null,...k,E,o("p",{role:"alert",class:"form-error"},i.form??""),y]),O=h?o("p",{role:"status",class:"auth-hint"},`If an account uses ${h}, a link to set a new password is on its way. It works for 30 minutes.`):null,_=e==="forgot"?o("button",{type:"button",class:"link auth-back",on:{click:l("login")},signal:t},"Back to log in"):o("a",{href:"/login",class:"auth-back"},"Back to log in"),{title:C,logo:T}=w(),K=U.includes(e);v(S),S.append(o("section",{class:"auth"},[o("h1",{class:T?"has-logo":""},[T?o("img",{src:T,alt:"",class:"brand-logo"}):null,C]),G(w(),"p"),o("div",{class:"auth-card"},K?[o("div",{role:"tablist",class:"tabs"},c),b]:[o("h2",{},I[e]),O??b,_]),o("p",{class:"auth-skip"},o("a",{href:"/"},"Just looking? Read the Open Air rooms"))]))}async function H(i){if(!p){if(e==="signup"&&$(s.name.trim())>m.userName){r({fields:{name:`Must be no more than ${m.userName} characters.`}});return}if(e==="signup"&&new TextEncoder().encode(s.password).length>m.passwordMaxBytes){r({fields:{password:"Use at most 71 characters (fewer if some aren't plain Latin letters, digits or punctuation)."}});return}p=!0,i.disabled=!0;try{if(e==="forgot"){await a.api.requestPasswordReset(s.email),p=!1,h=s.email.trim(),r();return}if(e==="reset"){await a.api.confirmPasswordReset(L,s.password);let l=X(L);try{let c=await a.api.logIn(l,s.password);p=!1,a.onLogin(c)}catch{p=!1,e="login",s.email=l,r({form:"Your password was changed. Log in with it."})}return}let t=e==="login"?await a.api.logIn(s.email,s.password):await a.api.signUp({name:s.name,email:s.email,password:s.password,...w().inviteOnly?{inviteCode:s.invite_code}:{}});p=!1,i.disabled=!1,a.onLogin(t)}catch(t){if(p=!1,!d||d.signal.aborted)return;if(t instanceof u&&t.codes.auth===F){e="login",r({form:`Your account was created, but logging in failed: ${A(t)} Log in to continue.`});return}let l=t instanceof u?t.fields:{},c=Object.fromEntries(Object.entries(l).filter(([O])=>x(e).some(_=>_.name===O)));e==="signup"&&t instanceof u&&t.codes.email==="validation_not_unique"&&(c.email="There is already an account with this email. Log in instead.");let y=e==="login"&&t instanceof u&&t.status===400,E=t instanceof u&&!c.invite_code?l.invite_code:void 0,k=e==="reset"&&t instanceof u&&t.codes.token?"This link has expired or was already used. Ask for a new one.":"",b=Object.keys(c).length?"":E||k||(y?"Wrong email or password.":A(t));r({form:b,fields:c})}}}return{mount(i,t){S=i,L=t.token??"",r(),R=a.store?.subscribe((l,c)=>{l.site!==c.site&&!p&&r()})??(()=>{})},unmount(){R(),d?.abort(),d=null,v(S)}}}export{se as createLoginView};
|
|
2
|
+
//# sourceMappingURL=login-TN6R7N2U.js.map
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
dialog.media{width:min(55rem,100%);height:min(49.25rem,100%);max-width:none;max-height:none;padding:0;border:1px solid var(--border);border-radius:1rem;background:color-mix(in srgb,var(--raised),var(--bg));color:var(--fg);box-shadow:var(--shadow)}dialog.media[open]{display:flex;flex-direction:column}dialog.media::backdrop{background:#08060eb3}.media-bar{display:flex;align-items:center;gap:.625rem;padding:.875rem 1rem .75rem 1.5rem;border-bottom:1px solid var(--border)}.media-bar h2{flex:1;min-width:0;margin:0;font-size:1.0625rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.media-bar .hash{width:auto;margin-right:1px}.media-bar .icon-button{width:2.25rem;height:2.25rem;color:var(--muted)}.media-body{flex:1;overflow-y:auto;padding:0 1.5rem 1.25rem}.media-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(8rem,1fr));gap:.375rem}.media-grid h3{grid-column:1 / -1;margin:1rem 0 .25rem;font-size:.8125rem;font-weight:600;color:var(--muted)}.media-tile{position:relative;display:block;width:100%;aspect-ratio:1;padding:0;border:0;border-radius:.375rem;overflow:hidden;background:var(--surface);cursor:pointer}.media-tile img{display:block;width:100%;height:100%;object-fit:cover}.media-tile:hover{opacity:.85}.media-status{margin:1rem 0 0;text-align:center;color:var(--muted);font-size:.9rem}@media(max-width:40rem){dialog.media{width:100%;height:100%;border:0;border-radius:0}.media-bar{padding-top:max(.5rem,env(safe-area-inset-top))}}
|
|
2
|
+
/*# sourceMappingURL=media-BCKZQR2R.css.map */
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../web/styles/media.css"],
|
|
4
|
+
"sourcesContent": ["/* Media grid (DESIGN.md \u00A730). Not part of app.css: the grid links this file when it first opens.\n Uses app.css's custom properties, so it follows the theme. */\n\ndialog.media {\n width: min(55rem, 100%);\n height: min(49.25rem, 100%);\n max-width: none;\n max-height: none;\n padding: 0;\n border: 1px solid var(--border);\n border-radius: 1rem;\n background: color-mix(in srgb, var(--raised), var(--bg));\n color: var(--fg);\n box-shadow: var(--shadow);\n}\n\ndialog.media[open] {\n display: flex;\n flex-direction: column;\n}\n\ndialog.media::backdrop {\n background: rgb(8 6 14 / 70%);\n}\n\n.media-bar {\n display: flex;\n align-items: center;\n gap: 0.625rem;\n padding: 0.875rem 1rem 0.75rem 1.5rem;\n border-bottom: 1px solid var(--border);\n}\n\n.media-bar h2 {\n flex: 1;\n min-width: 0;\n margin: 0;\n font-size: 1.0625rem;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.media-bar .hash {\n width: auto;\n margin-right: 1px;\n}\n\n.media-bar .icon-button {\n width: 2.25rem;\n height: 2.25rem;\n color: var(--muted);\n}\n\n.media-body {\n flex: 1;\n overflow-y: auto;\n padding: 0 1.5rem 1.25rem;\n}\n\n.media-grid {\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));\n gap: 0.375rem;\n}\n\n.media-grid h3 {\n grid-column: 1 / -1;\n margin: 1rem 0 0.25rem;\n font-size: 0.8125rem;\n font-weight: 600;\n color: var(--muted);\n}\n\n.media-tile {\n position: relative;\n display: block;\n width: 100%;\n aspect-ratio: 1;\n padding: 0;\n border: 0;\n border-radius: 0.375rem;\n overflow: hidden;\n background: var(--surface);\n cursor: pointer;\n}\n\n.media-tile img {\n display: block;\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n\n.media-tile:hover {\n opacity: 0.85;\n}\n\n.media-status {\n margin: 1rem 0 0;\n text-align: center;\n color: var(--muted);\n font-size: 0.9rem;\n}\n\n@media (max-width: 40rem) {\n dialog.media {\n width: 100%;\n height: 100%;\n border: 0;\n border-radius: 0;\n }\n .media-bar {\n padding-top: max(0.5rem, env(safe-area-inset-top));\n }\n}\n"],
|
|
5
|
+
"mappings": "AAGA,MAAM,CAAC,MACL,MAAO,IAAI,KAAK,CAAE,MAClB,OAAQ,IAAI,QAAQ,CAAE,MACtB,UAAW,KACX,WAAY,KAPd,QAQW,EACT,OAAQ,IAAI,MAAM,IAAI,UATx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cA8GmB,CACjB,CACA,CAvFD,UAwFG,YAAa,IAAI,KAAM,CAAE,IAAI,qBAC/B,CACF",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as i}from"./chunk-VTOUI25E.js";var P=(n,f,u,y)=>`${n}${f?", video":""}, ${u??"Unknown"}, ${y}`;var I=null;function B(){return I??=new Promise(n=>{let u=i("link",{rel:"stylesheet",href:"/assets/media-
|
|
2
|
-
//# sourceMappingURL=media-
|
|
1
|
+
import{a as i}from"./chunk-VTOUI25E.js";var P=(n,f,u,y)=>`${n}${f?", video":""}, ${u??"Unknown"}, ${y}`;var I=null;function B(){return I??=new Promise(n=>{let u=i("link",{rel:"stylesheet",href:"/assets/media-BCKZQR2R.css",on:{load:()=>n(),error:()=>{u.remove(),I=null,n()}}});document.head.append(u)}),I}var R=`media-${Date.now()}-${Math.random()}`,M=()=>history.state?.media===R,U=null,L=!1;function K(n){if(L)return;L=!0;let{api:f}=n,u=document.activeElement,y=new AbortController,{signal:l}=y;n.signal.addEventListener("abort",()=>h(!1),{signal:l});let S=i("h2",{id:"media-title"},n.label?["Media in ",i("span",{class:"hash"},"#"),n.label]:"Media"),E=i("div",{class:"media-grid"}),r=i("p",{class:"media-status",role:"status"}),O=i("div",{class:"media-body"},[E,r]),d=i("dialog",{class:"media","aria-labelledby":S.id},[i("header",{class:"media-bar"},[S,i("button",{type:"button",class:"icon-button ic i-x","aria-label":"Close",autofocus:!0,on:{click:()=>h(!0)},signal:l})]),O]),c=[],p,_=new Map,g=!1,x=!1,k="",m=!1,$=new Intl.DateTimeFormat(void 0,{month:"long",year:"numeric"});async function C(){if(!(x||g||m)){x=!0,r.textContent="Loading\u2026";try{let e=await f.media(n.room,p&&{sent:p.sent,message:p.message,pos:p.pos},l);if(m)return;g=!e.more,p=e.items.at(-1)??p;for(let t of e.items)Y(t);r.textContent=g?c.length?"":"No photos or videos here yet.":""}catch{if(m)return;b.unobserve(r),r.replaceChildren("Couldn't load media. ",i("button",{type:"button",class:"link",on:{click:()=>{C()}},signal:l},"Retry"));return}finally{x=!1}b.unobserve(r),!g&&!m&&b.observe(r)}}function V(e){let t=_.get(e.message);if(!t){let{message:a,sent:o,author:s}=e;t={id:a,room:n.room,author:s?.id??"",text:"",created:o,updated:o,edited_at:"",deleted:!1},t.files=[],t.file_names={},e.source!==a&&(t.forward_of=e.source),s&&(t.expand={author:s}),_.set(a,t)}return t.files.unshift(e.file),e.name&&(t.file_names[e.file]=e.name),t}function Y(e){let{file:t,video:a}=e,o=V(e),s=new Date(o.created.replace(" ","T")),v=$.format(s);v!==k&&(k=v,E.append(i("h3",{},v)));let G=n.name(o,t),j=()=>a?f.posterUrl(o,t):f.fileUrl(o,t,"240x240"),w=(!a||e.poster)&&i("img",{src:j(),alt:"",loading:"lazy",decoding:"async"});w&&a&&w.addEventListener("error",()=>w.remove(),{signal:l});let T=P(G,a,o.expand?.author?.name,s.toLocaleDateString()),N=i("button",{type:"button",class:"media-tile","aria-label":T,title:T,on:{click:()=>z(H)},signal:l},[w,a&&i("span",{class:"att-play","aria-hidden":"true"})]),H={message:o,file:t,video:a,tile:N};c.push(H),E.append(N)}function z({message:e,file:t,tile:a}){let o=c.map(({tile:s,...v})=>v).reverse();n.open(e,t,a,o,[!g,!1],()=>h(!0,!1))}n.follow((e,t)=>{let a=new Set(t||e.deleted?[]:e.files??[]);for(let o of c.filter(s=>s.message.id===e.id&&!a.has(s.file))){c.splice(c.indexOf(o),1);let s=o.tile.previousElementSibling;o.tile.remove(),s?.tagName==="H3"&&(!s.nextElementSibling||s.nextElementSibling.tagName==="H3")&&s.remove()}g&&!c.length&&(r.textContent="No photos or videos here yet.")});let b=new IntersectionObserver(e=>e.some(t=>t.isIntersecting)&&void C(),{root:O,rootMargin:"400px"});function h(e,t=!0){m||(m=!0,L=!1,y.abort(),b.disconnect(),n.follow(void 0),d.open&&d.close(),e?U=F().finally(()=>d.remove()):d.remove(),t&&u?.focus())}let D=()=>new Promise(e=>window.addEventListener("popstate",e,{once:!0})),A=()=>!!history.state?.viewer;async function F(){if(!M()&&A()&&await D(),!M())return;let e=D();history.back(),await e}d.addEventListener("close",()=>h(!0),{signal:l}),(async()=>(await Promise.all([B(),U]),!m&&(M()||history.pushState({media:R},""),window.addEventListener("popstate",()=>!M()&&!A()&&h(!1),{signal:l}),document.body.append(d),d.showModal(),b.observe(r))))()}export{K as openMedia};
|
|
2
|
+
//# sourceMappingURL=media-VCJWBQJZ.js.map
|
|
Binary file
|
|
Binary file
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as d}from"./chunk-VTOUI25E.js";function k(p,f){let t=/(?:^|[^A-Za-z0-9_@./])@([A-Za-z0-9_]{0,24})$/.exec(p.slice(0,f));return t?{start:f-t[1].length-1,query:t[1].toLowerCase()}:null}var x=120;function C(p){let{api:f,textarea:t,signal:a}=p;document.querySelector('link[href="/assets/emoji-
|
|
2
|
-
//# sourceMappingURL=mention-suggest-
|
|
1
|
+
import{a as d}from"./chunk-VTOUI25E.js";function k(p,f){let t=/(?:^|[^A-Za-z0-9_@./])@([A-Za-z0-9_]{0,24})$/.exec(p.slice(0,f));return t?{start:f-t[1].length-1,query:t[1].toLowerCase()}:null}var x=120;function C(p){let{api:f,textarea:t,signal:a}=p;document.querySelector('link[href="/assets/emoji-IHRUMGCY.css"]')||document.head.append(d("link",{rel:"stylesheet",href:"/assets/emoji-IHRUMGCY.css"}));let m=`${t.id}-people`,r=d("ul",{class:"emoji-suggest",id:m,role:"listbox","aria-label":"People",hidden:!0});document.body.append(r),a.addEventListener("abort",()=>r.remove(),{once:!0});let s=[],i=0,c=-1,v=-1,g,h=null;a.addEventListener("abort",()=>{clearTimeout(g),h?.abort()});function b(){let e=t.selectionStart,n=e===t.selectionEnd?k(t.value,e):null;if(n||(v=-1),!n||n.start===v)return u();clearTimeout(g),g=setTimeout(()=>{A(n.start,n.query)},x)}async function A(e,n){h?.abort();let o=new AbortController;h=o;let l;try{l=await f.request("/api/chat/mentionable",{query:{room:p.room(),q:n},signal:o.signal})}catch{return}let y=k(t.value,t.selectionStart);if(!(o.signal.aborted||a.aborted||y?.start!==e||y.query!==n)){if(s=l,!s.length)return u();e!==c&&(i=0),c=e,i=Math.min(i,s.length-1),w()}}function w(){r.replaceChildren(...s.map((n,o)=>d("li",{id:`${m}-${o}`,role:"option","aria-selected":String(o===i),on:{pointerdown:l=>l.preventDefault(),click:()=>E(o)},signal:a},[p.avatar(n),d("span",{class:"who"},n.name),d("span",{class:"handle"},`@${n.handle}`)]))),t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-controls",m),t.setAttribute("aria-activedescendant",`${m}-${i}`),r.hidden=!1;let e=(t.parentElement??t).getBoundingClientRect();r.style.setProperty("--x",`${Math.round(Math.max(8,t.getBoundingClientRect().left))}px`),r.style.setProperty("--b",`${Math.round(innerHeight-e.top+6)}px`)}function S(e){i=(e+s.length)%s.length;for(let[n,o]of[...r.children].entries())o.setAttribute("aria-selected",String(n===i));t.setAttribute("aria-activedescendant",`${m}-${i}`),r.children[i]?.scrollIntoView?.({block:"nearest"})}function E(e){let n=s[e];if(!n||c<0)return;let o=c;u(),t.focus();let l=t.selectionStart,y=/^\w*/.exec(t.value.slice(l))?.[0].length??0;t.setRangeText(`@${n.handle} `,o,l+y,"end"),t.dispatchEvent(new Event("input",{bubbles:!0}))}function u(){if(c=-1,clearTimeout(g),h?.abort(),!r.hidden){r.hidden=!0,r.replaceChildren();for(let e of["aria-autocomplete","aria-controls","aria-activedescendant"])t.removeAttribute(e)}}return t.addEventListener("input",b,{signal:a}),t.addEventListener("click",b,{signal:a}),t.addEventListener("keyup",e=>{!r.hidden&&/^(ArrowLeft|ArrowRight|Home|End)$/.test(e.key)&&b()},{signal:a}),t.addEventListener("blur",u,{signal:a}),(t.form??t.parentElement)?.addEventListener("keydown",e=>{if(e.target!==t||r.hidden||e.isComposing||e.keyCode===229)return;let n=!(e.shiftKey||e.ctrlKey||e.altKey||e.metaKey);if(e.key==="ArrowDown"||e.key==="ArrowUp"){if(!n)return;S(i+(e.key==="ArrowDown"?1:-1))}else if((e.key==="Enter"||e.key==="Tab")&&n)E(i);else if(e.key==="Escape")v=c,u();else return;e.preventDefault(),e.stopPropagation()},{capture:!0,signal:a}),{update:b,close:u,get isOpen(){return!r.hidden}}}export{C as createMentionSuggest,k as mentionToken};
|
|
2
|
+
//# sourceMappingURL=mention-suggest-K3UUHR4D.js.map
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.pin-bar{border-top:1px solid var(--line);background:var(--glass);-webkit-backdrop-filter:var(--glass-blur);backdrop-filter:var(--glass-blur)}.pin-row{display:flex;gap:.25rem;align-items:center;padding:.25rem 1.25rem .25rem 1.5rem}.pin-main{display:grid;flex:1;grid-template-columns:auto minmax(0,1fr);column-gap:.5rem;min-width:0;padding:.25rem .5rem;border:0;border-radius:.5rem;background:none;color:var(--text);text-align:left}.pin-main:before{grid-row:span 2;align-self:center;color:var(--accent)}.pin-main:hover{background:var(--hover)}.pin-label{font-size:.75rem;font-weight:600;color:var(--accent)}.pin-text,.pin-list button{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.pin-text{font-size:.875rem}.pin-bar.open .pin-more:before{transform:rotate(180deg)}.pin-unpin{font-size:1.25rem;color:var(--muted)}.pin-list{max-height:40vh;margin:0;padding:0 1.25rem .5rem 1.5rem;overflow-y:auto;list-style:none}.pin-list button{display:block;width:100%;padding:.375rem .5rem;border:0;border-radius:.5rem;background:none;color:var(--text);font-size:.875rem;text-align:left}.pin-list button:hover,.pin-list button.current{background:var(--hover)}
|
|
2
|
+
/*# sourceMappingURL=pins-DSUFB5EW.css.map */
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../web/styles/pins.css"],
|
|
4
|
+
"sourcesContent": ["/* A room's pin bar (DESIGN.md \u00A745). Not part of app.css: the chunk links this file the first time a room has pins.\n Uses app.css's custom properties and its .ic icons. The mark on a pinned message is in app/room.css. */\n\n.pin-bar {\n border-top: 1px solid var(--line);\n background: var(--glass);\n -webkit-backdrop-filter: var(--glass-blur);\n backdrop-filter: var(--glass-blur);\n}\n\n.pin-row {\n display: flex;\n gap: 0.25rem;\n align-items: center;\n padding: 0.25rem 1.25rem 0.25rem 1.5rem;\n}\n\n.pin-main {\n display: grid;\n flex: 1;\n grid-template-columns: auto minmax(0, 1fr);\n column-gap: 0.5rem;\n min-width: 0;\n padding: 0.25rem 0.5rem;\n border: 0;\n border-radius: 0.5rem;\n background: none;\n color: var(--text);\n text-align: left;\n}\n\n.pin-main::before {\n grid-row: span 2;\n align-self: center;\n color: var(--accent);\n}\n\n.pin-main:hover {\n background: var(--hover);\n}\n\n.pin-label {\n font-size: 0.75rem;\n font-weight: 600;\n color: var(--accent);\n}\n\n.pin-text,\n.pin-list button {\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n}\n\n.pin-text {\n font-size: 0.875rem;\n}\n\n.pin-bar.open .pin-more::before {\n transform: rotate(180deg);\n}\n\n.pin-unpin {\n font-size: 1.25rem;\n color: var(--muted);\n}\n\n.pin-list {\n max-height: 40vh;\n margin: 0;\n padding: 0 1.25rem 0.5rem 1.5rem;\n overflow-y: auto;\n list-style: none;\n}\n\n.pin-list button {\n display: block;\n width: 100%;\n padding: 0.375rem 0.5rem;\n border: 0;\n border-radius: 0.5rem;\n background: none;\n color: var(--text);\n font-size: 0.875rem;\n text-align: left;\n}\n\n.pin-list button:hover,\n.pin-list button.current {\n background: var(--hover);\n}\n"],
|
|
5
|
+
"mappings": "AAGA,CAAC,QACC,WAAY,IAAI,MAAM,IAAI,QAC1B,WAAY,IAAI,SAChB,wBAAyB,IAAI,cAC7B,gBAAiB,IAAI,aACvB,CAEA,CAAC,QACC,QAAS,KACT,IAAK,OACL,YAAa,OAbf,QAcW,OAAQ,QAAQ,OAAQ,MACnC,CAEA,CAAC,SACC,QAAS,KACT,KAAM,EACN,sBAAuB,KAAK,OAAO,CAAC,CAAE,KACtC,WAAY,MACZ,UAAW,EAtBb,QAuBW,OAAQ,MACjB,OAAQ,EAxBV,cAyBiB,MACf,WAAY,KACZ,MAAO,IAAI,QACX,WAAY,IACd,CAEA,CAdC,QAcQ,QACP,SAAU,KAAK,EACf,WAAY,OACZ,MAAO,IAAI,SACb,CAEA,CApBC,QAoBQ,OACP,WAAY,IAAI,QAClB,CAEA,CAAC,UACC,UAAW,OACX,YAAa,IACb,MAAO,IAAI,SACb,CAEA,CAAC,SACD,CAAC,SAAS,OACR,SAAU,OACV,YAAa,OACb,cAAe,QACjB,CAEA,CAPC,SAQC,UAAW,OACb,CAEA,CAvDC,OAuDO,CAAC,KAAK,CAAC,QAAQ,QACrB,UAAW,OAAO,OACpB,CAEA,CAAC,UACC,UAAW,QACX,MAAO,IAAI,QACb,CAEA,CAnBC,SAoBC,WAAY,KApEd,OAqEU,EArEV,QAsEW,EAAE,QAAQ,MAAO,OAC1B,WAAY,KACZ,WAAY,IACd,CAEA,CA3BC,SA2BS,OACR,QAAS,MACT,MAAO,KA7ET,QA8EW,QAAS,MAClB,OAAQ,EA/EV,cAgFiB,MACf,WAAY,KACZ,MAAO,IAAI,QACX,UAAW,QACX,WAAY,IACd,CAEA,CAvCC,SAuCS,MAAM,OAChB,CAxCC,SAwCS,MAAM,CAAC,QACf,WAAY,IAAI,QAClB",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{g as v,h as y}from"./chunk-SZMAZMR4.js";import{a as s}from"./chunk-VTOUI25E.js";var b=null;function w(){return b??=new Promise(i=>{let r=s("link",{rel:"stylesheet",href:"/assets/pins-DSUFB5EW.css",on:{load:()=>i(),error:()=>{r.remove(),b=null,i()}}});document.head.append(r)}),b}function C(i){let{signal:l}=i,r=s("span",{class:"pin-label"}),P=s("span",{class:"pin-text"}),p=s("button",{type:"button",class:"pin-main ic i-pin"},[r,P]),d=s("button",{type:"button",class:"icon-button pin-more ic i-chev","aria-label":"All pinned messages",title:"All pinned messages","aria-expanded":"false"}),m=s("button",{type:"button",class:"icon-button pin-unpin","aria-label":"Unpin",title:"Unpin"},"\xD7"),a=s("ul",{class:"pin-list",hidden:!0,"aria-label":"Pinned messages"}),u=s("div",{class:"pin-bar",hidden:!0,role:"region","aria-label":"Pinned messages"},[s("div",{class:"pin-row"},[p,d,m]),a]),t=[],o="",x="",f=e=>e.text||"Attachment",g=()=>Math.max(0,t.findIndex(e=>e.message===o));function h(){let e=g(),n=t[e];if(u.hidden=!n,!n){c(!1);return}o=n.message,r.textContent=t.length>1?`Pinned message ${e+1} of ${t.length}`:"Pinned message",P.textContent=f(n),p.title=f(n),p.setAttribute("aria-label",`${r.textContent}: ${f(n)}`),d.hidden=t.length<2,t.length<2&&c(!1),a.hidden||E()}function E(){a.replaceChildren(...t.map(e=>s("li",{},s("button",{type:"button",class:e.message===o?"current":"",dataset:{message:e.message}},f(e)))))}function c(e){a.hidden=!e,d.setAttribute("aria-expanded",String(e)),u.classList.toggle("open",e),e&&E()}p.addEventListener("click",()=>{let e=t[g()];if(!e)return;i.onOpen(e.message);let n=t[(g()+1)%t.length];n&&(o=n.message),h()},{signal:l}),d.addEventListener("click",()=>c(a.hidden!==!1),{signal:l}),m.addEventListener("click",()=>{let e=t[g()];e&&i.onUnpin(e.message)},{signal:l}),a.addEventListener("click",e=>{let n=e.target.closest("button[data-message]");n&&(o=n.dataset.message,c(!1),h(),i.onOpen(o))},{signal:l}),u.addEventListener("keydown",e=>{e.key!=="Escape"||a.hidden||(e.preventDefault(),c(!1),d.focus())},{signal:l});function A(e,n){t=y(e),m.hidden=!e||!v(e,n);let S=JSON.stringify([t,m.hidden]);S!==x&&(x=S,h())}function L(e){o=e,t.some(n=>n.message===e)&&h()}return{el:u,update:A,show:L}}export{C as createPinBar,w as loadStylesheet};
|
|
2
|
+
//# sourceMappingURL=pins-XWBYZN4P.js.map
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../web/src/views/room/pins.ts"],
|
|
4
|
+
"sourcesContent": ["// The pin bar (\u00A745): under the room header while the room has pinned messages. It shows one pin at a time, newest\n// first: its text (or \"Attachment\"), and \"2 of 3\" when there are more. Clicking it goes to that message, however far\n// back, and moves on to the next older pin, so clicking again walks through them all. With more than one, a button\n// lists them all, and whoever may pin (lib/rooms.ts canPin) gets an Unpin button. The pins come with the room, so\n// a change anyone makes shows here live. A lazy chunk (room.ts loads it the first time a room has pins), with a\n// stylesheet of its own (web/styles/pins.css).\n\nimport { h } from \"../../dom.ts\";\nimport { canPin, pinsOf } from \"../../lib/rooms.ts\";\nimport type { Pin, Room, User } from \"../../lib/types.ts\";\nimport * as S from \"../../strings/room-pins.ts\";\n\ndeclare const PINS_CSS: string;\n\nlet sheet: Promise<void> | null = null;\n/** Links pins.css once; resolves when it has loaded (or failed, to be tried again next time). */\nexport function loadStylesheet(): Promise<void> {\n sheet ??= new Promise((resolve) => {\n const failed = () => {\n link.remove();\n sheet = null;\n resolve();\n };\n const link = h(\"link\", { rel: \"stylesheet\", href: PINS_CSS, on: { load: () => resolve(), error: failed } });\n document.head.append(link);\n });\n return sheet;\n}\n\nexport interface PinBar {\n readonly el: HTMLElement;\n update(room: Room | undefined, me: User | null): void;\n /** Shows this pin (one just made): later updates keep it. */\n show(message: string): void;\n}\n\nexport function createPinBar(opts: {\n /** Go to the pinned message. */\n onOpen: (messageId: string) => void;\n /** Unpin it. */\n onUnpin: (messageId: string) => void;\n signal: AbortSignal;\n}): PinBar {\n const { signal } = opts;\n const label = h(\"span\", { class: \"pin-label\" });\n const text = h(\"span\", { class: \"pin-text\" });\n const main = h(\"button\", { type: \"button\", class: \"pin-main ic i-pin\" }, [label, text]);\n const more = h(\"button\", {\n type: \"button\",\n class: \"icon-button pin-more ic i-chev\",\n \"aria-label\": \"All pinned messages\",\n title: \"All pinned messages\",\n \"aria-expanded\": \"false\",\n });\n const unpin = h(\"button\", { type: \"button\", class: \"icon-button pin-unpin\", \"aria-label\": \"Unpin\", title: \"Unpin\" }, \"\u00D7\");\n const list = h(\"ul\", { class: \"pin-list\", hidden: true, \"aria-label\": \"Pinned messages\" });\n const el = h(\"div\", { class: \"pin-bar\", hidden: true, role: \"region\", \"aria-label\": \"Pinned messages\" }, [\n h(\"div\", { class: \"pin-row\" }, [main, more, unpin]),\n list,\n ]);\n\n let pins: readonly Pin[] = [];\n /** The pin shown, by its message: stays put when others are pinned or unpinned. */\n let current = \"\";\n let shownKey = \"\";\n\n const snippet = (p: Pin) => p.text || \"Attachment\";\n const indexOf = () =>\n Math.max(\n 0,\n pins.findIndex((p) => p.message === current),\n );\n\n function draw() {\n const i = indexOf();\n const p = pins[i];\n el.hidden = !p;\n if (!p) {\n setList(false);\n return;\n }\n current = p.message;\n label.textContent = pins.length > 1 ? `Pinned message ${i + 1} of ${pins.length}` : \"Pinned message\";\n text.textContent = snippet(p);\n main.title = snippet(p);\n main.setAttribute(\"aria-label\", `${label.textContent}: ${snippet(p)}`);\n more.hidden = pins.length < 2;\n if (pins.length < 2) setList(false);\n if (!list.hidden) fillList();\n }\n\n function fillList() {\n list.replaceChildren(\n ...pins.map((p) =>\n h(\n \"li\",\n {},\n h(\n \"button\",\n {\n type: \"button\",\n class: p.message === current ? \"current\" : \"\",\n dataset: { message: p.message },\n },\n snippet(p),\n ),\n ),\n ),\n );\n }\n\n function setList(open: boolean) {\n list.hidden = !open;\n more.setAttribute(\"aria-expanded\", String(open));\n el.classList.toggle(\"open\", open);\n if (open) fillList();\n }\n\n main.addEventListener(\n \"click\",\n () => {\n const p = pins[indexOf()];\n if (!p) return;\n opts.onOpen(p.message);\n // On to the next older one (back to the newest after the last).\n const next = pins[(indexOf() + 1) % pins.length];\n if (next) current = next.message;\n draw();\n },\n { signal },\n );\n more.addEventListener(\"click\", () => setList(list.hidden !== false), { signal });\n unpin.addEventListener(\n \"click\",\n () => {\n const p = pins[indexOf()];\n if (p) opts.onUnpin(p.message);\n },\n { signal },\n );\n list.addEventListener(\n \"click\",\n (e) => {\n const b = (e.target as Element).closest<HTMLElement>(\"button[data-message]\");\n if (!b) return;\n current = b.dataset.message!;\n setList(false);\n draw();\n opts.onOpen(current);\n },\n { signal },\n );\n el.addEventListener(\n \"keydown\",\n (e) => {\n if (e.key !== \"Escape\" || list.hidden) return;\n e.preventDefault();\n setList(false);\n more.focus();\n },\n { signal },\n );\n\n function update(room: Room | undefined, me: User | null) {\n pins = pinsOf(room);\n unpin.hidden = !room || !canPin(room, me);\n const key = JSON.stringify([pins, unpin.hidden]);\n if (key === shownKey) return;\n shownKey = key;\n draw();\n }\n\n function show(message: string) {\n current = message;\n // Not in the list yet: the room's update draws it.\n if (pins.some((p) => p.message === message)) draw();\n }\n\n return { el, update, show };\n}\n"],
|
|
5
|
+
"mappings": "uFAcA,IAAIA,EAA8B,KAE3B,SAASC,GAAgC,CAC9C,OAAAD,IAAU,IAAI,QAASE,GAAY,CAMjC,IAAMC,EAAOC,EAAE,OAAQ,CAAE,IAAK,aAAc,KAAM,4BAAU,GAAI,CAAE,KAAM,IAAMF,EAAQ,EAAG,MAL1E,IAAM,CACnBC,EAAK,OAAO,EACZH,EAAQ,KACRE,EAAQ,CACV,CACuG,CAAE,CAAC,EAC1G,SAAS,KAAK,OAAOC,CAAI,CAC3B,CAAC,EACMH,CACT,CASO,SAASK,EAAaC,EAMlB,CACT,GAAM,CAAE,OAAAC,CAAO,EAAID,EACbE,EAAQJ,EAAE,OAAQ,CAAE,MAAO,WAAY,CAAC,EACxCK,EAAOL,EAAE,OAAQ,CAAE,MAAO,UAAW,CAAC,EACtCM,EAAON,EAAE,SAAU,CAAE,KAAM,SAAU,MAAO,mBAAoB,EAAG,CAACI,EAAOC,CAAI,CAAC,EAChFE,EAAOP,EAAE,SAAU,CACvB,KAAM,SACN,MAA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,EACxC,IAAMG,EAAM,KAAK,UAAU,CAAClB,EAAMH,EAAM,MAAM,CAAC,EAC3CqB,IAAQhB,IACZA,EAAWgB,EACXZ,EAAK,EACP,CAEA,SAASa,EAAKC,EAAiB,CAC7BnB,EAAUmB,EAENpB,EAAK,KAAMI,GAAMA,EAAE,UAAYgB,CAAO,GAAGd,EAAK,CACpD,CAEA,MAAO,CAAE,GAAAP,EAAI,OAAAc,EAAQ,KAAAM,CAAK,CAC5B",
|
|
6
|
+
"names": ["sheet", "loadStylesheet", "resolve", "link", "h", "createPinBar", "opts", "signal", "label", "text", "main", "more", "unpin", "list", "el", "pins", "current", "shownKey", "snippet", "p", "indexOf", "draw", "i", "setList", "fillList", "open", "next", "b", "update", "room", "me", "pinsOf", "canPin", "key", "show", "message"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{f as Te,h as Pe,i as V,j as Le,k as Oe,l as Ce,n as j,o as Re,p as De,q as Ie}from"./chunk-RYZHXNLF.js";import{a as Ae}from"./chunk-RPCBA7VF.js";import{a as we}from"./chunk-AG73QNUN.js";import{a as f,b as _e}from"./chunk-UZDXAORM.js";import{j as L,l as O,o as xe,s as Se}from"./chunk-DC4TJ7HF.js";import{a as e,b as be,c as F}from"./chunk-VTOUI25E.js";var Ne=d=>`That image is too large (max ${d} MB).`;function Ve(){document.querySelector('link[href="/assets/account-EBCPOLWT.css"]')||document.head.append(e("link",{rel:"stylesheet",href:"/assets/account-EBCPOLWT.css"}))}var $e=3e3,je=512,ke="Choose a JPEG, PNG, WebP or GIF image.";function Me(d,u=f){return u.avatarTypes.includes(d.type)?d.size>u.avatarBytes?Ne(u.avatarBytes/1024/1024):"":ke}function Ke(d,u,C,R=f){return d?u.length<R.passwordMin?{next:`Must be at least ${R.passwordMin} characters.`}:u===d?{next:"That is your current password. Choose a new one."}:C!==u?{confirm:"The passwords don't match."}:{}:{current:"Enter your current password."}}function at({api:d,store:u,logOut:C,notify:R}){let K=(s,o)=>s instanceof L&&s.fields[o]||O(s),a=be("profile"),i=we(),{signal:l}=i,D,y=null,m=!1,w=()=>u.get().user,b=e("div",{class:"profile-picture"}),x=e("input",{id:`${a}-file`,type:"file",accept:f.avatarTypes.join(","),class:"visually-hidden"}),q=e("label",{for:`${a}-file`,class:"button"},"Change picture"),U=e("button",{type:"button"},"Remove"),S=e("p",{class:"field-error",role:"alert"}),J=e("p",{class:"field-status"}),Z=()=>J.textContent=`Signed in as ${w()?.name??""} on this device.`;Z();let A=e("input",{id:`${a}-name`,name:"name",autocomplete:"nickname","aria-describedby":`${a}-name-status`}),X=e("button",{type:"submit",class:"primary"},"Save"),Q=e("p",{id:`${a}-name-status`,class:"field-status",role:"status"}),_=e("input",{id:`${a}-handle`,name:"handle",autocomplete:"username",autocapitalize:"none",spellcheck:!1,"aria-describedby":`${a}-handle-status`}),ee=e("button",{type:"submit",class:"primary"},"Save"),te=e("p",{id:`${a}-handle-status`,class:"field-status",role:"status"},"People mention you by it: @handle."),Y=(s,o,t)=>{let r=`${a}-pw-${s}`,c=e("input",{id:r,type:"password",name:s,autocomplete:t,required:!0,...s==="current"?{}:{minlength:f.passwordMin},"aria-describedby":`${r}-error`}),n=e("p",{id:`${r}-error`,class:"field-error"}),M=e("div",{class:"field"},[e("label",{for:r},o),c,n]);return{input:c,error:n,el:M}},p={current:Y("current","Current password","current-password"),next:Y("next","New password","new-password"),confirm:Y("confirm","Confirm new password","new-password")},H=e("button",{type:"submit",class:"primary"},"Change password"),E=e("p",{class:"field-status",role:"status"}),g=e("button",{type:"button"},"Prepare my data"),I=e("button",{type:"button",class:"primary",hidden:!0},"Download"),h=e("p",{class:"field-status",role:"status"}),N,se=null,Ue=null,$=()=>Ue??=d.account(),oe=(s,o)=>{let t=e("input",{type:"radio",name:`${a}-del-messages`,value:s});return{input:t,el:e("label",{},[t,o])}},G=oe("keep","Keep my messages, shown as by \u201CDeleted account\u201D"),ae=oe("delete","Delete my messages too"),re=e("p",{id:`${a}-del-choice-error`,class:"field-error"}),T=e("input",{id:`${a}-del-password`,type:"password",name:"delete-password",autocomplete:"current-password","aria-describedby":`${a}-del-password-error`}),ne=e("p",{id:`${a}-del-password-error`,class:"field-error"}),W=e("button",{type:"submit",class:"danger"},"Delete my account"),v=e("p",{class:"field-status",role:"status"}),Ye={auto:"Auto",light:"Light",dark:"Dark"},ie=new Map,ce=e("div",{class:"segmented"},[...V.map(s=>{let o=e("input",{type:"radio",name:`${a}-theme`,value:s});return ie.set(s,o),e("label",{},[o,Ye[s]])})]),le=()=>{let s=Oe();for(let[o,t]of ie)t.checked=o===s},He={small:"Small",medium:"Medium",large:"Large"},de=new Map,ue=e("div",{class:"segmented"},[...j.map(s=>{let o=e("input",{type:"radio",name:`${a}-size`,value:s});return de.set(s,o),e("label",{},[o,He[s]])})]),pe=()=>{let s=De();for(let[o,t]of de)t.checked=o===s},fe=e("div");function B(){y&&URL.revokeObjectURL(y),y=null}function P(){let s=w();if(!s)return;let o=y?e("img",{class:"avatar s96",src:y,width:96,height:96,alt:""}):Ae(s,96,d.avatarUrl);b.replaceChildren(o),b.classList.toggle("busy",m),U.hidden=!s.avatar||m,x.disabled=m,q.classList.toggle("disabled",m)}async function me(s){if(!s||m)return;S.textContent="";let o=Me(new File([],s.name,{type:s.type}),f);if(o){S.textContent=o;return}m=!0;let t=await Pe(s,je);if(!i.active)return;let r=Me(t,f);if(r){m=!1,S.textContent=r;return}B(),y=URL.createObjectURL(t),P(),await he(()=>d.setAvatar(t))}async function he(s){m=!0,P();try{let o=await s();if(!i.active)return;u.set({user:o})}catch(o){let t=o instanceof L&&o.codes.avatar==="validation_invalid_mime_type";i.active&&(S.textContent=t?ke:K(o,"avatar"))}finally{i.active&&(m=!1,B(),P())}}async function ve(s,o){s.preventDefault();let[t,r,c]=o==="name"?[A,Q,X]:[_,te,ee],n=o==="name"?t.value.trim():t.value.trim().replace(/^@/,"").toLowerCase();r.classList.remove("error");let M=o==="handle"?/^[a-z0-9_]{3,24}$/.test(n)?"":"Use 3 to 24 letters a\u2013z, digits or underscores.":n?_e(n)>f.userName?`Must be no more than ${f.userName} characters.`:"":"A display name can't be empty.";if(M){r.textContent=M,r.classList.add("error"),t.setAttribute("aria-invalid","true");return}if(r.textContent="",t.removeAttribute("aria-invalid"),n!==w()?.[o]){c.disabled=!0;try{let k=await(o==="name"?d.rename(n):d.setHandle(n));if(!i.active)return;u.set({user:k}),t.value=k[o]??"",r.textContent="Saved."}catch(k){if(!i.active)return;r.textContent=K(k,o),r.classList.add("error"),t.setAttribute("aria-invalid","true")}finally{c.disabled=!1}}}function ye(s){for(let[t,r]of Object.entries(p)){let c=s[t]??"";r.error.textContent=c,c?r.input.setAttribute("aria-invalid","true"):r.input.removeAttribute("aria-invalid")}let o=Object.keys(p).find(t=>s[t]);o&&p[o].input.focus()}async function Ge(s){s.preventDefault();let o=p.current.input.value,t=p.next.input.value;E.textContent="",E.classList.remove("error");let r=Ke(o,t,p.confirm.input.value,f);if(ye(r),!Object.keys(r).length){H.disabled=!0;try{let c=await d.changePassword(o,t);if(!i.active)return;u.set({user:c});for(let n of Object.values(p))n.input.value="";E.textContent="Password changed. You were logged out everywhere else."}catch(c){if(!i.active)return;let n=c instanceof L?c.fields:{};n.oldPassword||n.password?ye({...n.oldPassword?{current:n.oldPassword}:{},...n.password?{next:n.password}:{}}):(E.textContent=O(c),E.classList.add("error"))}finally{i.active&&(H.disabled=!1)}}}function Ee(s){clearTimeout(N),se=s,h.classList.toggle("error",s.state==="failed"),h.textContent=s.state==="queued"?"Preparing your data. On a big account this takes a while: you can leave this page and come back.":s.state==="done"?`Ready: ${Te(s.size)}, to download until ${Se(xe(s.expires))}.`:s.state==="failed"?"Your data couldn't be prepared. Try again.":"",g.hidden=s.state==="queued",g.textContent=s.state==="done"?"Prepare again":"Prepare my data",I.hidden=s.state!=="done",s.state==="queued"&&(N=setTimeout(()=>{z()},$e))}async function z(){try{let s=await(await $()).exportStatus(l);i.active&&Ee(s)}catch{i.active&&g.hidden&&(N=setTimeout(()=>{z()},$e))}}async function ge(s,o){s.disabled=!0;try{await o()}catch(t){if(!i.active)return;h.textContent=O(t),h.classList.add("error")}finally{i.active&&(s.disabled=!1)}}let We=()=>ge(g,async()=>{let s=se,o=await(await $()).startExport();i.active&&(Ee(o),o.state==="done"&&s?.state==="done"&&s.id===o.id&&(h.textContent=`${h.textContent} It was prepared less than 10 minutes ago, so this one is still the newest.`))}),Be=()=>ge(I,async()=>{let s=await(await $()).exportFileUrl();if(!i.active)return;let o=e("a",{href:s,download:"",hidden:!0});document.body.append(o),o.click(),o.remove()});async function ze(s){s.preventDefault();let o=G.input.checked?"keep":ae.input.checked?"delete":null,t=T.value,r=(c,n)=>{re.textContent=c,ne.textContent=n,n?T.setAttribute("aria-invalid","true"):T.removeAttribute("aria-invalid"),c?G.input.focus():n&&T.focus()};if(v.textContent="",v.classList.remove("error"),r(o?"":"Choose whether your messages stay or go.",t?"":"Enter your password."),!(!o||!t)){W.disabled=!0,v.textContent="Deleting\u2026";try{if(await(await $()).deleteAccount(t,o),!i.active)return;C()}catch(c){if(!i.active)return;v.textContent="";let n=c instanceof L?c.fields:{};n.password||n.messages?r(n.messages??"",n.password??""):(v.textContent=O(c),v.classList.add("error"))}finally{i.active&&(W.disabled=!1)}}}return{mount(s){D=s,Ve(),A.value=w()?.name??"",_.value=w()?.handle??"",x.addEventListener("change",()=>{let t=x.files?.[0];x.value="",me(t)},{signal:l}),U.addEventListener("click",()=>{he(()=>d.removeAvatar())},{signal:l}),g.addEventListener("click",()=>{We()},{signal:l}),I.addEventListener("click",()=>{Be()},{signal:l}),i.defer(()=>clearTimeout(N)),z(),b.addEventListener("dragover",t=>t.preventDefault(),{signal:l}),b.addEventListener("drop",t=>{t.preventDefault(),me(t.dataTransfer?.files[0])},{signal:l});let o=e("section",{class:"profile","aria-labelledby":`${a}-title`},[e("header",{class:"room-header"},[e("a",{href:"/",class:"back ic i-back","aria-label":"Back to rooms"}),e("h1",{id:`${a}-title`},"Settings")]),e("div",{class:"profile-body"},[e("section",{class:"card","aria-label":"Profile"},[e("div",{class:"profile-avatar"},[b,e("div",{},[e("h2",{},"Profile picture"),e("div",{class:"profile-avatar-actions"},[x,q,U])])]),S,e("form",{class:"profile-name",on:{submit:t=>{ve(t,"name")}},signal:l},[e("label",{for:`${a}-name`},"Display name"),e("div",{class:"row"},[A,X]),Q]),e("form",{class:"profile-name",on:{submit:t=>{ve(t,"handle")}},signal:l},[e("label",{for:`${a}-handle`},"Handle"),e("div",{class:"row"},[_,ee]),te])]),e("fieldset",{class:"card profile-theme","aria-describedby":`${a}-theme-hint`},[e("legend",{},"Appearance"),e("p",{id:`${a}-theme-hint`,class:"field-status"},"Auto follows your system. Saved on this device."),ce]),e("fieldset",{class:"card profile-theme profile-size","aria-describedby":`${a}-size-hint`},[e("legend",{},"Text size"),e("p",{id:`${a}-size-hint`,class:"field-status"},"Larger text across the app. Saved on this device."),ue]),fe,e("form",{class:"card profile-password","aria-labelledby":`${a}-pw-title`,novalidate:!0,on:{submit:t=>{Ge(t)}},signal:l},[e("h2",{id:`${a}-pw-title`},"Password"),p.current.el,p.next.el,p.confirm.el,H,E]),u.get().user?.moderator?e("section",{class:"card profile-session","aria-labelledby":`${a}-stats-title`},[e("div",{},[e("h2",{id:`${a}-stats-title`},"Moderation"),e("p",{class:"field-status"},"How many people are online and use the app, as counts.")]),e("a",{href:"/stats"},"Usage statistics")]):null,e("section",{class:"card profile-session","aria-labelledby":`${a}-session-title`},[e("div",{},[e("h2",{id:`${a}-session-title`},"Session"),J]),e("button",{type:"button",class:"danger",on:{click:()=>C()},signal:l},"Log out")]),e("section",{class:"card profile-session profile-export","aria-labelledby":`${a}-data-title`},[e("div",{},[e("h2",{id:`${a}-data-title`},"Your data"),e("p",{class:"field-status"},"Your profile, the messages you wrote, your rooms and collections, as a JSON file. It is prepared in the background, then kept for 7 days."),h]),e("div",{class:"profile-export-actions"},[I,g])]),e("form",{class:"card profile-delete","aria-labelledby":`${a}-del-title`,novalidate:!0,on:{submit:t=>{ze(t)}},signal:l},[e("h2",{id:`${a}-del-title`},"Delete account"),e("p",{class:"field-status"},"Your name, handle, picture, e-mail, collections and sessions are deleted, and nobody can sign in to the account again. This can't be undone."),e("fieldset",{class:"profile-delete-choice","aria-describedby":`${a}-del-choice-error`},[G.el,ae.el]),re,e("div",{class:"field"},[e("label",{for:`${a}-del-password`},"Your password"),T,ne]),W,v])])]);F(D),D.append(o),P(),le(),pe(),import("./notify-EPDM772N.js").then(t=>i.active&&fe.replaceWith(t.notifySettings({id:a,onChange:R,signal:l})),()=>{}),ce.addEventListener("change",t=>{let r=t.target.value;V.includes(r)&&Ce(r)},{signal:l}),ue.addEventListener("change",t=>{let r=t.target.value;j.includes(r)&&Ie(r)},{signal:l}),addEventListener("storage",t=>(t.key===Le||t.key===null)&&le(),{signal:l}),addEventListener("storage",t=>(t.key===Re||t.key===null)&&pe(),{signal:l}),i.defer(u.subscribe((t,r)=>{t.user!==r.user&&(P(),Z(),t.user&&A.value.trim()===r.user?.name&&(A.value=t.user.name),t.user&&_.value.trim()===(r.user?.handle??"")&&(_.value=t.user.handle??""))})),i.defer(B)},unmount(){i.dispose(),F(D)}}}export{Me as avatarProblem,at as createProfileView,Ke as passwordProblem};
|
|
2
|
+
//# sourceMappingURL=profile-NQ6QCQIB.js.map
|
|
Binary file
|
|
Binary file
|