hexo-theme-gnix 6.2.0 → 8.0.0

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.
Files changed (59) hide show
  1. package/README.md +6 -2
  2. package/include/hexo/encrypt.js +42 -0
  3. package/include/hexo/feed.js +329 -0
  4. package/include/util/common.js +7 -9
  5. package/languages/en.yml +6 -3
  6. package/languages/zh-CN.yml +6 -3
  7. package/layout/archive.jsx +86 -65
  8. package/layout/comment/twikoo.jsx +2 -11
  9. package/layout/comment/waline.jsx +2 -2
  10. package/layout/common/article.jsx +5 -8
  11. package/layout/common/article_cover.jsx +11 -1
  12. package/layout/common/article_media.jsx +2 -4
  13. package/layout/common/footer.jsx +11 -31
  14. package/layout/common/head.jsx +6 -14
  15. package/layout/common/navbar.jsx +4 -4
  16. package/layout/common/scripts.jsx +6 -6
  17. package/layout/common/theme_selector.jsx +5 -6
  18. package/layout/common/toc.jsx +8 -14
  19. package/layout/index.jsx +2 -4
  20. package/layout/misc/article_licensing.jsx +4 -2
  21. package/layout/misc/open_graph.jsx +4 -4
  22. package/layout/misc/paginator.jsx +10 -4
  23. package/layout/misc/structured_data.jsx +3 -4
  24. package/layout/plugin/busuanzi.jsx +1 -1
  25. package/layout/plugin/cookie_consent.jsx +40 -31
  26. package/layout/plugin/swup.jsx +2 -22
  27. package/layout/search/insight.jsx +16 -3
  28. package/package.json +12 -8
  29. package/scripts/hot-reload.js +92 -0
  30. package/scripts/index.js +2 -0
  31. package/source/css/archive.css +251 -0
  32. package/source/css/default.css +250 -284
  33. package/source/css/encrypt.css +55 -0
  34. package/source/css/responsive/desktop.css +0 -119
  35. package/source/css/responsive/mobile.css +7 -23
  36. package/source/css/responsive/touch.css +9 -103
  37. package/source/css/shiki/shiki.css +7 -22
  38. package/source/css/twikoo.css +290 -830
  39. package/source/img/og_image.webp +0 -0
  40. package/source/js/archive-breadcrumb.js +132 -0
  41. package/source/js/busuanzi.js +1 -12
  42. package/source/js/components/accordion.js +192 -0
  43. package/source/js/components/chat.js +239 -0
  44. package/source/js/components/device-carousel.js +260 -0
  45. package/source/js/components/image-carousel.js +410 -0
  46. package/source/js/components/text-image-section.js +180 -0
  47. package/source/js/components/theme-stacked.js +526 -0
  48. package/source/js/components/tree.js +437 -0
  49. package/source/js/decrypt.js +112 -0
  50. package/source/js/insight.js +75 -65
  51. package/source/js/main.js +192 -99
  52. package/source/js/mdit/mermaid.js +12 -4
  53. package/source/js/swup.bundle.js +1 -0
  54. package/source/js/theme-selector.js +94 -113
  55. package/source/img/og_image.png +0 -0
  56. package/source/js/host/swup/Swup.umd.min.js +0 -1
  57. package/source/js/host/swup/head-plugin.umd.min.js +0 -1
  58. package/source/js/host/swup/scripts-plugin.umd.min.js +0 -2
  59. package/source/js/mdit/shiki.js +0 -158
