TrashView-C9iu_JEQ.js

3.6 KB · raw

1import{A as e,E as t,F as n,N as r,O as i,_ as a,b as o,t as s,w as c,x as l,y as u}from"./index-DMA67SNg.js";var d=c(`<div class=peach-list-empty><span>loading...`),f=c(`<div class=peach-list-empty style="padding:48px 20px;flex-direction:column;gap:6px"><span style=font-size:13px;color:var(--peach-t1)>Trash is empty.</span><span style=font-size:11px;color:var(--peach-t2)>Deleted entries appear here before being removed permanently.`),p=c(`<span class=peach-trash-purge-confirm-label>delete all permanently?`),m=c(`<button class="peach-btn peach-btn--sm peach-btn--danger">yes`),h=c(`<button class="peach-btn peach-btn--ghost peach-btn--sm">cancel`),g=c(`<div class="peach-settings-group peach-trash-list"><p class=peach-settings-sub-label> </p><div class=peach-trash-footer>`),_=c(`<div class="peach-overlay-view ov-enter-right"style=display:flex><div class=peach-overlay-header><button class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn"aria-label=Back><svg width=7 height=12 viewBox="0 0 7 12"fill=none stroke=currentColor stroke-width=1.1 stroke-linecap=round stroke-linejoin=round><path d="M6 1L1 6L6 11"></path></svg></button><span class=peach-overlay-title>trash</span><div class=peach-overlay-spacer></div></div><div class=peach-settings-body>`),v=c(`<button class="peach-btn peach-btn--sm peach-btn--danger">delete`),y=c(`<div class=peach-trash-entry-row><div class=peach-trash-entry-info><span class=peach-trash-entry-title></span><span class=peach-trash-entry-meta></span></div><div class=peach-trash-entry-actions><button class="peach-btn peach-btn--subtle peach-btn--sm">restore`),b=c(`<button class=peach-trash-delete-btn aria-label="Delete permanently">×`),x=c(`<button class=peach-trash-purge-all>permanently delete all`);function S(c){let[u,S]=r([]),[C,w]=r(!0),[T,E]=r(null),[D,O]=r(!1);n(async()=>{await k()});async function k(){w(!0),S((await s({type:`GET_DELETED_ENTRIES`})).data??[]),w(!1)}async function A(e){await s({type:`RESTORE_ENTRY`,payload:{id:e}}),c.onRestored(),await k()}async function j(e){await s({type:`PURGE_ENTRY`,payload:{id:e}}),E(null),await k()}async function M(){for(let e of u())await s({type:`PURGE_ENTRY`,payload:{id:e.id}});O(!1),await k()}function N(e){return e?new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`}):``}return(()=>{var n=_(),r=n.firstChild,s=r.firstChild,S=r.nextSibling;return a(s,`click`,c.onBack,!0),o(S,e(i,{get when(){return C()},get children(){return d()}}),null),o(S,e(i,{get when(){return l(()=>!C())()&&u().length===0},get children(){return f()}}),null),o(S,e(i,{get when(){return l(()=>!C())()&&u().length>0},get children(){var n=g(),r=n.firstChild,a=r.firstChild,s=r.nextSibling;return o(r,()=>u().length,a),o(r,()=>u().length===1?`entry`:`entries`,null),o(n,e(t,{get each(){return u()},children:t=>(()=>{var n=y(),r=n.firstChild,a=r.firstChild,s=a.nextSibling,c=r.nextSibling,u=c.firstChild;return o(a,()=>t.title),o(s,()=>N(t.deletedAt),null),o(s,(()=>{var e=l(()=>!!t.url);return()=>e()?` · ${t.url.replace(/^https?:\/\//,``).split(`/`)[0]}`:``})(),null),u.$$click=()=>void A(t.id),o(c,e(i,{get when(){return T()===t.id},get fallback(){return(()=>{var e=b();return e.$$click=()=>E(t.id),e})()},get children(){return[(()=>{var e=v();return e.$$click=()=>void j(t.id),e})(),(()=>{var e=h();return e.$$click=()=>E(null),e})()]}}),null),n})()}),s),o(s,e(i,{get when(){return D()},get fallback(){return(()=>{var e=x();return e.$$click=()=>O(!0),e})()},get children(){return[p(),(()=>{var e=m();return e.$$click=()=>void M(),e})(),(()=>{var e=h();return e.$$click=()=>O(!1),e})()]}})),n}}),null),n})()}u([`click`]);export{S as TrashView};