1import{u as we}from"./useToast-DMUvyE4w.js";import{usePreviewStore as ie}from"./preview-D-iFN_wX.js";import{f as Z,w as Y,o as se,p as o,y as e,F as L,S as D,q as z,H as d,x as E,_ as ne,I as J,J as N,K as V,D as ce,r as b,c as K,n as t,Y as ve,M as Ce,N as pe,C as ue,t as oe}from"./vue-_wPofmGe.js";import{_ as ee}from"./index-AV4uJzyH.js";import{u as ye}from"./useEditorApi-BLycaaqP.js";import{u as xe}from"./useWhiteLabel-CxKToVl0.js";import"./axios-C0Zqfgkc.js";const j="/api/v2/editor/ebook";function ke(){return localStorage.getItem("editor_token")??""}function Se(){return{"X-Editor-Token":ke(),"Content-Type":"application/json"}}async function G(m,x,u){const p={method:m,headers:Se()};u!==void 0&&(p.body=JSON.stringify(u));const f=await fetch(x,p);let _={};try{_=await f.json()}catch{}if(!f.ok||_?.error)throw new Error(_?.message??`Request failed (${f.status})`);return _}const Te=m=>G("GET",`${j}/${m}/settings`),me=(m,x=1,u=20,p="")=>G("GET",`${j}/${m}/books?page=${x}&per=${u}&q=${encodeURIComponent(p)}`),be=(m,x,u)=>G("PUT",`${j}/${m}/books/${x}`,u),Be=(m,x)=>G("DELETE",`${j}/${m}/books/${x}`),Pe=(m,x)=>G("POST",`${j}/${m}/books/bulk-delete`,{ids:x}),fe=m=>G("GET",`${j}/${m}/categories`),Ue=(m,x)=>G("POST",`${j}/${m}/categories`,x),ge=(m,x,u)=>G("PUT",`${j}/${m}/categories/${x}`,u),Ee=(m,x)=>G("DELETE",`${j}/${m}/categories/${x}`);async function Re(m,x,u,p){return new Promise((f,_)=>{const B=new FormData;B.append("epub",x),p&&p.length&&B.append("category_ids",p.join(","));const g=new XMLHttpRequest;g.open("POST",`${j}/${m}/books/upload`),g.setRequestHeader("X-Editor-Token",ke()),g.upload.onprogress=l=>{u&&l.lengthComputable&&u(Math.round(l.loaded/l.total*100))},g.onload=()=>{let l={};try{l=JSON.parse(g.responseText)}catch{}g.status>=200&&g.status<300&&!l?.error?f(l):_(new Error(l?.message??`Upload failed (${g.status})`))},g.onerror=()=>_(new Error("Network error during upload.")),g.send(B)})}const Ie=(m,x=1,u=20,p="")=>G("GET",`${j}/${m}/reports/summary?page=${x}&per=${u}&q=${encodeURIComponent(p)}`),Me=(m,x,u,p="")=>G("GET",`${j}/${m}/readers?page=${x}&per=${u}&q=${encodeURIComponent(p)}`),Ae=(m,x)=>G("DELETE",`${j}/${m}/readers/${x}`),Ne={class:"eb-tab"},Ve={class:"ed-card"},Le={key:0,class:"eb-upload-cats"},He=["onClick"],De=["disabled"],Oe={key:0,width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},je={key:1},Fe={key:2},ze={key:1,class:"eb-progress"},Ge={class:"ed-card"},qe={class:"ed-card-header"},Ke={key:0,class:"eb-count"},Je={class:"eb-search"},We={key:0,class:"eb-bulk-bar"},Xe={key:1,class:"eb-selectall"},Qe=["checked"],Ye={key:2,class:"eb-empty"},Ze={key:3,class:"eb-empty"},et={key:4,class:"eb-book-list"},tt=["checked","onChange"],ot={class:"eb-book-cover"},st=["src"],at={key:1,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5"},lt={class:"eb-book-body"},nt={class:"eb-book-title"},it={class:"eb-book-meta"},rt={key:0,class:"eb-book-cats"},dt={class:"eb-book-actions"},ut=["onClick"],ct=["title","onClick"],vt={key:0,width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},pt={key:1,width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},bt=["onClick"],gt={key:5,class:"eb-pager"},ht=["disabled"],yt=["disabled"],kt={class:"eb-drawer"},mt={class:"eb-drawer-head"},ft={class:"eb-drawer-body"},_t={class:"eb-field"},$t={class:"eb-field"},wt={class:"eb-field"},Ct={key:0,class:"eb-field"},xt={class:"eb-cat-chips"},St=["onClick"],Tt={class:"eb-drawer-foot"},he=20,Bt=Z({__name:"LibraryTab",props:{valueId:{}},emits:["toast","reload"],setup(m,{emit:x}){const u=m,p=x,f=ie(),_=b([]),B=b([]),g=b(!0),l=b(!1),r=b(0),$=b(null),k=b(1),P=b(0),R=b(!1),w=b(""),a=K(()=>Math.max(1,Math.ceil(P.value/he))),c=b(new Set),U=K(()=>_.value.length>0&&_.value.every(i=>c.value.has(i.id))),h=b(new Set),S=b(null),A=b({title:"",author:"",description:"",category_ids:new Set});async function H(){g.value=!0;try{const i=await me(u.valueId,k.value,he,w.value.trim());_.value=i.books??[],P.value=i.total??_.value.length,R.value=!!i.has_more}catch(i){p("toast",i?.message??"Could not load books","error")}finally{g.value=!1}}async function X(){try{B.value=(await fe(u.valueId)).categories??[]}catch{}}let q=null;Y(w,()=>{q&&clearTimeout(q),q=setTimeout(()=>{k.value=1,H()},350)});function I(i){i>=1&&i<=a.value&&(k.value=i,H())}function C(){$.value?.click()}async function M(i){const s=i.target,v=s.files?.[0];if(s.value="",!!v){if(!v.name.toLowerCase().endsWith(".epub")){p("toast","Please choose a .epub file","error");return}l.value=!0,r.value=0;try{const F=await Re(u.valueId,v,$e=>{r.value=$e},Array.from(h.value));p("toast",`"${F.book?.title??"Book"}" added`),k.value=1,await H(),f.refresh()}catch(F){p("toast",F?.message??"Upload failed","error")}finally{l.value=!1,r.value=0}}}function W(i){const s=c.value;s.has(i)?s.delete(i):s.add(i),c.value=new Set(s)}function re(){const i=c.value,s=U.value;_.value.forEach(v=>s?i.delete(v.id):i.add(v.id)),c.value=new Set(i)}function ae(){c.value=new Set}async function de(){const i=Array.from(c.value);if(i.length&&confirm(`Delete ${i.length} book(s)? Their content is removed from this app and cannot be undone.`))try{await Pe(u.valueId,i),p("toast",`${i.length} deleted`),ae(),_.value.length===i.length&&k.value>1&&k.value--,await H(),f.refresh()}catch(s){p("toast",s?.message??"Could not delete","error")}}function te(i){S.value=i,A.value={title:i.title,author:i.author??"",description:i.description??"",category_ids:new Set(i.category_ids??[])}}function T(i){const s=A.value.category_ids;s.has(i)?s.delete(i):s.add(i),A.value.category_ids=new Set(s)}async function n(){if(S.value)try{await be(u.valueId,S.value.id,{title:A.value.title,author:A.value.author,description:A.value.description,category_ids:Array.from(A.value.category_ids)}),p("toast","Saved"),S.value=null,await H(),f.refresh()}catch(i){p("toast",i?.message??"Could not save","error")}}async function y(i){try{await be(u.valueId,i.id,{is_active:i.is_active?0:1}),await H(),f.refresh()}catch(s){p("toast",s?.message??"Could not update","error")}}async function O(i){if(confirm(`Delete "${i.title}"? Its content is removed from this app and cannot be undone.`))try{await Be(u.valueId,i.id),p("toast","Deleted"),await H(),f.refresh()}catch(s){p("toast",s?.message??"Could not delete","error")}}function Q(i){const s=h.value;s.has(i)?s.delete(i):s.add(i),h.value=new Set(s)}function _e(i){return B.value.find(s=>
1s.id===i)?.name??""}return se(()=>{X(),H()}),(i,s)=>(t(),o("div",Ne,[e("div",Ve,[s[12]||(s[12]=e("div",{class:"ed-card-header"},"Add a book",-1)),s[13]||(s[13]=e("p",{class:"ed-card-desc"},"Upload an EPUB file. We extract the chapters for a true reflowable native reader: adjustable size, dark mode, bookmarks, and offline reading.",-1)),B.value.length?(t(),o("div",Le,[s[10]||(s[10]=e("span",{class:"eb-upload-cats-label"},"Assign to:",-1)),(t(!0),o(L,null,D(B.value,v=>(t(),o("button",{key:v.id,class:z(["eb-cat-chip",{on:h.value.has(v.id)}]),onClick:F=>Q(v.id)},d(v.name),11,He))),128))])):E("",!0),e("input",{ref_key:"fileInput",ref:$,type:"file",accept:".epub,application/epub+zip",class:"eb-hidden",onChange:M},null,544),e("button",{class:"eb-upload-btn",disabled:l.value,onClick:C},[l.value?E("",!0):(t(),o("svg",Oe,[...s[11]||(s[11]=[e("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"},null,-1),e("polyline",{points:"17 8 12 3 7 8"},null,-1),e("line",{x1:"12",y1:"3",x2:"12",y2:"15"},null,-1)])])),l.value?(t(),o("span",Fe,"Uploading & parsing... "+d(r.value)+"%",1)):(t(),o("span",je,"Choose EPUB file"))],8,De),l.value?(t(),o("div",ze,[e("div",{class:"eb-progress-bar",style:ne({width:r.value+"%"})},null,4)])):E("",!0)]),e("div",Ge,[e("div",qe,[s[14]||(s[14]=J("Library ",-1)),P.value?(t(),o("span",Ke,d(P.value),1)):E("",!0)]),e("div",Je,[s[15]||(s[15]=e("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e("circle",{cx:"11",cy:"11",r:"8"}),e("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})],-1)),N(e("input",{"onUpdate:modelValue":s[0]||(s[0]=v=>w.value=v),type:"search",placeholder:"Search title or author"},null,512),[[V,w.value]])]),c.value.size?(t(),o("div",We,[e("span",null,d(c.value.size)+" selected",1),e("div",{class:"eb-bulk-actions"},[e("button",{class:"ed-btn-tiny",onClick:ae},"Clear"),e("button",{class:"ed-btn-danger",onClick:de},"Delete selected")])])):E("",!0),_.value.length?(t(),o("label",Xe,[e("input",{type:"checkbox",checked:U.value,onChange:re},null,40,Qe),s[16]||(s[16]=J(" Select all on this page ",-1))])):E("",!0),g.value?(t(),o("div",Ye,"Loading...")):_.value.length?(t(),o("div",et,[(t(!0),o(L,null,D(_.value,v=>(t(),o("div",{key:v.id,class:z(["eb-book",{inactive:!v.is_active,picked:c.value.has(v.id)}])},[e("label",{class:"eb-book-check",onClick:s[1]||(s[1]=ce(()=>{},["stop"]))},[e("input",{type:"checkbox",checked:c.value.has(v.id),onChange:F=>W(v.id)},null,40,tt)]),e("div",ot,[v.cover_url?(t(),o("img",{key:0,src:v.cover_url,alt:""},null,8,st)):(t(),o("svg",at,[...s[17]||(s[17]=[e("path",{d:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20"},null,-1),e("path",{d:"M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"},null,-1)])]))]),e("div",lt,[e("div",nt,d(v.title),1),e("div",it,d(v.author||"Unknown author")+" · "+d(v.spine_count)+" chapters",1),v.category_ids&&v.category_ids.length?(t(),o("div",rt,[(t(!0),o(L,null,D(v.category_ids,F=>(t(),o("span",{key:F,class:"eb-book-cat-tag"},d(_e(F)),1))),128))])):E("",!0)]),e("div",dt,[e("button",{class:"eb-icon-btn",title:"Edit",onClick:F=>te(v)},[...s[18]||(s[18]=[e("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e("path",{d:"M18.5 2.5a2.12 2.12 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})],-1)])],8,ut),e("button",{class:"eb-icon-btn",title:v.is_active?"Hide":"Show",onClick:F=>y(v)},[v.is_active?(t(),o("svg",vt,[...s[19]||(s[19]=[e("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"},null,-1),e("circle",{cx:"12",cy:"12",r:"3"},null,-1)])])):(t(),o("svg",pt,[...s[20]||(s[20]=[e("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"},null,-1),e("line",{x1:"1",y1:"1",x2:"23",y2:"23"},null,-1)])]))],8,ct),e("button",{class:"eb-icon-btn danger",title:"Delete",onClick:F=>O(v)},[...s[21]||(s[21]=[e("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e("polyline",{points:"3 6 5 6 21 6"}),e("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)])],8,bt)])],2))),128))])):(t(),o("div",Ze,d(w.value.trim()?"No books match your search.":"No books yet. Upload an EPUB above to start your library."),1)),a.value>1?(t(),o("div",gt,[e("button",{class:"ed-btn-tiny",disabled:k.value===1,onClick:s[2]||(s[2]=v=>I(k.value-1))},"Prev",8,ht),e("span",null,"Page "+d(k.value)+" / "+d(a.value),1),e("button",{class:"ed-btn-tiny",disabled:k.value>=a.value,onClick:s[3]||(s[3]=v=>I(k.value+1))},"Next",8,yt)])):E("",!0)]),S.value?(t(),o("div",{key:0,class:"eb-drawer-overlay",onClick:s[9]||(s[9]=ce(v=>S.value=null,["self"]))},[e("div",kt,[e("div",mt,[s[22]||(s[22]=e("span",null,"Edit book",-1)),e("button",{class:"eb-drawer-close",onClick:s[4]||(s[4]=v=>S.value=null)},"Ã")]),e("div",ft,[e("label",_t,[s[23]||(s[23]=e("span",null,"Title",-1)),N(e("input",{"onUpdate:modelValue":s[5]||(s[5]=v=>A.value.title=v),type:"text"},null,512),[[V,A.value.title]])]),e("label",$t,[s[24]||(s[24]=e("span",null,"Author",-1)),N(e("input",{"onUpdate:modelValue":s[6]||(s[6]=v=>A.value.author=v),type:"text"},null,512),[[V,A.value.author]])]),e("label",wt,[s[25]||(s[25]=e("span",null,"Description",-1)),N(e("textarea",{"onUpdate:modelValue":s[7]||(s[7]=v=>A.value.description=v),rows:"4"},null,512),[[V,A.value.description]])]),B.value.length?(t(),o("div",Ct,[s[26]||(s[26]=e("span",null,"Categories",-1)),e("div",xt,[(t(!0),o(L,null,D(B.value,v=>
1(t(),o("button",{key:v.id,class:z(["eb-cat-chip",{on:A.value.category_ids.has(v.id)}]),onClick:F=>T(v.id)},d(v.name),11,St))),128))])])):E("",!0)]),e("div",Tt,[e("button",{class:"ed-btn-tiny",onClick:s[8]||(s[8]=v=>S.value=null)},"Cancel"),e("button",{class:"ed-btn-primary",onClick:n},"Save")])])])):E("",!0)]))}}),Pt=ee(Bt,[["__scopeId","data-v-251518b6"]]),Ut={class:"eb-tab"},Et={class:"ed-card"},Rt={class:"ebc-create"},It={class:"ebc-home-toggle"},Mt=["disabled"],At={class:"ed-card"},Nt={class:"ed-card-header"},Vt={key:0,class:"eb-count"},Lt={key:0,class:"eb-empty"},Ht={key:1,class:"eb-empty"},Dt={key:2,class:"ebc-list"},Ot={class:"ebc-main"},jt=["onKeyup","onBlur"],Ft={class:"ebc-name"},zt={class:"ebc-count"},Gt=["onClick"],qt=["onClick"],Kt=["onClick"],Jt=Z({__name:"CategoriesTab",props:{valueId:{}},emits:["toast","reload"],setup(m,{emit:x}){const u=m,p=x,f=ie(),_=b([]),B=b(!0),g=b(""),l=b(!0),r=b(null),$=b("");async function k(){B.value=!0;try{_.value=(await fe(u.valueId)).categories??[]}catch(U){p("toast",U?.message??"Could not load categories","error")}finally{B.value=!1}}async function P(){const U=g.value.trim();if(U)try{await Ue(u.valueId,{name:U,on_home:l.value?1:0}),g.value="",l.value=!0,p("toast","Category created"),await k(),f.refresh()}catch(h){p("toast",h?.message??"Could not create","error")}}async function R(U){try{await ge(u.valueId,U.id,{on_home:U.on_home?0:1}),await k(),f.refresh()}catch(h){p("toast",h?.message??"Could not update","error")}}function w(U){r.value=U.id,$.value=U.name}async function a(U){const h=$.value.trim();if(!h){r.value=null;return}try{await ge(u.valueId,U.id,{name:h}),r.value=null,p("toast","Renamed"),await k(),f.refresh()}catch(S){p("toast",S?.message??"Could not rename","error")}}async function c(U){if(confirm(`Delete the "${U.name}" category? The books stay in your library, only this grouping is removed.`))try{await Ee(u.valueId,U.id),p("toast","Category deleted"),await k(),f.refresh()}catch(h){p("toast",h?.message??"Could not delete","error")}}return se(k),(U,h)=>(t(),o("div",Ut,[e("div",Et,[h[4]||(h[4]=e("div",{class:"ed-card-header"},"New category",-1)),h[5]||(h[5]=e("p",{class:"ed-card-desc"},'Group books into bundles (for example "Trending", "New arrivals"). Categories shown on home appear as rails; all categories are filters on the browse page.',-1)),e("div",Rt,[N(e("input",{"onUpdate:modelValue":h[0]||(h[0]=S=>g.value=S),type:"text",placeholder:"Category name",onKeyup:ve(P,["enter"])},null,544),[[V,g.value]]),e("label",It,[N(e("input",{type:"checkbox","onUpdate:modelValue":h[1]||(h[1]=S=>l.value=S)},null,512),[[Ce,l.value]]),h[3]||(h[3]=J(" Show on home",-1))]),e("button",{class:"ed-btn-primary",disabled:!g.value.trim(),onClick:P},"Add",8,Mt)])]),e("div",At,[e("div",Nt,[h[6]||(h[6]=J("Categories ",-1)),_.value.length?(t(),o("span",Vt,d(_.value.length),1)):E("",!0)]),B.value?(t(),o("div",Lt,"Loading...")):_.value.length?(t(),o("div",Dt,[(t(!0),o(L,null,D(_.value,S=>(t(),o("div",{key:S.id,class:"ebc-row"},[e("div",Ot,[r.value===S.id?N((t(),o("input",{key:0,"onUpdate:modelValue":h[2]||(h[2]=A=>$.value=A),class:"ebc-edit-input",type:"text",onKeyup:ve(A=>a(S),["enter"]),onBlur:A=>a(S)},null,40,jt)),[[V,$.value]]):(t(),o(L,{key:1},[e("span",Ft,d(S.name),1),e("span",zt,d(S.book_count)+" "+d(S.book_count===1?"book":"books"),1)],64))]),e("button",{class:z(["ebc-home-btn",{on:S.on_home}]),onClick:A=>R(S)},d(S.on_home?"On home":"Hidden"),11,Gt),e("button",{class:"eb-icon-btn",title:"Rename",onClick:A=>w(S)},[...h[7]||(h[7]=[e("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e("path",{d:"M18.5 2.5a2.12 2.12 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})],-1)])],8,qt),e("button",{class:"eb-icon-btn danger",title:"Delete",onClick:A=>c(S)},[...h[8]||(h[8]=[e("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e("polyline",{points:"3 6 5 6 21 6"}),e("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)])],8,Kt)]))),128))])):(t(),o("div",Ht,"No categories yet. Create one above to start grouping books.")),h[9]||(h[9]=e("p",{class:"ed-card-desc",style:{"margin-top":"10px"}},"Assign books to a category from the Library tab (edit a book, pick its categories) or when uploading.",-1))])]))}}),Wt=ee(Jt,[["__scopeId","data-v-09008dff"]]),Xt={class:"eb-tab"},Qt={class:"ed-card"},Yt={class:"mode-grid"},Zt={key:0,class:"single-pick"},eo={key:0,class:"single-selected"},to=["src","alt"],oo={key:1,class:"single-thumb single-thumb--ph"},so={class:"single-meta"},ao={class:"single-title"},lo={class:"single-author"},no={key:1,class:"ed-card-desc",style:{margin:"0 0 8px"}},io={class:"single-search"},ro={class:"single-list"},uo=["onClick"],co=["src","alt"],vo={key:1,class:"single-tile-ph"},po={class:"single-tile-title"},bo=["disabled"],go={key:3,class:"ed-card-desc"},ho={class:"ed-card"},yo={class:"theme-grid"},ko=["onClick"],mo={class:"theme-book",viewBox:"0 0 32 22",fill:"none",xmlns:"http://www.w3.org/2000/svg"},fo=["fill"],_o=["fill"],$o=["fill"],wo={class:"theme-footer"},Co={class:"theme-name"},xo={class:"theme-tag"},So={key:0,class:"theme-check"},To={class:"ed-card"},Bo={class:"layout-grid"},Po=["onClick"],Uo={class:"layout-preview"},Eo={key:0,viewBox:"0 0 80 60",fill:"none"},Ro={key:1,viewBox:"0 0 80 60",fill:"none"},Io={key:2,viewBox:"0 0 80 60",fill:"none"},Mo={class:"layout-footer"},Ao={class:"layout-name"},No={class:"layout-tag"},Vo={key:0,class:"layout-check"},Lo={class:"ed-card"},Ho={class:"color-section-title"},Do={class:"color-list"},Oo={class:"color-label"},jo=["value","onChange"],Fo=["value","onChange"],zo=["onClick"],Go=20,qo=Z({__name:"AppearanceTab",props:{valueId:{},settings:{}},emits:["toast","reload"],setup(m,{emit:x}){const u=m,p=x,{apiSave:f}=ye(),_=ie(),B=[{code:"parchment",name:"Parchment",tag:"Warm cream + gold (default)",bg:"#fdf9ed",card:"#ffffff",accent:"#b8812a"},{code:"midnight",name:"Midnight",tag:"Deep navy + sky blue",bg:"#0f1422",card:"#1a2240",accent:"#6b9fff"},{code:"dawn",name:"Dawn",tag:"Sunrise peach + orange",bg:"#fff4ed",card:"#ffffff",accent:"#f07030"},{code:"rose",name:"Rose",tag:"Soft pink + dusty rose",bg:"#fff5f7",card:"#ffffff",accent:"#d4567a"},{code:"slate",name:"Slate",tag:"Dark glass + steel blue",bg:"#101820",card:"#182030",accent:"#64b8f0"},{code:"forest",name:"Forest",tag:"Sage green + earth tones",bg:"#f2f5f0",card:"#ffffff",accent:"#4a8a5e"}],g=[{code:"shelf",name:"Shelf",tag:"Bold cover grid, a bookstore shelf"},{code:"coverflow",name:"Cover Flow",tag:"Hero carousel + continue strip"},{code:"continue",name:"Continue",tag:"Reading-first, big resume card + list"}
1],l=[{title:"Backgrounds",keys:[{key:"bg",label:"Page background"},{key:"surface",label:"Card surface"},{key:"accentSurface",label:"Accent tint (chips)"}]},{title:"Borders",keys:[{key:"border",label:"Border / divider"}]},{title:"Text",keys:[{key:"text",label:"Primary text"},{key:"textSecondary",label:"Secondary text"},{key:"textMuted",label:"Muted / hint text"}]},{title:"Accent",keys:[{key:"accent",label:"Accent color"},{key:"accentEnd",label:"Accent gradient end"},{key:"accentText",label:"Text on accent"}]},{title:"Header bar",keys:[{key:"headerBg",label:"Header background"},{key:"headerTitle",label:"Header title"},{key:"headerIcon",label:"Header icons"}]}],r=pe({theme:u.settings?.theme??"parchment",structure:u.settings?.structure_code??"shelf",mode:u.settings?.mode??"library",single_book_id:Number(u.settings?.single_book_id??0)}),$=pe({...u.settings?.custom_colors??{}}),k=b([]),P=b(null),R=b(""),w=K(()=>P.value??k.value.find(T=>T.id===r.single_book_id)??null);Y(()=>u.settings,T=>{T&&(r.theme=T.theme??"parchment",r.structure=T.structure_code??"shelf",r.mode=T.mode??"library",r.single_book_id=Number(T.single_book_id??0),Object.keys($).forEach(n=>delete $[n]),Object.assign($,T.custom_colors??{}))});const a=b(1),c=b(0),U=b(!1),h=b(!1);async function S(T=!1){h.value=!0;try{const n=await me(u.valueId,a.value,Go,R.value.trim()),y=n.books??[];k.value=T?[...k.value,...y]:y,c.value=n.total??k.value.length,U.value=!!n.has_more}catch{}finally{h.value=!1}}function A(){a.value=1,S(!1)}function H(){a.value++,S(!0)}function X(){const T=k.value.find(n=>n.id===r.single_book_id);T&&(P.value=T)}let q=null;Y(R,()=>{q&&clearTimeout(q),q=setTimeout(A,300)}),se(async()=>{await S(!1),X()});async function I(T){r.mode=T,await f({url:`/api/v2/editor/ebook/${u.valueId}/settings`,body:{mode:T}}),p("reload")}async function C(T){r.single_book_id=T,P.value=k.value.find(n=>n.id===T)??P.value,await f({url:`/api/v2/editor/ebook/${u.valueId}/settings`,body:{single_book_id:T}}),p("reload")}function M(){_.postToPreview("ebook-settings",{theme:r.theme,structure_code:r.structure,customColors:{...$}})}async function W(){await f({url:`/api/v2/editor/ebook/${u.valueId}/appearance`,body:{theme:r.theme,structure_code:r.structure,custom_colors:$}}),p("reload")}async function re(T){r.theme=T,M(),await W()}async function ae(T){r.structure=T,M(),await W()}function de(){Object.keys($).length&&confirm("Reset every custom color back to the selected theme defaults?")&&(Object.keys($).forEach(T=>delete $[T]),M(),W())}function te(T,n){n?$[T]=n:delete $[T],M(),W()}return(T,n)=>(t(),o("div",Xt,[e("div",Qt,[n[7]||(n[7]=e("div",{class:"ed-card-header"},"Mode",-1)),n[8]||(n[8]=e("p",{class:"ed-card-desc"},"Run this as a full library (home, categories, browse) or a single-book reader that opens straight into one book.",-1)),e("div",Yt,[e("button",{class:z(["mode-card",{active:r.mode==="library"}]),onClick:n[0]||(n[0]=y=>I("library"))},[...n[3]||(n[3]=[e("div",{class:"mode-name"},"Library",-1),e("div",{class:"mode-tag"},"Many books, categories and a browse page",-1)])],2),e("button",{class:z(["mode-card",{active:r.mode==="single"}]),onClick:n[1]||(n[1]=y=>I("single"))},[...n[4]||(n[4]=[e("div",{class:"mode-name"},"Single book",-1),e("div",{class:"mode-tag"},"One book, minimal home, opens into the reader",-1)])],2)]),r.mode==="single"?(t(),o("div",Zt,[n[6]||(n[6]=e("div",{class:"single-pick-label"},"Book to show",-1)),w.value?(t(),o("div",eo,[w.value.cover_url?(t(),o("img",{key:0,src:w.value.cover_url,class:"single-thumb",alt:w.value.title},null,8,to)):(t(),o("div",oo)),e("div",so,[e("div",ao,d(w.value.title),1),e("div",lo,d(w.value.author||"Unknown author"),1)])])):(t(),o("div",no,"No book selected. Pick one below.")),e("div",io,[n[5]||(n[5]=e("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e("circle",{cx:"11",cy:"11",r:"8"}),e("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})],-1)),N(e("input",{"onUpdate:modelValue":n[2]||(n[2]=y=>R.value=y),type:"search",placeholder:"Search books by title or author"},null,512),[[V,R.value]])]),e("div",ro,[(t(!0),o(L,null,D(k.value,y=>(t(),o("button",{key:y.id,class:z(["single-tile",{on:y.id===r.single_book_id}]),onClick:O=>
1C(y.id)},[y.cover_url?(t(),o("img",{key:0,src:y.cover_url,alt:y.title},null,8,co)):(t(),o("div",vo)),e("span",po,d(y.title),1)],10,uo))),128))]),U.value?(t(),o("button",{key:2,class:"single-more",disabled:h.value,onClick:H},d(h.value?"Loading...":"Load more"),9,bo)):E("",!0),!k.value.length&&!h.value?(t(),o("p",go,d(R.value.trim()?"No books match your search.":"Upload a book in the Library tab first."),1)):E("",!0)])):E("",!0)]),e("div",ho,[n[10]||(n[10]=e("div",{class:"ed-card-header"},"Reader theme",-1)),n[11]||(n[11]=e("p",{class:"ed-card-desc"},"Pick a visual identity for your reading app. Updates the preview instantly. Text uses your app's font (set in the Design tab).",-1)),e("div",yo,[(t(),o(L,null,D(B,y=>e("button",{key:y.code,class:z(["theme-card",{active:r.theme===y.code}]),onClick:O=>re(y.code)},[e("div",{class:"theme-preview",style:ne({background:y.bg})},[e("div",{class:"theme-preview-card",style:ne({background:y.card})},[(t(),o("svg",mo,[e("rect",{x:"3",y:"3",width:"26",height:"5",rx:"1.5",fill:y.accent,opacity:"0.28"},null,8,fo),e("rect",{x:"5",y:"9",width:"22",height:"5",rx:"1.5",fill:y.accent,opacity:"0.45"},null,8,_o),e("rect",{x:"2",y:"15",width:"28",height:"5",rx:"1.5",fill:y.accent,opacity:"0.20"},null,8,$o)])),e("div",{class:"theme-preview-bar",style:ne({background:y.accent,marginTop:"4px"})},null,4)],4)],4),e("div",wo,[e("div",null,[e("div",Co,d(y.name),1),e("div",xo,d(y.tag),1)]),r.theme===y.code?(t(),o("div",So,[...n[9]||(n[9]=[e("svg",{viewBox:"0 0 16 16",fill:"none"},[e("circle",{cx:"8",cy:"8",r:"8",fill:"currentColor"}),e("path",{d:"M4.5 8l2.5 2.5 4.5-4.5",stroke:"#fff","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])])):E("",!0)])],10,ko)),64))])]),e("div",To,[n[16]||(n[16]=e("div",{class:"ed-card-header"},"Home structure",-1)),n[17]||(n[17]=e("p",{class:"ed-card-desc"},"Choose how the books home screen is arranged.",-1)),e("div",Bo,[(t(),o(L,null,D(g,y=>e("button",{key:y.code,class:z(["layout-card",{active:r.structure===y.code}]),onClick:O=>ae(y.code)},[e("div",Uo,[y.code==="shelf"?(t(),o("svg",Eo,[...n[12]||(n[12]=[ue('<rect x="2" y="2" width="36" height="3.5" rx="1.5" fill="currentColor" opacity="0.22" data-v-318d4579></rect><rect x="2" y="10" width="36" height="22" rx="3" fill="currentColor" opacity="0.20" data-v-318d4579></rect><rect x="42" y="10" width="36" height="22" rx="3" fill="currentColor" opacity="0.20" data-v-318d4579></rect><rect x="2" y="35" width="36" height="22" rx="3" fill="currentColor" opacity="0.14" data-v-318d4579></rect><rect x="42" y="35" width="36" height="22" rx="3" fill="currentColor" opacity="0.14" data-v-318d4579></rect><line x1="7" y1="10" x2="7" y2="32" stroke="currentColor" stroke-width="1" opacity="0.30" data-v-318d4579></line><line x1="47" y1="10" x2="47" y2="32" stroke="currentColor" stroke-width="1" opacity="0.30" data-v-318d4579></line>',7)])])):y.code==="coverflow"?(t(),o("svg",Ro,[...n[13]||(n[13]=[ue('<rect x="14" y="4" width="52" height="30" rx="4" fill="currentColor" opacity="0.24" data-v-318d4579></rect><rect x="2" y="9" width="9" height="20" rx="2" fill="currentColor" opacity="0.10" data-v-318d4579></rect><rect x="69" y="9" width="9" height="20" rx="2" fill="currentColor" opacity="0.10" data-v-318d4579></rect><line x1="34" y1="40" x2="46" y2="40" stroke="currentColor" stroke-width="2" stroke-linecap="round" opacity="0.30" data-v-318d4579></line><rect x="2" y="46" width="17" height="12" rx="2" fill="currentColor" opacity="0.16" data-v-318d4579></rect><rect x="22" y="46" width="17" height="12" rx="2" fill="currentColor" opacity="0.16" data-v-318d4579></rect><rect x="42" y="46" width="17" height="12" rx="2" fill="currentColor" opacity="0.16" data-v-318d4579></rect><rect x="62" y="46" width="16" height="12" rx="2" fill="currentColor" opacity="0.16" data-v-318d4579></rect>',8)])])):(t(),o("svg",Io,[...n[14]||(n[14]=[ue('<rect x="2" y="2" width="76" height="24" rx="4" fill="currentColor" opacity="0.22" data-v-318d4579></rect><rect x="6" y="6" width="14" height="16" rx="2" fill="currentColor" opacity="0.42" data-v-318d4579></rect><rect x="24" y="8" width="40" height="3" rx="1.5" fill="currentColor" opacity="0.34" data-v-318d4579></rect><rect x="24" y="14" width="28" height="3" rx="1.5" fill="currentColor" opacity="0.22" data-v-318d4579></rect><rect x="24" y="20" width="50" height="3" rx="1.5" fill="currentColor" opacity="0.40" data-v-318d4579></rect><rect x="2" y="30" width="76" height="8" rx="2" fill="currentColor" opacity="0.14" data-v-318d4579></rect><rect x="2" y="41" width="76" height="8" rx="2" fill="currentColor" opacity="0.14" data-v-318d4579></rect><rect x="2" y="52" width="76" height="6" rx="2" fill="currentColor" opacity="0.10" data-v-318d4579></rect>',8)])]))]),e("div",Mo,[e("div",null,[e("div",Ao,d(y.name),1),e("div",No,d(y.tag),1)]),r.structure===y.code?(t(),o("div",Vo,[...n[15]||(n[15]=[e("svg",{viewBox:"0 0 16 16",fill:"none"}
1,[e("circle",{cx:"8",cy:"8",r:"8",fill:"currentColor"}),e("path",{d:"M4.5 8l2.5 2.5 4.5-4.5",stroke:"#fff","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])])):E("",!0)])],10,Po)),64))])]),e("div",Lo,[n[18]||(n[18]=e("div",{class:"ed-card-header"},"Custom colors",-1)),n[19]||(n[19]=e("p",{class:"ed-card-desc"},"Override any theme token. Leave blank to inherit the selected theme. Changes apply instantly.",-1)),(t(),o(L,null,D(l,y=>e("div",{key:y.title,class:"color-section"},[e("div",Ho,d(y.title),1),e("div",Do,[(t(!0),o(L,null,D(y.keys,O=>(t(),o("div",{key:O.key,class:"color-row"},[e("label",Oo,d(O.label),1),e("input",{type:"color",class:"color-swatch",value:$[O.key]||"#000000",onChange:Q=>te(O.key,Q.target.value)},null,40,jo),e("input",{type:"text",class:"color-hex",value:$[O.key]??"",onChange:Q=>te(O.key,Q.target.value),placeholder:"theme default"},null,40,Fo),e("button",{class:z(["color-reset",{visible:$[O.key]}]),onClick:Q=>te(O.key,""),type:"button"},"Reset",10,zo)]))),128))])])),64)),e("div",{class:"color-actions"},[e("button",{class:"ed-btn-tiny",type:"button",onClick:de},"Reset all to theme defaults")])])]))}}),Ko=ee(qo,[["__scopeId","data-v-318d4579"]]),Jo={class:"ed-card"},Wo={class:"eb-storage-grid"},Xo=["onClick"],Qo={class:"eb-storage-body"},Yo={key:0,class:"eb-storage-fields"},Zo={class:"ed-form-grid"},es={class:"ed-form-group"},ts={class:"ed-form-group"},os={class:"ed-form-group"},ss={class:"ed-form-group"},as={key:1,class:"eb-storage-fields"},ls={class:"ed-form-group"},ns={class:"ed-form-group"},is={key:2,class:"eb-storage-fields"},rs={class:"ed-form-grid"},ds={class:"ed-form-group"},us={class:"ed-form-group"},cs={class:"ed-form-group"},vs={class:"ed-form-group"},ps={class:"ed-form-group"},bs={class:"ed-form-group"},gs={class:"eb-storage-actions"},hs=["disabled"],ys=Z({__name:"StorageTab",props:{valueId:{},settings:{}},emits:["toast","reload"],setup(m,{emit:x}){const{brandName:u}=xe(),p=K(()=>[{id:"local",title:`${u.value} storage`,sub:"Default. We host it. Best for text books."},{id:"s3",title:"Amazon S3",sub:"Or any S3-compatible (R2, Spaces, B2)"},{id:"gcs",title:"Google Cloud Storage",sub:"Bucket + service-account JSON"},{id:"ftp",title:"FTP / FTPS",sub:"Existing host + public base URL"}]),f=m,_=x,{apiSave:B}=ye(),g=b(f.settings?.storage_type??"local"),l=b({...f.settings?.storage_config??{}}),r=b(!1);Y(()=>f.settings,w=>{w&&(g.value=w.storage_type??"local",l.value={...w.storage_config??{}})},{immediate:!0});const $=K(()=>g.value==="s3"),k=K(()=>g.value==="gcs"),P=K(()=>g.value==="ftp");async function R(){r.value=!0;try{const w={storage_type:g.value,storage_config:{}};$.value&&(w.storage_config={s3_bucket:l.value.s3_bucket,s3_region:l.value.s3_region,s3_access_key:l.value.s3_access_key,s3_secret_key:l.value.s3_secret_key}),k.value&&(w.storage_config={gcs_bucket:l.value.gcs_bucket,gcs_service_json:l.value.gcs_service_json}),P.value&&(w.storage_config={ftp_host:l.value.ftp_host,ftp_port:l.value.ftp_port,ftp_user:l.value.ftp_user,ftp_pass:l.value.ftp_pass,ftp_path:l.value.ftp_path,ftp_base_url:l.value.ftp_base_url}),await B({url:`/api/v2/editor/ebook/${f.valueId}/appearance`,body:w}),_("toast","Storage configuration saved","success"),_("reload")}catch(w){_("toast",w.message??"Save failed","error")}finally{r.value=!1}}return(w,a)=>(t(),o("div",Jo,[a[27]||(a[27]=e("div",{class:"ed-card-header"},"Book storage",-1)),a[28]||(a[28]=e("p",{class:"ed-card-desc"},[J(" Where your books' images, audio, and video are stored. By default we host them for you (best for text books, which are tiny). If you upload "),e("strong",null,"large, media-heavy books"),J(" and hit the size limit, switch to your own cloud storage below, the heavy files go to your bucket and your app keeps streaming them. ")],-1)),e("div",Wo,[(t(!0),o(L,null,D(p.value,c=>(t(),o("button",{key:c.id,class:z(["eb-storage-opt",{active:g.value===c.id}]),onClick:U=>g.value=c.id},[a[12]||(a[12]=e("span",{class:"eb-storage-radio","aria-hidden":"true"},[e("span",{class:"eb-storage-radio-dot"})],-1)),e("span",Qo,[e("strong",null,d(c.title),1),e("span",null,d(c.sub),1)])],10,Xo))),128))]),$.value?(t(),o("div",Yo,[e("div",Zo,[e("div",es,[a[13]||(a[13]=e("label",{class:"ed-label"},"Bucket",-1)),N(e("input",{class:"ed-input","onUpdate:modelValue":a[0]||(a[0]=c=>l.value.s3_bucket=c),placeholder:"my-books-bucket"},null,512),[[V,l.value.s3_bucket]])]),e("div",ts,[a[14]||(a[14]=e("label",{class:"ed-label"},"Region",-1)),N(e("input",{class:"ed-input","onUpdate:modelValue":a[1]||(a[1]=c=>l.value.s3_region=c),placeholder:"us-east-1"},null,512),[[V,l.value.s3_region]])]),e("div",os,[a[15]||(a[15]=e("label",{class:"ed-label"},"Access key",-1)),N(e("input",{class:"ed-input","onUpdate:modelValue":a[2]||(a[2]=c=>l.value.s3_access_key=c),placeholder:"AKIA..."},null,512),[[V,l.value.s3_access_key]])]),e("div",ss,[a[16]||(a[16]=e("label",{class:"ed-label"},"Secret key",-1)),N(e("input",{class:"ed-input",type:"password","onUpdate:modelValue":a[3]||(a[3]=c=>l.value.s3_secret_key=c),placeholder:"â¢â¢â¢â¢â¢â¢"},null,512),[[V,l.value.s3_secret_key]])])])])):E("",!0),k.value?(t(),o("div",as,[e("div",ls,[a[17]||(a[17]=e("label",{class:"ed-label"},"Bucket name",-1)),N(e("input",{class:"ed-input","onUpdate:modelValue":a[4]||(a[4]=c=>l.value.gcs_bucket=c),placeholder:"my-books-bucket"},null,512),[[V,l.value.gcs_bucket]])]),e("div",ns,[a[18]||(a[18]=e("label",{class:"ed-label"},"Service account JSON",-1)),N(e("textarea",{class:"ed-input",rows:"6","onUpdate:modelValue":a[5]||(a[5]=c=>l.value.gcs_service_json=c),placeholder:'{"type":"service_account",...}'},null,512),[[V,l.value.gcs_service_json]]),a[19]||(a[19]=e("p",{class:"eb-hint"},"Paste the entire service-account key JSON exported from Google Cloud Console.",-1))])])):E("",!0),P.value?(t(),o("div",is,[e("div",rs,[e("div",ds,[a[20]||(a[20]=e("label",{class:"ed-label"},"Host",-1)),N(e("input",{class:"ed-input","onUpdate:modelValue":a[6]||(a[6]=c=>l.value.ftp_host=c),placeholder:"ftp.example.com"},null,512),[[V,l.value.ftp_host]])]),e("div",us,[a[21]||(a[21]=e("label",{class:"ed-label"},"Port",-1)),N(e("input",{class:"ed-input",type:"number","onUpdate:modelValue":a[7]||(a[7]=c=>l.value.ftp_port=c),placeholder:"21"},null,512),[[V,l.value.ftp_port,void 0,{number:!0}]])]),e("div",cs,[a[22]||(a[22]=e("label",{class:"ed-label"},"Username",-1)),N(e("input",{class:"ed-input","onUpdate:modelValue":a[8]||(a[8]=c=>l.value.ftp_user=c)}
1,null,512),[[V,l.value.ftp_user]])]),e("div",vs,[a[23]||(a[23]=e("label",{class:"ed-label"},"Password",-1)),N(e("input",{class:"ed-input",type:"password","onUpdate:modelValue":a[9]||(a[9]=c=>l.value.ftp_pass=c)},null,512),[[V,l.value.ftp_pass]])]),e("div",ps,[a[24]||(a[24]=e("label",{class:"ed-label"},"Remote path",-1)),N(e("input",{class:"ed-input","onUpdate:modelValue":a[10]||(a[10]=c=>l.value.ftp_path=c),placeholder:"/books"},null,512),[[V,l.value.ftp_path]])]),e("div",bs,[a[25]||(a[25]=e("label",{class:"ed-label"},"Public base URL",-1)),N(e("input",{class:"ed-input","onUpdate:modelValue":a[11]||(a[11]=c=>l.value.ftp_base_url=c),placeholder:"https://cdn.example.com/books"},null,512),[[V,l.value.ftp_base_url]])])]),a[26]||(a[26]=e("p",{class:"eb-hint"},"Implicit FTPS uses port 990. Plain FTP uses 21.",-1))])):E("",!0),e("div",gs,[e("button",{class:"ed-btn-primary",disabled:r.value,onClick:R},d(r.value?"Savingâ¦":"Save storage configuration"),9,hs)])]))}}),ks=ee(ys,[["__scopeId","data-v-bcaf9e35"]]),ms={class:"eb-tab"},fs={class:"ed-card"},_s={key:0,class:"eb-empty"},$s={key:1,class:"eb-stats"},ws={class:"eb-stat"},Cs={class:"eb-stat-num"},xs={class:"eb-stat"},Ss={class:"eb-stat-num"},Ts={class:"eb-stat"},Bs={class:"eb-stat-num"},Ps={class:"ed-card"},Us={class:"ed-card-header"},Es={key:0,class:"eb-rt-count"},Rs={class:"eb-rt-search"},Is={key:0,class:"eb-empty"},Ms={key:1,class:"eb-rank"},As={class:"eb-rank-title"},Ns={class:"eb-rank-num"},Vs={key:2,class:"eb-rt-pager"},Ls=["disabled"],Hs=["disabled"],Ds={class:"ed-card"},Os={class:"ed-card-header"},js={key:0,class:"eb-rt-count"},Fs={class:"eb-rt-search"},zs={key:0,class:"eb-empty"},Gs={key:1,class:"eb-reader-list"},qs={class:"eb-reader-body"},Ks={class:"eb-reader-name"},Js={class:"eb-reader-meta"},Ws=["onClick"],Xs={key:2,class:"eb-rt-pager"},Qs=["disabled"],Ys=["disabled"],le=20,Zs=Z({__name:"ReportsTab",props:{valueId:{}},emits:["toast","reload"],setup(m,{emit:x}){const u=m,p=x,f=b({unique_readers:0,total_sessions:0}),_=b([]),B=b([]),g=b(!0),l=b(""),r=b(1),$=b(0),k=K(()=>Math.max(1,Math.ceil($.value/le))),P=b(""),R=b(1),w=b(0),a=K(()=>Math.max(1,Math.ceil(w.value/le)));async function c(){try{const I=await Ie(u.valueId,r.value,le,l.value.trim());f.value=I.summary??f.value,_.value=I.book_stats??[],$.value=I.total??_.value.length}catch(I){p("toast",I?.message??"Could not load reports","error")}}async function U(){try{const I=await Me(u.valueId,R.value,le,P.value.trim());B.value=I.rows??[],w.value=I.total??B.value.length}catch(I){p("toast",I?.message??"Could not load readers","error")}}async function h(){g.value=!0,await Promise.all([c(),U()]),g.value=!1}let S=null;Y(l,()=>{S&&clearTimeout(S),S=setTimeout(()=>{r.value=1,c()},350)});function A(I){I>
1=1&&I<=k.value&&(r.value=I,c())}let H=null;Y(P,()=>{H&&clearTimeout(H),H=setTimeout(()=>{R.value=1,U()},350)});function X(I){I>=1&&I<=a.value&&(R.value=I,U())}async function q(I){if(confirm("Remove this reader's reading history and bookmarks?"))try{await Ae(u.valueId,I),B.value.length===1&&R.value>1&&R.value--,await U()}catch(C){p("toast",C?.message??"Could not remove","error")}}return se(h),(I,C)=>(t(),o("div",ms,[e("div",fs,[C[9]||(C[9]=e("div",{class:"ed-card-header"},"Overview",-1)),g.value?(t(),o("div",_s,"Loadingâ¦")):(t(),o("div",$s,[e("div",ws,[e("div",Cs,d(f.value.unique_readers),1),C[6]||(C[6]=e("div",{class:"eb-stat-label"},"Readers",-1))]),e("div",xs,[e("div",Ss,d(f.value.total_sessions),1),C[7]||(C[7]=e("div",{class:"eb-stat-label"},"Reading records",-1))]),e("div",Ts,[e("div",Bs,d($.value),1),C[8]||(C[8]=e("div",{class:"eb-stat-label"},"Books",-1))])]))]),e("div",Ps,[e("div",Us,[C[10]||(C[10]=J("Most read ",-1)),$.value?(t(),o("span",Es,d($.value),1)):E("",!0)]),e("div",Rs,[C[11]||(C[11]=e("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e("circle",{cx:"11",cy:"11",r:"8"}),e("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})],-1)),N(e("input",{"onUpdate:modelValue":C[0]||(C[0]=M=>l.value=M),type:"search",placeholder:"Search books by title"},null,512),[[V,l.value]])]),_.value.length?(t(),o("div",Ms,[(t(!0),o(L,null,D(_.value,M=>(t(),o("div",{key:M.book_id,class:"eb-rank-row"},[e("span",As,d(M.title),1),e("span",Ns,d(M.readers)+" reader"+d(M.readers===1?"":"s"),1)]))),128))])):(t(),o("div",Is,d(l.value.trim()?"No books match your search.":"No books yet."),1)),k.value>1?(t(),o("div",Vs,[e("button",{class:"ed-btn-tiny",disabled:r.value===1,onClick:C[1]||(C[1]=M=>A(r.value-1))},"Prev",8,Ls),e("span",null,"Page "+d(r.value)+" / "+d(k.value),1),e("button",{class:"ed-btn-tiny",disabled:r.value>=k.value,onClick:C[2]||(C[2]=M=>A(r.value+1))},"Next",8,Hs)])):E("",!0)]),e("div",Ds,[e("div",Os,[C[12]||(C[12]=J("Readers ",-1)),w.value?(t(),o("span",js,d(w.value),1)):E("",!0)]),e("div",Fs,[C[13]||(C[13]=e("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e("circle",{cx:"11",cy:"11",r:"8"}),e("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})],-1)),N(e("input",{"onUpdate:modelValue":C[3]||(C[3]=M=>P.value=M),type:"search",placeholder:"Search readers by name or email"},null,512),[[V,P.value]])]),B.value.length?(t(),o("div",Gs,[(t(!0),o(L,null,D(B.value,M=>(t(),o("div",{key:M.id,class:"eb-reader"},[e("div",qs,[e("div",Ks,d((M.firstname||"")+" "+(M.lastname||"")),1),e("div",Js,d(M.email)+" · "+d(M.books_read)+" book"+d(M.books_read===1?"":"s"),1)]),e("button",{class:"eb-icon-btn danger",title:"Remove",onClick:W=>q(M.id)},[...C[14]||(C[14]=[e("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e("polyline",{points:"3 6 5 6 21 6"}),e("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"})],-1)])],8,Ws)]))),128))])):(t(),o("div",zs,d(P.value.trim()?"No readers match your search.":"No readers yet."),1)),a.value>1?(t(),o("div",Xs,[e("button",{class:"ed-btn-tiny",disabled:R.value===1,onClick:C[4]||(C[4]=M=>X(R.value-1))},"Prev",8,Qs),e("span",null,"Page "+d(R.value)+" / "+d(a.value),1),e("button",{class:"ed-btn-tiny",disabled:R.value>=a.value,onClick:C[5]||(C[5]=M=>X(R.value+1))},"Next",8,Ys)])):E("",!0)])]))}}),ea=ee(Zs,[["__scopeId","data-v-6e2e4680"]]),ta={class:"ebook-editor"},oa={key:0,class:"ed-loading"},sa={class:"ed-sub-nav"},aa=["onClick"],la=Z({__name:"EbookEditor",props:{feature:{},featureData:{},featureItems:{},schema:{},dataType:{}},setup(m){const x=m,{toast:u}=we(),p=ie();function f(){return x.feature?.value_id}const _=b(!0),B=b(null),g=b("library"),l=[{id:"library",label:"Library"},{id:"categories",label:"Categories"},{id:"appearance",label:"Appearance"},{id:"storage",label:"Storage"},{id:"reports",label:"Reports"}];async function r(){try{const P=await Te(f());B.value=P.settings??{}}catch(P){u(P?.message??"Failed to load reader settings","error")}finally{_.value=!1}}function $(P,R="success"){u(P,R)}function k(){r(),p.refresh()}return se(r),(P,R)=>(t(),o("div",ta,[_.value?(t(),o("div",oa,[...R[0]||(R[0]=[e("div",{class:"ed-spinner"},null,-1)])])):(t(),o(L,{key:1},[e("div",sa,[(t(),o(L,null,D(l,w=>e("button",{key:w.id,class:z(["ed-sub-nav-item",{active:g.value===w.id}]),onClick:a=>g.value=w.id},d(w.label),11,aa)),64))]),g.value==="library"?(t(),oe(Pt,{key:0,"value-id":f(),onToast:$,onReload:k},null,8,["value-id"])):E("",!0),g.value==="categories"?(t(),oe(Wt,{key:1,"value-id":f(),onToast:$,onReload:k},null,8,["value-id"])):E("",!0),g.value==="appearance"?(t(),oe(Ko,{key:2,"value-id":f(),settings:B.value,onToast:$,onReload:k},null,8,["value-id","settings"])):E("",!0),g.value==="storage"?(t(),oe(ks,{key:3,"value-id":f(),settings:B.value,onToast:$,onReload:k},null,8,["value-id","settings"])):E("",!0),g.value==="reports"?(t(),oe(ea,{key:4,"value-id":f(),onToast:$,onReload:k},null,8,["value-id"])):E("",!0)],64))]))}}),pa=ee(la,[["__scopeId","data-v-e4796499"]]);export{pa as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.