@@ -0,0 +1 @@
1
+ var y=new WeakMap;function k(f,S,z,G){if(!f&&!y.has(S))return!1;let J=y.get(S)??new WeakMap;y.set(S,J);let K=J.get(z)??new Set;J.set(z,K);let Y=K.has(G);if(f)K.add(G);else K.delete(G);return Y&&f}function Gf(f,S){let z=f.target;if(z instanceof Text)z=z.parentElement;if(z instanceof Element&&f.currentTarget instanceof Node){let G=z.closest(S);if(G&&f.currentTarget.contains(G))return G}}function Jf(f,S,z,G={}){let{signal:J,base:K=document}=G;if(J?.aborted)return;let{once:Y,...Z}=G,X=K instanceof Document?K.documentElement:K,Q=Boolean(typeof G==="object"?G.capture:G),q=(D)=>{let W=Gf(D,String(f));if(W){let V=Object.assign(D,{delegateTarget:W});if(z.call(X,V),Y)X.removeEventListener(S,q,Z),k(!1,X,z,B)}},B=JSON.stringify({selector:f,type:S,capture:Q});if(!k(!0,X,z,B))X.addEventListener(S,q,Z);J?.addEventListener("abort",()=>{k(!1,X,z,B)})}var w=Jf;function $(){return $=Object.assign?Object.assign.bind():function(f){for(var S=1;S<arguments.length;S++){var z=arguments[S];for(var G in z)({}).hasOwnProperty.call(z,G)&&(f[G]=z[G])}return f},$.apply(null,arguments)}var o=(f,S)=>String(f).toLowerCase().replace(/[\s/_.]+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+|-+$/g,"")||S||"",T=({hash:f}={})=>window.location.pathname+window.location.search+(f?window.location.hash:""),Kf=(f,S={})=>{let z=$({url:f=f||T({hash:!0}),random:Math.random(),source:"swup"},S);window.history.pushState(z,"",f)},O=(f=null,S={})=>{f=f||T({hash:!0});let z=$({},window.history.state||{},{url:f,random:Math.random(),source:"swup"},S);window.history.replaceState(z,"",f)},Qf=(f,S,z,G)=>{let J=new AbortController;return G=$({},G,{signal:J.signal}),w(f,S,z,G),{destroy:()=>J.abort()}};class F extends URL{constructor(f,S=document.baseURI){super(f.toString(),S),Object.setPrototypeOf(this,F.prototype)}get url(){return this.pathname+this.search}static fromElement(f){let S=f.getAttribute("href")||f.getAttribute("xlink:href")||"";return new F(S)}static fromUrl(f){return new F(f)}}class _ extends Error{constructor(f,S){super(f),this.url=void 0,this.status=void 0,this.aborted=void 0,this.timedOut=void 0,this.name="FetchError",this.url=S.url,this.status=S.status,this.aborted=S.aborted||!1,this.timedOut=S.timedOut||!1}}async function Xf(f,S={}){var z;f=F.fromUrl(f).url;let{visit:G=this.visit}=S,J=$({},this.options.requestHeaders,S.headers),K=(z=S.timeout)!=null?z:this.options.timeout,Y=new AbortController,{signal:Z}=Y;S=$({},S,{headers:J,signal:Z});let X,Q=!1,q=null;K&&K>0&&(q=setTimeout(()=>{Q=!0,Y.abort("timeout")},K));try{X=await this.hooks.call("fetch:request",G,{url:f,options:S},(P,{url:C,options:N})=>fetch(C,N)),q&&clearTimeout(q)}catch(P){if(Q)throw this.hooks.call("fetch:timeout",G,{url:f}),new _(`Request timed out: ${f}`,{url:f,timedOut:Q});if((P==null?void 0:P.name)==="AbortError"||Z.aborted)throw new _(`Request aborted: ${f}`,{url:f,aborted:!0});throw P}let{status:B,url:I}=X,D=await X.text();if(B===500)throw this.hooks.call("fetch:error",G,{status:B,response:X,url:I}),new _(`Server error: ${I}`,{status:B,url:I});if(!D)throw new _(`Empty response: ${I}`,{status:B,url:I});let{url:W}=F.fromUrl(I),V={url:W,html:D};return!G.cache.write||S.method&&S.method!=="GET"||f!==W||this.cache.set(V.url,V),V}class l{constructor(f){this.swup=void 0,this.pages=new Map,this.swup=f}get size(){return this.pages.size}get all(){let f=new Map;return this.pages.forEach((S,z)=>{f.set(z,$({},S))}),f}has(f){return this.pages.has(this.resolve(f))}get(f){let S=this.pages.get(this.resolve(f));return S?$({},S):S}set(f,S){S=$({},S,{url:f=this.resolve(f)}),this.pages.set(f,S),this.swup.hooks.callSync("cache:set",void 0,{page:S})}update(f,S){f=this.resolve(f);let z=$({},this.get(f),S,{url:f});this.pages.set(f,z)}delete(f){this.pages.delete(this.resolve(f))}clear(){this.pages.clear(),this.swup.hooks.callSync("cache:clear",void 0,void 0)}prune(f){this.pages.forEach((S,z)=>{f(z,S)&&this.delete(z)})}resolve(f){let{url:S}=F.fromUrl(f);return this.swup.resolveUrl(S)}}var h=(f,S=document)=>S.querySelector(f),m=(f,S=document)=>Array.from(S.querySelectorAll(f)),r=()=>new Promise((f)=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{f()})})});function i(f){return!!f&&(typeof f=="object"||typeof f=="function")&&typeof f.then=="function"}function Yf(f,S=[]){return new Promise((z,G)=>{let J=f(...S);i(J)?J.then(z,G):z(J)})}function p(f,S){let z=f==null?void 0:f.closest(`[${S}]`);return z!=null&&z.hasAttribute(S)?(z==null?void 0:z.getAttribute(S))||!0:void 0}class n{constructor(f){this.swup=void 0,this.swupClasses=["to-","is-changing","is-rendering","is-popstate","is-animating","is-leaving"],this.swup=f}get selectors(){let{scope:f}=this.swup.visit.animation;return f==="containers"?this.swup.visit.containers:f==="html"?["html"]:Array.isArray(f)?f:[]}get selector(){return this.selectors.join(",")}get targets(){return this.selector.trim()?m(this.selector):[]}add(...f){this.targets.forEach((S)=>S.classList.add(...f))}remove(...f){this.targets.forEach((S)=>S.classList.remove(...f))}clear(){this.targets.forEach((f)=>{let S=f.className.split(" ").filter((z)=>this.isSwupClass(z));f.classList.remove(...S)})}isSwupClass(f){return this.swupClasses.some((S)=>f.startsWith(S))}}class v{constructor(f,S){this.id=void 0,this.state=void 0,this.from=void 0,this.to=void 0,this.containers=void 0,this.animation=void 0,this.trigger=void 0,this.cache=void 0,this.history=void 0,this.scroll=void 0,this.meta=void 0;let{to:z,from:G,hash:J,el:K,event:Y}=S;this.id=Math.random(),this.state=1,this.from={url:G!=null?G:f.location.url,hash:f.location.hash},this.to={url:z,hash:J},this.containers=f.options.containers,this.animation={animate:!0,wait:!1,name:void 0,native:f.options.native,scope:f.options.animationScope,selector:f.options.animationSelector},this.trigger={el:K,event:Y},this.cache={read:f.options.cache,write:f.options.cache},this.history={action:"push",popstate:!1,direction:void 0},this.scroll={reset:!0,target:void 0},this.meta={}}advance(f){this.state<f&&(this.state=f)}abort(){this.state=8}get done(){return this.state>=7}}function Zf(f){return new v(this,f)}class s{constructor(f){this.swup=void 0,this.registry=new Map,this.hooks=["animation:out:start","animation:out:await","animation:out:end","animation:in:start","animation:in:await","animation:in:end","animation:skip","cache:clear","cache:set","content:replace","content:scroll","enable","disable","fetch:request","fetch:error","fetch:timeout","history:popstate","link:click","link:self","link:anchor","link:newtab","page:load","page:view","scroll:top","scroll:anchor","visit:start","visit:transition","visit:abort","visit:end"],this.swup=f,this.init()}init(){this.hooks.forEach((f)=>this.create(f))}create(f){this.registry.has(f)||this.registry.set(f,new Map)}exists(f){return this.registry.has(f)}get(f){let S=this.registry.get(f);if(S)return S;console.error(`Unknown hook '${f}'`)}clear(){this.registry.forEach((f)=>f.clear())}on(f,S,z={}){let G=this.get(f);if(!G)return console.warn(`Hook '${f}' not found.`),()=>{};let J=$({},z,{id:G.size+1,hook:f,handler:S});return G.set(S,J),()=>this.off(f,S)}before(f,S,z={}){return this.on(f,S,$({},z,{before:!0}))}replace(f,S,z={}){return this.on(f,S,$({},z,{replace:!0}))}once(f,S,z={}){return this.on(f,S,$({},z,{once:!0}))}off(f,S){let z=this.get(f);z&&S?z.delete(S)||console.warn(`Handler for hook '${f}' not found.`):z&&z.clear()}async call(f,S,z,G){let[J,K,Y]=this.parseCallArgs(f,S,z,G),{before:Z,handler:X,after:Q}=this.getHandlers(f,Y);await this.run(Z,J,K);let[q]=await this.run(X,J,K,!0);return await this.run(Q,J,K),this.dispatchDomEvent(f,J,K),q}callSync(f,S,z,G){let[J,K,Y]=this.parseCallArgs(f,S,z,G),{before:Z,handler:X,after:Q}=this.getHandlers(f,Y);this.runSync(Z,J,K);let[q]=this.runSync(X,J,K,!0);return this.runSync(Q,J,K),this.dispatchDomEvent(f,J,K),q}parseCallArgs(f,S,z,G){return S instanceof v||typeof S!="object"&&typeof z!="function"?[S,z,G]:[void 0,S,z]}async run(f,S=this.swup.visit,z,G=!1){let J=[];for(let{hook:K,handler:Y,defaultHandler:Z,once:X}of f)if(S==null||!S.done){X&&this.off(K,Y);try{let Q=await Yf(Y,[S,z,Z]);J.push(Q)}catch(Q){if(G)throw Q;console.error(`Error in hook '${K}':`,Q)}}return J}runSync(f,S=this.swup.visit,z,G=!1){let J=[];for(let{hook:K,handler:Y,defaultHandler:Z,once:X}of f)if(S==null||!S.done){X&&this.off(K,Y);try{let Q=Y(S,z,Z);J.push(Q),i(Q)&&console.warn(`Swup will not await Promises in handler for synchronous hook '${K}'.`)}catch(Q){if(G)throw Q;console.error(`Error in hook '${K}':`,Q)}}return J}getHandlers(f,S){let z=this.get(f);if(!z)return{found:!1,before:[],handler:[],after:[],replaced:!1};let G=Array.from(z.values()),J=this.sortRegistrations,K=G.filter(({before:q,replace:B})=>q&&!B).sort(J),Y=G.filter(({replace:q})=>q).filter((q)=>!0).sort(J),Z=G.filter(({before:q,replace:B})=>!q&&!B).sort(J),X=Y.length>0,Q=[];if(S&&(Q=[{id:0,hook:f,handler:S}],X)){let q=Y.length-1,{handler:B,once:I}=Y[q],D=(W)=>{let V=Y[W-1];return V?(P,C)=>V.handler(P,C,D(W-1)):S};Q=[{id:0,hook:f,once:I,handler:B,defaultHandler:D(q)}]}return{found:!0,before:K,handler:Q,after:Z,replaced:X}}sortRegistrations(f,S){var z,G;return((z=f.priority)!=null?z:0)-((G=S.priority)!=null?G:0)||f.id-S.id||0}dispatchDomEvent(f,S,z){if(S!=null&&S.done)return;let G={hook:f,args:z,visit:S||this.swup.visit};document.dispatchEvent(new CustomEvent("swup:any",{detail:G,bubbles:!0})),document.dispatchEvent(new CustomEvent(`swup:${f}`,{detail:G,bubbles:!0}))}parseName(f){let[S,...z]=f.split(".");return[S,z.reduce((G,J)=>$({},G,{[J]:!0}),{})]}}var qf=(f)=>{if(f&&f.charAt(0)==="#"&&(f=f.substring(1)),!f)return null;let S=decodeURIComponent(f),z=document.getElementById(f)||document.getElementById(S)||h(`a[name='${CSS.escape(f)}']`)||h(`a[name='${CSS.escape(S)}']`);return z||f!=="top"||(z=document.body),z},M="transition",E="animation";async function Bf({selector:f,elements:S}){if(f===!1&&!S)return;let z=[];if(S)z=Array.from(S);else if(f&&(z=m(f,document.body),!z.length))return void console.warn(`[swup] No elements found matching animationSelector \`${f}\``);let G=z.map((J)=>function(K){let{type:Y,timeout:Z,propCount:X}=function(Q){let q=window.getComputedStyle(Q),B=U(q,`${M}Delay`),I=U(q,`${M}Duration`),D=c(B,I),W=U(q,`${E}Delay`),V=U(q,`${E}Duration`),P=c(W,V),C=Math.max(D,P),N=C>0?D>P?M:E:null;return{type:N,timeout:C,propCount:N?N===M?I.length:V.length:0}}(K);return!(!Y||!Z)&&new Promise((Q)=>{let q=`${Y}end`,B=performance.now(),I=0,D=()=>{K.removeEventListener(q,W),Q()},W=(V)=>{V.target===K&&((performance.now()-B)/1000<V.elapsedTime||++I>=X&&D())};setTimeout(()=>{I<X&&D()},Z+1),K.addEventListener(q,W)})}(J));G.filter(Boolean).length>0?await Promise.all(G):f&&console.warn(`[swup] No CSS animation duration defined on elements matching \`${f}\``)}function U(f,S){return(f[S]||"").split(", ")}function c(f,S){for(;f.length<S.length;)f=f.concat(f);return Math.max(...S.map((z,G)=>a(z)+a(f[G])))}function a(f){return 1000*parseFloat(f)}function Df(f,S={},z={}){if(typeof f!="string")throw Error("swup.navigate() requires a URL parameter");if(this.shouldIgnoreVisit(f,{el:z.el,event:z.event}))return void window.location.assign(f);let{url:G,hash:J}=F.fromUrl(f),K=this.createVisit($({},z,{to:G,hash:J}));this.performNavigation(K,S)}async function If(f,S={}){if(this.navigating){if(this.visit.state>=6)return f.state=2,void(this.onVisitEnd=()=>this.performNavigation(f,S));await this.hooks.call("visit:abort",this.visit,void 0),delete this.visit.to.document,this.visit.state=8}this.navigating=!0,this.visit=f;let{el:z}=f.trigger;S.referrer=S.referrer||this.location.url,S.animate===!1&&(f.animation.animate=!1),f.animation.animate||this.classes.clear();let G=S.history||p(z,"data-swup-history");typeof G=="string"&&["push","replace"].includes(G)&&(f.history.action=G);let J=S.animation||p(z,"data-swup-animation");var K,Y;typeof J=="string"&&(f.animation.name=J),f.meta=S.meta||{},typeof S.cache=="object"?(f.cache.read=(K=S.cache.read)!=null?K:f.cache.read,f.cache.write=(Y=S.cache.write)!=null?Y:f.cache.write):S.cache!==void 0&&(f.cache={read:!!S.cache,write:!!S.cache}),delete S.cache;try{await this.hooks.call("visit:start",f,void 0),f.state=3;let Z=this.hooks.call("page:load",f,{options:S},async(Q,q)=>{let B;return Q.cache.read&&(B=this.cache.get(Q.to.url)),q.page=B||await this.fetchPage(Q.to.url,q.options),q.cache=!!B,q.page});Z.then(({html:Q})=>{f.advance(5),f.to.html=Q,f.to.document=new DOMParser().parseFromString(Q,"text/html")});let X=f.to.url+f.to.hash;if(f.history.popstate||(f.history.action==="replace"||f.to.url===this.location.url?O(X):(this.currentHistoryIndex++,Kf(X,{index:this.currentHistoryIndex}))),this.location=F.fromUrl(X),f.history.popstate&&this.classes.add("is-popstate"),f.animation.name&&this.classes.add(`to-${o(f.animation.name)}`),f.animation.wait&&await Z,f.done)return;if(await this.hooks.call("visit:transition",f,void 0,async()=>{if(!f.animation.animate)return await this.hooks.call("animation:skip",void 0),void await this.renderPage(f,await Z);f.advance(4),await this.animatePageOut(f),f.animation.native&&document.startViewTransition?await document.startViewTransition(async()=>await this.renderPage(f,await Z)).finished:await this.renderPage(f,await Z),await this.animatePageIn(f)}),f.done)return;await this.hooks.call("visit:end",f,void 0,()=>this.classes.clear()),f.state=7,this.navigating=!1,this.onVisitEnd&&(this.onVisitEnd(),this.onVisitEnd=void 0)}catch(Z){if(!Z||Z!=null&&Z.aborted)return void(f.state=8);f.state=9,console.error(Z),this.options.skipPopStateHandling=()=>(window.location.assign(f.to.url+f.to.hash),!0),window.history.back()}finally{delete f.to.document}}var Nf=async function(f){await this.hooks.call("animation:out:start",f,void 0,()=>{this.classes.add("is-changing","is-animating","is-leaving")}),await this.hooks.call("animation:out:await",f,{skip:!1},(S,{skip:z})=>{if(!z)return this.awaitAnimations({selector:S.animation.selector})}),await this.hooks.call("animation:out:end",f,void 0)},Pf=function(f){var S;let z=f.to.document;if(!z)return!1;let G=((S=z.querySelector("title"))==null?void 0:S.innerText)||"";document.title=G;let J=m('[data-swup-persist]:not([data-swup-persist=""])'),K=f.containers.map((Y)=>{let Z=document.querySelector(Y),X=z.querySelector(Y);return Z&&X?(Z.replaceWith(X.cloneNode(!0)),!0):(Z||console.warn(`[swup] Container missing in current document: ${Y}`),X||console.warn(`[swup] Container missing in incoming document: ${Y}`),!1)}).filter(Boolean);return J.forEach((Y)=>{let Z=Y.getAttribute("data-swup-persist"),X=h(`[data-swup-persist="${Z}"]`);X&&X!==Y&&X.replaceWith(Y)}),K.length===f.containers.length},Vf=function(f){let S={behavior:"auto"},{target:z,reset:G}=f.scroll,J=z!=null?z:f.to.hash,K=!1;return J&&(K=this.hooks.callSync("scroll:anchor",f,{hash:J,options:S},(Y,{hash:Z,options:X})=>{let Q=this.getAnchorElement(Z);return Q&&Q.scrollIntoView(X),!!Q})),G&&!K&&(K=this.hooks.callSync("scroll:top",f,{options:S},(Y,{options:Z})=>(window.scrollTo($({top:0,left:0},Z)),!0))),K},Wf=async function(f){if(f.done)return;let S=this.hooks.call("animation:in:await",f,{skip:!1},(z,{skip:G})=>{if(!G)return this.awaitAnimations({selector:z.animation.selector})});await r(),await this.hooks.call("animation:in:start",f,void 0,()=>{this.classes.remove("is-animating")}),await S,await this.hooks.call("animation:in:end",f,void 0)},$f=async function(f,S){if(f.done)return;f.advance(6);let{url:z}=S;this.isSameResolvedUrl(T(),z)||(O(z),this.location=F.fromUrl(z),f.to.url=this.location.url,f.to.hash=this.location.hash),await this.hooks.call("content:replace",f,{page:S},(G,{})=>{if(this.classes.remove("is-leaving"),G.animation.animate&&this.classes.add("is-rendering"),!this.replaceContent(G))throw Error("[swup] Container mismatch, aborting");G.animation.animate&&(this.classes.add("is-changing","is-animating","is-rendering"),G.animation.name&&this.classes.add(`to-${o(G.animation.name)}`))}),await this.hooks.call("content:scroll",f,void 0,()=>this.scrollToContent(f)),await this.hooks.call("page:view",f,{url:this.location.url,title:document.title})},Cf=function(f){var S;if(S=f,Boolean(S==null?void 0:S.isSwupPlugin)){if(f.swup=this,!f._checkRequirements||f._checkRequirements())return f._beforeMount&&f._beforeMount(),f.mount(),this.plugins.push(f),this.plugins}else console.error("Not a swup plugin instance",f)};function Ff(f){let S=this.findPlugin(f);if(S)return S.unmount(),S._afterUnmount&&S._afterUnmount(),this.plugins=this.plugins.filter((z)=>z!==S),this.plugins;console.error("No such plugin",S)}function Hf(f){return this.plugins.find((S)=>S===f||S.name===f||S.name===`Swup${String(f)}`)}function _f(f){if(typeof this.options.resolveUrl!="function")return console.warn("[swup] options.resolveUrl expects a callback function."),f;let S=this.options.resolveUrl(f);return S&&typeof S=="string"?S.startsWith("//")||S.startsWith("http")?(console.warn("[swup] options.resolveUrl needs to return a relative url"),f):S:(console.warn("[swup] options.resolveUrl needs to return a url"),f)}function Of(f,S){return this.resolveUrl(f)===this.resolveUrl(S)}var Tf={animateHistoryBrowsing:!1,animationSelector:'[class*="transition-"]',animationScope:"html",cache:!0,containers:["#swup"],hooks:{},ignoreVisit:(f,{el:S}={})=>!(S==null||!S.closest("[data-no-swup]")),linkSelector:"a[href]",linkToSelf:"scroll",native:!1,plugins:[],resolveUrl:(f)=>f,requestHeaders:{"X-Requested-With":"swup",Accept:"text/html, application/xhtml+xml"},skipPopStateHandling:(f)=>{var S;return((S=f.state)==null?void 0:S.source)!=="swup"},timeout:0};class u{get currentPageUrl(){return this.location.url}constructor(f={}){var S,z;this.version="4.8.3",this.options=void 0,this.defaults=Tf,this.plugins=[],this.visit=void 0,this.cache=void 0,this.hooks=void 0,this.classes=void 0,this.location=F.fromUrl(window.location.href),this.currentHistoryIndex=void 0,this.clickDelegate=void 0,this.navigating=!1,this.onVisitEnd=void 0,this.use=Cf,this.unuse=Ff,this.findPlugin=Hf,this.log=()=>{},this.navigate=Df,this.performNavigation=If,this.createVisit=Zf,this.delegateEvent=Qf,this.fetchPage=Xf,this.awaitAnimations=Bf,this.renderPage=$f,this.replaceContent=Pf,this.animatePageIn=Wf,this.animatePageOut=Nf,this.scrollToContent=Vf,this.getAnchorElement=qf,this.getCurrentUrl=T,this.resolveUrl=_f,this.isSameResolvedUrl=Of,this.options=$({},this.defaults,f),this.handleLinkClick=this.handleLinkClick.bind(this),this.handlePopState=this.handlePopState.bind(this),this.cache=new l(this),this.classes=new n(this),this.hooks=new s(this),this.visit=this.createVisit({to:""}),this.currentHistoryIndex=(S=(z=window.history.state)==null?void 0:z.index)!=null?S:1,this.enable()}async enable(){var f;let{linkSelector:S}=this.options;this.clickDelegate=this.delegateEvent(S,"click",this.handleLinkClick),window.addEventListener("popstate",this.handlePopState),this.options.animateHistoryBrowsing&&(window.history.scrollRestoration="manual"),this.options.native=this.options.native&&!!document.startViewTransition,this.options.plugins.forEach((z)=>this.use(z));for(let[z,G]of Object.entries(this.options.hooks)){let[J,K]=this.hooks.parseName(z);this.hooks.on(J,G,K)}((f=window.history.state)==null?void 0:f.source)!=="swup"&&O(null,{index:this.currentHistoryIndex}),await r(),await this.hooks.call("enable",void 0,void 0,()=>{let z=document.documentElement;z.classList.add("swup-enabled"),z.classList.toggle("swup-native",this.options.native)})}async destroy(){this.clickDelegate.destroy(),window.removeEventListener("popstate",this.handlePopState),this.cache.clear(),this.options.plugins.forEach((f)=>this.unuse(f)),await this.hooks.call("disable",void 0,void 0,()=>{let f=document.documentElement;f.classList.remove("swup-enabled"),f.classList.remove("swup-native")}),this.hooks.clear()}shouldIgnoreVisit(f,{el:S,event:z}={}){let{origin:G,url:J,hash:K}=F.fromUrl(f);return G!==window.location.origin||!(!S||!this.triggerWillOpenNewWindow(S))||!!this.options.ignoreVisit(J+K,{el:S,event:z})}handleLinkClick(f){let S=f.delegateTarget,{href:z,url:G,hash:J}=F.fromElement(S);if(this.shouldIgnoreVisit(z,{el:S,event:f}))return;if(this.navigating&&G===this.visit.to.url)return void f.preventDefault();let K=this.createVisit({to:G,hash:J,el:S,event:f});f.metaKey||f.ctrlKey||f.shiftKey||f.altKey?this.hooks.callSync("link:newtab",K,{href:z}):f.button===0&&this.hooks.callSync("link:click",K,{el:S,event:f},()=>{var Y;let Z=(Y=K.from.url)!=null?Y:"";f.preventDefault(),G&&G!==Z?this.isSameResolvedUrl(G,Z)||this.performNavigation(K):J?this.hooks.callSync("link:anchor",K,{hash:J},()=>{O(G+J),this.scrollToContent(K)}):this.hooks.callSync("link:self",K,void 0,()=>{this.options.linkToSelf==="navigate"?this.performNavigation(K):(O(G),this.scrollToContent(K))})})}handlePopState(f){var S,z,G,J;let K=(S=(z=f.state)==null?void 0:z.url)!=null?S:window.location.href;if(this.options.skipPopStateHandling(f))return;if(this.isSameResolvedUrl(T(),this.location.url))return;let{url:Y,hash:Z}=F.fromUrl(K),X=this.createVisit({to:Y,hash:Z,event:f});X.history.popstate=!0;let Q=(G=(J=f.state)==null?void 0:J.index)!=null?G:0;Q&&Q!==this.currentHistoryIndex&&(X.history.direction=Q-this.currentHistoryIndex>0?"forwards":"backwards",this.currentHistoryIndex=Q),X.animation.animate=!1,X.scroll.reset=!1,X.scroll.target=!1,this.options.animateHistoryBrowsing&&(X.animation.animate=!0,X.scroll.reset=!0),this.hooks.callSync("history:popstate",X,{event:f},()=>{this.performNavigation(X)})}triggerWillOpenNewWindow(f){return!!f.matches('[download], [target="_blank"]')}}function A(){return A=Object.assign?Object.assign.bind():function(f){for(var S=1;S<arguments.length;S++){var z=arguments[S];for(var G in z)Object.prototype.hasOwnProperty.call(z,G)&&(f[G]=z[G])}return f},A.apply(this,arguments)}var e=(f)=>String(f).split(".").map((S)=>String(parseInt(S||"0",10))).concat(["0","0"]).slice(0,3).join(".");class x{constructor(){this.isSwupPlugin=!0,this.swup=void 0,this.version=void 0,this.requires={},this.handlersToUnregister=[]}mount(){}unmount(){this.handlersToUnregister.forEach((f)=>f()),this.handlersToUnregister=[]}_beforeMount(){if(!this.name)throw Error("You must define a name of plugin when creating a class.")}_afterUnmount(){}_checkRequirements(){return typeof this.requires!="object"||Object.entries(this.requires).forEach(([f,S])=>{if(!function(z,G,J){let K=function(Y,Z){var X;if(Y==="swup")return(X=Z.version)!=null?X:"";{var Q;let q=Z.findPlugin(Y);return(Q=q==null?void 0:q.version)!=null?Q:""}}(z,J);return!!K&&((Y,Z)=>Z.every((X)=>{let[,Q,q]=X.match(/^([\D]+)?(.*)$/)||[];var B,I;return((D,W)=>{let V={"":(P)=>P===0,">":(P)=>P>0,">=":(P)=>P>=0,"<":(P)=>P<0,"<=":(P)=>P<=0};return(V[W]||V[""])(D)})((I=q,B=e(B=Y),I=e(I),B.localeCompare(I,void 0,{numeric:!0})),Q||">=")}))(K,G)}(f,S=Array.isArray(S)?S:[S],this.swup)){let z=`${f} ${S.join(", ")}`;throw Error(`Plugin version mismatch: ${this.name} requires ${z}`)}}),!0}on(f,S,z={}){var G;S=!(G=S).name.startsWith("bound ")||G.hasOwnProperty("prototype")?S.bind(this):S;let J=this.swup.hooks.on(f,S,z);return this.handlersToUnregister.push(J),J}once(f,S,z={}){return this.on(f,S,A({},z,{once:!0}))}before(f,S,z={}){return this.on(f,S,A({},z,{before:!0}))}replace(f,S,z={}){return this.on(f,S,A({},z,{replace:!0}))}off(f,S){return this.swup.hooks.off(f,S)}}function L(){return L=Object.assign?Object.assign.bind():function(f){for(var S=1;S<arguments.length;S++){var z=arguments[S];for(var G in z)({}).hasOwnProperty.call(z,G)&&(f[G]=z[G])}return f},L.apply(null,arguments)}function t(f){return f.localName!=="title"&&!f.matches("[data-swup-theme]")}function ff(f,S){return f.outerHTML===S.outerHTML}function Sf(f,S=[]){let z=Array.from(f.attributes);return S.length?z.filter(({name:G})=>S.some((J)=>J instanceof RegExp?J.test(G):G===J)):z}function Af(f){return f.matches("link[rel=stylesheet][href]")}class g extends x{constructor(f={}){var S;super(),S=this,this.name="SwupHeadPlugin",this.requires={swup:">=4.6"},this.defaults={persistTags:!1,persistAssets:!1,awaitAssets:!1,attributes:["lang","dir"],timeout:3000},this.options=void 0,this.updateHead=async function(z,{page:{}}){let{awaitAssets:G,attributes:J,timeout:K}=S.options,Y=z.to.document,{removed:Z,added:X}=function(Q,q,{shouldPersist:B=()=>!1}={}){let I=Array.from(Q.children),D=Array.from(q.children),W=(V=I,D.reduce((N,H,R)=>(V.some((j)=>ff(H,j))||N.push({el:H,index:R}),N),[]));var V;let P=function(N,H){return N.reduce((R,j)=>(H.some((zf)=>ff(j,zf))||R.push({el:j}),R),[])}(I,D);P.reverse().filter(({el:N})=>t(N)).filter(({el:N})=>!B(N)).forEach(({el:N})=>Q.removeChild(N));let C=W.filter(({el:N})=>t(N)).map((N)=>{let H=N.el.cloneNode(!0);return Q.insertBefore(H,Q.children[(N.index||0)+1]||null),L({},N,{el:H})});return{removed:P.map(({el:N})=>N),added:C.map(({el:N})=>N)}}(document.head,Y.head,{shouldPersist:(Q)=>S.isPersistentTag(Q)});if(S.swup.log(`Removed ${Z.length} / added ${X.length} tags in head`),J!=null&&J.length&&function(Q,q,B=[]){let I=new Set;for(let{name:D,value:W}of Sf(q,B))Q.setAttribute(D,W),I.add(D);for(let{name:D}of Sf(Q,B))I.has(D)||Q.removeAttribute(D)}(document.documentElement,Y.documentElement,J),G){let Q=function(q,B=0){return q.filter(Af).map((I)=>function(D,W=0){let V,P=(C)=>{D.sheet?C():V=setTimeout(()=>P(C),10)};return new Promise((C)=>{P(()=>C(D)),W>0&&setTimeout(()=>{V&&clearTimeout(V),C(D)},W)})}(I,B))}(X,K);Q.length&&(S.swup.log(`Waiting for ${Q.length} assets to load`),await Promise.all(Q))}},this.options=L({},this.defaults,f),this.options.persistAssets&&!this.options.persistTags&&(this.options.persistTags="link[rel=stylesheet], script[src], style")}mount(){this.before("content:replace",this.updateHead)}isPersistentTag(f){let{persistTags:S}=this.options;return typeof S=="function"?S(f):typeof S=="string"&&S.length>0?f.matches(S):Boolean(S)}}function b(){return b=Object.assign?Object.assign.bind():function(f){for(var S=1;S<arguments.length;S++){var z=arguments[S];for(var G in z)Object.prototype.hasOwnProperty.call(z,G)&&(f[G]=z[G])}return f},b.apply(this,arguments)}class d extends x{constructor(f={}){super(),this.name="SwupScriptsPlugin",this.requires={swup:">=4"},this.defaults={head:!0,body:!0,optin:!1},this.options=void 0,this.options=b({},this.defaults,f)}mount(){this.on("content:replace",this.runScripts)}runScripts(){let{head:f,body:S,optin:z}=this.options,G=this.getScope({head:f,body:S});if(!G)return;let J=Array.from(G.querySelectorAll(z?"script[data-swup-reload-script]":"script:not([data-swup-ignore-script])"));J.forEach((K)=>this.runScript(K)),this.swup.log(`Executed ${J.length} scripts.`)}runScript(f){let S=document.createElement("script");for(let{name:z,value:G}of f.attributes)S.setAttribute(z,G);return S.textContent=f.textContent,f.replaceWith(S),S}getScope({head:f,body:S}){return f&&S?document:f?document.head:S?document.body:null}}var xf=new u({containers:["#swup"],cache:!0,native:!0,animationSelector:!1,plugins:[new g({persistTags:!0}),new d({optin:!0})]});window.swup=xf;
@@ -1,6 +1,5 @@
1
1
  ((window, document, localStorage) => {
2
2
  const STORAGE_KEY = "themePreference";
3
- const DEFAULT_THEME = "system";
4
3
  const colorSchemeMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
5
4
 
6
5
  const THEME_MAP = {
@@ -15,168 +14,150 @@
15
14
  let currentIndex = 0;
16
15
  let previewTheme = null;
17
16
  let originalTheme = null;
18
- let isModalOpen = false;
19
- let modal = null;
20
17
  let themeOptions = [];
18
+ let shouldApply = false;
19
+ let previousFocus = null;
20
+ let popoverEl = null;
21
21
 
22
22
  function getThemePreference() {
23
23
  const stored = localStorage.getItem(STORAGE_KEY);
24
- return stored && stored in THEME_MAP ? stored : DEFAULT_THEME;
25
- }
26
-
27
- function resolveTheme(theme) {
28
- return theme === "system" ? (colorSchemeMediaQuery.matches ? "mocha" : "nord") : theme;
24
+ return stored && stored in THEME_MAP ? stored : "system";
29
25
  }
30
26
 
31
27
  function applyTheme(theme, persist = false) {
28
+ const resolved = theme === "system" ? (colorSchemeMediaQuery.matches ? "mocha" : "nord") : theme;
32
29
  const html = document.documentElement;
33
- const resolvedTheme = resolveTheme(theme);
34
- html.setAttribute("data-theme", resolvedTheme);
30
+ html.setAttribute("data-theme", resolved);
35
31
  html.classList.remove("night", "light");
36
- html.classList.add(THEME_MAP[resolvedTheme]);
37
-
38
- if (persist) {
39
- localStorage.setItem(STORAGE_KEY, theme);
40
- }
32
+ html.classList.add(THEME_MAP[resolved]);
33
+ if (persist) localStorage.setItem(STORAGE_KEY, theme);
41
34
  }
42
35
 
43
- function previewThemeOnOption(option, index) {
44
- if (index === currentIndex) {
45
- option.classList.add("is-focused");
46
- option.scrollIntoView({ block: "nearest", behavior: "smooth" });
36
+ function updateFocus() {
37
+ themeOptions.forEach((option, index) => {
38
+ const focused = index === currentIndex;
39
+ option.classList.toggle("is-focused", focused);
40
+ option.setAttribute("aria-selected", focused ? "true" : "false");
41
+ if (!focused) return;
47
42
 
43
+ option.scrollIntoView({ block: "nearest", behavior: "smooth" });
48
44
  const theme = option.getAttribute("data-theme-option");
49
45
  if (theme !== previewTheme) {
50
46
  previewTheme = theme;
51
47
  applyTheme(theme);
52
48
  }
53
- } else {
54
- option.classList.remove("is-focused");
55
- }
56
- }
57
-
58
- function updateFocus() {
59
- themeOptions.forEach(previewThemeOnOption);
49
+ });
60
50
  }
61
51
 
62
- function openModal() {
63
- modal = document.getElementById("theme-selector-modal");
64
- if (!modal || isModalOpen) return;
65
-
66
- isModalOpen = true;
52
+ function onOpen(el) {
53
+ previousFocus = document.activeElement;
67
54
  originalTheme = getThemePreference();
68
- themeOptions = modal.querySelectorAll(".theme-option");
55
+ previewTheme = null;
56
+ shouldApply = false;
57
+ themeOptions = el.querySelectorAll(".theme-option");
69
58
 
70
59
  themeOptions.forEach((option, index) => {
71
60
  const theme = option.getAttribute("data-theme-option");
72
- if (theme === originalTheme) {
73
- currentIndex = index;
74
- option.classList.add("is-active");
75
- } else {
76
- option.classList.remove("is-active");
77
- }
61
+ if (theme === originalTheme) currentIndex = index;
62
+ option.classList.toggle("is-active", theme === originalTheme);
63
+ option.setAttribute("aria-selected", theme === originalTheme ? "true" : "false");
78
64
  });
79
65
 
80
66
  updateFocus();
81
- modal.classList.add("is-active");
67
+ el.focus();
82
68
  }
83
69
 
84
- function closeModal(apply = false) {
85
- if (!modal || !isModalOpen) return;
86
-
87
- isModalOpen = false;
88
-
89
- if (apply && previewTheme) {
70
+ function onClose() {
71
+ if (shouldApply && previewTheme) {
90
72
  applyTheme(previewTheme, true);
91
73
  } else if (previewTheme && previewTheme !== originalTheme) {
92
74
  applyTheme(originalTheme);
93
75
  }
94
76
 
95
- modal.classList.remove("is-active");
96
77
  themeOptions.forEach((option) => {
97
- option.classList.remove("is-active");
98
- option.classList.remove("is-focused");
78
+ option.classList.remove("is-active", "is-focused");
79
+ option.setAttribute("aria-selected", "false");
99
80
  });
100
81
 
101
82
  previewTheme = null;
102
83
  originalTheme = null;
103
- modal = null;
104
84
  themeOptions = [];
85
+ shouldApply = false;
86
+ previousFocus?.focus();
87
+ previousFocus = null;
105
88
  }
106
89
 
107
- function handleKeyboard(event) {
108
- if (!isModalOpen) return;
109
-
110
- const maxIndex = themeOptions.length - 1;
111
-
112
- switch (event.key) {
113
- case "j":
114
- case "ArrowDown":
115
- case "Down":
116
- event.preventDefault();
117
- currentIndex = currentIndex < maxIndex ? currentIndex + 1 : 0;
118
- updateFocus();
119
- break;
120
-
121
- case "k":
122
- case "ArrowUp":
123
- case "Up":
124
- event.preventDefault();
125
- currentIndex = currentIndex > 0 ? currentIndex - 1 : maxIndex;
126
- updateFocus();
127
- break;
128
-
129
- case "Enter":
130
- event.preventDefault();
131
- closeModal(true);
132
- break;
133
-
134
- case "Escape":
135
- case "Esc":
136
- event.preventDefault();
137
- closeModal(false);
138
- break;
139
- }
90
+ function setup() {
91
+ popoverEl = document.getElementById("theme-selector-popover");
92
+ if (!popoverEl) return;
93
+
94
+ popoverEl.addEventListener("toggle", (event) => {
95
+ if (event.newState === "open") {
96
+ onOpen(popoverEl);
97
+ } else {
98
+ onClose();
99
+ }
100
+ });
101
+
102
+ popoverEl.addEventListener("click", (event) => {
103
+ if (event.target === popoverEl) popoverEl.hidePopover();
104
+ });
105
+
106
+ popoverEl.addEventListener(
107
+ "keydown",
108
+ (event) => {
109
+ const maxIndex = themeOptions.length - 1;
110
+
111
+ switch (event.key) {
112
+ case "Tab":
113
+ event.preventDefault();
114
+ currentIndex = event.shiftKey ? (currentIndex > 0 ? currentIndex - 1 : maxIndex) : currentIndex < maxIndex ? currentIndex + 1 : 0;
115
+ updateFocus();
116
+ break;
117
+
118
+ case "j":
119
+ case "ArrowDown":
120
+ case "Down":
121
+ event.preventDefault();
122
+ currentIndex = currentIndex < maxIndex ? currentIndex + 1 : 0;
123
+ updateFocus();
124
+ break;
125
+
126
+ case "k":
127
+ case "ArrowUp":
128
+ case "Up":
129
+ event.preventDefault();
130
+ currentIndex = currentIndex > 0 ? currentIndex - 1 : maxIndex;
131
+ updateFocus();
132
+ break;
133
+
134
+ case "Enter":
135
+ event.preventDefault();
136
+ shouldApply = true;
137
+ popoverEl.hidePopover();
138
+ break;
139
+ }
140
+ },
141
+ { passive: false },
142
+ );
140
143
  }
141
144
 
142
- // 监听系统主题改变
143
145
  colorSchemeMediaQuery.addEventListener("change", () => {
144
- if (getThemePreference() === "system") {
145
- applyTheme("system", true);
146
- }
146
+ if (getThemePreference() === "system") applyTheme("system", true);
147
147
  });
148
148
 
149
- // 处理 modal 点击事件(关闭背景)
150
- window.handleThemeModalClick = (event) => {
151
- if (event.target.classList.contains("theme-selector-modal")) {
152
- event.preventDefault();
153
- closeModal(false);
154
- }
155
- };
156
-
157
- // 处理主题选项点击
158
- window.selectThemeOption = (event, index) => {
159
- if (!isModalOpen) return;
160
- event.preventDefault();
161
- event.stopPropagation();
162
-
149
+ window.selectThemeOption = (index) => {
163
150
  currentIndex = index;
164
151
  updateFocus();
165
- setTimeout(() => closeModal(true), 150);
152
+ // Brief delay so the focused highlight is visible before the popover closes
153
+ setTimeout(() => {
154
+ shouldApply = true;
155
+ popoverEl.hidePopover();
156
+ }, 150);
166
157
  };
167
158
 
168
- // 暴露打开 modal 的函数
169
- window.openThemeModal = () => {
170
- openModal();
171
- };
172
-
173
- // 监听键盘事件
174
- document.addEventListener("keydown", handleKeyboard, {
175
- capture: true,
176
- passive: false,
177
- });
178
-
179
- // Export for navbar to get current theme
180
159
  window.getThemePreference = getThemePreference;
181
160
  window.applyTheme = applyTheme;
161
+
162
+ setup();
182
163
  })(window, document, window.localStorage);
Binary file
@@ -1 +0,0 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t||self).Swup=e()}(this,function(){const t=new WeakMap;function e(e,n,o,i){if(!e&&!t.has(n))return!1;const r=t.get(n)??new WeakMap;t.set(n,r);const s=r.get(o)??new Set;r.set(o,s);const a=s.has(i);return e?s.add(i):s.delete(i),a&&e}const n=(t,e)=>String(t).toLowerCase().replace(/[\s/_.]+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+|-+$/g,"")||e||"",o=function(t){let{hash:e}=void 0===t?{}:t;return window.location.pathname+window.location.search+(e?window.location.hash:"")},i=function(t,e){void 0===t&&(t=null),void 0===e&&(e={}),t=t||o({hash:!0});const n={...window.history.state||{},url:t,random:Math.random(),source:"swup",...e};window.history.replaceState(n,"",t)},r=(t,n,o,i)=>{const r=new AbortController;return function(t,n,o,i={}){const{signal:r,base:s=document}=i;if(r?.aborted)return;const{once:a,...c}=i,l=s instanceof Document?s.documentElement:s,h=Boolean("object"==typeof i?i.capture:i),u=i=>{const r=function(t,e){let n=t.target;if(n instanceof Text&&(n=n.parentElement),n instanceof Element&&t.currentTarget instanceof Element){const o=n.closest(e);if(o&&t.currentTarget.contains(o))return o}}(i,String(t));if(r){const t=Object.assign(i,{delegateTarget:r});o.call(l,t),a&&(l.removeEventListener(n,u,c),e(!1,l,o,d))}},d=JSON.stringify({selector:t,type:n,capture:h});e(!0,l,o,d)||l.addEventListener(n,u,c),r?.addEventListener("abort",()=>{e(!1,l,o,d)})}(t,n,o,i={...i,signal:r.signal}),{destroy:()=>r.abort()}};class s extends URL{constructor(t,e){void 0===e&&(e=document.baseURI),super(t.toString(),e),Object.setPrototypeOf(this,s.prototype)}get url(){return this.pathname+this.search}static fromElement(t){const e=t.getAttribute("href")||t.getAttribute("xlink:href")||"";return new s(e)}static fromUrl(t){return new s(t)}}const a=function(t,e){void 0===e&&(e={});try{const o=this;function n(n){const{status:r,url:a}=u;return Promise.resolve(u.text()).then(function(n){if(500===r)throw o.hooks.call("fetch:error",i,{status:r,response:u,url:a}),new c(`Server error: ${a}`,{status:r,url:a});if(!n)throw new c(`Empty response: ${a}`,{status:r,url:a});const{url:l}=s.fromUrl(a),h={url:l,html:n};return!i.cache.write||e.method&&"GET"!==e.method||t!==l||o.cache.set(h.url,h),h})}t=s.fromUrl(t).url;const{visit:i=o.visit}=e,r={...o.options.requestHeaders,...e.headers},a=e.timeout??o.options.timeout,l=new AbortController,{signal:h}=l;e={...e,headers:r,signal:h};let u,d=!1,f=null;a&&a>0&&(f=setTimeout(()=>{d=!0,l.abort("timeout")},a));const m=function(n,r){try{var s=Promise.resolve(o.hooks.call("fetch:request",i,{url:t,options:e},(t,e)=>{let{url:n,options:o}=e;return fetch(n,o)})).then(function(t){u=t,f&&clearTimeout(f)})}catch(t){return r(t)}return s&&s.then?s.then(void 0,r):s}(0,function(e){if(d)throw o.hooks.call("fetch:timeout",i,{url:t}),new c(`Request timed out: ${t}`,{url:t,timedOut:d});if("AbortError"===e?.name||h.aborted)throw new c(`Request aborted: ${t}`,{url:t,aborted:!0});throw e});return Promise.resolve(m&&m.then?m.then(n):n())}catch(p){return Promise.reject(p)}};class c extends Error{constructor(t,e){super(t),this.url=void 0,this.status=void 0,this.aborted=void 0,this.timedOut=void 0,this.name="FetchError",this.url=e.url,this.status=e.status,this.aborted=e.aborted||!1,this.timedOut=e.timedOut||!1}}class l{constructor(t){this.swup=void 0,this.pages=new Map,this.swup=t}get size(){return this.pages.size}get all(){const t=new Map;return this.pages.forEach((e,n)=>{t.set(n,{...e})}),t}has(t){return this.pages.has(this.resolve(t))}get(t){const e=this.pages.get(this.resolve(t));return e?{...e}:e}set(t,e){t=this.resolve(t),e={...e,url:t},this.pages.set(t,e),this.swup.hooks.callSync("cache:set",void 0,{page:e})}update(t,e){t=this.resolve(t);const n={...this.get(t),...e,url:t};this.pages.set(t,n)}delete(t){this.pages.delete(this.resolve(t))}clear(){this.pages.clear(),this.swup.hooks.callSync("cache:clear",void 0,void 0)}prune(t){this.pages.forEach((e,n)=>{t(n,e)&&this.delete(n)})}resolve(t){const{url:e}=s.fromUrl(t);return this.swup.resolveUrl(e)}}const h=function(t,e){return void 0===e&&(e=document),e.querySelector(t)},u=function(t,e){return void 0===e&&(e=document),Array.from(e.querySelectorAll(t))},d=()=>new Promise(t=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})});function f(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then}function m(t,e){const n=t?.closest(`[${e}]`);return n?.hasAttribute(e)?n?.getAttribute(e)||!0:void 0}class p{constructor(t){this.swup=void 0,this.swupClasses=["to-","is-changing","is-rendering","is-popstate","is-animating","is-leaving"],this.swup=t}get selectors(){const{scope:t}=this.swup.visit.animation;return"containers"===t?this.swup.visit.containers:"html"===t?["html"]:Array.isArray(t)?t:[]}get selector(){return this.selectors.join(",")}get targets(){return this.selector.trim()?u(this.selector):[]}add(){this.targets.forEach(t=>t.classList.add(...[].slice.call(arguments)))}remove(){this.targets.forEach(t=>t.classList.remove(...[].slice.call(arguments)))}clear(){this.targets.forEach(t=>{const e=t.className.split(" ").filter(t=>this.isSwupClass(t));t.classList.remove(...e)})}isSwupClass(t){return this.swupClasses.some(e=>t.startsWith(e))}}class v{constructor(t,e){this.id=void 0,this.state=void 0,this.from=void 0,this.to=void 0,this.containers=void 0,this.animation=void 0,this.trigger=void 0,this.cache=void 0,this.history=void 0,this.scroll=void 0,this.meta=void 0;const{to:n,from:o,hash:i,el:r,event:s}=e;this.id=Math.random(),this.state=1,this.from={url:o??t.location.url,hash:t.location.hash},this.to={url:n,hash:i},this.containers=t.options.containers,this.animation={animate:!0,wait:!1,name:void 0,native:t.options.native,scope:t.options.animationScope,selector:t.options.animationSelector},this.trigger={el:r,event:s},this.cache={read:t.options.cache,write:t.options.cache},this.history={action:"push",popstate:!1,direction:void 0},this.scroll={reset:!0,target:void 0},this.meta={}}advance(t){this.state<t&&(this.state=t)}abort(){this.state=8}get done(){return this.state>=7}}function g(t){return new v(this,t)}const w="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function y(t,e,n){if(!t.s){if(n instanceof k){if(!n.s)return void(n.o=y.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(y.bind(null,t,e),y.bind(null,t,2));t.s=e,t.v=n;const o=t.o;o&&o(t)}}const k=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,n){const o=new t,i=this.s;if(i){const t=1&i?e:n;if(t){try{y(o,1,t(this.v))}catch(t){y(o,2,t)}return o}return this}return this.o=function(t){try{const i=t.v;1&t.s?y(o,1,e?e(i):i):n?y(o,1,n(i)):y(o,2,i)}catch(t){y(o,2,t)}},o},t}();function P(t){return t instanceof k&&1&t.s}class b{constructor(t){this.swup=void 0,this.registry=new Map,this.hooks=["animation:out:start","animation:out:await","animation:out:end","animation:in:start","animation:in:await","animation:in:end","animation:skip","cache:clear","cache:set","content:replace","content:scroll","enable","disable","fetch:request","fetch:error","fetch:timeout","history:popstate","link:click","link:self","link:anchor","link:newtab","page:load","page:view","scroll:top","scroll:anchor","visit:start","visit:transition","visit:abort","visit:end"],this.swup=t,this.init()}init(){this.hooks.forEach(t=>this.create(t))}create(t){this.registry.has(t)||this.registry.set(t,new Map)}exists(t){return this.registry.has(t)}get(t){const e=this.registry.get(t);if(e)return e;console.error(`Unknown hook '${t}'`)}clear(){this.registry.forEach(t=>t.clear())}on(t,e,n){void 0===n&&(n={});const o=this.get(t);if(!o)return console.warn(`Hook '${t}' not found.`),()=>{};const i=o.size+1,r={...n,id:i,hook:t,handler:e};return o.set(e,r),()=>this.off(t,e)}before(t,e,n){return void 0===n&&(n={}),this.on(t,e,{...n,before:!0})}replace(t,e,n){return void 0===n&&(n={}),this.on(t,e,{...n,replace:!0})}once(t,e,n){return void 0===n&&(n={}),this.on(t,e,{...n,once:!0})}off(t,e){const n=this.get(t);n&&e?n.delete(e)||console.warn(`Handler for hook '${t}' not found.`):n&&n.clear()}call(t,e,n,o){try{const i=this,[r,s,a]=i.parseCallArgs(t,e,n,o),{before:c,handler:l,after:h}=i.getHandlers(t,a);return Promise.resolve(i.run(c,r,s)).then(function(){return Promise.resolve(i.run(l,r,s,!0)).then(function(e){let[n]=e;return Promise.resolve(i.run(h,r,s)).then(function(){return i.dispatchDomEvent(t,r,s),n})})})}catch(t){return Promise.reject(t)}}callSync(t,e,n,o){const[i,r,s]=this.parseCallArgs(t,e,n,o),{before:a,handler:c,after:l}=this.getHandlers(t,s);this.runSync(a,i,r);const[h]=this.runSync(c,i,r,!0);return this.runSync(l,i,r),this.dispatchDomEvent(t,i,r),h}parseCallArgs(t,e,n,o){return e instanceof v||"object"!=typeof e&&"function"!=typeof n?[e,n,o]:[void 0,e,n]}run(t,e,n,o){void 0===o&&(o=!1);try{let i;const r=this;void 0===e&&(e=r.swup.visit);const s=[],a=function(t,e,n){if("function"==typeof t[w]){var o,i,r,s=t[w]();if(function t(a){try{for(;!((o=s.next()).done||n&&n());)if((a=e(o.value))&&a.then){if(!P(a))return void a.then(t,r||(r=y.bind(null,i=new k,2)));a=a.v}i?y(i,1,a):i=a}catch(t){y(i||(i=new k),2,t)}}(),s.return){var a=function(t){try{o.done||s.return()}catch(t){}return t};if(i&&i.then)return i.then(a,function(t){throw a(t)});a()}return i}if(!("length"in t))throw new TypeError("Object is not iterable");for(var c=[],l=0;l<t.length;l++)c.push(t[l]);return function(t,e,n){var o,i,r=-1;return function s(a){try{for(;++r<t.length&&(!n||!n());)if((a=e(r))&&a.then){if(!P(a))return void a.then(s,i||(i=y.bind(null,o=new k,2)));a=a.v}o?y(o,1,a):o=a}catch(t){y(o||(o=new k),2,t)}}(),o}(c,function(t){return e(c[t])},n)}(t,function(t){let{hook:i,handler:a,defaultHandler:c,once:l}=t;if(!e?.done)return l&&r.off(i,a),function(t,o){try{var i=Promise.resolve(function(t,e){return void 0===e&&(e=[]),new Promise((n,o)=>{const i=t(...e);f(i)?i.then(n,o):n(i)})}(a,[e,n,c])).then(function(t){s.push(t)})}catch(t){return o(t)}return i&&i.then?i.then(void 0,o):i}(0,function(t){if(o)throw t;console.error(`Error in hook '${i}':`,t)})},function(){return i});return Promise.resolve(a&&a.then?a.then(function(t){return i?t:s}):i?a:s)}catch(t){return Promise.reject(t)}}runSync(t,e,n,o){void 0===e&&(e=this.swup.visit),void 0===o&&(o=!1);const i=[];for(const{hook:r,handler:s,defaultHandler:a,once:c}of t)if(!e?.done){c&&this.off(r,s);try{const t=s(e,n,a);i.push(t),f(t)&&console.warn(`Swup will not await Promises in handler for synchronous hook '${r}'.`)}catch(t){if(o)throw t;console.error(`Error in hook '${r}':`,t)}}return i}getHandlers(t,e){const n=this.get(t);if(!n)return{found:!1,before:[],handler:[],after:[],replaced:!1};const o=Array.from(n.values()),i=this.sortRegistrations,r=o.filter(t=>{let{before:e,replace:n}=t;return e&&!n}).sort(i),s=o.filter(t=>{let{replace:e}=t;return e}).filter(t=>!0).sort(i),a=o.filter(t=>{let{before:e,replace:n}=t;return!e&&!n}).sort(i),c=s.length>0;let l=[];if(e&&(l=[{id:0,hook:t,handler:e}],c)){const n=s.length-1,{handler:o,once:i}=s[n],r=t=>{const n=s[t-1];return n?(e,o)=>n.handler(e,o,r(t-1)):e};l=[{id:0,hook:t,once:i,handler:o,defaultHandler:r(n)}]}return{found:!0,before:r,handler:l,after:a,replaced:c}}sortRegistrations(t,e){return(t.priority??0)-(e.priority??0)||t.id-e.id||0}dispatchDomEvent(t,e,n){if(e?.done)return;const o={hook:t,args:n,visit:e||this.swup.visit};document.dispatchEvent(new CustomEvent("swup:any",{detail:o,bubbles:!0})),document.dispatchEvent(new CustomEvent(`swup:${t}`,{detail:o,bubbles:!0}))}parseName(t){const[e,...n]=t.split(".");return[e,n.reduce((t,e)=>({...t,[e]:!0}),{})]}}const S=t=>{if(t&&"#"===t.charAt(0)&&(t=t.substring(1)),!t)return null;const e=decodeURIComponent(t);let n=document.getElementById(t)||document.getElementById(e)||h(`a[name='${CSS.escape(t)}']`)||h(`a[name='${CSS.escape(e)}']`);return n||"top"!==t||(n=document.body),n},E=function(t){let{selector:e,elements:n}=t;try{if(!1===e&&!n)return Promise.resolve();let t=[];if(n)t=Array.from(n);else if(e&&(t=u(e,document.body),!t.length))return console.warn(`[swup] No elements found matching animationSelector \`${e}\``),Promise.resolve();const o=t.map(t=>function(t){const{type:e,timeout:n,propCount:o}=function(t){const e=window.getComputedStyle(t),n=x(e,`${C}Delay`),o=x(e,`${C}Duration`),i=$(n,o),r=x(e,`${U}Delay`),s=x(e,`${U}Duration`),a=$(r,s),c=Math.max(i,a),l=c>0?i>a?C:U:null;return{type:l,timeout:c,propCount:l?l===C?o.length:s.length:0}}(t);return!(!e||!n)&&new Promise(i=>{const r=`${e}end`,s=performance.now();let a=0;const c=()=>{t.removeEventListener(r,l),i()},l=e=>{e.target===t&&((performance.now()-s)/1e3<e.elapsedTime||++a>=o&&c())};setTimeout(()=>{a<o&&c()},n+1),t.addEventListener(r,l)})}(t));return o.filter(Boolean).length>0?Promise.resolve(Promise.all(o)).then(function(){}):(e&&console.warn(`[swup] No CSS animation duration defined on elements matching \`${e}\``),Promise.resolve())}catch(t){return Promise.reject(t)}},C="transition",U="animation";function x(t,e){return(t[e]||"").split(", ")}function $(t,e){for(;t.length<e.length;)t=t.concat(t);return Math.max(...e.map((e,n)=>A(e)+A(t[n])))}function A(t){return 1e3*parseFloat(t)}const H=function(t,e){void 0===e&&(e={});try{let a;const c=this;function r(r){if(a)return r;c.navigating=!0,c.visit=t;const{el:l}=t.trigger;e.referrer=e.referrer||c.location.url,!1===e.animate&&(t.animation.animate=!1),t.animation.animate||c.classes.clear();const h=e.history||m(l,"data-swup-history");"string"==typeof h&&["push","replace"].includes(h)&&(t.history.action=h);const u=e.animation||m(l,"data-swup-animation");return"string"==typeof u&&(t.animation.name=u),t.meta=e.meta||{},"object"==typeof e.cache?(t.cache.read=e.cache.read??t.cache.read,t.cache.write=e.cache.write??t.cache.write):void 0!==e.cache&&(t.cache={read:!!e.cache,write:!!e.cache}),delete e.cache,function(r,a){try{var l=function(r,a){try{var l=Promise.resolve(c.hooks.call("visit:start",t,void 0)).then(function(){function r(){if(!t.done)return Promise.resolve(c.hooks.call("visit:transition",t,void 0,function(){try{let n;function e(e){return n?e:(t.advance(4),Promise.resolve(c.animatePageOut(t)).then(function(){function e(){return Promise.resolve(c.animatePageIn(t)).then(function(){})}const n=function(){if(t.animation.native&&document.startViewTransition)return Promise.resolve(document.startViewTransition(function(){try{const e=c.renderPage;return Promise.resolve(a).then(function(n){return Promise.resolve(e.call(c,t,n))})}catch(t){return Promise.reject(t)}}).finished).then(function(){});{const e=c.renderPage;return Promise.resolve(a).then(function(n){return Promise.resolve(e.call(c,t,n)).then(function(){})})}}();return n&&n.then?n.then(e):e()}))}const o=function(){if(!t.animation.animate)return Promise.resolve(c.hooks.call("animation:skip",void 0)).then(function(){const e=c.renderPage;return Promise.resolve(a).then(function(o){return Promise.resolve(e.call(c,t,o)).then(function(){n=1})})})}();return Promise.resolve(o&&o.then?o.then(e):e(o))}catch(i){return Promise.reject(i)}})).then(function(){if(!t.done)return Promise.resolve(c.hooks.call("visit:end",t,void 0,()=>c.classes.clear())).then(function(){t.state=7,c.navigating=!1,c.onVisitEnd&&(c.onVisitEnd(),c.onVisitEnd=void 0)})})}t.state=3;const a=c.hooks.call("page:load",t,{options:e},function(t,e){try{function n(t){return e.page=t,e.cache=!!o,e.page}let o;return t.cache.read&&(o=c.cache.get(t.to.url)),Promise.resolve(o?n(o):Promise.resolve(c.fetchPage(t.to.url,e.options)).then(n))}catch(i){return Promise.reject(i)}});a.then(e=>{let{html:n}=e;t.advance(5),t.to.html=n,t.to.document=(new DOMParser).parseFromString(n,"text/html")});const l=t.to.url+t.to.hash;t.history.popstate||("replace"===t.history.action||t.to.url===c.location.url?i(l):(c.currentHistoryIndex++,function(t,e){void 0===e&&(e={});const n={url:t=t||o({hash:!0}),random:Math.random(),source:"swup",...e};window.history.pushState(n,"",t)}(l,{index:c.currentHistoryIndex}))),c.location=s.fromUrl(l),t.history.popstate&&c.classes.add("is-popstate"),t.animation.name&&c.classes.add(`to-${n(t.animation.name)}`);const h=function(){if(t.animation.wait)return Promise.resolve(a).then(function(){})}();return h&&h.then?h.then(r):r()})}catch(t){return a(t)}return l&&l.then?l.then(void 0,a):l}(0,function(e){e&&!e?.aborted?(t.state=9,console.error(e),c.options.skipPopStateHandling=()=>(window.location.assign(t.to.url+t.to.hash),!0),window.history.back()):t.state=8})}catch(t){return a(!0,t)}return l&&l.then?l.then(a.bind(null,!1),a.bind(null,!0)):a(!1,l)}(0,function(e,n){if(delete t.to.document,e)throw n;return n})}const l=function(){if(c.navigating)return function(){if(!(c.visit.state>=6))return Promise.resolve(c.hooks.call("visit:abort",c.visit,void 0)).then(function(){delete c.visit.to.document,c.visit.state=8});t.state=2,c.onVisitEnd=()=>c.performNavigation(t,e),a=1}()}();return Promise.resolve(l&&l.then?l.then(r):r(l))}catch(h){return Promise.reject(h)}};function T(t,e,n){if(void 0===e&&(e={}),void 0===n&&(n={}),"string"!=typeof t)throw new Error("swup.navigate() requires a URL parameter");if(this.shouldIgnoreVisit(t,{el:n.el,event:n.event}))return void window.location.assign(t);const{url:o,hash:i}=s.fromUrl(t),r=this.createVisit({...n,to:o,hash:i});this.performNavigation(r,e)}const j=function(t){try{const e=this;return Promise.resolve(e.hooks.call("animation:out:start",t,void 0,()=>{e.classes.add("is-changing","is-animating","is-leaving")})).then(function(){return Promise.resolve(e.hooks.call("animation:out:await",t,{skip:!1},(t,n)=>{let{skip:o}=n;if(!o)return e.awaitAnimations({selector:t.animation.selector})})).then(function(){return Promise.resolve(e.hooks.call("animation:out:end",t,void 0)).then(function(){})})})}catch(t){return Promise.reject(t)}},L=function(t){const e=t.to.document;if(!e)return!1;const n=e.querySelector("title")?.innerText||"";document.title=n;const o=u('[data-swup-persist]:not([data-swup-persist=""])'),i=t.containers.map(t=>{const n=document.querySelector(t),o=e.querySelector(t);return n&&o?(n.replaceWith(o.cloneNode(!0)),!0):(n||console.warn(`[swup] Container missing in current document: ${t}`),o||console.warn(`[swup] Container missing in incoming document: ${t}`),!1)}).filter(Boolean);return o.forEach(t=>{const e=t.getAttribute("data-swup-persist"),n=h(`[data-swup-persist="${e}"]`);n&&n!==t&&n.replaceWith(t)}),i.length===t.containers.length},V=function(t){const e={behavior:"auto"},{target:n,reset:o}=t.scroll,i=n??t.to.hash;let r=!1;return i&&(r=this.hooks.callSync("scroll:anchor",t,{hash:i,options:e},(t,e)=>{let{hash:n,options:o}=e;const i=this.getAnchorElement(n);return i&&i.scrollIntoView(o),!!i})),o&&!r&&(r=this.hooks.callSync("scroll:top",t,{options:e},(t,e)=>{let{options:n}=e;return window.scrollTo({top:0,left:0,...n}),!0})),r},I=function(t){try{const e=this;if(t.done)return Promise.resolve();const n=e.hooks.call("animation:in:await",t,{skip:!1},(t,n)=>{let{skip:o}=n;if(!o)return e.awaitAnimations({selector:t.animation.selector})});return Promise.resolve(d()).then(function(){return Promise.resolve(e.hooks.call("animation:in:start",t,void 0,()=>{e.classes.remove("is-animating")})).then(function(){return Promise.resolve(n).then(function(){return Promise.resolve(e.hooks.call("animation:in:end",t,void 0)).then(function(){})})})})}catch(t){return Promise.reject(t)}},q=function(t,e){try{const r=this;if(t.done)return Promise.resolve();t.advance(6);const{url:a}=e;return r.isSameResolvedUrl(o(),a)||(i(a),r.location=s.fromUrl(a),t.to.url=r.location.url,t.to.hash=r.location.hash),Promise.resolve(r.hooks.call("content:replace",t,{page:e},(t,e)=>{if(r.classes.remove("is-leaving"),t.animation.animate&&r.classes.add("is-rendering"),!r.replaceContent(t))throw new Error("[swup] Container mismatch, aborting");t.animation.animate&&(r.classes.add("is-changing","is-animating","is-rendering"),t.animation.name&&r.classes.add(`to-${n(t.animation.name)}`))})).then(function(){return Promise.resolve(r.hooks.call("content:scroll",t,void 0,()=>r.scrollToContent(t))).then(function(){return Promise.resolve(r.hooks.call("page:view",t,{url:r.location.url,title:document.title})).then(function(){})})})}catch(t){return Promise.reject(t)}},N=function(t){var e;if(e=t,Boolean(e?.isSwupPlugin)){if(t.swup=this,!t._checkRequirements||t._checkRequirements())return t._beforeMount&&t._beforeMount(),t.mount(),this.plugins.push(t),this.plugins}else console.error("Not a swup plugin instance",t)};function R(t){const e=this.findPlugin(t);if(e)return e.unmount(),e._afterUnmount&&e._afterUnmount(),this.plugins=this.plugins.filter(t=>t!==e),this.plugins;console.error("No such plugin",e)}function O(t){return this.plugins.find(e=>e===t||e.name===t||e.name===`Swup${String(t)}`)}function D(t){if("function"!=typeof this.options.resolveUrl)return console.warn("[swup] options.resolveUrl expects a callback function."),t;const e=this.options.resolveUrl(t);return e&&"string"==typeof e?e.startsWith("//")||e.startsWith("http")?(console.warn("[swup] options.resolveUrl needs to return a relative url"),t):e:(console.warn("[swup] options.resolveUrl needs to return a url"),t)}function M(t,e){return this.resolveUrl(t)===this.resolveUrl(e)}const W={animateHistoryBrowsing:!1,animationSelector:'[class*="transition-"]',animationScope:"html",cache:!0,containers:["#swup"],hooks:{},ignoreVisit:function(t,e){let{el:n}=void 0===e?{}:e;return!!n?.closest("[data-no-swup]")},linkSelector:"a[href]",linkToSelf:"scroll",native:!1,plugins:[],resolveUrl:t=>t,requestHeaders:{"X-Requested-With":"swup",Accept:"text/html, application/xhtml+xml"},skipPopStateHandling:t=>"swup"!==t.state?.source,timeout:0};return class{get currentPageUrl(){return this.location.url}constructor(t){void 0===t&&(t={}),this.version="4.8.2",this.options=void 0,this.defaults=W,this.plugins=[],this.visit=void 0,this.cache=void 0,this.hooks=void 0,this.classes=void 0,this.location=s.fromUrl(window.location.href),this.currentHistoryIndex=void 0,this.clickDelegate=void 0,this.navigating=!1,this.onVisitEnd=void 0,this.use=N,this.unuse=R,this.findPlugin=O,this.log=()=>{},this.navigate=T,this.performNavigation=H,this.createVisit=g,this.delegateEvent=r,this.fetchPage=a,this.awaitAnimations=E,this.renderPage=q,this.replaceContent=L,this.animatePageIn=I,this.animatePageOut=j,this.scrollToContent=V,this.getAnchorElement=S,this.getCurrentUrl=o,this.resolveUrl=D,this.isSameResolvedUrl=M,this.options={...this.defaults,...t},this.handleLinkClick=this.handleLinkClick.bind(this),this.handlePopState=this.handlePopState.bind(this),this.cache=new l(this),this.classes=new p(this),this.hooks=new b(this),this.visit=this.createVisit({to:""}),this.currentHistoryIndex=window.history.state?.index??1,this.enable()}enable(){try{const t=this,{linkSelector:e}=t.options;t.clickDelegate=t.delegateEvent(e,"click",t.handleLinkClick),window.addEventListener("popstate",t.handlePopState),t.options.animateHistoryBrowsing&&(window.history.scrollRestoration="manual"),t.options.native=t.options.native&&!!document.startViewTransition,t.options.plugins.forEach(e=>t.use(e));for(const[e,n]of Object.entries(t.options.hooks)){const[o,i]=t.hooks.parseName(e);t.hooks.on(o,n,i)}return"swup"!==window.history.state?.source&&i(null,{index:t.currentHistoryIndex}),Promise.resolve(d()).then(function(){return Promise.resolve(t.hooks.call("enable",void 0,void 0,()=>{const e=document.documentElement;e.classList.add("swup-enabled"),e.classList.toggle("swup-native",t.options.native)})).then(function(){})})}catch(t){return Promise.reject(t)}}destroy(){try{const t=this;return t.clickDelegate.destroy(),window.removeEventListener("popstate",t.handlePopState),t.cache.clear(),t.options.plugins.forEach(e=>t.unuse(e)),Promise.resolve(t.hooks.call("disable",void 0,void 0,()=>{const t=document.documentElement;t.classList.remove("swup-enabled"),t.classList.remove("swup-native")})).then(function(){t.hooks.clear()})}catch(t){return Promise.reject(t)}}shouldIgnoreVisit(t,e){let{el:n,event:o}=void 0===e?{}:e;const{origin:i,url:r,hash:a}=s.fromUrl(t);return i!==window.location.origin||!(!n||!this.triggerWillOpenNewWindow(n))||!!this.options.ignoreVisit(r+a,{el:n,event:o})}handleLinkClick(t){const e=t.delegateTarget,{href:n,url:o,hash:r}=s.fromElement(e);if(this.shouldIgnoreVisit(n,{el:e,event:t}))return;if(this.navigating&&o===this.visit.to.url)return void t.preventDefault();const a=this.createVisit({to:o,hash:r,el:e,event:t});t.metaKey||t.ctrlKey||t.shiftKey||t.altKey?this.hooks.callSync("link:newtab",a,{href:n}):0===t.button&&this.hooks.callSync("link:click",a,{el:e,event:t},()=>{const e=a.from.url??"";t.preventDefault(),o&&o!==e?this.isSameResolvedUrl(o,e)||this.performNavigation(a):r?this.hooks.callSync("link:anchor",a,{hash:r},()=>{i(o+r),this.scrollToContent(a)}):this.hooks.callSync("link:self",a,void 0,()=>{"navigate"===this.options.linkToSelf?this.performNavigation(a):(i(o),this.scrollToContent(a))})})}handlePopState(t){const e=t.state?.url??window.location.href;if(this.options.skipPopStateHandling(t))return;if(this.isSameResolvedUrl(o(),this.location.url))return;const{url:n,hash:i}=s.fromUrl(e),r=this.createVisit({to:n,hash:i,event:t});r.history.popstate=!0;const a=t.state?.index??0;a&&a!==this.currentHistoryIndex&&(r.history.direction=a-this.currentHistoryIndex>0?"forwards":"backwards",this.currentHistoryIndex=a),r.animation.animate=!1,r.scroll.reset=!1,r.scroll.target=!1,this.options.animateHistoryBrowsing&&(r.animation.animate=!0,r.scroll.reset=!0),this.hooks.callSync("history:popstate",r,{event:t},()=>{this.performNavigation(r)})}triggerWillOpenNewWindow(t){return!!t.matches('[download], [target="_blank"]')}}});
@@ -1 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).SwupHeadPlugin=t()}(this,function(){function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},e.apply(this,arguments)}const t=e=>String(e).split(".").map(e=>String(parseInt(e||"0",10))).concat(["0","0"]).slice(0,3).join(".");class n{constructor(){this.isSwupPlugin=!0,this.swup=void 0,this.version=void 0,this.requires={},this.handlersToUnregister=[]}mount(){}unmount(){this.handlersToUnregister.forEach(e=>e()),this.handlersToUnregister=[]}_beforeMount(){if(!this.name)throw new Error("You must define a name of plugin when creating a class.")}_afterUnmount(){}_checkRequirements(){return"object"!=typeof this.requires||Object.entries(this.requires).forEach(([e,n])=>{if(!function(e,n,r){const s=function(e,t){var n;if("swup"===e)return null!=(n=t.version)?n:"";{var r;const n=t.findPlugin(e);return null!=(r=null==n?void 0:n.version)?r:""}}(e,r);return!!s&&((e,n)=>n.every(n=>{const[,r,s]=n.match(/^([\D]+)?(.*)$/)||[];var o,i;return((e,t)=>{const n={"":e=>0===e,">":e=>e>0,">=":e=>e>=0,"<":e=>e<0,"<=":e=>e<=0};return(n[t]||n[""])(e)})((i=s,o=t(o=e),i=t(i),o.localeCompare(i,void 0,{numeric:!0})),r||">=")}))(s,n)}(e,n=Array.isArray(n)?n:[n],this.swup)){const t=`${e} ${n.join(", ")}`;throw new Error(`Plugin version mismatch: ${this.name} requires ${t}`)}}),!0}on(e,t,n={}){var r;t=!(r=t).name.startsWith("bound ")||r.hasOwnProperty("prototype")?t.bind(this):t;const s=this.swup.hooks.on(e,t,n);return this.handlersToUnregister.push(s),s}once(t,n,r={}){return this.on(t,n,e({},r,{once:!0}))}before(t,n,r={}){return this.on(t,n,e({},r,{before:!0}))}replace(t,n,r={}){return this.on(t,n,e({},r,{replace:!0}))}off(e,t){return this.swup.hooks.off(e,t)}}function r(e){return"title"!==e.localName&&!e.matches("[data-swup-theme]")}function s(e,t){return e.outerHTML===t.outerHTML}function o(e,t){void 0===t&&(t=[]);const n=Array.from(e.attributes);return t.length?n.filter(e=>{let{name:n}=e;return t.some(e=>e instanceof RegExp?e.test(n):n===e)}):n}function i(e){return e.matches("link[rel=stylesheet][href]")}return class extends n{constructor(e){void 0===e&&(e={}),super();const t=this;this.name="SwupHeadPlugin",this.requires={swup:">=4.6"},this.defaults={persistTags:!1,persistAssets:!1,awaitAssets:!1,attributes:["lang","dir"],timeout:3e3},this.options=void 0,this.updateHead=function(e,n){try{const{awaitAssets:n,attributes:u,timeout:a}=t.options,l=e.to.document,{removed:c,added:h}=function(e,t,n){let{shouldPersist:o=()=>!1}=void 0===n?{}:n;const i=Array.from(e.children),u=Array.from(t.children),a=(l=i,u.reduce((e,t,n)=>(l.some(e=>s(t,e))||e.push({el:t,index:n}),e),[]));var l;const c=function(e,t){return e.reduce((e,n)=>(t.some(e=>s(n,e))||e.push({el:n}),e),[])}(i,u);c.reverse().filter(e=>{let{el:t}=e;return r(t)}).filter(e=>{let{el:t}=e;return!o(t)}).forEach(t=>{let{el:n}=t;return e.removeChild(n)});const h=a.filter(e=>{let{el:t}=e;return r(t)}).map(t=>{let n=t.el.cloneNode(!0);return e.insertBefore(n,e.children[(t.index||0)+1]||null),{...t,el:n}});return{removed:c.map(e=>{let{el:t}=e;return t}),added:h.map(e=>{let{el:t}=e;return t})}}(document.head,l.head,{shouldPersist:e=>t.isPersistentTag(e)});t.swup.log(`Removed ${c.length} / added ${h.length} tags in head`),u?.length&&function(e,t,n){void 0===n&&(n=[]);const r=new Set;for(const{name:s,value:i}of o(t,n))e.setAttribute(s,i),r.add(s);for(const{name:t}of o(e,n))r.has(t)||e.removeAttribute(t)}(document.documentElement,l.documentElement,u);const d=function(){if(n){const n=(void 0===(e=a)&&(e=0),h.filter(i).map(t=>function(e,t){let n;void 0===t&&(t=0);const r=t=>{e.sheet?t():n=setTimeout(()=>r(t),10)};return new Promise(s=>{r(()=>s(e)),t>0&&setTimeout(()=>{n&&clearTimeout(n),s(e)},t)})}(t,e))),r=function(){if(n.length)return t.swup.log(`Waiting for ${n.length} assets to load`),Promise.resolve(Promise.all(n)).then(function(){})}();if(r&&r.then)return r.then(function(){})}var e}();return Promise.resolve(d&&d.then?d.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},this.options={...this.defaults,...e},this.options.persistAssets&&!this.options.persistTags&&(this.options.persistTags="link[rel=stylesheet], script[src], style")}mount(){this.before("content:replace",this.updateHead)}isPersistentTag(e){const{persistTags:t}=this.options;return"function"==typeof t?t(e):"string"==typeof t&&t.length>0?e.matches(t):Boolean(t)}}});
@@ -1,2 +0,0 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t||self).SwupScriptsPlugin=e()}(this,function(){function t(){return t=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},t.apply(this,arguments)}const e=t=>String(t).split(".").map(t=>String(parseInt(t||"0",10))).concat(["0","0"]).slice(0,3).join(".");class n{constructor(){this.isSwupPlugin=!0,this.swup=void 0,this.version=void 0,this.requires={},this.handlersToUnregister=[]}mount(){}unmount(){this.handlersToUnregister.forEach(t=>t()),this.handlersToUnregister=[]}_beforeMount(){if(!this.name)throw new Error("You must define a name of plugin when creating a class.")}_afterUnmount(){}_checkRequirements(){return"object"!=typeof this.requires||Object.entries(this.requires).forEach(([t,n])=>{if(!function(t,n,r){const o=function(t,e){var n;if("swup"===t)return null!=(n=e.version)?n:"";{var r;const n=e.findPlugin(t);return null!=(r=null==n?void 0:n.version)?r:""}}(t,r);return!!o&&((t,n)=>n.every(n=>{const[,r,o]=n.match(/^([\D]+)?(.*)$/)||[];var s,i;return((t,e)=>{const n={"":t=>0===t,">":t=>t>0,">=":t=>t>=0,"<":t=>t<0,"<=":t=>t<=0};return(n[e]||n[""])(t)})((i=o,s=e(s=t),i=e(i),s.localeCompare(i,void 0,{numeric:!0})),r||">=")}))(o,n)}(t,n=Array.isArray(n)?n:[n],this.swup)){const e=`${t} ${n.join(", ")}`;throw new Error(`Plugin version mismatch: ${this.name} requires ${e}`)}}),!0}on(t,e,n={}){var r;e=!(r=e).name.startsWith("bound ")||r.hasOwnProperty("prototype")?e.bind(this):e;const o=this.swup.hooks.on(t,e,n);return this.handlersToUnregister.push(o),o}once(e,n,r={}){return this.on(e,n,t({},r,{once:!0}))}before(e,n,r={}){return this.on(e,n,t({},r,{before:!0}))}replace(e,n,r={}){return this.on(e,n,t({},r,{replace:!0}))}off(t,e){return this.swup.hooks.off(t,e)}}return class extends n{constructor(t){void 0===t&&(t={}),super(),this.name="SwupScriptsPlugin",this.requires={swup:">=4"},this.defaults={head:!0,body:!0,optin:!1},this.options=void 0,this.options={...this.defaults,...t}}mount(){this.on("content:replace",this.runScripts)}runScripts(){const{head:t,body:e,optin:n}=this.options,r=this.getScope({head:t,body:e});if(!r)return;const o=Array.from(r.querySelectorAll(n?"script[data-swup-reload-script]":"script:not([data-swup-ignore-script])"));o.forEach(t=>this.runScript(t)),this.swup.log(`Executed ${o.length} scripts.`)}runScript(t){const e=document.createElement("script");for(const{name:n,value:r}of t.attributes)e.setAttribute(n,r);return e.textContent=t.textContent,t.replaceWith(e),e}getScope(t){let{head:e,body:n}=t;return e&&n?document:e?document.head:n?document.body:null}}});
2
- //# sourceMappingURL=index.umd.js.map
@@ -1,158 +0,0 @@
1
- // Constants and Configuration
2
- const SELECTORS = {
3
- figureHighlight: "figure.shiki",
4
- preCode: "pre code",
5
- preShiki: "pre.shiki",
6
- expandBtn: ".code-expand-btn",
7
- };
8
-
9
- const CLASSES = {
10
- copyTrue: "copy-true",
11
- closed: "closed",
12
- wrapActive: "wrap-active",
13
- expandDone: "expand-done",
14
- };
15
-
16
- showAlert = (element, text, duration = 800) => {
17
- element.textContent = text;
18
- element.style.opacity = 1;
19
- element.style.visibility = "visible";
20
- setTimeout(() => {
21
- element.style.opacity = 0;
22
- element.style.visibility = "hidden";
23
- }, duration);
24
- };
25
-
26
- // Feature Handlers
27
- const FeatureHandlers = {
28
- async copy(parentElement, clickElement) {
29
- const buttonParent = parentElement.parentNode;
30
- buttonParent.classList.add(CLASSES.copyTrue);
31
-
32
- const codeElement = buttonParent.querySelector(SELECTORS.preCode);
33
- await navigator.clipboard.writeText(codeElement.innerText);
34
- showAlert(clickElement.previousElementSibling, "Copied");
35
-
36
- buttonParent.classList.remove(CLASSES.copyTrue);
37
- },
38
-
39
- toggleWrap(element) {
40
- const code = element.closest(SELECTORS.figureHighlight).querySelector("code");
41
-
42
- function setWrap(enabled) {
43
- Object.assign(code.style, {
44
- whiteSpace: enabled ? "pre-wrap" : "pre",
45
- wordBreak: enabled ? "break-all" : "normal",
46
- overflowWrap: enabled ? "anywhere" : "normal",
47
- });
48
-
49
- element.classList.toggle(CLASSES.wrapActive, enabled);
50
- }
51
- setWrap(code.style.whiteSpace !== "pre-wrap");
52
- },
53
-
54
- expandCode(figure) {
55
- const expandBtn = figure.querySelector(SELECTORS.expandBtn);
56
- const pre = figure.querySelector(SELECTORS.preShiki);
57
- const isExpanded = figure.classList.contains("expanded");
58
- const showLines = parseInt(figure.dataset.maxLines || "10", 10);
59
-
60
- if (isExpanded) {
61
- const computedStyle = getComputedStyle(pre);
62
- const lineHeight = parseFloat(computedStyle.lineHeight) || 20;
63
- const paddingTop = parseFloat(computedStyle.paddingTop) || 0;
64
- const paddingBottom = parseFloat(computedStyle.paddingBottom) || 0;
65
- const targetHeight = showLines * lineHeight + paddingTop + paddingBottom;
66
-
67
- figure.classList.remove("expanded");
68
- pre.style.maxHeight = `${targetHeight}px`;
69
- expandBtn.classList.remove(CLASSES.expandDone);
70
- } else {
71
- const fullHeight = pre.scrollHeight;
72
-
73
- figure.classList.add("expanded");
74
- pre.style.maxHeight = `${fullHeight}px`;
75
- expandBtn.classList.add(CLASSES.expandDone);
76
-
77
- setTimeout(() => {
78
- pre.style.maxHeight = "none";
79
- }, 300);
80
- }
81
- },
82
- };
83
-
84
- function handleToolbarClick(event) {
85
- const target = event.target;
86
- const classList = target.classList;
87
-
88
- const handlers = {
89
- expand: () => FeatureHandlers.expandCode(this),
90
- "copy-button": () => FeatureHandlers.copy(this, target),
91
- "toggle-wrap": () => FeatureHandlers.toggleWrap(this),
92
- };
93
-
94
- for (const [className, handler] of Object.entries(handlers)) {
95
- if (classList.contains(className)) {
96
- handler();
97
- break;
98
- }
99
- }
100
- }
101
-
102
- // Code expand button event handler
103
- function handleExpandBtnClick(event) {
104
- event.preventDefault();
105
- event.stopPropagation();
106
-
107
- const expandBtn = event.currentTarget;
108
- const figure = expandBtn.closest(SELECTORS.figureHighlight);
109
-
110
- if (figure) {
111
- FeatureHandlers.expandCode(figure);
112
- }
113
- }
114
-
115
- // Main initialization function
116
- function addHighlightTool() {
117
- const figures = document.querySelectorAll(SELECTORS.figureHighlight);
118
- if (!figures.length) return;
119
-
120
- figures.forEach((figure) => {
121
- if (figure.hasAttribute("data-shiki-initialized")) return;
122
- figure.setAttribute("data-shiki-initialized", "true");
123
-
124
- // Add event listener to existing shiki-tools
125
- const toolbar = figure.querySelector(".shiki-tools");
126
- if (toolbar) {
127
- toolbar.addEventListener("click", handleToolbarClick);
128
- }
129
-
130
- // Add event listener to code expand button
131
- const expandBtn = figure.querySelector(SELECTORS.expandBtn);
132
- if (expandBtn) {
133
- expandBtn.addEventListener("click", handleExpandBtnClick);
134
- }
135
-
136
- // Initialize collapsed state for collapsible code blocks
137
- if (figure.dataset.collapsible === "true") {
138
- const pre = figure.querySelector(SELECTORS.preShiki);
139
- const showLines = parseInt(figure.dataset.maxLines || "10", 10);
140
-
141
- if (pre) {
142
- // 确保元素已经渲染完成后再设置高度
143
- requestAnimationFrame(() => {
144
- const lineHeight = parseFloat(getComputedStyle(pre).lineHeight) || 20;
145
- const maxHeight = showLines * lineHeight;
146
- pre.style.maxHeight = `${maxHeight}px`;
147
- pre.style.overflow = "hidden";
148
- });
149
- }
150
- }
151
- });
152
- } // Event listeners
153
-
154
- if (document.readyState === "loading") {
155
- document.addEventListener("DOMContentLoaded", addHighlightTool);
156
- } else {
157
- addHighlightTool();
158
- }