// ==UserScript== // @name BOOK☆WALKER 書櫃隨機閱讀 // @namespace https://www.bookwalker.com.tw/ // @version 0.0.2 // @description 從目前書櫃分類或自訂書單的全部分頁隨機選書,在新分頁閱讀。 // @homepageURL https://github.com/VdustR/monkey-script-bookwalker-tw-random-pick // @match https://www.bookwalker.com.tw/bookcase/available_book_list // @match https://www.bookwalker.com.tw/bookcase/available_book_list?* // @match https://www.bookwalker.com.tw/bookcase/available_book_list/* // @run-at document-idle // @grant none // ==/UserScript== (function(){var e=Array.isArray,t=Array.prototype.indexOf,n=Array.prototype.includes,r=Array.from,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyDescriptors,s=Object.prototype,c=Array.prototype,l=Object.getPrototypeOf,u=Object.isExtensible,d=()=>{};function f(e){for(var t=0;t{e=n,t=r}),resolve:e,reject:t}}var m=1024,h=2048,g=4096,_=8192,v=16384,y=32768,b=1<<25,x=65536,S=1<<19,ee=1<<20,C=1<<25,w=1<<21,te=1<<22,ne=1<<23,re=Symbol(`$state`),ie=Symbol(`component`),ae=Symbol(``),oe=Symbol(`attributes`),se=Symbol(`class`),ce=Symbol(`style`),le=Symbol(`text`),ue=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},de=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`),fe={},T=Symbol(`uninitialized`),pe=`http://www.w3.org/1999/xhtml`;function me(){console.warn(`https://svelte.dev/e/derived_inert`)}function he(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function ge(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var E=!1;function _e(e){E=e}var D;function O(e){if(e===null)throw he(),fe;return D=e}function ve(){return O(Rt(D))}function k(e){if(E){if(Rt(D)!==null)throw he(),fe;D=e}}function ye(e=1){if(E){for(var t=e,n=D;t--;)n=Rt(n);D=n}}function be(e=!0){for(var t=0,n=D;;){if(n.nodeType===8){var r=n.data;if(r===`]`){if(t===0)return n;--t}else(r===`[`||r===`[!`||r[0]===`[`&&!isNaN(Number(r.slice(1))))&&(t+=1)}var i=Rt(n);e&&n.remove(),n=i}}function xe(e){if(!e||e.nodeType!==8)throw he(),fe;return e.data}function Se(e){return e===this.v}function Ce(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function we(e){return!Ce(e,this.v)}function Te(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function Ee(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function De(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function Oe(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function ke(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function Ae(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function je(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var A=null;function Me(e){A=e}function Ne(e,t=!1,n){A={p:A,i:!1,c:null,e:null,s:e,x:null,r:q,l:null}}function Pe(e){var t=A,n=t.e;if(n!==null){t.e=null;for(var r of n)Xt(r)}return e!==void 0&&(t.x=e),t.i=!0,A=t.p,Fe(e)}function Fe(e={}){return i(e,ie,{value:!0}),e}function Ie(){return!0}var Le=[];function Re(){var e=Le;Le=[],f(e)}function ze(e){if(Le.length===0&&!ct){var t=Le;queueMicrotask(()=>{t===Le&&Re()})}Le.push(e)}function Be(){for(;Le.length>0;)Re()}var Ve=~(h|g|m);function j(e,t){e.f=e.f&Ve|t}function He(e){e.f&512||e.deps===null?j(e,m):j(e,g)}function Ue(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),j(e,m)}function We(e){var t=W,n=q;K(null),vn(null);try{return e()}finally{K(t),vn(n)}}function Ge(e,t,n,r){let i=Ie()?Ye:$e;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=q,c=Ke(),l=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(e=>e.promise)):null;function u(e){if(!(s.f&16384)){c();try{r([...o,...e])}catch(e){V(e,s)}qe()}}var d=Je();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>Ze(e))).then(u).catch(e=>V(e,s)).finally(d)}l?l.then(()=>{c(),f(),qe()}):f()}function Ke(){var e=q,t=W,n=A,r=M;return function(i=!0){vn(e),K(t),Me(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function qe(e=!0){vn(null),K(null),Me(null),e&&M?.deactivate()}function Je(){var e=q,t=e.b,n=M,r=!!t?.is_rendered();return t?.update_pending_count(1,n),n.increment(r,e),()=>{t?.update_pending_count(-1,n),n.decrement(r,e)}}function Ye(e){var t=2|h;return q!==null&&(q.f|=S),{ctx:A,deps:null,effects:null,equals:Se,f:t,fn:e,reactions:null,rv:0,v:T,wv:0,parent:q,ac:null}}var Xe=Symbol(`obsolete`);function Ze(e,t,n){let r=q;r===null&&Te();var i=void 0,a=wt(T),o=!W,s=new Set;return $t(()=>{var t=q,n=p();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==ue&&n.reject(e)}).finally(qe)}catch(e){n.reject(e),qe()}var c=M;if(o){if(t.f&32768)var l=Je();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(Xe);else for(let e of s.values())e.reject(Xe);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==Xe&&(c.activate(),t?(a.f|=ne,Ot(a,t)):(a.f&8388608&&(a.f^=ne),Ot(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),Yt(()=>{for(let e of s)e.reject(Xe)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function Qe(e){let t=Ye(e);return bn(t),t}function $e(e){let t=Ye(e);return t.equals=we,t}function et(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n{t.ac.abort(ue),t.ac=null}),t.fn!==null&&(t.teardown=d),Mn(t,0),an(t))}function it(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&Nn(t)}var at=null,M=null,ot=null,N=null,st=null,ct=!1,lt=!1,ut=null,dt=null,ft=0,pt=1,mt=class e{id=pt++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;#r=new Set;#i=new Set;#a=0;#o=new Map;#s=null;#c=[];#l=[];#u=new Set;#d=new Set;#f=new Map;#p=new Set;is_fork=!1;#m=!1;constructor(){at===null?at=this:(at.#n=this,this.#t=at),at=this}#h(){if(this.is_fork)return!0;for(let n of this.#o.keys()){for(var e=n,t=!1;e.parent!==null;){if(this.#f.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#f.has(e)||this.#f.set(e,{d:[],m:[]}),this.#p.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#f.get(e);if(n){this.#f.delete(e);for(var r of n.d)j(r,h),t(r);for(r of n.m)j(r,g),t(r)}this.#p.add(e)}#g(){var e=[];for(let i of this.#c)if(!(i.f&16384||!(i.f&6144))){for(var t=i,n=!1;t.parent!==null;){t=t.parent;var r=t.f;if(r&96){if(!(r&1024)){n=!0;break}t.f^=m}}n||e.push(t)}return this.#c=[],e}#_(){this.#e=!0;for(let e of this.#u)this.#d.delete(e),j(e,h),this.schedule(e);for(let e of this.#d)j(e,g),this.schedule(e);this.apply();for(var t=ut=[],n=[],r=dt=[];this.#c.length>0;){ft++>1e3&&(this.#S(),gt());for(let e of this.#g())try{this.#v(e,t,n)}catch(t){throw xt(e),this.#h()||this.discard(),t}}if(M=null,r.length>0){var i=e.ensure();for(let e of r)i.schedule(e)}if(ut=null,dt=null,this.#h()){this.#x(n),this.#x(t);for(let[e,t]of this.#f)bt(e,t);r.length>0&&M.#_();return}let a=this.#y();if(a){this.#x(n),this.#x(t),a.#b(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),ot=this,vt(n),vt(t),ot=null,this.#s?.resolve();var o=M;if(this.#a===0&&(this.#c.length===0||o!==null)&&this.#S(),this.#c.length>0){if(o!==null){for(let e of this.#c)o.#c.push(e);this.#c=[]}else o=this}o!==null&&(P.clear(),o.#_())}#v(e,t,n){e.f^=m;for(var r=e.first;r!==null;){var i=r.f,a=!!(i&96);if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=m:i&4?t.push(r):Dn(r)&&(i&16&&this.#d.add(r),Nn(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}#y(){for(var e=this.#t;e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=e.#t}return null}#b(e){for(let[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve).catch(e.reject)}e.async_deriveds.clear(),this.transfer_effects(e.#u,e.#d);let t=e=>{var n=e.reactions;if(n!==null&&!(e.f&2&&!(e.f&6144)))for(let e of n){var r=e.f;if(r&2)t(e);else{var i=e;r&4194320&&!this.async_deriveds.has(i)&&(this.#d.delete(i),j(i,h),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#S(),M=this,this.#_()}#x(e){for(var t=0;t{this.#m=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#u.add(t);for(let e of t)this.#d.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}settled(){return(this.#s??=p()).promise}static ensure(){if(M===null){let t=M=new e;!lt&&!ct&&ze(()=>{t.#e||t.flush()})}return M}apply(){N=null}schedule(e){if(st=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}this.#c.push(e)}#S(){if(this.linked){var e=this.#t,t=this.#n;e===null||(e.#n=t),t===null?at=e:t.#t=e,this.linked=!1}}};function ht(e){var t=ct;ct=!0;try{var n;for(e&&(M!==null&&!M.is_fork&&M.flush(),n=e());;){if(Be(),M===null)return n;M.flush()}}finally{ct=t}}function gt(){try{De()}catch(e){V(e,st)}}var _t=null;function vt(e){var t=e.length;if(t!==0){for(var n=0;n0)){P.clear();for(let e of _t){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)_t.has(n)&&(_t.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Nn(n)}}_t.clear()}}_t=null}}function yt(e){M.schedule(e)}function bt(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),j(e,m);for(var n=e.first;n!==null;)bt(n,t),n=n.next}}function xt(e){j(e,m);for(var t=e.first;t!==null;)xt(t),t=t.next}var St=new Set,P=new Map,Ct=!1;function wt(e,t){return{f:0,v:e,reactions:null,equals:Se,rv:0,wv:0}}function F(e,t){let n=wt(e,t);return bn(n),n}function Tt(e,t=!1,n=!0){let r=wt(e);return t||(r.equals=we),r}function I(e,t,n=!1){return W!==null&&(!G||W.f&131072)&&Ie()&&W.f&4325394&&(yn===null||!yn.has(e))&&Ae(),Ot(e,n?Mt(t):t,dt)}var Et=null,Dt=0;function Ot(e,t,n=null){if(!e.equals(t)){gn?P.set(e,t):P.has(e)||P.set(e,e.v);var r=mt.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&tt(t),N===null&&He(t)}e.wv=En(),Et=null,Dt=0,jt(e,h,n),Et=null,Ie()&&q!==null&&q.f&1024&&!(q.f&96)&&(X===null?xn([e]):X.push(e)),!r.is_fork&&St.size>0&&!Ct&&kt()}return t}function kt(){Ct=!1;for(let e of St){e.f&1024&&j(e,g);let t;try{t=Dn(e)}catch{t=!0}t&&Nn(e)}St.clear()}function At(e){I(e,e.v+1)}function jt(e,t,n){var r=e.reactions;if(r!==null){var i=Ie(),a=r.length;if(Dt+=a,Dt>1e5&&Et===null&&(Et=new Set),Et!==null){if(Et.has(e))return;Et.add(e)}for(var o=0;o{if(wn===d)return e();var t=W,n=wn;K(null),Tn(d);var r=e();return K(t),Tn(n),r};return i&&r.set(`length`,F(t.length,u)),new Proxy(t,{defineProperty(e,t,n){(!(`value`in n)||n.configurable===!1||n.enumerable===!1||n.writable===!1)&&Oe();var i=r.get(t);return i===void 0?f(()=>{var e=F(n.value,u);return r.set(t,e),e}):I(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>F(T,u));r.set(t,e),At(o)}}else I(n,T),At(o);return!0},get(e,n,i){if(n===re)return t;var o=r.get(n),s=n in e;if(o===void 0&&(!s||a(e,n)?.writable)&&(o=f(()=>F(Mt(s?e[n]:T),u)),r.set(n,o)),o!==void 0){var c=Z(o);return c===T?void 0:c}return Reflect.get(e,n,i)},getOwnPropertyDescriptor(e,t){this.has?.(e,t);var n=Reflect.getOwnPropertyDescriptor(e,t),i=r.get(t);if(i!==void 0){var a=Z(i);if(a===T)return;if(n&&`value`in n)n.value=a;else return{enumerable:!0,configurable:!0,value:a,writable:!0}}return n},has(e,t){if(t===re)return!0;var n=r.get(t),i=n!==void 0&&n.v!==T||Reflect.has(e,t);return(n!==void 0||q!==null&&(!i||a(e,t)?.writable))&&(n===void 0&&(n=f(()=>F(i?Mt(e[t]):T,u)),r.set(t,n)),Z(n)===T)?!1:i},set(e,t,n,s){var c=r.get(t),l=t in e;if(i&&t===`length`)for(var d=n;dF(T,u)),r.set(d+``,p)):I(p,T)}if(c===void 0)(!l||a(e,t)?.writable)&&(c=f(()=>F(void 0,u)),I(c,Mt(n)),r.set(t,c));else{l=c.v!==T;var m=f(()=>Mt(n));I(c,m)}var h=Reflect.getOwnPropertyDescriptor(e,t);if(h?.set&&h.set.call(s,n),!l){if(i&&typeof t==`string`){var g=r.get(`length`),_=Number(t);Number.isInteger(_)&&_>=g.v&&I(g,_+1)}At(o)}return!0},ownKeys(e){Z(o);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==T});for(var[n,i]of r)i.v!==T&&!(n in e)&&t.push(n);return t},setPrototypeOf(){ke()}})}var Nt,Pt,Ft,It;function Lt(){if(Nt===void 0){Nt=window,Pt=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;Ft=a(t,`firstChild`).get,It=a(t,`nextSibling`).get,u(e)&&(e[se]=void 0,e[oe]=null,e[ce]=void 0,e.__e=void 0),u(n)&&(n[le]=void 0)}}function L(e=``){return document.createTextNode(e)}function R(e){return Ft.call(e)}function Rt(e){return It.call(e)}function z(e,t){if(!E)return R(e);var n=R(D);if(n===null)n=D.appendChild(L());else if(t&&n.nodeType!==3){var r=L();return n?.before(r),O(r),r}return t&&Wt(n),O(n),n}function zt(e,t=!1){if(!E){var n=R(e);return n instanceof Comment&&n.data===``?Rt(n):n}if(t){if(D?.nodeType!==3){var r=L();return D?.before(r),O(r),r}Wt(D)}return D}function Bt(e,t=!1){if(!E)return R(e);var n=z(e,t);return k(e),n}function B(e,t=1,n=!1){let r=E?D:e;for(var i;t--;)i=r,r=Rt(r);if(!E)return r;if(n){if(r?.nodeType!==3){var a=L();return r===null?i?.after(a):r.before(a),O(a),a}Wt(r)}return O(r),r}function Vt(e){e.textContent=``}function Ht(){return!1}function Ut(e,t,n){return t==null||t===`http://www.w3.org/1999/xhtml`?n?document.createElement(e,{is:n}):document.createElement(e):n?document.createElementNS(t,e,{is:n}):document.createElementNS(t,e)}function Wt(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===3;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function Gt(e){var t=q;if(t===null)return W.f|=ne,e;if(!(t.f&32768)&&!(t.f&4))throw e;V(e,t)}function V(e,t){if(!(t!==null&&t.f&16384)){for(;t!==null;){if(t.f&128&&!(t.f&33570816)){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}}function Kt(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function qt(e,t){var n=q;n!==null&&n.f&8192&&(e|=_);var r={ctx:A,deps:null,nodes:null,f:e|h|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};M?.register_created_effect(r);var i=r;if(e&4)ut===null?mt.ensure().schedule(r):ut.push(r);else if(t!==null){try{Nn(r)}catch(e){throw U(r),e}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&!(i.f&524288)&&(i=i.first,e&16&&e&65536&&i!==null&&(i.f|=x))}if(i!==null&&(i.parent=n,n!==null&&Kt(i,n),W!==null&&W.f&2&&!(e&64))){var a=W;(a.effects??=[]).push(i)}return r}function Jt(){return W!==null&&!G}function Yt(e){let t=qt(8,null);return j(t,m),t.teardown=e,t}function Xt(e){return qt(4|ee,e)}function Zt(e){mt.ensure();let t=qt(64|S,e);return(e={})=>new Promise(n=>{e.outro?ln(t,()=>{U(t),n(void 0)}):(U(t),n(void 0))})}function Qt(e){return qt(4,e)}function $t(e){return qt(te|S,e)}function en(e,t=0){return qt(8|t,e)}function tn(e,t=[],n=[],r=[]){Ge(r,t,n,t=>{qt(8,()=>{e(...t.map(Z))})})}function nn(e,t=0){return qt(16|t,e)}function H(e){return qt(32|S,e)}function rn(e){var t=e.teardown;if(t!==null){let n=gn,r=W;_n(!0),K(null);try{t.call(null)}catch(t){V(t,e.parent)}finally{_n(n),K(r)}}}function an(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&We(()=>{e.abort(ue)});var r=n.next;n.f&64?n.parent=null:U(n,t),n=r}}function on(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||U(t),t=n}}function U(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(sn(e.nodes.start,e.nodes.end),n=!0),e.f|=b,an(e,t&&!n),Mn(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();rn(e),e.f^=b,e.f|=v;var i=e.parent;i!==null&&i.first!==null&&cn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function sn(e,t){for(;e!==null;){var n=e===t?null:Rt(e);e.remove(),e=n}}function cn(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function ln(e,t,n=!0){var r=[];e.f|=256,un(e,r,!0);var i=()=>{n&&U(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function un(e,t,n){if(!(e.f&8192)){e.f^=_;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next;if(!(i.f&64)){var o=!!(i.f&65536)||!!(i.f&32)&&!!(e.f&16);un(i,t,o?n:!1)}i=a}}}function dn(e){e.f&=-257,fn(e,!0)}function fn(e,t){if(!(e.f&256)&&e.f&8192){e.f^=_,e.f&1024||(j(e,h),mt.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=!!(n.f&65536)||!!(n.f&32);fn(n,i?t:!1),n=r}var a=e.nodes&&e.nodes.t;if(a!==null)for(let e of a)(e.is_global||t)&&e.in()}}function pn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:Rt(n);t.append(n),n=i}}var mn=null,hn=!1,gn=!1;function _n(e){gn=e}var W=null,G=!1;function K(e){W=e}var q=null;function vn(e){q=e}var yn=null;function bn(e){W!==null&&(W.f&2097152||W.f&2)&&(yn??=new Set).add(e)}var J=null,Y=0,X=null;function xn(e){X=e}var Sn=1,Cn=0,wn=Cn;function Tn(e){wn=e}function En(){return++Sn}function Dn(e){var t=e.f;if(t&2048)return!0;if(t&4096){for(var n=e.deps,r=n.length,i=0;ie.wv)return!0}t&512&&N===null&&j(e,m)}return!1}function On(e,t,n=!0){var r=e.reactions;if(r!==null&&!(yn!==null&&yn.has(e)))for(var i=0;i{e.ac.abort(ue)}),e.ac=null);try{e.f|=w;var u=e.fn,d=u();e.f|=y;var f=An(e);if(Ie()&&X!==null&&!G&&f!==null&&!(e.f&6146))for(var p=0;p0)for(t.length=Y+J.length,r=0;r{s.ac.abort(ue),s.ac=null,j(s,h)}),rt(s),Mn(s,0)}}function Mn(e,t){var n=e.deps;if(n!==null)for(var r=t;r{e.isConnected&&e.dispatchEvent(t)}))}function Wn(e,t,n,r={}){function i(e){if(r.capture||Xn.call(t,e),!e.cancelBubble)return We(()=>n?.call(this,e))}return e.startsWith(`pointer`)||e.startsWith(`touch`)||e===`wheel`?(i.__removed=!1,ze(()=>{i.__removed||t.addEventListener(e,i,r)})):t.addEventListener(e,i,r),i}function Gn(e,t,n,r,i){var a={capture:r,passive:i},o=Wn(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&Yt(()=>{o.__removed=!0,t.removeEventListener(e,o,a)})}function Kn(e,t,n){(t[Bn]??={})[e]=n}function qn(e){for(var t=0;t{Yn=!1,Jn=null}));var s=0,c=Jn===e&&e[Bn];if(c){var l=a.indexOf(c);if(l!==-1&&(t===document||t===window)){e[Bn]=t;return}var u=a.indexOf(t);if(u===-1)return;l<=u&&(s=l)}if(o=a[s]||e.target,o!==t){i(e,`currentTarget`,{configurable:!0,get(){return o||n}});var d=W,f=q;K(null),vn(null);try{for(var p,m=[];o!==null&&o!==t;){try{var h=o[Bn]?.[r];h!=null&&(!o.disabled||e.target===o)&&h.call(o,e)}catch(e){p?m.push(e):p=e}if(e.cancelBubble)break;s++,o=s{throw e});throw p}}finally{e[Bn]=t,delete e.currentTarget,K(d),vn(f)}}}var Zn=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Qn(e){return Zn?.createHTML(e)??e}function $n(e){var t=Ut(`template`);return t.innerHTML=Qn(e.replaceAll(``,``)),t.content}function er(e,t){var n=q;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function Q(e,t){var n=!!(t&1),r=!!(t&2),i,a=!e.startsWith(``);return()=>{if(E)return er(D,null),D;i===void 0&&(i=$n(a?e:``+e),n||(i=R(i)));var t=r||Pt?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=R(t),s=t.lastChild;er(o,s)}else er(t,t);return t}}function tr(e,t,n=`svg`){var r=!e.startsWith(``),i=!!(t&1),a=`<${n}>${r?e:``+e}`,o;return()=>{if(E)return er(D,null),D;if(!o){var e=R($n(a));if(i)for(o=document.createDocumentFragment();R(e);)o.appendChild(R(e));else o=R(e)}var t=o.cloneNode(!0);if(i){var n=R(t),r=t.lastChild;er(n,r)}else er(t,t);return t}}function nr(e,t){return tr(e,t,`svg`)}function $(e,t){if(E){var n=q;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=D),ve();return}e!==null&&e.before(t)}function rr(e){let t=0,n=wt(0),r;return()=>{Jt()&&(Z(n),en(()=>(t===0&&(r=Ln(()=>e(()=>At(n)))),t+=1,()=>{ze(()=>{--t,t===0&&(r?.(),r=void 0,At(n))})})))}}var ir=x|S;function ar(e,t,n,r){new or(e,t,n,r)}var or=class{parent;is_pending=!1;transform_error;#e;#t=E?D:null;#n;#r;#i;#a=null;#o=null;#s=null;#c=null;#l=0;#u=0;#d=!1;#f=new Set;#p=new Set;#m=null;#h=rr(()=>(this.#m=wt(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=q;t.b=this,t.f|=128,n(e)},this.parent=q.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=nn(()=>{if(E){let e=this.#t;ve();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#y():this.#g()}else this.#b()},ir),E&&(this.#e=D)}#g(){try{this.#a=H(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed,{reset:n,invoke_onerror:r}=this.#v(e);ze(r),t&&(this.#s=H(()=>{t(this.#e,()=>e,()=>n)}))}#v(e){var t=!1,n=!1;let r=()=>{if(t){ge();return}t=!0,n&&je(),this.#s!==null&&ln(this.#s,()=>{this.#s=null}),this.#S(()=>{this.#b()})};return{reset:r,invoke_onerror:()=>{try{n=!0,this.#n.onerror?.(e,r),n=!1}catch(e){V(e,this.#i&&this.#i.parent)}}}}#y(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=H(()=>e(this.#e)),ze(()=>{var e=this.#c=document.createDocumentFragment(),t=L(),n=!1;if(e.append(t),this.#a=this.#S(()=>{try{return H(()=>this.#r(t))}catch(e){try{this.error(e),n=!0}catch(e){V(e,this.#i.parent)}return null}}),this.#a===null){this.#c=null,n&&this.#x(M);return}this.#u===0&&(this.#e.before(e),this.#c=null,ln(this.#o,()=>{this.#o=null}),this.#x(M))}))}#b(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=H(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();pn(this.#a,e);let t=this.#n.pending;this.#o=H(()=>t(this.#e))}else this.#x(M)}catch(e){this.error(e)}}#x(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){Ue(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#S(e){var t=q,n=W,r=A;vn(this.#i),K(this.#i),Me(this.#i.ctx);try{return mt.ensure(),e()}finally{vn(t),K(n),Me(r)}}#C(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#C(e,t);return}this.#u+=e,this.#u===0&&(this.#x(t),this.#o&&ln(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#C(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,ze(()=>{this.#d=!1,this.#m&&Ot(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),Z(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;M?.is_fork?(this.#a&&M.skip_effect(this.#a),this.#o&&M.skip_effect(this.#o),this.#s&&M.skip_effect(this.#s),M.oncommit(()=>{this.#w(e)})):this.#w(e)}#w(e){this.#a&&=(U(this.#a),null),this.#o&&=(U(this.#o),null),this.#s&&=(U(this.#s),null),E&&(O(this.#t),ye(),O(be()));let t=this.#n.failed,n=e=>{let{reset:n,invoke_onerror:r}=this.#v(e);r(),t&&(this.#s=this.#S(()=>{try{return H(()=>{var r=q;r.b=this,r.f|=128,t(this.#e,()=>e,()=>n)})}catch(e){return V(e,this.#i.parent),null}}))};ze(()=>{var t;try{t=this.transform_error(e)}catch(e){V(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(n,e=>V(e,this.#i&&this.#i.parent)):n(t)})}};function sr(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[le]??=e.nodeValue)&&(e[le]=n,e.nodeValue=`${n}`)}function cr(e,t){return ur(e,t)}var lr=new Map;function ur(e,{target:t,anchor:n,props:i={},events:a,context:o,intro:s=!0,transformError:c}){Lt();var l=void 0,u=Zt(()=>{var s=n??t.appendChild(L());ar(s,{pending:()=>{}},t=>{Ne({});var n=A;if(o&&(n.c=o),a&&(i.$$events=a),E&&er(t,null),l=e(t,i)||Fe(),E&&(q.nodes.end=D,D===null||D.nodeType!==8||D.data!==`]`))throw he(),fe;Pe()},c);var u=new Set,d=e=>{for(var n=0;n{for(var e of u)for(let n of[t,document]){var r=lr.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Xn),r.delete(e),r.size===0&&lr.delete(n)):r.set(e,i)}Hn.delete(d),s!==n&&s.parentNode?.removeChild(s)}});return dr.set(l,u),l}var dr=new WeakMap,fr=class{anchor;#e=new Map;#t=new Map;#n=new Map;#r=new Set;#i=!0;constructor(e,t=!0){this.anchor=e,this.#i=t}#a=e=>{if(this.#e.has(e)){var t=this.#e.get(e),n=this.#t.get(t);if(n)dn(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(dn(r.effect),this.#t.set(t,r.effect),this.#n.delete(t),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),n=r.effect)}for(let[t,n]of this.#e){if(this.#e.delete(t),t===e)break;let r=this.#n.get(n);r&&(U(r.effect),this.#n.delete(n))}for(let[e,r]of this.#t){if(e===t||this.#r.has(e))continue;let i=()=>{if(Array.from(this.#e.values()).includes(e)){var t=document.createDocumentFragment();pn(r,t),t.append(L()),this.#n.set(e,{effect:r,fragment:t})}else U(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),ln(r,i,!1)):i()}}};#o=e=>{this.#e.delete(e);let t=Array.from(this.#e.values());for(let[e,n]of this.#n)t.includes(e)||(U(n.effect),this.#n.delete(e))};ensure(e,t){var n=M,r=Ht();if(t&&!this.#t.has(e)&&!this.#n.has(e)){if(r){var i=document.createDocumentFragment(),a=L();i.append(a),this.#n.set(e,{effect:H(()=>t(a)),fragment:i})}else this.#t.set(e,H(()=>t(this.anchor)))}if(this.#e.set(n,e),r){for(let[t,r]of this.#t)t===e?n.unskip_effect(r):n.skip_effect(r);for(let[t,r]of this.#n)t===e?n.unskip_effect(r.effect):n.skip_effect(r.effect);n.oncommit(this.#a),n.ondiscard(this.#o)}else E&&(this.anchor=D),this.#a(n)}};function pr(e,t,n=!1){var r;E&&(r=D,ve());var i=new fr(e),a=n?x:0;function o(e,t){if(E){var n=xe(r);if(e!==parseInt(n.substring(1))){var a=be();O(a),i.anchor=a,_e(!1),i.ensure(e,t),_e(!0);return}}i.ensure(e,t)}nn(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}function mr(e,t){return t}function hr(e,t,n){for(var i=[],a=t.length,o,s=t.length,c=0;c{if(o){if(o.pending.delete(n),o.done.add(n),o.pending.size===0){var t=e.outrogroups;gr(e,r(o.done)),t.delete(o),t.size===0&&(e.outrogroups=null)}}else--s},!1)}if(s===0){var l=i.length===0&&n!==null&&e.pending.size===0;if(l){var u=n,d=u.parentNode;Vt(d),d.append(u),e.items.clear()}gr(e,t,!l)}else o={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(o)}function gr(e,t,n=!0){var r;if(e.pending.size>0){r=new Set;for(let t of e.pending.values())for(let n of t)r.add(e.items.get(n).e)}for(var i=0;i{var t=i();return e(t)?t:t==null?[]:r(t)}),p,m=new Map,h=!0;function g(e){v.effect.f&16384||(v.pending.delete(e),v.fallback=d,br(v,p,c,n,a),d!==null&&(p.length===0?d.f&33554432?(d.f^=C,Sr(d,null,c)):dn(d):ln(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:nn(()=>{p=Z(f);var e=p.length;let t=!1;E&&xe(c)===`[!`!=(e===0)&&(c=be(),O(c),_e(!1),t=!0);for(var r=new Set,u=M,v=Ht(),y=0;ys(c)):(d=H(()=>s(_r??=L())),d.f|=C)),e>r.size&&Ee(``,``,``),E&&e>0&&O(be()),!h){if(m.set(u,r),v){for(let[e,t]of l)r.has(e)||u.skip_effect(t.e);u.oncommit(g),u.ondiscard(_)}else g(u)}t&&_e(!0),Z(f)}),flags:n,items:l,pending:m,outrogroups:null,fallback:d};h=!1,E&&(c=D)}function yr(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function br(e,t,n,i,a){var o=!!(i&8),s=t.length,c=e.items,l=yr(e.effect.first),u,d=null,f,p=[],m=[],h,g,_,v;if(o)for(v=0;v0){var ne=i&4&&s===0?n:null;if(o){for(v=0;v{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function xr(e,t,n,r,i,a,o,s){var c=o&1?o&16?wt(n):Tt(n,!1,!1):null,l=o&2?wt(i):null;return{v:c,i:l,e:H(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function Sr(e,t,n){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end,a=t&&!(t.f&33554432)?t.nodes.start:n;r!==null;){var o=Rt(r);if(a.before(r),r===i)return;r=o}}function Cr(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function wr(e,t){Qt(()=>{e=q?.parent?.nodes?.start??e;var n=e.getRootNode(),r=n.host?n:n.head??n.ownerDocument.head;if(!r.querySelector(`#`+t.hash)){let e=Ut(`style`);e.id=t.hash,e.textContent=t.code,r.appendChild(e)}})}var Tr=Symbol(`is custom element`),Er=Symbol(`is html`),Dr=de?`link`:`LINK`;function Or(e,t,n,r){var i=kr(e);E&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===Dr)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[ae]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&jr(e).has(t)?e[t]=n:e.setAttribute(t,n))}function kr(e){return e[oe]??={[Tr]:e.nodeName.includes(`-`),[Er]:e.namespaceURI===pe}}var Ar=new Map;function jr(e){var t=e.getAttribute(`is`)||e.nodeName,n=Ar.get(t);if(n)return n;Ar.set(t,n=new Set);for(var r,i=e,a=Element.prototype;a!==i;){for(var s in r=o(i),r)r[s].set&&s!==`innerHTML`&&s!==`textContent`&&s!==`innerText`&&n.add(s);i=l(i)}return n}function Mr(e,t){return e===t||e?.[re]===t}function Nr(e=Fe(),t,n,r){var i=A.r,a=q;return Qt(()=>{var o,s;return en(()=>{o=s,s=r?.()||[],Ln(()=>{Mr(n(...s),e)||(t(e,...s),o&&Mr(n(...o),e)&&t(null,...o))})}),()=>{let r=a;for(;r!==i&&r.parent!==null&&r.parent.f&33554432;)r=r.parent;let o=()=>{s&&Mr(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);var Pr=`.pageNumSelect option`,Fr=`a[href*="/browserViewer/"][href$="/read"]`;function Ir(e,t){if(!e?.trim())return``;try{let n=new URL(e,t);return n.protocol===`https:`||n.protocol===`http:`?n.href:``}catch{return``}}function Lr(e,t){return[...e.querySelectorAll(`.readerBooks`)].flatMap(e=>{let n=e.querySelector(`[data-action*="display_book_info"]`),r=Ir(e.querySelector(Fr)?.getAttribute(`href`)??null,t);if(!n||!r||new URL(r).origin!==new URL(t).origin)return[];let i=e=>n.getAttribute(`data-${e}`)?.trim()??``,a=[...e.querySelectorAll(`.readerBookMoreMenu li`)].filter(e=>!e.getAttribute(`data-action`)?.includes(`display_book_info`)).map(e=>({label:e.textContent.trim(),attributes:[...e.attributes].filter(e=>e.name.startsWith(`data-`)).map(e=>[e.name,e.value])})).filter(e=>e.label.length>0&&e.attributes.length>0);return[{id:e.querySelector(`input[name="products"]`)?.value??``,readerUrl:r,coverUrl:Ir(i(`product_image`),t),name:i(`product_name`)||`未提供書名`,author:i(`author`)||`未提供作者`,category:i(`category`),publisher:i(`vendor`),publishAt:i(`publish_at`),buyAt:i(`buy_at`),lastRead:i(`last_read`),siteActions:a}]})}function Rr(e){let t=new URL(e);return/^\/bookcase\/available_book_list\/?$/.test(t.pathname)&&(t.pathname=`/bookcase/available_book_list/all`),t}function zr(e,t){let n=Rr(t);n.hash=``;let r=new Set([n.href]);for(let t of e.querySelectorAll(Pr)){if(!t.value.trim())continue;let e;try{e=new URL(t.value,n)}catch{continue}if(e.origin!==n.origin||e.pathname!==n.pathname)continue;let i=e.searchParams.get(`page`);if(i!==null&&!/^\d+$/.test(i)||i===(n.searchParams.get(`page`)??`1`))continue;let a=new URL(n);i!==null&&a.searchParams.set(`page`,i),r.add(a.href)}return[...r]}var Br=class{pending;root;currentUrl;fetchPage;constructor(e,t,n=fetch){this.root=e,this.currentUrl=Rr(t).href,this.fetchPage=n.bind(globalThis)}get(){return this.pending??=this.load().catch(e=>{throw this.pending=void 0,e}),this.pending}async load(){let e=zr(this.root,this.currentUrl),t=new URL(this.currentUrl);t.hash=``;let n=new Map,r=0,i=(await Promise.allSettled(Array.from({length:Math.min(3,e.length)},async()=>{for(;re.status===`rejected`);if(i?.status===`rejected`)throw i.reason;return[...n.values()]}};function Vr(e,t=Math.random){return e[Math.floor(t()*e.length)]}var Hr=`#bw_user > div > div.rwdWrapper2.rwdWrapperFull.areaFlex > div.rwdMain > div.readerSettingBox > div:nth-child(1) > div:nth-child(5)`;function Ur(e,t){let n=document.querySelector(`[data-controller~="bookcase"]`);if(!n)throw Error(`找不到網站的書櫃操作元件,請重新整理後再試。`);let r=document.createElement(`button`);r.type=`button`,r.hidden=!0;for(let[t,n]of e.attributes)t.startsWith(`data-`)&&r.setAttribute(t,n);n.append(r),t(),setTimeout(()=>{r.click(),setTimeout(()=>{r.remove()},1e3)},0)}var Wr=e=>{$(e,Gr())},Gr=nr(``),Kr=Q(` `),qr=Q(``),Jr=Q(`無封面圖片`),Yr=Q(`
`),Xr=Q(``),Zr=Q(`

