TrashView-ffLbxXUW.js

3.6 KB · raw

1import{B as e,F as t,G as n,I as r,Q as i,R as a,U as o,Y as s,et as c,q as l,z as u}from"./index-C3AHYAm6.js";var d=o(`<div class=peach-list-empty><span>loading...`),f=o(`<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=o(`<span class=peach-trash-purge-confirm-label>delete all permanently?`),m=o(`<button class="peach-btn peach-btn--sm peach-btn--danger">yes`),h=o(`<button class="peach-btn peach-btn--ghost peach-btn--sm">cancel`),g=o(`<div class="peach-settings-group peach-trash-list"><p class=peach-settings-sub-label> </p><div class=peach-trash-footer>`),_=o(`<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=o(`<button class="peach-btn peach-btn--sm peach-btn--danger">delete`),y=o(`<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=o(`<button class=peach-trash-delete-btn aria-label="Delete permanently">×`),x=o(`<button class=peach-trash-purge-all>permanently delete all`);function S(a){let[o,S]=i([]),[C,w]=i(!0),[T,E]=i(null),[D,O]=i(!1);c(async()=>{await k()});async function k(){w(!0),S((await t({type:`GET_DELETED_ENTRIES`})).data??[]),w(!1)}async function A(e){await t({type:`RESTORE_ENTRY`,payload:{id:e}}),a.onRestored(),await k()}async function j(e){await t({type:`PURGE_ENTRY`,payload:{id:e}}),E(null),await k()}async function M(){for(let e of o())await t({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 t=_(),i=t.firstChild,c=i.firstChild,S=i.nextSibling;return r(c,`click`,a.onBack,!0),u(S,s(l,{get when(){return C()},get children(){return d()}}),null),u(S,s(l,{get when(){return e(()=>!C())()&&o().length===0},get children(){return f()}}),null),u(S,s(l,{get when(){return e(()=>!C())()&&o().length>0},get children(){var t=g(),r=t.firstChild,i=r.firstChild,a=r.nextSibling;return u(r,()=>o().length,i),u(r,()=>o().length===1?`entry`:`entries`,null),u(t,s(n,{get each(){return o()},children:t=>(()=>{var n=y(),r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=r.nextSibling,c=o.firstChild;return u(i,()=>t.title),u(a,()=>N(t.deletedAt),null),u(a,(()=>{var n=e(()=>!!t.url);return()=>n()?` · ${t.url.replace(/^https?:\/\//,``).split(`/`)[0]}`:``})(),null),c.$$click=()=>void A(t.id),u(o,s(l,{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})()}),a),u(a,s(l,{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})()]}})),t}}),null),t})()}a([`click`]);export{S as TrashView};