@banou/ftube 0.0.0-stage → 0.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 (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +44 -2
  3. package/__yt_engine__/engine.html +9 -0
  4. package/app.webmanifest +31 -0
  5. package/assets/account-BL8Hv7lS.js +157 -0
  6. package/assets/account-By94iboj.js +1 -0
  7. package/assets/account-DfiXzypA-YE6OyKjK.js +1 -0
  8. package/assets/account-generation-BP_-Qyck-BOth6YQ_.js +1 -0
  9. package/assets/agent-source-E4g0cDzU.js +1 -0
  10. package/assets/api-1NDCtwel-CAaxX8P1.js +3 -0
  11. package/assets/binary-encoding-By5K7InN.js +1 -0
  12. package/assets/build-CNn3bm6X.js +1 -0
  13. package/assets/busy-C1JPjoZ_-CJ0641jK.js +1 -0
  14. package/assets/cards-Csel8naI.js +2334 -0
  15. package/assets/channel-B5f9YTIf.js +1160 -0
  16. package/assets/client-version-D9kIz6Gz.js +1 -0
  17. package/assets/comments-CJp9O808.js +612 -0
  18. package/assets/dislikes-DH5jCVEY.js +1 -0
  19. package/assets/dist-7VpLCl1k.js +1 -0
  20. package/assets/dist-BOrL1gYg.js +2 -0
  21. package/assets/downloads-CMXDjA_E.js +191 -0
  22. package/assets/egress.worker-DopXr5uP.js +104 -0
  23. package/assets/engine-B_kFyW7L.js +2 -0
  24. package/assets/feed-channels-Dg2mvF5x.js +251 -0
  25. package/assets/feed-groups-CnyR4sOO.js +160 -0
  26. package/assets/feed-history-BDAGG9N5.js +368 -0
  27. package/assets/feed-playlists-DcGR2AL6.js +167 -0
  28. package/assets/feed-subscriptions-Sm3tKz4P.js +165 -0
  29. package/assets/feed-you-lxbqknXX.js +110 -0
  30. package/assets/formats-CDwXfKnr.js +1 -0
  31. package/assets/frame-BrGNSf3s.js +2 -0
  32. package/assets/fs-CjRTQ7Nu.js +1 -0
  33. package/assets/fs-CwRtKje1-CBsYhX2-.js +1 -0
  34. package/assets/fullscreen-view-BLgosU84.js +269 -0
  35. package/assets/group-C00s0aT7.js +183 -0
  36. package/assets/groups-button-CvVnqwlu.js +25 -0
  37. package/assets/hashtag-CCIhITaL.js +115 -0
  38. package/assets/icons-DKsqNLSs.js +1 -0
  39. package/assets/index-A5dHbptn.css +1 -0
  40. package/assets/index-DwsYJ-bu.js +1328 -0
  41. package/assets/lib-h0P14ZFl.js +70 -0
  42. package/assets/linkify-B6hdFhsL.js +1 -0
  43. package/assets/packages-C3w3tSjj-BCtDk0vj.js +1 -0
  44. package/assets/party-CUcxsJDF.js +180 -0
  45. package/assets/playlist-DF7wsidw.js +521 -0
  46. package/assets/playlist-card-Btoc7D8f.js +91 -0
  47. package/assets/playlist-panel-D97BwT1f.js +199 -0
  48. package/assets/post-CQ9mfVos.js +39 -0
  49. package/assets/post-card-ZUQixO1G.js +76 -0
  50. package/assets/privacy-hkbqXFeB.js +46 -0
  51. package/assets/protobuf-BXZ2dCCc.js +1 -0
  52. package/assets/read-more-BhddUSlS.js +20 -0
  53. package/assets/rich-text-07paR5O3.js +25 -0
  54. package/assets/roboto-cyrillic-ext-BCp_3N7R.woff2 +0 -0
  55. package/assets/roboto-cyrillic-fOt7epNf.woff2 +0 -0
  56. package/assets/roboto-greek-DlT9XTxE.woff2 +0 -0
  57. package/assets/roboto-greek-ext-Bgw4czJT.woff2 +0 -0
  58. package/assets/roboto-latin-ccAYIvAh.woff2 +0 -0
  59. package/assets/roboto-latin-ext-DYIxWhlt.woff2 +0 -0
  60. package/assets/roboto-math-4a3xuzGk.woff2 +0 -0
  61. package/assets/roboto-symbols-B7iHSfaG.woff2 +0 -0
  62. package/assets/roboto-vietnamese-_f1XEJpo.woff2 +0 -0
  63. package/assets/rooms-B-AvBY-c-FNDqRDHE.js +1 -0
  64. package/assets/rooms-B91zuirR.js +1 -0
  65. package/assets/save-menu-DF1WKqSE.js +462 -0
  66. package/assets/search-Cx5IpDtZ.js +1026 -0
  67. package/assets/settings-kESE_uBm.js +99 -0
  68. package/assets/shaka-BwT9pJcV.js +36 -0
  69. package/assets/share-dialog-Cp0BJ6bg.js +156 -0
  70. package/assets/shorts-BxDB7m0c.js +686 -0
  71. package/assets/shorts-grid-Bgbkl5dP.js +11 -0
  72. package/assets/sign-in-Bx3zmj-m.js +97 -0
  73. package/assets/signed-out-prompt-CEAx65kq.js +79 -0
  74. package/assets/signin-DkI8Ogzz.js +18 -0
  75. package/assets/social-bXt3vmd4.js +1 -0
  76. package/assets/video-card-compact-r-K4XyDb.js +190 -0
  77. package/assets/watch-CkxSP1IA.js +1802 -0
  78. package/assets/web-BNanCsH5.js +43 -0
  79. package/favicon.ico +0 -0
  80. package/favicon.svg +5 -0
  81. package/icons/icon-192.png +0 -0
  82. package/icons/icon-512.png +0 -0
  83. package/index-Bj-Q3X8Q.js +4120 -0
  84. package/index.html +32 -0
  85. package/package.json +45 -4
  86. package/store/background.webp +0 -0
  87. package/store/channel.webp +0 -0
  88. package/store/cover.webp +0 -0
  89. package/store/phone.webp +0 -0
  90. package/store/search.webp +0 -0
  91. package/store/watch.webp +0 -0
@@ -0,0 +1,368 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-BNanCsH5.js","assets/dist-BOrL1gYg.js","assets/binary-encoding-By5K7InN.js"])))=>i.map(i=>d[i]);
2
+ import{D as e}from"./build-CNn3bm6X.js";import{E as t,bt as n,ct as r,d as i,in as a,n as o,on as s,sn as c}from"./icons-DKsqNLSs.js";import{O as l,a as u,c as d,d as f,g as p,h as m,k as ee,o as h,ot as g,s as _,t as te,y as v}from"./sign-in-Bx3zmj-m.js";import{A as ne,G as y,Y as b,Z as x,j as re,ln as S}from"./cards-Csel8naI.js";import{A as C,L as w,P as T,R as E,n as D}from"../index-Bj-Q3X8Q.js";import{h as O,t as k,y as A}from"./client-version-D9kIz6Gz.js";import{n as j,t as ie}from"./video-card-compact-r-K4XyDb.js";import{t as M}from"./signed-out-prompt-CEAx65kq.js";c();var N=`yt-client-history`,P=`imports`,F=`browser`,I=e=>new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)}),ae=e=>{let t=indexedDB.open(N,1);return t.onupgradeneeded=()=>{e?t.result.createObjectStore(P):t.transaction?.abort()},I(t)},L=async(e,t)=>{let n=await ae(e===`readwrite`);try{let r=n.transaction(P,e),i=new Promise((e,t)=>{r.oncomplete=()=>e(),r.onerror=()=>t(r.error),r.onabort=()=>t(r.error)}),[a]=await Promise.all([I(t(r.objectStore(P))),i]);return a}finally{n.close()}},oe=async()=>{let e=await L(`readonly`,e=>e.get(F)).catch(e=>{if(!(e instanceof DOMException&&e.name===`AbortError`))throw e});return Array.isArray(e?.entries)?e:void 0},R=async e=>{await L(`readwrite`,t=>t.put(e,F))},z=()=>I(indexedDB.deleteDatabase(N)).then(()=>{}),B=`www.youtube.com`,V=`https://${B}`,H=`Import your watch history from YouTube on this browser`,U=`Show the history you imported for the YouTube account on this browser`,W=class extends Error{},G=class extends W{constructor(){super(`This browser is not signed in to YouTube`)}},K=e=>e instanceof W?e.message:e instanceof Error&&e.name===`ExtensionOutdatedError`?`Update the FKN extension to import your history`:`Could not import your history, try again`,q=(e=navigator)=>e.userAgentData?.brands?.some(({brand:e})=>e===`Chromium`)===!0,J=async(e,t)=>{let[n]=await e.requestNetwork([B],t);if(!n?.allow)throw new W(`Allow YouTube access to import your history`);let[r,i,a]=await Promise.all([`LOGIN_INFO`,`SAPISID`,`__Secure-3PAPISID`].map(t=>e.cookie({url:V,name:t}))),o=i?.value||a?.value;return r&&o?o:void 0},Y=async e=>{let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(`yt-client history ${e}`));return Array.from(new Uint8Array(t),e=>e.toString(16).padStart(2,`0`)).join(``)},se=e=>async(t,n)=>{let r=t instanceof Request?t:new Request(t),i=new Headers(n?.headers??r.headers);return i.delete(`cookie`),i.set(`origin`,V),i.set(`referer`,`${V}/`),e.fetch(r.url,{method:r.method,headers:i,body:n?.body??null,credentials:`include`})},X=500,Z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`,ce=[`jan`,`feb`,`mar`,`apr`,`may`,`jun`,`jul`,`aug`,`sep`,`oct`,`nov`,`dec`],le=[`sunday`,`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`],ue=(e,t)=>{let n=e?.trim().toLowerCase();if(!n)return;let r=e=>Z(new Date(t.getFullYear(),t.getMonth(),t.getDate()-e));if(n===`today`)return r(0);if(n===`yesterday`)return r(1);let i=le.indexOf(n);if(i!==-1)return r((t.getDay()-i+7)%7||7);let a=n.match(/^([a-z]+)\.? (\d{1,2})(?:, (\d{4}))?$/),o=ce.indexOf(a?.[1]?.slice(0,3)??``);if(!a||o===-1)return;let s=Number(a[2]),c=new Date(t.getFullYear(),t.getMonth(),t.getDate()),l=a[3]?Number(a[3]):t.getFullYear();!a[3]&&new Date(l,o,s)>c&&--l;let u=new Date(l,o,s);return u.getMonth()===o?Z(u):void 0},de=864e5,fe=(e,t)=>{let[n=0,r=1,i=1]=e.split(`-`).map(Number),a=new Date(n,r-1,i),o=Math.round((new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()-a.getTime())/de);return o===0?`Today`:o===1?`Yesterday`:o>1&&o<7?a.toLocaleDateString(`en`,{weekday:`long`}):a.toLocaleDateString(`en`,n===t.getFullYear()?{month:`short`,day:`numeric`}:{month:`short`,day:`numeric`,year:`numeric`})},pe=(e,t,n)=>({id:e.id,title:e.title,thumbnail:e.thumbnail,durationSeconds:e.durationSeconds,progressPercent:e.progressPercent,isLive:e.isLive,isShort:e.isShort,channel:e.channel&&{id:e.channel.id,name:e.channel.name},...t?{watchedOn:t}:n?{heading:n}:{}}),me=async(e,t,n)=>{let r=[],i=new Set,a=e;for(let e=1;;e++){for(let e of a.sections??[]){let n=e.header?.title?.toString(),a=n&&n!==`N/A`?n:void 0,o=ue(a,t);for(let t of e.contents??[]){let e=O(t)??A(t);e&&!i.has(e.id)&&(i.add(e.id),r.push(pe(e,o,a)))}}if(n?.(r.length),!a.has_continuation||e>=X)return r;a=await a.getContinuation()}},he=e=>e?.responseContext?.mainAppWebResponseContext?.loggedOut===!0,ge=async(t,{now:n=new Date,onProgress:r}={})=>{let i=await J(t,H);if(!i)throw new G;let{Innertube:a,YT:o}=await e(async()=>{let{Innertube:e,YT:t}=await import(`./web-BNanCsH5.js`).then(e=>e.t);return{Innertube:e,YT:t}},__vite__mapDeps([0,1,2])),s=await a.create({fetch:se(t),cookie:`SAPISID=${i}`,generate_session_locally:!0,retrieve_innertube_config:!1,retrieve_player:!1,lang:`en`,user_agent:navigator.userAgent});s.session.context.client.clientVersion=k;let c=await s.actions.execute(`/browse`,{browseId:`FEhistory`});if(he(c.data))throw new G;let l=await me(new o.History(s.actions,c),n,r);return{importedAt:n.getTime(),session:await Y(i),entries:l}},_e=async(e,t)=>{let n=await ge(e,{onProgress:t}).catch(async e=>{throw e instanceof G&&await z(),e});return await R(n),n},ve=async(e,t)=>{let n=await J(e,U);if(n&&t.session===await Y(n))return t;await z()},Q=(e,t)=>{if(t.hideShorts&&e.isShort===!0||t.type===`videos`&&e.isShort===!0||t.type===`shorts`&&e.isShort!==!0||t.channelIds!==void 0&&(!e.channel||!t.channelIds.has(e.channel.id)))return!1;let n=t.query?.trim().toLowerCase();if(n){let t=e.title.toLowerCase(),r=e.channel?.name.toLowerCase()??``;if(!t.includes(n)&&!r.includes(n))return!1}return!0},ye=(e,t)=>{let n=0;for(let r=e.length-1;r>=0&&!e[r].sections.some(e=>e.items.some(e=>Q(e,t)));r--)n++;return n},be=p(`
3
+ query WatchHistory($query: String, $cursor: String) {
4
+ history(query: $query, cursor: $cursor) {
5
+ sections {
6
+ title
7
+ items {
8
+ id
9
+ title
10
+ thumbnail
11
+ thumbnailSrcset
12
+ durationSeconds
13
+ viewCount
14
+ publishedText
15
+ isLive
16
+ isShort
17
+ progressPercent
18
+ channel { id name avatar isVerified isVerifiedArtist }
19
+ byline { text isVerified isVerifiedArtist }
20
+ collaborators { id name avatar handle subscriberCountText isVerified isVerifiedArtist }
21
+ }
22
+ }
23
+ cursor
24
+ }
25
+ }
26
+ `),xe=p(`
27
+ mutation RemoveFromHistory($videoId: ID!) {
28
+ removeFromHistory(videoId: $videoId)
29
+ }
30
+ `),Se=p(`
31
+ mutation ClearHistory {
32
+ clearHistory
33
+ }
34
+ `),Ce=8,$=g`
35
+ max-width: 88rem;
36
+ padding: 2.4rem 1.6rem;
37
+
38
+ &.signed-out {
39
+ max-width: none;
40
+ }
41
+
42
+ .head {
43
+ display: flex;
44
+ flex-wrap: wrap;
45
+ align-items: center;
46
+ justify-content: space-between;
47
+ gap: 1.2rem 1.6rem;
48
+ margin-bottom: 2rem;
49
+ }
50
+
51
+ .heading {
52
+ margin: 0;
53
+ font-size: 2rem;
54
+ font-weight: 700;
55
+ line-height: 2.8rem;
56
+ color: var(--text-primary);
57
+ }
58
+
59
+ .clear-history {
60
+ display: inline-flex;
61
+ align-items: center;
62
+ gap: 0.8rem;
63
+ height: 3.6rem;
64
+ padding: 0 1.4rem;
65
+ border: none;
66
+ border-radius: 1.8rem;
67
+ background: var(--bg-chip);
68
+ color: var(--text-primary);
69
+ font-size: 1.4rem;
70
+ font-weight: 500;
71
+ cursor: pointer;
72
+ transition: background 0.15s ease;
73
+ }
74
+
75
+ .clear-history:hover:not(:disabled) {
76
+ background: var(--bg-chip-hover);
77
+ }
78
+
79
+ .clear-history:disabled {
80
+ cursor: default;
81
+ opacity: 0.6;
82
+ }
83
+
84
+ .controls {
85
+ display: flex;
86
+ flex-direction: column;
87
+ gap: 1.2rem;
88
+ margin-bottom: 2.4rem;
89
+ }
90
+
91
+ .search-form {
92
+ display: flex;
93
+ align-items: center;
94
+ gap: 0.8rem;
95
+ max-width: 40rem;
96
+ height: 3.6rem;
97
+ padding: 0 0.8rem 0 1.2rem;
98
+ border-bottom: 1px solid var(--border-subtle);
99
+ color: var(--text-secondary);
100
+ }
101
+
102
+ .search-form:focus-within {
103
+ border-bottom-color: var(--text-primary);
104
+ }
105
+
106
+ .search-input {
107
+ flex: 1;
108
+ min-width: 0;
109
+ border: none;
110
+ background: transparent;
111
+ color: var(--text-primary);
112
+ font-size: 1.4rem;
113
+ outline: none;
114
+ }
115
+
116
+ .search-clear {
117
+ flex: none;
118
+ width: 2.8rem;
119
+ height: 2.8rem;
120
+ display: flex;
121
+ align-items: center;
122
+ justify-content: center;
123
+ border: none;
124
+ border-radius: 50%;
125
+ background: transparent;
126
+ color: var(--text-secondary);
127
+ cursor: pointer;
128
+ }
129
+
130
+ .search-clear:hover {
131
+ background: var(--bg-hover);
132
+ color: var(--text-primary);
133
+ }
134
+
135
+ .filters {
136
+ display: flex;
137
+ flex-wrap: wrap;
138
+ align-items: center;
139
+ gap: 1.2rem 2.4rem;
140
+ }
141
+
142
+ .chips {
143
+ display: flex;
144
+ flex-wrap: wrap;
145
+ align-items: center;
146
+ gap: 0.8rem;
147
+ }
148
+
149
+ .chip {
150
+ height: 3.2rem;
151
+ padding: 0 1.2rem;
152
+ border: none;
153
+ border-radius: 0.8rem;
154
+ background: var(--bg-chip);
155
+ color: var(--text-primary);
156
+ font-size: 1.4rem;
157
+ font-weight: 500;
158
+ white-space: nowrap;
159
+ cursor: pointer;
160
+ transition: background 0.15s ease;
161
+ }
162
+
163
+ .chip:hover {
164
+ background: var(--bg-chip-hover);
165
+ }
166
+
167
+ .chip[aria-pressed='true'] {
168
+ background: var(--bg-inverse);
169
+ color: var(--text-inverse);
170
+ }
171
+
172
+ .chip .emoji {
173
+ margin-right: 0.6rem;
174
+ }
175
+
176
+ .manage {
177
+ font-size: 1.4rem;
178
+ font-weight: 500;
179
+ color: var(--accent);
180
+ }
181
+
182
+ .section + .section {
183
+ margin-top: 3.2rem;
184
+ }
185
+
186
+ .section-title {
187
+ margin: 0 0 1.6rem;
188
+ font-size: 1.6rem;
189
+ font-weight: 500;
190
+ line-height: 2.2rem;
191
+ color: var(--text-primary);
192
+ }
193
+
194
+ .entries {
195
+ display: flex;
196
+ flex-direction: column;
197
+ gap: 1.6rem;
198
+ }
199
+
200
+ .entry {
201
+ display: flex;
202
+ align-items: flex-start;
203
+ gap: 0.8rem;
204
+ }
205
+
206
+ .card {
207
+ flex: 1;
208
+ min-width: 0;
209
+ }
210
+
211
+ .remove {
212
+ flex: none;
213
+ width: 2.4rem;
214
+ height: 2.4rem;
215
+ display: flex;
216
+ align-items: center;
217
+ justify-content: center;
218
+ border: none;
219
+ border-radius: 50%;
220
+ background: transparent;
221
+ color: var(--text-primary);
222
+ cursor: pointer;
223
+ opacity: 0;
224
+ transition: background 0.15s ease, opacity 0.15s ease;
225
+ }
226
+
227
+ .entry:hover .remove,
228
+ .remove:focus-visible {
229
+ opacity: 1;
230
+ }
231
+
232
+ .remove:hover {
233
+ background: var(--bg-hover);
234
+ }
235
+
236
+ .remove:disabled {
237
+ cursor: default;
238
+ }
239
+
240
+ .more {
241
+ display: block;
242
+ height: 3.6rem;
243
+ margin: 2.4rem auto 0;
244
+ padding: 0 1.6rem;
245
+ border: 1px solid var(--border-strong);
246
+ border-radius: 1.8rem;
247
+ background: transparent;
248
+ color: var(--accent);
249
+ font-size: 1.4rem;
250
+ font-weight: 500;
251
+ cursor: pointer;
252
+ }
253
+
254
+ .more:hover {
255
+ background: var(--accent-hover);
256
+ border-color: transparent;
257
+ }
258
+
259
+ .notice {
260
+ padding: 2.4rem 0;
261
+ font-size: 1.4rem;
262
+ color: var(--text-secondary);
263
+ text-align: center;
264
+ }
265
+
266
+ .prompt {
267
+ max-width: 56rem;
268
+ margin: 4.8rem auto 0;
269
+ padding: 2.4rem;
270
+ border-radius: 1.2rem;
271
+ background: var(--bg-subtle);
272
+ text-align: center;
273
+ }
274
+
275
+ .prompt h2 {
276
+ margin: 0;
277
+ font-size: 2rem;
278
+ font-weight: 700;
279
+ color: var(--text-primary);
280
+ }
281
+
282
+ > .actions {
283
+ display: flex;
284
+ flex-wrap: wrap;
285
+ justify-content: flex-start;
286
+ gap: 0.8rem;
287
+ margin: 0 0 2.4rem;
288
+ }
289
+
290
+ > .actions .sign-in {
291
+ display: inline-flex;
292
+ align-items: center;
293
+ justify-content: center;
294
+ gap: 0.8rem;
295
+ min-height: 3.6rem;
296
+ max-width: 100%;
297
+ padding: 0.6rem 1.5rem;
298
+ border: 1px solid var(--border-strong);
299
+ border-radius: 1.8rem;
300
+ background: transparent;
301
+ color: var(--accent);
302
+ font-size: 1.4rem;
303
+ font-weight: 500;
304
+ cursor: pointer;
305
+ transition: background 0.15s ease, border-color 0.15s ease;
306
+ }
307
+
308
+ > .actions .sign-in svg {
309
+ flex: none;
310
+ }
311
+
312
+ > .actions .sign-in:hover {
313
+ background: var(--accent-hover);
314
+ border-color: transparent;
315
+ }
316
+
317
+ > .actions .sign-in:disabled {
318
+ cursor: default;
319
+ opacity: 0.6;
320
+ }
321
+ `,we=g`
322
+ .confirm-note {
323
+ margin: 0 0 2rem;
324
+ font-size: 1.4rem;
325
+ line-height: 2rem;
326
+ color: var(--text-secondary);
327
+ }
328
+
329
+ .confirm-actions {
330
+ display: flex;
331
+ justify-content: flex-end;
332
+ gap: 0.8rem;
333
+ }
334
+
335
+ .cancel,
336
+ .confirm {
337
+ height: 3.6rem;
338
+ padding: 0 1.6rem;
339
+ border: none;
340
+ border-radius: 1.8rem;
341
+ font-size: 1.4rem;
342
+ font-weight: 500;
343
+ cursor: pointer;
344
+ }
345
+
346
+ .cancel {
347
+ background: transparent;
348
+ color: var(--text-primary);
349
+ }
350
+
351
+ .cancel:hover {
352
+ background: var(--bg-hover);
353
+ }
354
+
355
+ .confirm {
356
+ background: var(--bg-inverse);
357
+ color: var(--text-inverse);
358
+ }
359
+
360
+ .confirm:hover:not(:disabled) {
361
+ background: var(--bg-inverse-hover);
362
+ }
363
+
364
+ .confirm:disabled {
365
+ cursor: default;
366
+ opacity: 0.6;
367
+ }
368
+ `,Te=({draftQuery:e,onQueryInput:n,onSubmit:r,onClearSearch:i,showClear:a,type:s,onType:c,hideShorts:l,group:u,orderedGroups:f,onGroup:p})=>d(`div`,{className:`controls`,children:[d(`form`,{className:`search-form`,role:`search`,onSubmit:r,children:[_(t,{size:18,strokeWidth:1.5,"aria-hidden":`true`}),_(`input`,{type:`search`,className:`search-input`,"aria-label":`Search watch history`,placeholder:`Search watch history`,value:e,onInput:e=>n(e.currentTarget.value)}),a?_(`button`,{type:`button`,className:`search-clear`,"aria-label":`Clear search`,onClick:i,children:_(o,{size:16,strokeWidth:1.5})}):void 0]}),d(`div`,{className:`filters`,children:[d(`div`,{className:`chips`,role:`group`,"aria-label":`Filter by type`,children:[_(`button`,{type:`button`,className:`chip`,"aria-pressed":s===`all`,onClick:()=>c(`all`),children:`All`}),_(`button`,{type:`button`,className:`chip`,"aria-pressed":s===`videos`,onClick:()=>c(`videos`),children:`Videos`}),l?void 0:_(`button`,{type:`button`,className:`chip`,"aria-pressed":s===`shorts`,onClick:()=>c(`shorts`),children:`Shorts`})]}),f.length>0?d(`div`,{className:`chips`,role:`group`,"aria-label":`Groups`,children:[_(`button`,{type:`button`,className:`chip`,"aria-pressed":!u,onClick:()=>p(void 0),children:`All channels`}),f.map(({group:e})=>d(`button`,{type:`button`,className:`chip`,"aria-pressed":e.id===u?.id,onClick:()=>p(e.id),children:[_(`span`,{className:`emoji`,"aria-hidden":`true`,children:e.emoji}),e.name]},e.id)),_(v,{href:`/feed/groups`,className:`manage`,children:`Manage`})]}):void 0]})]}),Ee=e=>{let t=S(`hideShorts`),n=E(),r=w(n),[i,a]=s(`all`),[o,c]=s(void 0),l=t&&i===`shorts`?`all`:i,u=n.find(e=>e.id===o);return{hideShorts:t,orderedGroups:r,group:u,setGroupId:c,type:l,setType:a,filter:{type:l,channelIds:u?new Set(T(n,u.id).map(e=>e.id)):void 0,query:e,hideShorts:t},hasFilter:l!==`all`||u!==void 0||(e?.trim()??``)!==``}},De=()=>d(`main`,{css:$,children:[_(`div`,{className:`head`,children:_(`h1`,{className:`heading`,children:`Watch history`})}),_(`div`,{className:`entries`,children:Array.from({length:Ce},(e,t)=>_(j,{},t))})]}),Oe=()=>{D(`History`);let{ready:e,signedIn:t}=f(),[n,r]=s(``),[a,c]=s(``),[p,m]=s(!1),[h,g]=s(!1),[v,S]=s([]),{hideShorts:C,orderedGroups:w,group:T,setGroupId:E,type:O,setType:k,filter:A,hasFilter:M}=Ee(a),N=a||void 0,[{data:P,error:F,fetching:I,operation:ae},L]=ee({query:be,variables:{query:N,cursor:v[v.length-1]?.cursor},pause:!e||!t}),[,oe]=l(xe),[,R]=l(Se),[z,B]=s(()=>new Set),[V,H]=s([]),U=ae?.variables.query===N?P?.history:void 0,W=U&&v[v.length-1]!==U?[...v,U]:v,{items:G,cursor:K}=re({pages:W.map(e=>({items:e.sections.flatMap(e=>e.items.map(t=>({...t,sectionTitle:e.title??``}))),cursor:e.cursor})),key:e=>e.id}),q=ye(W,A)>=5,J=[],Y=new Map,se={type:A.type,channelIds:A.channelIds,hideShorts:C};for(let e of G){if(z.has(e.id)||!Q(e,se))continue;let t=Y.get(e.sectionTitle);t||(t={title:e.sectionTitle,items:[]},Y.set(e.sectionTitle,t),J.push(t)),t.items.push(e)}let X=()=>{!U?.cursor||I||F||S(e=>e[e.length-1]===U?e:[...e,U])},Z=e=>{V.includes(e)||(H(t=>[...t,e]),oe({videoId:e}).then(t=>{if(H(t=>t.filter(t=>t!==e)),t.error){u(x(t.error));return}B(t=>new Set(t).add(e)),u(`Removed from watch history`)}))};return e?t?d(`main`,{css:$,children:[d(`div`,{className:`head`,children:[_(`h1`,{className:`heading`,children:`Watch history`}),d(`button`,{type:`button`,className:`clear-history`,disabled:h,onClick:()=>m(!0),children:[_(i,{size:18,strokeWidth:1.5}),`Clear all watch history`]})]}),_(Te,{draftQuery:n,onQueryInput:r,onSubmit:e=>{e.preventDefault();let t=n.trim();t!==a&&(S([]),c(t))},onClearSearch:()=>{r(``),a!==``&&(S([]),c(``))},showClear:!!(n||a),type:O,onType:k,hideShorts:C,group:T,orderedGroups:w,onGroup:E}),I&&G.length===0?_(`div`,{className:`entries`,children:Array.from({length:Ce},(e,t)=>_(j,{},t))}):void 0,J.map(e=>d(`section`,{className:`section`,children:[e.title?_(`h2`,{className:`section-title`,children:e.title}):void 0,_(`div`,{className:`entries`,children:e.items.map(e=>d(`div`,{className:`entry`,children:[_(`div`,{className:`card`,children:_(ie,{video:e})}),_(`button`,{type:`button`,className:`remove`,"aria-label":`Remove ${e.title} from watch history`,disabled:V.includes(e.id),onClick:()=>Z(e.id),children:_(o,{size:16,strokeWidth:1.5})})]},e.id))})]},e.title)),U&&!I&&!F&&J.length===0&&(!M||q||!K)?_(`div`,{className:`prompt`,children:_(`h2`,{children:M?`No matching videos`:`Nothing watched yet`})}):void 0,I&&G.length>0?_(`p`,{className:`notice`,children:`Loading more…`}):void 0,F&&!I?_(b,{error:F,reexecute:L}):void 0,q&&K&&!I&&!F?_(`button`,{type:`button`,className:`more`,onClick:X,children:`Load more`}):void 0,_(ne,{onVisible:X,disabled:I||!!F||!K||q}),p?_(y,{title:`Clear watch history?`,onClose:()=>{h||m(!1)},children:d(`div`,{css:we,children:[_(`p`,{className:`confirm-note`,children:`Your YouTube watch history will be cleared from all devices.`}),d(`div`,{className:`confirm-actions`,children:[_(`button`,{type:`button`,className:`cancel`,disabled:h,onClick:()=>m(!1),children:`Cancel`}),_(`button`,{type:`button`,className:`confirm`,disabled:h,onClick:()=>{h||(g(!0),R({}).then(e=>{if(g(!1),e.error){u(x(e.error));return}m(!1),S([]),B(new Set),r(``),c(``),L({requestPolicy:`network-only`}),u(`Watch history cleared`)}))},children:h?`Clearing…`:`Clear watch history`})]})]})}):void 0]}):_(Ae,{onSignIn:te}):_(De,{})},ke=(e,t)=>{let n=[];for(let r of e){let e=r.watchedOn??r.heading??``,i=n[n.length-1];i?.key===e?i.entries.push(r):n.push({key:e,title:r.watchedOn?fe(r.watchedOn,t):r.heading,entries:[r]})}return n},Ae=({onSignIn:e})=>{let t=C(),[o,c]=s(``),{hideShorts:l,orderedGroups:f,group:p,setGroupId:ee,type:g,setType:te,filter:v,hasFilter:ne}=Ee(o),y=t===!0&&q(),[b,x]=s(),[re,S]=s(!1),[w,T]=s(!1),[E,D]=s(),[O,k]=s();a(()=>{let e=!0,t=(t,n=t!==void 0)=>{e&&(x(t),S(n&&!t),T(!0))};return oe().then(async e=>{if(!e||!y)return t(void 0,e!==void 0);t(await ve((await m()).browserSession,e))}).catch(()=>t(void 0,!0)),()=>{e=!1}},[y]);let A=()=>{E===void 0&&(k(void 0),D(0),m().then(({browserSession:e})=>_e(e,D)).then(e=>{x(e),S(!1)},e=>{k(K(e)),e instanceof G&&(x(void 0),S(!1))}).finally(()=>D(void 0)))},j=d(`button`,{type:`button`,className:`sign-in`,onClick:()=>{z().then(()=>{x(void 0),S(!1),u(`Imported history deleted`)},()=>u(`Could not delete the imported history`))},children:[_(i,{size:20,strokeWidth:1.5}),`Delete imported history`]}),N=e=>d(`button`,{type:`button`,className:`sign-in`,disabled:E!==void 0,onClick:A,children:[_(n,{size:20,strokeWidth:1.5}),E===void 0?e:`Importing… ${E} videos`]});if(!w)return _(De,{});if(!b)return d(`main`,{css:$,className:`signed-out`,children:[_(`h1`,{className:`heading`,children:`Watch history`}),_(M,{icon:r,title:`Keep track of what you watch`,subtitle:`Watch history isn't viewable when signed out.`,onSignIn:e,actions:d(h,{children:[y?N(`Import from YouTube on this browser`):void 0,re?j:void 0]}),children:O?_(`p`,{className:`notice`,children:O}):void 0})]});let P=b.entries.filter(e=>Q(e,v));return d(`main`,{css:$,children:[_(`h1`,{className:`heading`,children:`Watch history`}),d(`div`,{className:`actions`,children:[y?N(`Import again`):void 0,j]}),_(Te,{draftQuery:o,onQueryInput:c,onSubmit:e=>e.preventDefault(),onClearSearch:()=>c(``),showClear:!!o,type:g,onType:te,hideShorts:l,group:p,orderedGroups:f,onGroup:ee}),O?_(`p`,{className:`notice`,children:O}):void 0,ke(P,new Date).map(e=>d(`section`,{className:`section`,children:[e.title?_(`h2`,{className:`section-title`,children:e.title}):void 0,_(`div`,{className:`entries`,children:e.entries.map(e=>_(ie,{video:e},e.id))})]},e.key)),P.length===0?_(`div`,{className:`prompt`,children:_(`h2`,{children:ne?`No matching videos`:`Nothing watched yet`})}):void 0]})};export{Oe as default};
@@ -0,0 +1,167 @@
1
+ import{$ as e,f as t,on as n,sn as r,wt as i}from"./icons-DKsqNLSs.js";import{c as a,d as o,g as s,k as c,ot as l,s as u}from"./sign-in-Bx3zmj-m.js";import{A as d,Y as f,j as p}from"./cards-Csel8naI.js";import{n as m}from"../index-Bj-Q3X8Q.js";import{t as h}from"./playlist-card-Btoc7D8f.js";import{t as g}from"./signed-out-prompt-CEAx65kq.js";r();var _=s(`
2
+ query LibraryPlaylists($cursor: String) {
3
+ playlists(cursor: $cursor) {
4
+ items {
5
+ id
6
+ title
7
+ thumbnail
8
+ videoCountText
9
+ channel { id name }
10
+ }
11
+ cursor
12
+ }
13
+ }
14
+ `),v=[{id:`WL`,title:`Watch later`,Icon:i},{id:`LL`,title:`Liked videos`,Icon:t}],y=12,b=4,x=l`
15
+ padding: 2.4rem 1.6rem;
16
+
17
+ .heading {
18
+ margin: 0 0 2.4rem;
19
+ font-size: 2rem;
20
+ font-weight: 700;
21
+ line-height: 2.8rem;
22
+ color: var(--text-primary);
23
+ }
24
+
25
+ .grid {
26
+ display: grid;
27
+ grid-template-columns: repeat(auto-fill, minmax(25.6rem, 1fr));
28
+ column-gap: 1.6rem;
29
+ row-gap: 2.4rem;
30
+ }
31
+
32
+ .card {
33
+ display: flex;
34
+ flex-direction: column;
35
+ min-width: 0;
36
+ }
37
+
38
+ .cover {
39
+ position: relative;
40
+ aspect-ratio: 16 / 9;
41
+ border-radius: 1.2rem;
42
+ overflow: hidden;
43
+ background: var(--bg-elevated);
44
+ }
45
+
46
+ .cover img {
47
+ display: block;
48
+ width: 100%;
49
+ height: 100%;
50
+ object-fit: cover;
51
+ }
52
+
53
+ .cover-fallback {
54
+ display: flex;
55
+ align-items: center;
56
+ justify-content: center;
57
+ width: 100%;
58
+ height: 100%;
59
+ color: var(--text-tertiary);
60
+ }
61
+
62
+ .count {
63
+ position: absolute;
64
+ right: 0.6rem;
65
+ bottom: 0.6rem;
66
+ display: flex;
67
+ align-items: center;
68
+ gap: 0.4rem;
69
+ padding: 0.1rem 0.4rem;
70
+ border-radius: 0.4rem;
71
+ background: var(--bg-badge);
72
+ color: var(--text-on-media);
73
+ font-size: 1.2rem;
74
+ font-weight: 500;
75
+ line-height: 1.8rem;
76
+ }
77
+
78
+ .card-title {
79
+ margin: 1.2rem 0 0;
80
+ font-size: 1.6rem;
81
+ font-weight: 500;
82
+ line-height: 2.2rem;
83
+ color: var(--text-primary);
84
+ display: -webkit-box;
85
+ -webkit-line-clamp: 2;
86
+ -webkit-box-orient: vertical;
87
+ overflow: hidden;
88
+ }
89
+
90
+ .card-meta {
91
+ display: flex;
92
+ align-items: center;
93
+ gap: 0.4rem;
94
+ margin-top: 0.4rem;
95
+ font-size: 1.4rem;
96
+ color: var(--text-secondary);
97
+ }
98
+
99
+ .card-meta svg {
100
+ flex: none;
101
+ }
102
+
103
+ .card:hover .card-meta {
104
+ color: var(--text-primary);
105
+ }
106
+
107
+ .notice {
108
+ padding: 2.4rem 0;
109
+ font-size: 1.4rem;
110
+ color: var(--text-secondary);
111
+ text-align: center;
112
+ }
113
+
114
+ .prompt {
115
+ max-width: 56rem;
116
+ margin: 4.8rem auto 0;
117
+ padding: 2.4rem;
118
+ border-radius: 1.2rem;
119
+ background: var(--bg-subtle);
120
+ text-align: center;
121
+ }
122
+
123
+ .prompt h2 {
124
+ margin: 0;
125
+ font-size: 2rem;
126
+ font-weight: 700;
127
+ color: var(--text-primary);
128
+ }
129
+
130
+ @media (max-width: 500px) {
131
+ .grid {
132
+ grid-template-columns: 1fr;
133
+ }
134
+ }
135
+ `,S=l`
136
+ min-width: 0;
137
+ animation: playlist-card-pulse 1.6s ease-in-out infinite;
138
+
139
+ .cover {
140
+ aspect-ratio: 16 / 9;
141
+ border-radius: 1.2rem;
142
+ background: var(--bg-elevated);
143
+ }
144
+
145
+ .bar {
146
+ height: 1.6rem;
147
+ border-radius: 0.4rem;
148
+ background: var(--bg-elevated);
149
+ margin-top: 1.2rem;
150
+ }
151
+
152
+ .bar.short {
153
+ width: 60%;
154
+ margin-top: 0.8rem;
155
+ }
156
+
157
+ @keyframes playlist-card-pulse {
158
+ 0%,
159
+ 100% {
160
+ opacity: 1;
161
+ }
162
+
163
+ 50% {
164
+ opacity: 0.55;
165
+ }
166
+ }
167
+ `,C=()=>a(`div`,{css:S,"aria-hidden":`true`,children:[u(`div`,{className:`cover`}),u(`div`,{className:`bar`}),u(`div`,{className:`bar short`})]}),w=()=>{m(`Playlists`);let{ready:t,signedIn:r}=o(),[i,s]=n([]),[{data:l,error:S,fetching:w},T]=c({query:_,variables:{cursor:i[i.length-1]?.cursor},pause:!t||!r}),E=l?.playlists,{items:D,cursor:O}=p({pages:E?[...i,E]:i,key:e=>e.id}),k=D.filter(e=>!v.some(t=>t.id===e.id));return t?r?a(`main`,{css:x,children:[u(`h1`,{className:`heading`,children:`Playlists`}),a(`div`,{className:`grid`,children:[v.map(e=>u(h,{id:e.id,title:e.title,fallbackIcon:e.Icon},e.id)),k.map(e=>u(h,{id:e.id,title:e.title,thumbnail:e.thumbnail,videoCountText:e.videoCountText,channelName:e.channel?.name},e.id)),w?Array.from({length:k.length===0?y:b},(e,t)=>u(C,{},`skeleton-${t}`)):void 0]}),l&&!w&&!S&&k.length===0?u(`div`,{className:`prompt`,children:u(`h2`,{children:`No playlists yet`})}):void 0,w&&k.length>0?u(`p`,{className:`notice`,children:`Loading more…`}):void 0,S&&!w?u(f,{error:S,reexecute:T}):void 0,u(d,{onVisible:()=>{!E?.cursor||w||S||s(e=>e[e.length-1]===E?e:[...e,E])},disabled:w||!!S||!O})]}):u(`main`,{css:x,children:u(g,{icon:e,title:`Enjoy your playlists`,subtitle:`Sign in to access playlists that you've created or saved`})}):a(`main`,{css:x,children:[u(`h1`,{className:`heading`,children:`Playlists`}),u(`div`,{className:`grid`,children:Array.from({length:y},(e,t)=>u(C,{},t))})]})};export{w as default};