`,1),Qr=Q(`

正在整理書櫃的全部分頁…

完成後會從所有可閱讀書籍中隨機選一本。

`,1),$r=Q(`

這個書櫃沒有可閱讀的書籍

請切換其他書櫃分類或自訂書單後再試。

`,1),ei=Q(`

無法載入書櫃

`,1),ti=Q(`
`),ni=Q(`

隨機閱讀

`,1),ri={hash:`svelte-1n46o8q`,code:`.bw-random-mount {display:contents;}.toolbar.svelte-1n46o8q {display:inline-flex;align-items:center;justify-content:center;padding:0;font:inherit;color:inherit;background:#fff;cursor:pointer;}svg.svelte-1n46o8q {width:20px;height:20px;flex:none;}dialog.svelte-1n46o8q {--accent: #80563d;--ink: #333;--muted: #666;--line: #e6dfda;border:0;border-radius:6px;padding:20px 24px 16px;width:min(600px, calc(100vw - 32px));max-width:none;max-height:calc(100dvh - 32px);box-sizing:border-box;overflow:auto;background:#fff;color:var(--ink);font:14px/1.5 Arial, "Microsoft JhengHei", sans-serif;box-shadow:0 12px 40px #0004;scrollbar-color:#b6a79e #faf8f6;}dialog.svelte-1n46o8q::backdrop {background:#211c18a6;}dialog[open].svelte-1n46o8q { animation: svelte-1n46o8q-reveal 180ms cubic-bezier(.16,1,.3,1);} @keyframes svelte-1n46o8q-reveal { from { clip-path: inset(0 0 8% 0); } to { clip-path: inset(0); } }header.svelte-1n46o8q {display:flex;align-items:center;justify-content:space-between;gap:12px;}h2.svelte-1n46o8q {margin:0;font-size:18px;font-weight:700;line-height:1.4;color:var(--accent);}.close.svelte-1n46o8q {border:0;padding:8px;margin:-6px -8px -6px 0;background:transparent;color:var(--muted);}.scope.svelte-1n46o8q {margin:4px 0 18px;color:var(--muted);display:flex;flex-wrap:wrap;gap:8px 16px;}.scope.svelte-1n46o8q span:where(.svelte-1n46o8q) {font-variant-numeric:tabular-nums;}.book.svelte-1n46o8q {display:grid;grid-template-columns:144px minmax(0, 1fr);gap:20px;align-items:start;}.cover.svelte-1n46o8q {display:grid;place-items:center;min-height:180px;background:#f7f4f1;color:var(--muted);}img.svelte-1n46o8q {display:block;width:100%;max-height:230px;object-fit:contain;}h3.svelte-1n46o8q {margin:0 0 6px;font-size:19px;line-height:1.5;font-weight:700;overflow-wrap:anywhere;text-wrap:pretty;}.author.svelte-1n46o8q {color:var(--muted);margin:0 0 14px;overflow-wrap:anywhere;}dl.svelte-1n46o8q {margin:0;font-size:13px;}dl.svelte-1n46o8q div:where(.svelte-1n46o8q) {display:grid;grid-template-columns:60px minmax(0, 1fr);gap:8px;margin:4px 0;}dt.svelte-1n46o8q {color:var(--muted);}dd.svelte-1n46o8q {margin:0;overflow-wrap:anywhere;font-variant-numeric:tabular-nums;}footer.svelte-1n46o8q {margin-top:20px;padding-top:16px;border-top:1px solid var(--line);}.primary-actions.svelte-1n46o8q, .secondary-actions.svelte-1n46o8q {display:flex;flex-wrap:wrap;align-items:center;gap:8px;}button.svelte-1n46o8q, a.svelte-1n46o8q {box-sizing:border-box;font:inherit;cursor:pointer;}dialog.svelte-1n46o8q button:where(.svelte-1n46o8q), dialog.svelte-1n46o8q a:where(.svelte-1n46o8q) {display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:40px;padding:8px 14px;border:1px solid #b9aaa0;border-radius:3px;background:#fff;color:var(--accent);text-decoration:none;transition:background-color 150ms ease-out;}dialog.svelte-1n46o8q .close:where(.svelte-1n46o8q) {border:0;min-width:40px;padding:8px;color:var(--muted);}dialog.svelte-1n46o8q .primary:where(.svelte-1n46o8q) {background:var(--accent);color:#fff;border-color:var(--accent);}dialog.svelte-1n46o8q button:where(.svelte-1n46o8q):hover, dialog.svelte-1n46o8q a:where(.svelte-1n46o8q):hover {background:#f5efeb;}dialog.svelte-1n46o8q .primary:where(.svelte-1n46o8q):hover {background:#68432f;border-color:#68432f;}button.svelte-1n46o8q:disabled {opacity:.55;cursor:wait;}button.svelte-1n46o8q:focus-visible, a.svelte-1n46o8q:focus-visible {outline:2px solid #80563d;outline-offset:3px;}.secondary-actions.svelte-1n46o8q {margin-top:8px;gap:0 16px;}.secondary-actions.svelte-1n46o8q button:where(.svelte-1n46o8q) {padding:6px 0;min-height:36px;border:0;background:transparent;text-decoration:underline;text-underline-offset:4px;font-size:13px;}.secondary-actions.svelte-1n46o8q button:where(.svelte-1n46o8q):hover {color:#4e3020;}.feedback.svelte-1n46o8q {margin:0;color:var(--muted);font-size:12px;}.feedback.svelte-1n46o8q:not(:empty) {margin-top:6px;}.message.svelte-1n46o8q {padding:12px 0 16px;}.message.svelte-1n46o8q p:where(.svelte-1n46o8q) {margin:8px 0 16px;}.hint.svelte-1n46o8q {color:var(--muted);}.sr-only.svelte-1n46o8q {position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap;}dialog.svelte-1n46o8q :where(.svelte-1n46o8q)::selection {background:#eee0d7;color:#412a1c;} @media (max-width: 480px) {dialog.svelte-1n46o8q {padding:16px;}.book.svelte-1n46o8q {grid-template-columns:90px minmax(0, 1fr);gap:14px;}.cover.svelte-1n46o8q {min-height:120px;}img.svelte-1n46o8q {max-height:150px;}h3.svelte-1n46o8q {font-size:17px;}dl.svelte-1n46o8q div:where(.svelte-1n46o8q) {grid-template-columns:1fr;gap:0;margin:6px 0;}.primary-actions.svelte-1n46o8q a:where(.svelte-1n46o8q) {flex:1;}.secondary-actions.svelte-1n46o8q button:where(.svelte-1n46o8q) {min-height:44px;} } @media (prefers-reduced-motion: reduce) {dialog[open].svelte-1n46o8q { animation: none;}dialog.svelte-1n46o8q button:where(.svelte-1n46o8q), dialog.svelte-1n46o8q a:where(.svelte-1n46o8q) {transition:none;} }`};function ii(e,t){Ne(t,!0),wr(e,ri);let n=F(Mt({kind:`idle`})),r=F(!1),i=F(``),a=F(!1),o=F(void 0),s=document.querySelector(`.readerTitle`)?.textContent.trim()||`目前書櫃`,c=new Br(document,location.href),l=Qe(()=>Z(n).kind===`book`?[[`類別`,Z(n).book.category],[`出版社`,Z(n).book.publisher],[`出版日期`,Z(n).book.publishAt],[`購買日期`,Z(n).book.buyAt],[`最後閱讀`,Z(n).book.lastRead]].filter(e=>e[1]):[]);function u(){Z(o)?.close()}async function d(){if(!Z(r)){I(r,!0),I(i,``),Z(n).kind!==`book`&&I(n,{kind:`loading`},!0),await Pn(),Z(o)&&!Z(o).open&&Z(o).showModal();try{let e=await c.get(),t=Vr(e);I(a,!1),I(n,t?{kind:`book`,book:t,count:e.length}:{kind:`empty`},!0)}catch(e){I(n,{kind:`error`,message:e instanceof Error?e.message:`載入失敗,請重試。`},!0)}finally{I(r,!1)}}}async function f(){if(Z(n).kind!==`book`)return;let e=Z(n).book;try{await navigator.clipboard.writeText(`${e.name}\n作者:${e.author}\n${e.readerUrl}`),I(i,`已複製書籍資訊`)}catch{I(i,`無法複製,請檢查瀏覽器的剪貼簿權限。`)}}function p(e){try{Ur(e,u)}catch(e){I(n,{kind:`error`,message:e instanceof Error?e.message:`操作失敗,請重新整理。`},!0)}}var m=ni(),h=zt(m);Wr(z(h)),k(h);var g=B(h,2),_=z(g),v=B(z(_),2);k(_);var y=B(_,2),b=z(y,!0),x=B(b),S=e=>{var t=Kr(),r=Bt(t);tn(()=>sr(r,`共 ${Z(n).count??``} 本`)),$(e,t)};pr(x,e=>{Z(n).kind===`book`&&e(S)}),k(y);var ee=B(y,2),C=e=>{var t=Zr(),o=zt(t),s=z(o),c=z(s),u=e=>{var t=qr();tn(()=>{Or(t,`src`,Z(n).book.coverUrl),Or(t,`alt`,`${Z(n).book.name} 封面`)}),Gn(`error`,t,()=>{I(a,!0)}),Un(t),$(e,t)},m=e=>{$(e,Jr())};pr(c,e=>{Z(n).book.coverUrl&&!Z(a)?e(u):e(m,-1)}),k(s);var h=B(s,2),g=z(h),_=Bt(g,!0),v=B(g,2),y=Bt(v,!0),b=B(v,2);vr(b,21,()=>Z(l),mr,(e,t)=>{var n=Yr(),r=z(n),i=Bt(r,!0),a=Bt(B(r),!0);k(n),tn(()=>{sr(i,Z(t)[0]),sr(a,Z(t)[1])}),$(e,n)}),k(b),k(h),k(o);var x=B(o,2),S=z(x),ee=z(S),C=B(ee,2),w=z(C);Wr(w);var te=B(w,1,!0);k(C),k(S);var ne=B(S,2),re=z(ne);vr(B(re,2),17,()=>Z(n).book.siteActions,mr,(e,t)=>{var n=Xr(),r=Bt(n,!0);tn(()=>sr(r,Z(t).label)),Kn(`click`,n,()=>{p(Z(t))}),$(e,n)}),k(ne);var ie=Bt(B(ne,2),!0);k(x),tn(()=>{Or(o,`aria-busy`,Z(r)),sr(_,Z(n).book.name),sr(y,Z(n).book.author),Or(ee,`href`,Z(n).book.readerUrl),C.disabled=Z(r),sr(te,Z(r)?`抽選中…`:`重骰`),sr(ie,Z(i))}),Kn(`click`,C,()=>{d()}),Kn(`click`,re,()=>{f()}),$(e,t)},w=e=>{var t=ti(),i=z(t),a=e=>{var t=Qr();ye(),$(e,t)},o=e=>{var t=$r();ye(),$(e,t)},s=e=>{var t=ei(),i=B(zt(t)),a=Bt(i,!0),o=B(i,2);tn(()=>{sr(a,Z(n).message),o.disabled=Z(r)}),Kn(`click`,o,()=>{d()}),$(e,t)};pr(i,e=>{Z(n).kind===`loading`?e(a):Z(n).kind===`empty`?e(o,1):Z(n).kind===`error`&&e(s,2)}),k(t),tn(()=>Or(t,`aria-busy`,Z(r))),$(e,t)};pr(ee,e=>{Z(n).kind===`book`?e(C):e(w,-1)}),k(g),Nr(g,e=>I(o,e),()=>Z(o)),tn(()=>{h.disabled=Z(r),sr(b,s)}),Kn(`click`,h,()=>{d()}),Kn(`click`,g,e=>{e.target===Z(o)&&u()}),Kn(`click`,v,u),$(e,m),Pe()}if(qn([`click`]),!document.getElementById(`bookwalker-random-book-button`)){let e=document.querySelector(Hr),t=document.querySelector(`.readerSettingBox .readerSettingColumn`);if(t){let n=document.createElement(`div`);n.className=`bw-random-mount`,e?e.insertAdjacentElement(`afterend`,n):t.append(n),cr(ii,{target:n})}}})();