DeepLearning_2026 / lecture-01 /assets /slidev /VClicks-CApbHuZe.js
vlbthambawita's picture
Release lecture-01-v1.3
5ad7801 verified
Raw
History Blame Contribute Delete
2.16 kB
import{B as e,C as t,G as n,O as r,R as i,T as a,j as o,m as s,p as c,tt as l,v as u,z as d}from"../modules/shiki-CJZsCeMT.js";import{G as f,it as p}from"../useNav-By_bInSV.js";import{n as m}from"./context-C6dxaFaS.js";import{u as h}from"../index-n1yr0O7U.js";var g=a({__name:`VClickGap`,props:{size:{type:[String,Number],default:1}},setup(t){let n=t,{$clicksContext:r}=m(),a=h(),o=+n.size;return Number.isNaN(o)&&(console.warn(`[slidev] Invalid size for VClickGap: ${n.size}`),o=1),i(()=>{let e=r.currentOffset+o-1;r.register(a,{max:e,delta:o})}),d(()=>{r.unregister(a)}),(t,n)=>(e(),u(s))}}),_=[`ul`,`ol`],v=/[\s,]+/,y=a({props:{depth:{type:[Number,String],default:1},every:{type:[Number,String],default:1},at:{type:[Number,String],default:`+1`},hide:{type:Boolean,default:!1},fade:{type:Boolean,default:!1},animation:{type:[String,Array],default:void 0},handleSpecialElements:{type:Boolean,default:!0}},render(){let e=+this.every,i=f(this.at),a=typeof i==`string`,s=this.$slots.default?.();if(i==null||!s)return s;let u=n(`click`),d=(e,t)=>{let n={hide:this.hide};return typeof this.animation==`string`?this.animation.split(v).forEach(e=>{e&&(n[e]=!0)}):Array.isArray(this.animation)&&this.animation.forEach(e=>n[e]=!0),this.fade&&(n.fade=!0),l(e,[[u,t,``,n]])},m=e=>e.flatMap(e=>o(e)&&typeof e.type==`symbol`&&Array.isArray(e.children)?m(e.children):[e]);s=m(p(s));let h=(e,t=1)=>m(e).map(e=>{if(!o(e))return e;if(_.includes(e.type)&&Array.isArray(e.children)){let n=x(e.children,t+1);return r(e,{},n)}return r(e)}),y=1,b=0,x=(t,n=1)=>m(t).map(t=>{if(!o(t)||t.type===c)return t;let s=+i+Math.ceil(y++/e)-1,l;l=n<+this.depth&&Array.isArray(t.children)?r(t,{},h(t.children,n)):r(t);let u=s-b;return b=s,d(l,a?u>=0?`+${u}`:`${u}`:s)}),S=()=>t(g,{size:+i+Math.ceil((y-1)/e)-1-b});if(this.handleSpecialElements){if(s.length===1&&_.includes(s[0].type)&&Array.isArray(s[0].children))return r(s[0],{},[...x(s[0].children),S()]);if(s.length===1&&s[0].type===`table`){let e=s[0];if(Array.isArray(e.children))return r(e,{},e.children.map(e=>o(e)?e.type===`tbody`&&Array.isArray(e.children)?r(e,{},[...x(e.children),S()]):r(e):e))}}return[...x(s),S()]}});export{y as t};