@nzlov/dsh-bing-wallpaper 0.0.0-stage → 1.4.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.
- package/LICENSE +25 -0
- package/README.md +47 -2
- package/README.zh-CN.md +48 -0
- package/THIRD_PARTY_NOTICES.md +18 -0
- package/bing-source.js +212 -0
- package/boot-theme.js +80 -0
- package/client.js +131 -0
- package/cordis.patch.yml +4 -0
- package/icon.svg +6 -0
- package/index.js +120 -0
- package/locale/en.json +46 -0
- package/locale/zh.json +46 -0
- package/package.json +62 -4
- package/third-party/material-color-utilities-LICENSE.txt +191 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 nzlov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
This license covers the plugin code and original SVG icon, NOT photographs
|
|
24
|
+
retrieved from Bing. Wallpaper copyrights and usage terms remain with Bing
|
|
25
|
+
and the respective photographers; the plugin does not redistribute them.
|
package/README.md
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Bing wallpaper for DSH
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[简体中文](README.zh-CN.md) · English
|
|
4
|
+
|
|
5
|
+
Daily Bing wallpapers, image-derived theme colours, and automatic light/dark appearance for DSH Web. A standalone plugin with no changes to DSH itself.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- China and international (US) Bing sources, with separate caches and no automatic cross-source fallback.
|
|
10
|
+
- Ten colour styles: M3 Content, M3 Tonal Spot, M3 Fruit Salad, M3 Rainbow, M3 Monochrome, Vibrant, Faithful, Soft, Dysfunctional, and Muted.
|
|
11
|
+
- Clickable palette cards show light and dark previews separated by a diagonal line.
|
|
12
|
+
- Wallpaper visibility from 10% to 100%, with a reading overlay; photos, icons, and semantic status colours are not recoloured.
|
|
13
|
+
- Scheduled, system, follow-DSH, or fixed light/dark appearance. The default schedule is 07:00–19:00 in the browser’s local time zone.
|
|
14
|
+
- Image title, date, source, and copyright overlaid at the bottom of the photo; refresh icon in the top-right corner.
|
|
15
|
+
- Automatic update checks, keeping the previous image on failure; Chinese and English UI.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
Requires DSH `>=0.2.2-rc.4 <0.3.0`.
|
|
20
|
+
|
|
21
|
+
In DSH’s plugin manager, install **`@nzlov/dsh-bing-wallpaper`**, or ask the DSH agent to install that npm bundle. The npm package is prebuilt; no manual build is needed. Installation affects all sessions in the current profile.
|
|
22
|
+
|
|
23
|
+
To install from source (requires Git, Node.js, and npm):
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
git clone https://github.com/nzlov/dsh-bing-wallpaper.git
|
|
27
|
+
cd dsh-bing-wallpaper
|
|
28
|
+
npm ci --ignore-scripts
|
|
29
|
+
npm run build
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Then install this directory in DSH using its absolute path.
|
|
33
|
+
|
|
34
|
+
Open **Settings → Bing daily wallpaper**. Rebuild after changing source files; follow Plugin Manager’s restart instructions when updating an installed bundle.
|
|
35
|
+
|
|
36
|
+
## Notes
|
|
37
|
+
|
|
38
|
+
- No API key or CDN is required. Requests go only to fixed Bing HTTPS endpoints; chat content and browser credentials are not forwarded to Bing.
|
|
39
|
+
- Images are cached in memory, not saved as an offline wallpaper library. Update checks use an hourly server cache, so refreshing does not necessarily download a new image. The two regions may show the same photo.
|
|
40
|
+
- Plugin controls are saved in the current browser. DSH’s appearance preference is shared across the profile; use scheduling in one primary browser to avoid competing schedules.
|
|
41
|
+
|
|
42
|
+
## License and credits
|
|
43
|
+
|
|
44
|
+
Author: [nzlov](https://github.com/nzlov).
|
|
45
|
+
|
|
46
|
+
- Plugin code and the original SVG icon: [MIT](LICENSE).
|
|
47
|
+
- Material Color Utilities: Apache-2.0; see [third-party notices](THIRD_PARTY_NOTICES.md) and the [included license](third-party/material-color-utilities-LICENSE.txt).
|
|
48
|
+
- Photographs belong to Bing and the respective photographers. The plugin’s license does not grant rights to redistribute or commercially use those photographs. Follow the copyright link shown on each image.
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# DSH Bing 每日壁纸
|
|
2
|
+
|
|
3
|
+
简体中文 · [English](README.md)
|
|
4
|
+
|
|
5
|
+
为 DSH Web 添加每日 Bing 壁纸、从图片提取的主题色,以及自动日夜外观。独立插件,不修改 DSH 本体。
|
|
6
|
+
|
|
7
|
+
## 特性
|
|
8
|
+
|
|
9
|
+
- 国内(中国)与国际(美国)Bing 来源,缓存独立,失败时不自动混用其他来源。
|
|
10
|
+
- 十种取色风格:M3 Content、M3 Tonal Spot、M3 Fruit Salad、M3 Rainbow、M3 Monochrome、Vibrant、Faithful、Soft、Dysfunctional、Muted。
|
|
11
|
+
- 平铺配色卡片,日夜预览以斜线分隔,点击即可切换。
|
|
12
|
+
- 壁纸可见度 10%–100%,保留阅读蒙层;照片、图标及语义状态色不重新染色。
|
|
13
|
+
- 支持定时、跟随系统、跟随 DSH,以及固定浅色或深色。默认按浏览器本地时间在 07:00–19:00 使用浅色。
|
|
14
|
+
- 标题、日期、来源与版权叠放在图片底部,右上角提供刷新图标。
|
|
15
|
+
- 自动检查更新,失败保留上一张图片;界面支持中英文。
|
|
16
|
+
|
|
17
|
+
## 安装
|
|
18
|
+
|
|
19
|
+
需要 DSH `>=0.2.2-rc.4 <0.3.0`。
|
|
20
|
+
|
|
21
|
+
在 DSH 插件管理中安装 **`@nzlov/dsh-bing-wallpaper`**,或让 DSH Agent 安装该 npm bundle。npm 包已预构建,无需手动构建。安装会影响当前 profile 的所有会话。
|
|
22
|
+
|
|
23
|
+
如需从源码安装(需要 Git、Node.js 和 npm):
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
git clone https://github.com/nzlov/dsh-bing-wallpaper.git
|
|
27
|
+
cd dsh-bing-wallpaper
|
|
28
|
+
npm ci --ignore-scripts
|
|
29
|
+
npm run build
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
随后在 DSH 中使用本目录的绝对路径安装。
|
|
33
|
+
|
|
34
|
+
启用后打开 **设置 → Bing 每日壁纸**。修改源码后需重新构建;更新已安装的插件时,按插件管理器提示决定是否重启。
|
|
35
|
+
|
|
36
|
+
## 使用须知
|
|
37
|
+
|
|
38
|
+
- 无需 API Key 或 CDN。上游仅访问固定 Bing HTTPS 接口,不向 Bing 发送聊天内容或浏览器凭据。
|
|
39
|
+
- 图片仅缓存在内存,不提供离线壁纸库。服务端按小时缓存,因此点击刷新不一定下载新图;两个地区也可能展示同一张照片。
|
|
40
|
+
- 插件控制项保存在当前浏览器,DSH 的外观偏好则由整个 profile 共享。建议仅在一个主要浏览器启用定时切换,避免不同时间表互相覆盖。
|
|
41
|
+
|
|
42
|
+
## 许可与版权
|
|
43
|
+
|
|
44
|
+
作者:[nzlov](https://github.com/nzlov)。
|
|
45
|
+
|
|
46
|
+
- 插件代码及原创 SVG 图标采用 [MIT 许可](LICENSE)。
|
|
47
|
+
- Material Color Utilities 采用 Apache-2.0,详见[第三方声明](THIRD_PARTY_NOTICES.md)及[附带许可](third-party/material-color-utilities-LICENSE.txt)。
|
|
48
|
+
- 图片版权归 Bing 及原摄影作者所有。插件许可不包含图片的再分发或商业使用授权,请遵守每张图片所附版权链接中的条款。
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
The prebuilt browser artifact includes **Material Color Utilities 0.3.0**
|
|
4
|
+
(`@material/material-color-utilities`), copyright 2021–2024 Google LLC and
|
|
5
|
+
contributors, licensed under the Apache License, Version 2.0.
|
|
6
|
+
|
|
7
|
+
Source: https://github.com/material-foundation/material-color-utilities
|
|
8
|
+
|
|
9
|
+
The utility implementation is bundled without source changes; the plugin maps
|
|
10
|
+
its HCT palettes to DSH theme roles and applies additional contrast adjustments.
|
|
11
|
+
The plugin’s custom Muted palette and DSH integration are separate additions.
|
|
12
|
+
|
|
13
|
+
The full Apache-2.0 license is included in
|
|
14
|
+
`third-party/material-color-utilities-LICENSE.txt`. Copyright and license notices
|
|
15
|
+
are also retained in the generated JavaScript artifact.
|
|
16
|
+
|
|
17
|
+
esbuild is a development-only build tool and is not part of the browser runtime.
|
|
18
|
+
Bing photographs remain owned by their respective rights holders.
|
package/bing-source.js
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
// Intentionally dependency-free: each market uses only its fixed HTTPS Bing origin.
|
|
2
|
+
export const MARKET = 'zh-CN'
|
|
3
|
+
export const DAILY_PATH = '/bing-daily-theme/api/daily'
|
|
4
|
+
export const IMAGE_PATH = '/bing-daily-theme/api/image'
|
|
5
|
+
const BING_ORIGINS = new Map([
|
|
6
|
+
['zh-CN', 'https://cn.bing.com'],
|
|
7
|
+
['en-US', 'https://www.bing.com'],
|
|
8
|
+
])
|
|
9
|
+
|
|
10
|
+
export function isBingMarket(market) {
|
|
11
|
+
return BING_ORIGINS.has(market)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function isSafeBingUrl(url) {
|
|
15
|
+
return [...BING_ORIGINS.values()].includes(url.origin) && !url.username && !url.password
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// No URLs, query strings, slashes, percent escapes, or alternate Bing resources.
|
|
19
|
+
export function isBingImageId(id) {
|
|
20
|
+
return typeof id === 'string' && id.length <= 240
|
|
21
|
+
&& /^OHR\.[A-Za-z0-9][A-Za-z0-9_-]*_1920x1080\.jpg$/.test(id)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class BingSourceError extends Error {}
|
|
25
|
+
|
|
26
|
+
function parseDate(value) {
|
|
27
|
+
if (typeof value !== 'string' || !/^\d{8}$/.test(value)) throw new BingSourceError('Invalid Bing date')
|
|
28
|
+
const date = `${value.slice(0, 4)}-${value.slice(4, 6)}-${value.slice(6, 8)}`
|
|
29
|
+
const parsed = new Date(`${date}T00:00:00Z`)
|
|
30
|
+
if (!Number.isFinite(+parsed) || parsed.toISOString().slice(0, 10) !== date) {
|
|
31
|
+
throw new BingSourceError('Invalid Bing date')
|
|
32
|
+
}
|
|
33
|
+
return date
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function parseArchive(bytes, market) {
|
|
37
|
+
const origin = BING_ORIGINS.get(market)
|
|
38
|
+
let image
|
|
39
|
+
try { image = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes)).images?.[0] } catch {
|
|
40
|
+
throw new BingSourceError('Invalid Bing archive JSON')
|
|
41
|
+
}
|
|
42
|
+
if (!image || typeof image.url !== 'string' || image.url.length > 2048) {
|
|
43
|
+
throw new BingSourceError('Missing Bing image')
|
|
44
|
+
}
|
|
45
|
+
let url
|
|
46
|
+
try { url = new URL(image.url, origin) } catch { throw new BingSourceError('Invalid Bing image URL') }
|
|
47
|
+
const id = url.searchParams.get('id')
|
|
48
|
+
if (!isSafeBingUrl(url) || url.pathname !== '/th'
|
|
49
|
+
|| url.hash || url.searchParams.getAll('id').length !== 1 || !isBingImageId(id)) {
|
|
50
|
+
throw new BingSourceError('Invalid Bing image ID')
|
|
51
|
+
}
|
|
52
|
+
let copyrightUrl = `${origin}/`
|
|
53
|
+
if (typeof image.copyrightlink === 'string' && image.copyrightlink.length <= 2048) {
|
|
54
|
+
try {
|
|
55
|
+
const link = new URL(image.copyrightlink, origin)
|
|
56
|
+
if (isSafeBingUrl(link)) copyrightUrl = link.href
|
|
57
|
+
} catch { /* Never pass an arbitrary or executable URL to the Client. */ }
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
id,
|
|
61
|
+
metadata: {
|
|
62
|
+
date: parseDate(image.startdate),
|
|
63
|
+
title: typeof image.title === 'string' ? image.title.slice(0, 300) : '',
|
|
64
|
+
copyright: typeof image.copyright === 'string' ? image.copyright.slice(0, 1000) : '',
|
|
65
|
+
copyrightUrl,
|
|
66
|
+
imageUrl: `${IMAGE_PATH}?${market === MARKET ? '' : `market=${market}&`}id=${encodeURIComponent(id)}`,
|
|
67
|
+
market,
|
|
68
|
+
},
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function readLimited(response, limit) {
|
|
73
|
+
const length = response.headers.get('content-length')
|
|
74
|
+
if (length !== null && (!/^\d+$/.test(length) || Number(length) > limit)) {
|
|
75
|
+
await response.body?.cancel().catch(() => {})
|
|
76
|
+
throw new BingSourceError('Bing response exceeds size limit')
|
|
77
|
+
}
|
|
78
|
+
if (!response.body) throw new BingSourceError('Empty Bing response')
|
|
79
|
+
const reader = response.body.getReader()
|
|
80
|
+
const chunks = []
|
|
81
|
+
let size = 0
|
|
82
|
+
try {
|
|
83
|
+
while (true) {
|
|
84
|
+
const { done, value } = await reader.read()
|
|
85
|
+
if (done) break
|
|
86
|
+
size += value.byteLength
|
|
87
|
+
if (size > limit) throw new BingSourceError('Bing response exceeds size limit')
|
|
88
|
+
chunks.push(value)
|
|
89
|
+
}
|
|
90
|
+
if (!size) throw new BingSourceError('Empty Bing response')
|
|
91
|
+
const bytes = new Uint8Array(size)
|
|
92
|
+
let offset = 0
|
|
93
|
+
for (const chunk of chunks) { bytes.set(chunk, offset); offset += chunk.byteLength }
|
|
94
|
+
return bytes
|
|
95
|
+
} catch (error) {
|
|
96
|
+
await reader.cancel().catch(() => {})
|
|
97
|
+
throw error
|
|
98
|
+
} finally {
|
|
99
|
+
reader.releaseLock()
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Options are test seams, not plugin configuration. Production always uses defaults.
|
|
104
|
+
export function createBingSource({
|
|
105
|
+
fetchImpl = globalThis.fetch,
|
|
106
|
+
now = Date.now,
|
|
107
|
+
timeoutMs = 10_000,
|
|
108
|
+
metadataMaxBytes = 128 * 1024,
|
|
109
|
+
imageMaxBytes = 8 * 1024 * 1024,
|
|
110
|
+
refreshMs = 60 * 60 * 1000,
|
|
111
|
+
retryMs = 60 * 1000,
|
|
112
|
+
} = {}) {
|
|
113
|
+
let disposed = false
|
|
114
|
+
// No shared fallback or cache admission across markets, even for identical IDs.
|
|
115
|
+
const states = new Map([...BING_ORIGINS.keys()].map(market => [market, {
|
|
116
|
+
snapshot: undefined,
|
|
117
|
+
nextCheck: 0,
|
|
118
|
+
stale: false,
|
|
119
|
+
pending: undefined,
|
|
120
|
+
images: new Map(),
|
|
121
|
+
}]))
|
|
122
|
+
const controllers = new Set()
|
|
123
|
+
|
|
124
|
+
async function download(url, kind) {
|
|
125
|
+
if (disposed) throw new BingSourceError('Bing source disposed')
|
|
126
|
+
const controller = new AbortController()
|
|
127
|
+
controllers.add(controller)
|
|
128
|
+
const timer = setTimeout(() => controller.abort(new BingSourceError('Bing request timed out')), timeoutMs)
|
|
129
|
+
try {
|
|
130
|
+
const response = await fetchImpl(url, {
|
|
131
|
+
method: 'GET',
|
|
132
|
+
redirect: 'error',
|
|
133
|
+
credentials: 'omit',
|
|
134
|
+
signal: controller.signal,
|
|
135
|
+
headers: { accept: kind === 'image' ? 'image/jpeg' : 'application/json' },
|
|
136
|
+
})
|
|
137
|
+
if (!response.ok || response.redirected || (response.url && response.url !== url)) {
|
|
138
|
+
await response.body?.cancel().catch(() => {})
|
|
139
|
+
throw new BingSourceError('Bing upstream request failed')
|
|
140
|
+
}
|
|
141
|
+
const type = response.headers.get('content-type')?.split(';')[0].trim().toLowerCase()
|
|
142
|
+
if (kind === 'image' ? type !== 'image/jpeg' : !['application/json', 'text/javascript'].includes(type)) {
|
|
143
|
+
await response.body?.cancel().catch(() => {})
|
|
144
|
+
throw new BingSourceError('Unexpected Bing response type')
|
|
145
|
+
}
|
|
146
|
+
const bytes = await readLimited(response, kind === 'image' ? imageMaxBytes : metadataMaxBytes)
|
|
147
|
+
controller.signal.throwIfAborted()
|
|
148
|
+
if (kind === 'image' && !(bytes[0] === 0xff && bytes[1] === 0xd8 && bytes[2] === 0xff)) {
|
|
149
|
+
throw new BingSourceError('Invalid Bing JPEG')
|
|
150
|
+
}
|
|
151
|
+
return bytes
|
|
152
|
+
} finally {
|
|
153
|
+
clearTimeout(timer)
|
|
154
|
+
controllers.delete(controller)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async function refresh(market, state) {
|
|
159
|
+
const origin = BING_ORIGINS.get(market)
|
|
160
|
+
try {
|
|
161
|
+
const archiveUrl = `${origin}/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=${market}`
|
|
162
|
+
const record = parseArchive(await download(archiveUrl, 'metadata'), market)
|
|
163
|
+
let image = state.images.get(record.id)
|
|
164
|
+
if (!image) {
|
|
165
|
+
// Archive URLs only admit an ID; never fetch their endpoint or parameters.
|
|
166
|
+
const url = `${origin}/th?id=${encodeURIComponent(record.id)}`
|
|
167
|
+
image = { bytes: await download(url, 'image'), contentType: 'image/jpeg' }
|
|
168
|
+
}
|
|
169
|
+
if (disposed) throw new BingSourceError('Bing source disposed')
|
|
170
|
+
// Atomic publication: a failed new download never replaces the old picture.
|
|
171
|
+
state.images.delete(record.id)
|
|
172
|
+
state.images.set(record.id, image)
|
|
173
|
+
while (state.images.size > 2) state.images.delete(state.images.keys().next().value)
|
|
174
|
+
state.snapshot = record.metadata
|
|
175
|
+
state.stale = false
|
|
176
|
+
state.nextCheck = now() + refreshMs
|
|
177
|
+
} catch (error) {
|
|
178
|
+
state.stale = true
|
|
179
|
+
state.nextCheck = now() + retryMs
|
|
180
|
+
if (disposed || !state.snapshot) throw error
|
|
181
|
+
}
|
|
182
|
+
return { ...state.snapshot, ...(state.stale ? { stale: true } : {}) }
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
async daily(market = MARKET) {
|
|
187
|
+
if (disposed) throw new BingSourceError('Bing source disposed')
|
|
188
|
+
if (!isBingMarket(market)) throw new BingSourceError('Unsupported Bing market')
|
|
189
|
+
const state = states.get(market)
|
|
190
|
+
if (now() < state.nextCheck) {
|
|
191
|
+
if (!state.snapshot) throw new BingSourceError('Bing temporarily unavailable')
|
|
192
|
+
return { ...state.snapshot, ...(state.stale ? { stale: true } : {}) }
|
|
193
|
+
}
|
|
194
|
+
if (!state.pending) state.pending = refresh(market, state).finally(() => { state.pending = undefined })
|
|
195
|
+
return state.pending
|
|
196
|
+
},
|
|
197
|
+
image(id, market = MARKET) {
|
|
198
|
+
if (disposed || !isBingMarket(market) || !isBingImageId(id)) return undefined
|
|
199
|
+
// Even syntactically valid IDs must have been admitted by this market's archive.
|
|
200
|
+
return states.get(market).images.get(id)
|
|
201
|
+
},
|
|
202
|
+
dispose() {
|
|
203
|
+
disposed = true
|
|
204
|
+
for (const controller of controllers) controller.abort(new BingSourceError('Bing source disposed'))
|
|
205
|
+
controllers.clear()
|
|
206
|
+
for (const state of states.values()) {
|
|
207
|
+
state.images.clear()
|
|
208
|
+
state.snapshot = undefined
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
}
|
|
212
|
+
}
|
package/boot-theme.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Dependency-free bridge for the interval before Client plugins can run.
|
|
2
|
+
export const PREFERENCES_KEY = 'dsh.bing-daily-theme.preferences.v1';
|
|
3
|
+
export const BOOT_CACHE_KEY = 'dsh.bing-daily-theme.boot.v1';
|
|
4
|
+
export const BOOT_STYLE_ID = 'bdt-boot-theme';
|
|
5
|
+
|
|
6
|
+
export function makeBootCache(settings, tokens, imageUrl) {
|
|
7
|
+
if (!settings.enabled || !settings.dynamic) return null;
|
|
8
|
+
const keys = {
|
|
9
|
+
background: '--dsw-alias-bg-layer-1', primary: '--dsw-alias-label-primary',
|
|
10
|
+
secondary: '--dsw-alias-label-secondary', tertiary: '--dsw-alias-label-tertiary',
|
|
11
|
+
border: '--dsw-alias-border-l2', brand: '--dsw-alias-brand-primary',
|
|
12
|
+
};
|
|
13
|
+
const colors = {};
|
|
14
|
+
for (const scheme of ['light', 'dark']) {
|
|
15
|
+
colors[scheme] = Object.fromEntries(Object.entries(keys).map(([role, key]) => [role, tokens[key][scheme]]));
|
|
16
|
+
}
|
|
17
|
+
return { version: 1, market: settings.market || 'zh-CN', paletteMode: settings.paletteMode, strength: settings.strength, colors, imageUrl };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// This pure function is also embedded verbatim in the Host's early script.
|
|
21
|
+
// All persisted values are untrusted: no arbitrary CSS or URL interpolation.
|
|
22
|
+
export function bootThemeCSS(settings, cache, now, systemDark, followDark) {
|
|
23
|
+
settings ??= { enabled: true, dynamic: true, paletteMode: 'content', mode: 'schedule', day: '07:00', night: '19:00', strength: 28 };
|
|
24
|
+
if (!settings || settings.enabled !== true || settings.dynamic !== true || !cache || cache.version !== 1
|
|
25
|
+
|| cache.paletteMode !== settings.paletteMode || cache.strength !== settings.strength
|
|
26
|
+
|| !['zh-CN', 'en-US'].includes(settings.market ?? 'zh-CN') || (cache.market ?? 'zh-CN') !== (settings.market ?? 'zh-CN')
|
|
27
|
+
|| !Number.isFinite(settings.strength) || settings.strength < 10 || settings.strength > 100) return '';
|
|
28
|
+
// Follow stays selector-driven: structured row activation order may change
|
|
29
|
+
// after a Host plugin reload, and the native body selector is authoritative.
|
|
30
|
+
if (settings.mode === 'follow' && typeof followDark !== 'boolean') {
|
|
31
|
+
return bootThemeCSS(settings, cache, now, systemDark, false).replaceAll('[data-dsh-boot]', 'body:not([data-ds-dark-theme]) [data-dsh-boot]')
|
|
32
|
+
+ bootThemeCSS(settings, cache, now, systemDark, true).replaceAll('[data-dsh-boot]', 'body[data-ds-dark-theme] [data-dsh-boot]');
|
|
33
|
+
}
|
|
34
|
+
let dark;
|
|
35
|
+
if (settings.mode === 'schedule') {
|
|
36
|
+
const time = value => typeof value === 'string' && /^([01]\d|2[0-3]):[0-5]\d$/.test(value);
|
|
37
|
+
if (!time(settings.day) || !time(settings.night) || settings.day === settings.night) return '';
|
|
38
|
+
const minutes = value => Number(value.slice(0, 2)) * 60 + Number(value.slice(3));
|
|
39
|
+
const start = minutes(settings.day), end = minutes(settings.night);
|
|
40
|
+
const current = now.getHours() * 60 + now.getMinutes();
|
|
41
|
+
dark = !(start < end ? current >= start && current < end : current >= start || current < end);
|
|
42
|
+
} else if (settings.mode === 'system') dark = systemDark;
|
|
43
|
+
else if (settings.mode === 'follow') dark = followDark;
|
|
44
|
+
else if (settings.mode === 'light' || settings.mode === 'dark') dark = settings.mode === 'dark';
|
|
45
|
+
else return '';
|
|
46
|
+
const colors = cache.colors?.[dark ? 'dark' : 'light'];
|
|
47
|
+
const roles = ['background', 'primary', 'secondary', 'tertiary', 'border', 'brand'];
|
|
48
|
+
if (!colors || !roles.every(role => {
|
|
49
|
+
if (typeof colors[role] !== 'string') return false;
|
|
50
|
+
const match = /^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/.exec(colors[role]);
|
|
51
|
+
return match && match.slice(1).every(channel => Number(channel) <= 255);
|
|
52
|
+
})) return '';
|
|
53
|
+
// The opaque backing also works when the in-memory image cache is empty.
|
|
54
|
+
// Never store blob URLs or request an arbitrary cached URL at startup.
|
|
55
|
+
const url = cache.imageUrl;
|
|
56
|
+
const alpha = Math.sqrt(1 - settings.strength / 100);
|
|
57
|
+
const matte = colors.background.replace('rgb(', 'rgba(').replace(')', `, ${alpha})`);
|
|
58
|
+
const imageMatch = typeof url === 'string' && url.length <= 300
|
|
59
|
+
&& /^\/bing-daily-theme\/api\/image\?(market=en-US&)?id=OHR\.[A-Za-z0-9][A-Za-z0-9_-]*_1920x1080\.jpg$/.exec(url);
|
|
60
|
+
const image = imageMatch && Boolean(imageMatch[1]) === (settings.market === 'en-US')
|
|
61
|
+
? `linear-gradient(${matte},${matte}),linear-gradient(${dark ? 'rgba(0, 0, 0, 0.62)' : 'rgba(255, 255, 255, 0.56)'},${dark ? 'rgba(0, 0, 0, 0.62)' : 'rgba(255, 255, 255, 0.56)'}),url("${url}")` : 'none';
|
|
62
|
+
return `[data-dsh-boot]{--dsw-alias-bg-base:${colors.background};--dsw-alias-label-primary:${colors.primary};--dsw-alias-label-secondary:${colors.secondary};--dsw-alias-label-tertiary:${colors.tertiary};--dsw-alias-border-l2:${colors.border};--dsw-alias-brand-primary:${colors.brand};background-color:${colors.background}!important;background-image:${image}!important;background-size:cover;background-position:center;color-scheme:${dark ? 'dark' : 'light'}}`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// No network await, timer, observer, global preference or body-style writes.
|
|
66
|
+
function startBootTheme(preferencesKey, cacheKey, styleId, resolveCSS) {
|
|
67
|
+
try {
|
|
68
|
+
const css = resolveCSS(JSON.parse(localStorage.getItem(preferencesKey)), JSON.parse(localStorage.getItem(cacheKey)),
|
|
69
|
+
new Date(), typeof matchMedia === 'function' && matchMedia('(prefers-color-scheme: dark)').matches);
|
|
70
|
+
if (!css) return;
|
|
71
|
+
document.getElementById(styleId)?.remove();
|
|
72
|
+
const style = document.createElement('style');
|
|
73
|
+
style.id = styleId; style.textContent = css; document.head.append(style);
|
|
74
|
+
} catch { /* Storage denial or damaged cache must never block shell startup. */ }
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function bootThemeInjection() {
|
|
78
|
+
const text = `;(${startBootTheme.toString()})(${JSON.stringify(PREFERENCES_KEY)},${JSON.stringify(BOOT_CACHE_KEY)},${JSON.stringify(BOOT_STYLE_ID)},${bootThemeCSS.toString()});`;
|
|
79
|
+
return { kind: 'script', placement: 'body', text };
|
|
80
|
+
}
|
package/client.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// Generated by npm run build. Edit palette.js / client-main.js / appearance.js / boot-theme.js / compatibility.js / palette-preview.js instead.
|
|
2
|
+
(()=>{var we=Object.defineProperty;var xe=(t,e)=>{for(var r in e)we(t,r,{get:e[r],enumerable:!0})};var Kt={};xe(Kt,{DEFAULTS:()=>ct,PALETTE_MODES:()=>se,WALLPAPER_VEIL:()=>Ut,backgroundAlpha:()=>ie,contrast:()=>ht,extractAccent:()=>Be,hslToRgb:()=>Fe,localDate:()=>De,luminance:()=>Yt,makeTokens:()=>Ne,normalizeSettings:()=>Se,normalizeStrength:()=>$t,rgbToHsl:()=>le,scheduledScheme:()=>Ie,wallpaperShade:()=>Te});function Y(t){return t<0?-1:t===0?0:1}function pt(t,e,r){return(1-r)*t+r*e}function Qt(t,e,r){return r<t?t:r>e?e:r}function kt(t,e,r){return r<t?t:r>e?e:r}function Ct(t){return t=t%360,t<0&&(t=t+360),t}function G(t){return t=t%360,t<0&&(t=t+360),t}function _t(t,e){return 180-Math.abs(Math.abs(t-e)-180)}function Dt(t,e){let r=t[0]*e[0][0]+t[1]*e[0][1]+t[2]*e[0][2],a=t[0]*e[1][0]+t[1]*e[1][1]+t[2]*e[1][2],n=t[0]*e[2][0]+t[1]*e[2][1]+t[2]*e[2][2];return[r,a,n]}var te=[[.41233895,.35762064,.18051042],[.2126,.7152,.0722],[.01932141,.11916382,.95034478]],ke=[[3.2413774792388685,-1.5376652402851851,-.49885366846268053],[-.9691452513005321,1.8758853451067872,.04156585616912061],[.05562093689691305,-.20395524564742123,1.0571799111220335]],ee=[95.047,100,108.883];function gt(t,e,r){return(255<<24|(t&255)<<16|(e&255)<<8|r&255)>>>0}function Gt(t){let e=ft(t[0]),r=ft(t[1]),a=ft(t[2]);return gt(e,r,a)}function Pt(t){return t>>16&255}function At(t){return t>>8&255}function vt(t){return t&255}function re(t,e,r){let a=ke,n=a[0][0]*t+a[0][1]*e+a[0][2]*r,i=a[1][0]*t+a[1][1]*e+a[1][2]*r,s=a[2][0]*t+a[2][1]*e+a[2][2]*r,c=ft(n),m=ft(i),l=ft(s);return gt(c,m,l)}function Ce(t){let e=st(Pt(t)),r=st(At(t)),a=st(vt(t));return Dt([e,r,a],te)}function qt(t){let e=st(Pt(t)),r=st(At(t)),a=st(vt(t)),n=te,i=n[0][0]*e+n[0][1]*r+n[0][2]*a,s=n[1][0]*e+n[1][1]*r+n[1][2]*a,c=n[2][0]*e+n[2][1]*r+n[2][2]*a,m=ee,l=i/m[0],d=s/m[1],h=c/m[2],f=Ft(l),u=Ft(d),g=Ft(h),p=116*u-16,P=500*(f-u),T=200*(u-g);return[p,P,T]}function ae(t){let e=rt(t),r=ft(e);return gt(r,r,r)}function Rt(t){let e=Ce(t)[1];return 116*Ft(e/100)-16}function rt(t){return 100*Pe((t+16)/116)}function Bt(t){return Ft(t/100)*116-16}function st(t){let e=t/255;return e<=.040449936?e/12.92*100:Math.pow((e+.055)/1.055,2.4)*100}function ft(t){let e=t/100,r=0;return e<=.0031308?r=e*12.92:r=1.055*Math.pow(e,1/2.4)-.055,Qt(0,255,Math.round(r*255))}function ne(){return ee}function Ft(t){let e=.008856451679035631,r=24389/27;return t>e?Math.pow(t,1/3):(r*t+16)/116}function Pe(t){let e=.008856451679035631,r=24389/27,a=t*t*t;return a>e?a:(116*t-16)/r}var et=class t{static make(e=ne(),r=200/Math.PI*rt(50)/100,a=50,n=2,i=!1){let s=e,c=s[0]*.401288+s[1]*.650173+s[2]*-.051461,m=s[0]*-.250268+s[1]*1.204414+s[2]*.045854,l=s[0]*-.002079+s[1]*.048952+s[2]*.953127,d=.8+n/10,h=d>=.9?pt(.59,.69,(d-.9)*10):pt(.525,.59,(d-.8)*10),f=i?1:d*(1-1/3.6*Math.exp((-r-42)/92));f=f>1?1:f<0?0:f;let u=d,g=[f*(100/c)+1-f,f*(100/m)+1-f,f*(100/l)+1-f],p=1/(5*r+1),P=p*p*p*p,T=1-P,S=P*r+.1*T*T*Math.cbrt(5*r),C=rt(a)/e[1],E=1.48+Math.sqrt(C),M=.725/Math.pow(C,.2),O=M,I=[Math.pow(S*g[0]*c/100,.42),Math.pow(S*g[1]*m/100,.42),Math.pow(S*g[2]*l/100,.42)],R=[400*I[0]/(I[0]+27.13),400*I[1]/(I[1]+27.13),400*I[2]/(I[2]+27.13)],V=(2*R[0]+R[1]+.05*R[2])*M;return new t(C,V,M,O,h,u,g,S,Math.pow(S,.25),E)}constructor(e,r,a,n,i,s,c,m,l,d){this.n=e,this.aw=r,this.nbb=a,this.ncb=n,this.c=i,this.nc=s,this.rgbD=c,this.fl=m,this.fLRoot=l,this.z=d}};et.DEFAULT=et.make();var it=class t{constructor(e,r,a,n,i,s,c,m,l){this.hue=e,this.chroma=r,this.j=a,this.q=n,this.m=i,this.s=s,this.jstar=c,this.astar=m,this.bstar=l}distance(e){let r=this.jstar-e.jstar,a=this.astar-e.astar,n=this.bstar-e.bstar,i=Math.sqrt(r*r+a*a+n*n);return 1.41*Math.pow(i,.63)}static fromInt(e){return t.fromIntInViewingConditions(e,et.DEFAULT)}static fromIntInViewingConditions(e,r){let a=(e&16711680)>>16,n=(e&65280)>>8,i=e&255,s=st(a),c=st(n),m=st(i),l=.41233895*s+.35762064*c+.18051042*m,d=.2126*s+.7152*c+.0722*m,h=.01932141*s+.11916382*c+.95034478*m,f=.401288*l+.650173*d-.051461*h,u=-.250268*l+1.204414*d+.045854*h,g=-.002079*l+.048952*d+.953127*h,p=r.rgbD[0]*f,P=r.rgbD[1]*u,T=r.rgbD[2]*g,S=Math.pow(r.fl*Math.abs(p)/100,.42),C=Math.pow(r.fl*Math.abs(P)/100,.42),E=Math.pow(r.fl*Math.abs(T)/100,.42),M=Y(p)*400*S/(S+27.13),O=Y(P)*400*C/(C+27.13),I=Y(T)*400*E/(E+27.13),R=(11*M+-12*O+I)/11,V=(M+O-2*I)/9,w=(20*M+20*O+21*I)/20,B=(40*M+20*O+I)/20,j=Math.atan2(V,R)*180/Math.PI,_=j<0?j+360:j>=360?j-360:j,dt=_*Math.PI/180,wt=B*r.nbb,ot=100*Math.pow(wt/r.aw,r.c*r.z),xt=4/r.c*Math.sqrt(ot/100)*(r.aw+4)*r.fLRoot,It=_<20.14?_+360:_,y=.25*(Math.cos(It*Math.PI/180+2)+3.8),D=5e4/13*y*r.nc*r.ncb*Math.sqrt(R*R+V*V)/(w+.305),U=Math.pow(D,.9)*Math.pow(1.64-Math.pow(.29,r.n),.73),Z=U*Math.sqrt(ot/100),q=Z*r.fLRoot,Q=50*Math.sqrt(U*r.c/(r.aw+4)),tt=(1+100*.007)*ot/(1+.007*ot),v=1/.0228*Math.log(1+.0228*q),J=v*Math.cos(dt),ut=v*Math.sin(dt);return new t(_,Z,ot,xt,q,Q,tt,J,ut)}static fromJch(e,r,a){return t.fromJchInViewingConditions(e,r,a,et.DEFAULT)}static fromJchInViewingConditions(e,r,a,n){let i=4/n.c*Math.sqrt(e/100)*(n.aw+4)*n.fLRoot,s=r*n.fLRoot,c=r/Math.sqrt(e/100),m=50*Math.sqrt(c*n.c/(n.aw+4)),l=a*Math.PI/180,d=(1+100*.007)*e/(1+.007*e),h=1/.0228*Math.log(1+.0228*s),f=h*Math.cos(l),u=h*Math.sin(l);return new t(a,r,e,i,s,m,d,f,u)}static fromUcs(e,r,a){return t.fromUcsInViewingConditions(e,r,a,et.DEFAULT)}static fromUcsInViewingConditions(e,r,a,n){let i=r,s=a,c=Math.sqrt(i*i+s*s),l=(Math.exp(c*.0228)-1)/.0228/n.fLRoot,d=Math.atan2(s,i)*(180/Math.PI);d<0&&(d+=360);let h=e/(1-(e-100)*.007);return t.fromJchInViewingConditions(h,l,d,n)}toInt(){return this.viewed(et.DEFAULT)}viewed(e){let r=this.chroma===0||this.j===0?0:this.chroma/Math.sqrt(this.j/100),a=Math.pow(r/Math.pow(1.64-Math.pow(.29,e.n),.73),1/.9),n=this.hue*Math.PI/180,i=.25*(Math.cos(n+2)+3.8),s=e.aw*Math.pow(this.j/100,1/e.c/e.z),c=i*(5e4/13)*e.nc*e.ncb,m=s/e.nbb,l=Math.sin(n),d=Math.cos(n),h=23*(m+.305)*a/(23*c+11*a*d+108*a*l),f=h*d,u=h*l,g=(460*m+451*f+288*u)/1403,p=(460*m-891*f-261*u)/1403,P=(460*m-220*f-6300*u)/1403,T=Math.max(0,27.13*Math.abs(g)/(400-Math.abs(g))),S=Y(g)*(100/e.fl)*Math.pow(T,1/.42),C=Math.max(0,27.13*Math.abs(p)/(400-Math.abs(p))),E=Y(p)*(100/e.fl)*Math.pow(C,1/.42),M=Math.max(0,27.13*Math.abs(P)/(400-Math.abs(P))),O=Y(P)*(100/e.fl)*Math.pow(M,1/.42),I=S/e.rgbD[0],R=E/e.rgbD[1],V=O/e.rgbD[2],w=1.86206786*I-1.01125463*R+.14918677*V,B=.38752654*I+.62144744*R-.00897398*V,L=-.0158415*I-.03412294*R+1.04996444*V;return re(w,B,L)}static fromXyzInViewingConditions(e,r,a,n){let i=.401288*e+.650173*r-.051461*a,s=-.250268*e+1.204414*r+.045854*a,c=-.002079*e+.048952*r+.953127*a,m=n.rgbD[0]*i,l=n.rgbD[1]*s,d=n.rgbD[2]*c,h=Math.pow(n.fl*Math.abs(m)/100,.42),f=Math.pow(n.fl*Math.abs(l)/100,.42),u=Math.pow(n.fl*Math.abs(d)/100,.42),g=Y(m)*400*h/(h+27.13),p=Y(l)*400*f/(f+27.13),P=Y(d)*400*u/(u+27.13),T=(11*g+-12*p+P)/11,S=(g+p-2*P)/9,C=(20*g+20*p+21*P)/20,E=(40*g+20*p+P)/20,O=Math.atan2(S,T)*180/Math.PI,I=O<0?O+360:O>=360?O-360:O,R=I*Math.PI/180,V=E*n.nbb,w=100*Math.pow(V/n.aw,n.c*n.z),B=4/n.c*Math.sqrt(w/100)*(n.aw+4)*n.fLRoot,L=I<20.14?I+360:I,j=1/4*(Math.cos(L*Math.PI/180+2)+3.8),dt=5e4/13*j*n.nc*n.ncb*Math.sqrt(T*T+S*S)/(C+.305),wt=Math.pow(dt,.9)*Math.pow(1.64-Math.pow(.29,n.n),.73),ot=wt*Math.sqrt(w/100),xt=ot*n.fLRoot,It=50*Math.sqrt(wt*n.c/(n.aw+4)),y=(1+100*.007)*w/(1+.007*w),k=Math.log(1+.0228*xt)/.0228,D=k*Math.cos(R),U=k*Math.sin(R);return new t(I,ot,w,B,xt,It,y,D,U)}xyzInViewingConditions(e){let r=this.chroma===0||this.j===0?0:this.chroma/Math.sqrt(this.j/100),a=Math.pow(r/Math.pow(1.64-Math.pow(.29,e.n),.73),1/.9),n=this.hue*Math.PI/180,i=.25*(Math.cos(n+2)+3.8),s=e.aw*Math.pow(this.j/100,1/e.c/e.z),c=i*(5e4/13)*e.nc*e.ncb,m=s/e.nbb,l=Math.sin(n),d=Math.cos(n),h=23*(m+.305)*a/(23*c+11*a*d+108*a*l),f=h*d,u=h*l,g=(460*m+451*f+288*u)/1403,p=(460*m-891*f-261*u)/1403,P=(460*m-220*f-6300*u)/1403,T=Math.max(0,27.13*Math.abs(g)/(400-Math.abs(g))),S=Y(g)*(100/e.fl)*Math.pow(T,1/.42),C=Math.max(0,27.13*Math.abs(p)/(400-Math.abs(p))),E=Y(p)*(100/e.fl)*Math.pow(C,1/.42),M=Math.max(0,27.13*Math.abs(P)/(400-Math.abs(P))),O=Y(P)*(100/e.fl)*Math.pow(M,1/.42),I=S/e.rgbD[0],R=E/e.rgbD[1],V=O/e.rgbD[2],w=1.86206786*I-1.01125463*R+.14918677*V,B=.38752654*I+.62144744*R-.00897398*V,L=-.0158415*I-.03412294*R+1.04996444*V;return[w,B,L]}};var nt=class t{static sanitizeRadians(e){return(e+Math.PI*8)%(Math.PI*2)}static trueDelinearized(e){let r=e/100,a=0;return r<=.0031308?a=r*12.92:a=1.055*Math.pow(r,1/2.4)-.055,a*255}static chromaticAdaptation(e){let r=Math.pow(Math.abs(e),.42);return Y(e)*400*r/(r+27.13)}static hueOf(e){let r=Dt(e,t.SCALED_DISCOUNT_FROM_LINRGB),a=t.chromaticAdaptation(r[0]),n=t.chromaticAdaptation(r[1]),i=t.chromaticAdaptation(r[2]),s=(11*a+-12*n+i)/11,c=(a+n-2*i)/9;return Math.atan2(c,s)}static areInCyclicOrder(e,r,a){let n=t.sanitizeRadians(r-e),i=t.sanitizeRadians(a-e);return n<i}static intercept(e,r,a){return(r-e)/(a-e)}static lerpPoint(e,r,a){return[e[0]+(a[0]-e[0])*r,e[1]+(a[1]-e[1])*r,e[2]+(a[2]-e[2])*r]}static setCoordinate(e,r,a,n){let i=t.intercept(e[n],r,a[n]);return t.lerpPoint(e,i,a)}static isBounded(e){return 0<=e&&e<=100}static nthVertex(e,r){let a=t.Y_FROM_LINRGB[0],n=t.Y_FROM_LINRGB[1],i=t.Y_FROM_LINRGB[2],s=r%4<=1?0:100,c=r%2===0?0:100;if(r<4){let m=s,l=c,d=(e-m*n-l*i)/a;return t.isBounded(d)?[d,m,l]:[-1,-1,-1]}else if(r<8){let m=s,l=c,d=(e-l*a-m*i)/n;return t.isBounded(d)?[l,d,m]:[-1,-1,-1]}else{let m=s,l=c,d=(e-m*a-l*n)/i;return t.isBounded(d)?[m,l,d]:[-1,-1,-1]}}static bisectToSegment(e,r){let a=[-1,-1,-1],n=a,i=0,s=0,c=!1,m=!0;for(let l=0;l<12;l++){let d=t.nthVertex(e,l);if(d[0]<0)continue;let h=t.hueOf(d);if(!c){a=d,n=d,i=h,s=h,c=!0;continue}(m||t.areInCyclicOrder(i,h,s))&&(m=!1,t.areInCyclicOrder(i,r,h)?(n=d,s=h):(a=d,i=h))}return[a,n]}static midpoint(e,r){return[(e[0]+r[0])/2,(e[1]+r[1])/2,(e[2]+r[2])/2]}static criticalPlaneBelow(e){return Math.floor(e-.5)}static criticalPlaneAbove(e){return Math.ceil(e-.5)}static bisectToLimit(e,r){let a=t.bisectToSegment(e,r),n=a[0],i=t.hueOf(n),s=a[1];for(let c=0;c<3;c++)if(n[c]!==s[c]){let m=-1,l=255;n[c]<s[c]?(m=t.criticalPlaneBelow(t.trueDelinearized(n[c])),l=t.criticalPlaneAbove(t.trueDelinearized(s[c]))):(m=t.criticalPlaneAbove(t.trueDelinearized(n[c])),l=t.criticalPlaneBelow(t.trueDelinearized(s[c])));for(let d=0;d<8&&!(Math.abs(l-m)<=1);d++){let h=Math.floor((m+l)/2),f=t.CRITICAL_PLANES[h],u=t.setCoordinate(n,f,s,c),g=t.hueOf(u);t.areInCyclicOrder(i,r,g)?(s=u,l=h):(n=u,i=g,m=h)}}return t.midpoint(n,s)}static inverseChromaticAdaptation(e){let r=Math.abs(e),a=Math.max(0,27.13*r/(400-r));return Y(e)*Math.pow(a,1/.42)}static findResultByJ(e,r,a){let n=Math.sqrt(a)*11,i=et.DEFAULT,s=1/Math.pow(1.64-Math.pow(.29,i.n),.73),m=.25*(Math.cos(e+2)+3.8)*(5e4/13)*i.nc*i.ncb,l=Math.sin(e),d=Math.cos(e);for(let h=0;h<5;h++){let f=n/100,u=r===0||n===0?0:r/Math.sqrt(f),g=Math.pow(u*s,1/.9),P=i.aw*Math.pow(f,1/i.c/i.z)/i.nbb,T=23*(P+.305)*g/(23*m+11*g*d+108*g*l),S=T*d,C=T*l,E=(460*P+451*S+288*C)/1403,M=(460*P-891*S-261*C)/1403,O=(460*P-220*S-6300*C)/1403,I=t.inverseChromaticAdaptation(E),R=t.inverseChromaticAdaptation(M),V=t.inverseChromaticAdaptation(O),w=Dt([I,R,V],t.LINRGB_FROM_SCALED_DISCOUNT);if(w[0]<0||w[1]<0||w[2]<0)return 0;let B=t.Y_FROM_LINRGB[0],L=t.Y_FROM_LINRGB[1],j=t.Y_FROM_LINRGB[2],_=B*w[0]+L*w[1]+j*w[2];if(_<=0)return 0;if(h===4||Math.abs(_-a)<.002)return w[0]>100.01||w[1]>100.01||w[2]>100.01?0:Gt(w);n=n-(_-a)*n/(2*_)}return 0}static solveToInt(e,r,a){if(r<1e-4||a<1e-4||a>99.9999)return ae(a);e=G(e);let n=e/180*Math.PI,i=rt(a),s=t.findResultByJ(n,r,i);if(s!==0)return s;let c=t.bisectToLimit(i,n);return Gt(c)}static solveToCam(e,r,a){return it.fromInt(t.solveToInt(e,r,a))}};nt.SCALED_DISCOUNT_FROM_LINRGB=[[.001200833568784504,.002389694492170889,.0002795742885861124],[.0005891086651375999,.0029785502573438758,.0003270666104008398],[.00010146692491640572,.0005364214359186694,.0032979401770712076]];nt.LINRGB_FROM_SCALED_DISCOUNT=[[1373.2198709594231,-1100.4251190754821,-7.278681089101213],[-271.815969077903,559.6580465940733,-32.46047482791194],[1.9622899599665666,-57.173814538844006,308.7233197812385]];nt.Y_FROM_LINRGB=[.2126,.7152,.0722];nt.CRITICAL_PLANES=[.015176349177441876,.045529047532325624,.07588174588720938,.10623444424209313,.13658714259697685,.16693984095186062,.19729253930674434,.2276452376616281,.2579979360165119,.28835063437139563,.3188300904430532,.350925934958123,.3848314933096426,.42057480301049466,.458183274052838,.4976837250274023,.5391024159806381,.5824650784040898,.6277969426914107,.6751227633498623,.7244668422128921,.775853049866786,.829304845476233,.8848452951698498,.942497089126609,1.0022825574869039,1.0642236851973577,1.1283421258858297,1.1946592148522128,1.2631959812511864,1.3339731595349034,1.407011200216447,1.4823302800086415,1.5599503113873272,1.6398909516233677,1.7221716113234105,1.8068114625156377,1.8938294463134073,1.9832442801866852,2.075074464868551,2.1693382909216234,2.2660538449872063,2.36523901573795,2.4669114995532007,2.5710888059345764,2.6777882626779785,2.7870270208169257,2.898822059350997,3.0131901897720907,3.1301480604002863,3.2497121605402226,3.3718988244681087,3.4967242352587946,3.624204428461639,3.754355295633311,3.887192587735158,4.022731918402185,4.160988767090289,4.301978482107941,4.445716283538092,4.592217266055746,4.741496401646282,4.893568542229298,5.048448422192488,5.20615066083972,5.3666897647573375,5.5300801301023865,5.696336044816294,5.865471690767354,6.037501145825082,6.212438385869475,6.390297286737924,6.571091626112461,6.7548350853498045,6.941541251256611,7.131223617812143,7.323895587840543,7.5195704746346665,7.7182615035334345,7.919981813454504,8.124744458384042,8.332562408825165,8.543448553206703,8.757415699253682,8.974476575321063,9.194643831691977,9.417930041841839,9.644347703669503,9.873909240696694,10.106627003236781,10.342513269534024,10.58158024687427,10.8238400726681,11.069304815507364,11.317986476196008,11.569896988756009,11.825048221409341,12.083451977536606,12.345119996613247,12.610063955123938,12.878295467455942,13.149826086772048,13.42466730586372,13.702830557985108,13.984327217668513,14.269168601521828,14.55736596900856,14.848930523210871,15.143873411576273,15.44220572664832,15.743938506781891,16.04908273684337,16.35764934889634,16.66964922287304,16.985093187232053,17.30399201960269,17.62635644741625,17.95219714852476,18.281524751807332,18.614349837764564,18.95068293910138,19.290534541298456,19.633915083172692,19.98083495742689,20.331304511189067,20.685334046541502,21.042933821039977,21.404114048223256,21.76888489811322,22.137256497705877,22.50923893145328,22.884842241736916,23.264076429332462,23.6469514538663,24.033477234264016,24.42366364919083,24.817520537484558,25.21505769858089,25.61628489293138,26.021211842414342,26.429848230738664,26.842203703840827,27.258287870275353,27.678110301598522,28.10168053274597,28.529008062403893,28.96010235337422,29.39497283293396,29.83362889318845,30.276079891419332,30.722335150426627,31.172403958865512,31.62629557157785,32.08401920991837,32.54558406207592,33.010999283389665,33.4802739966603,33.953417292456834,34.430438229418264,34.911345834551085,35.39614910352207,35.88485700094671,36.37747846067349,36.87402238606382,37.37449765026789,37.87891309649659,38.38727753828926,38.89959975977785,39.41588851594697,39.93615253289054,40.460400508064545,40.98864111053629,41.520882981230194,42.05713473317016,42.597404951718396,43.141702194811224,43.6900349931913,44.24241185063697,44.798841244188324,45.35933162437017,45.92389141541209,46.49252901546552,47.065252796817916,47.64207110610409,48.22299226451468,48.808024568002054,49.3971762874833,49.9904556690408,50.587870934119984,51.189430279724725,51.79514187861014,52.40501387947288,53.0190544071392,53.637271562750364,54.259673423945976,54.88626804504493,55.517063457223934,56.15206766869424,56.79128866487574,57.43473440856916,58.08241284012621,58.734331877617365,59.39049941699807,60.05092333227251,60.715611475655585,61.38457167773311,62.057811747619894,62.7353394731159,63.417162620860914,64.10328893648692,64.79372614476921,65.48848194977529,66.18756403501224,66.89098006357258,67.59873767827808,68.31084450182222,69.02730813691093,69.74813616640164,70.47333615344107,71.20291564160104,71.93688215501312,72.67524319850172,73.41800625771542,74.16517879925733,74.9167682708136,75.67278210128072,76.43322770089146,77.1981124613393,77.96744375590167,78.74122893956174,79.51947534912904,80.30219030335869,81.08938110306934,81.88105503125999,82.67721935322541,83.4778813166706,84.28304815182372,85.09272707154808,85.90692527145302,86.72564993000343,87.54890820862819,88.3767072518277,89.2090541872801,90.04595612594655,90.88742016217518,91.73345337380438,92.58406282226491,93.43925555268066,94.29903859396902,95.16341895893969,96.03240364439274,96.9059996312159,97.78421388448044,98.6670533535366,99.55452497210776];var F=class t{static from(e,r,a){return new t(nt.solveToInt(e,r,a))}static fromInt(e){return new t(e)}toInt(){return this.argb}get hue(){return this.internalHue}set hue(e){this.setInternalState(nt.solveToInt(e,this.internalChroma,this.internalTone))}get chroma(){return this.internalChroma}set chroma(e){this.setInternalState(nt.solveToInt(this.internalHue,e,this.internalTone))}get tone(){return this.internalTone}set tone(e){this.setInternalState(nt.solveToInt(this.internalHue,this.internalChroma,e))}constructor(e){this.argb=e;let r=it.fromInt(e);this.internalHue=r.hue,this.internalChroma=r.chroma,this.internalTone=Rt(e),this.argb=e}setInternalState(e){let r=it.fromInt(e);this.internalHue=r.hue,this.internalChroma=r.chroma,this.internalTone=Rt(e),this.argb=e}inViewingConditions(e){let a=it.fromInt(this.toInt()).xyzInViewingConditions(e),n=it.fromXyzInViewingConditions(a[0],a[1],a[2],et.make());return t.from(n.hue,n.chroma,Bt(a[1]))}};var X=class t{static ratioOfTones(e,r){return e=kt(0,100,e),r=kt(0,100,r),t.ratioOfYs(rt(e),rt(r))}static ratioOfYs(e,r){let a=e>r?e:r,n=a===r?e:r;return(a+5)/(n+5)}static lighter(e,r){if(e<0||e>100)return-1;let a=rt(e),n=r*(a+5)-5,i=t.ratioOfYs(n,a),s=Math.abs(i-r);if(i<r&&s>.04)return-1;let c=Bt(n)+.4;return c<0||c>100?-1:c}static darker(e,r){if(e<0||e>100)return-1;let a=rt(e),n=(a+5)/r-5,i=t.ratioOfYs(a,n),s=Math.abs(i-r);if(i<r&&s>.04)return-1;let c=Bt(n)-.4;return c<0||c>100?-1:c}static lighterUnsafe(e,r){let a=t.lighter(e,r);return a<0?100:a}static darkerUnsafe(e,r){let a=t.darker(e,r);return a<0?0:a}};var mt=class t{static isDisliked(e){let r=Math.round(e.hue)>=90&&Math.round(e.hue)<=111,a=Math.round(e.chroma)>16,n=Math.round(e.tone)<65;return r&&a&&n}static fixIfDisliked(e){return t.isDisliked(e)?F.from(e.hue,e.chroma,70):e}};var x=class t{static fromPalette(e){return new t(e.name??"",e.palette,e.tone,e.isBackground??!1,e.background,e.secondBackground,e.contrastCurve,e.toneDeltaPair)}constructor(e,r,a,n,i,s,c,m){if(this.name=e,this.palette=r,this.tone=a,this.isBackground=n,this.background=i,this.secondBackground=s,this.contrastCurve=c,this.toneDeltaPair=m,this.hctCache=new Map,!i&&s)throw new Error(`Color ${e} has secondBackgrounddefined, but background is not defined.`);if(!i&&c)throw new Error(`Color ${e} has contrastCurvedefined, but background is not defined.`);if(i&&!c)throw new Error(`Color ${e} has backgrounddefined, but contrastCurve is not defined.`)}getArgb(e){return this.getHct(e).toInt()}getHct(e){let r=this.hctCache.get(e);if(r!=null)return r;let a=this.getTone(e),n=this.palette(e).getHct(a);return this.hctCache.size>4&&this.hctCache.clear(),this.hctCache.set(e,n),n}getTone(e){let r=e.contrastLevel<0;if(this.toneDeltaPair){let a=this.toneDeltaPair(e),n=a.roleA,i=a.roleB,s=a.delta,c=a.polarity,m=a.stayTogether,d=this.background(e).getTone(e),h=c==="nearer"||c==="lighter"&&!e.isDark||c==="darker"&&e.isDark,f=h?n:i,u=h?i:n,g=this.name===f.name,p=e.isDark?1:-1,P=f.contrastCurve.get(e.contrastLevel),T=u.contrastCurve.get(e.contrastLevel),S=f.tone(e),C=X.ratioOfTones(d,S)>=P?S:t.foregroundTone(d,P),E=u.tone(e),M=X.ratioOfTones(d,E)>=T?E:t.foregroundTone(d,T);return r&&(C=t.foregroundTone(d,P),M=t.foregroundTone(d,T)),(M-C)*p>=s||(M=kt(0,100,C+s*p),(M-C)*p>=s||(C=kt(0,100,M-s*p))),50<=C&&C<60?p>0?(C=60,M=Math.max(M,C+s*p)):(C=49,M=Math.min(M,C+s*p)):50<=M&&M<60&&(m?p>0?(C=60,M=Math.max(M,C+s*p)):(C=49,M=Math.min(M,C+s*p)):p>0?M=60:M=49),g?C:M}else{let a=this.tone(e);if(this.background==null)return a;let n=this.background(e).getTone(e),i=this.contrastCurve.get(e.contrastLevel);if(X.ratioOfTones(n,a)>=i||(a=t.foregroundTone(n,i)),r&&(a=t.foregroundTone(n,i)),this.isBackground&&50<=a&&a<60&&(X.ratioOfTones(49,n)>=i?a=49:a=60),this.secondBackground){let[s,c]=[this.background,this.secondBackground],[m,l]=[s(e).getTone(e),c(e).getTone(e)],[d,h]=[Math.max(m,l),Math.min(m,l)];if(X.ratioOfTones(d,a)>=i&&X.ratioOfTones(h,a)>=i)return a;let f=X.lighter(d,i),u=X.darker(h,i),g=[];return f!==-1&&g.push(f),u!==-1&&g.push(u),t.tonePrefersLightForeground(m)||t.tonePrefersLightForeground(l)?f<0?100:f:g.length===1?g[0]:u<0?0:u}return a}}static foregroundTone(e,r){let a=X.lighterUnsafe(e,r),n=X.darkerUnsafe(e,r),i=X.ratioOfTones(a,e),s=X.ratioOfTones(n,e);if(t.tonePrefersLightForeground(e)){let m=Math.abs(i-s)<.1&&i<r&&s<r;return i>=r||i>=s||m?a:n}else return s>=r||s>=i?n:a}static tonePrefersLightForeground(e){return Math.round(e)<60}static toneAllowsLightForeground(e){return Math.round(e)<=49}static enableLightForeground(e){return t.tonePrefersLightForeground(e)&&!t.toneAllowsLightForeground(e)?49:e}};var b=class t{static fromInt(e){let r=F.fromInt(e);return t.fromHct(r)}static fromHct(e){return new t(e.hue,e.chroma,e)}static fromHueAndChroma(e,r){let a=new Wt(e,r).create();return new t(e,r,a)}constructor(e,r,a){this.hue=e,this.chroma=r,this.keyColor=a,this.cache=new Map}tone(e){let r=this.cache.get(e);return r===void 0&&(r=F.from(this.hue,this.chroma,e).toInt(),this.cache.set(e,r)),r}getHct(e){return F.fromInt(this.tone(e))}},Wt=class{constructor(e,r){this.hue=e,this.requestedChroma=r,this.chromaCache=new Map,this.maxChromaValue=200}create(){let n=0,i=100;for(;n<i;){let s=Math.floor((n+i)/2),c=this.maxChroma(s)<this.maxChroma(s+1);if(this.maxChroma(s)>=this.requestedChroma-.01)if(Math.abs(n-50)<Math.abs(i-50))i=s;else{if(n===s)return F.from(this.hue,this.requestedChroma,n);n=s}else c?n=s+1:i=s}return F.from(this.hue,this.requestedChroma,n)}maxChroma(e){if(this.chromaCache.has(e))return this.chromaCache.get(e);let r=F.from(this.hue,this.maxChromaValue,e).chroma;return this.chromaCache.set(e,r),r}};var A=class{constructor(e,r,a,n){this.low=e,this.normal=r,this.medium=a,this.high=n}get(e){return e<=-1?this.low:e<0?pt(this.low,this.normal,(e- -1)/1):e<.5?pt(this.normal,this.medium,(e-0)/.5):e<1?pt(this.medium,this.high,(e-.5)/.5):this.high}};var W=class{constructor(e,r,a,n,i){this.roleA=e,this.roleB=r,this.delta=a,this.polarity=n,this.stayTogether=i}};var N;(function(t){t[t.MONOCHROME=0]="MONOCHROME",t[t.NEUTRAL=1]="NEUTRAL",t[t.TONAL_SPOT=2]="TONAL_SPOT",t[t.VIBRANT=3]="VIBRANT",t[t.EXPRESSIVE=4]="EXPRESSIVE",t[t.FIDELITY=5]="FIDELITY",t[t.CONTENT=6]="CONTENT",t[t.RAINBOW=7]="RAINBOW",t[t.FRUIT_SALAD=8]="FRUIT_SALAD"})(N||(N={}));function Mt(t){return t.variant===N.FIDELITY||t.variant===N.CONTENT}function z(t){return t.variant===N.MONOCHROME}function Ae(t,e,r,a){let n=r,i=F.from(t,e,r);if(i.chroma<e){let s=i.chroma;for(;i.chroma<e;){n+=a?-1:1;let c=F.from(t,e,n);if(s>c.chroma||Math.abs(c.chroma-e)<.4)break;let m=Math.abs(c.chroma-e),l=Math.abs(i.chroma-e);m<l&&(i=c),s=Math.max(s,c.chroma)}}return n}var o=class t{static highestSurface(e){return e.isDark?t.surfaceBright:t.surfaceDim}};o.contentAccentToneDelta=15;o.primaryPaletteKeyColor=x.fromPalette({name:"primary_palette_key_color",palette:t=>t.primaryPalette,tone:t=>t.primaryPalette.keyColor.tone});o.secondaryPaletteKeyColor=x.fromPalette({name:"secondary_palette_key_color",palette:t=>t.secondaryPalette,tone:t=>t.secondaryPalette.keyColor.tone});o.tertiaryPaletteKeyColor=x.fromPalette({name:"tertiary_palette_key_color",palette:t=>t.tertiaryPalette,tone:t=>t.tertiaryPalette.keyColor.tone});o.neutralPaletteKeyColor=x.fromPalette({name:"neutral_palette_key_color",palette:t=>t.neutralPalette,tone:t=>t.neutralPalette.keyColor.tone});o.neutralVariantPaletteKeyColor=x.fromPalette({name:"neutral_variant_palette_key_color",palette:t=>t.neutralVariantPalette,tone:t=>t.neutralVariantPalette.keyColor.tone});o.background=x.fromPalette({name:"background",palette:t=>t.neutralPalette,tone:t=>t.isDark?6:98,isBackground:!0});o.onBackground=x.fromPalette({name:"on_background",palette:t=>t.neutralPalette,tone:t=>t.isDark?90:10,background:t=>o.background,contrastCurve:new A(3,3,4.5,7)});o.surface=x.fromPalette({name:"surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?6:98,isBackground:!0});o.surfaceDim=x.fromPalette({name:"surface_dim",palette:t=>t.neutralPalette,tone:t=>t.isDark?6:new A(87,87,80,75).get(t.contrastLevel),isBackground:!0});o.surfaceBright=x.fromPalette({name:"surface_bright",palette:t=>t.neutralPalette,tone:t=>t.isDark?new A(24,24,29,34).get(t.contrastLevel):98,isBackground:!0});o.surfaceContainerLowest=x.fromPalette({name:"surface_container_lowest",palette:t=>t.neutralPalette,tone:t=>t.isDark?new A(4,4,2,0).get(t.contrastLevel):100,isBackground:!0});o.surfaceContainerLow=x.fromPalette({name:"surface_container_low",palette:t=>t.neutralPalette,tone:t=>t.isDark?new A(10,10,11,12).get(t.contrastLevel):new A(96,96,96,95).get(t.contrastLevel),isBackground:!0});o.surfaceContainer=x.fromPalette({name:"surface_container",palette:t=>t.neutralPalette,tone:t=>t.isDark?new A(12,12,16,20).get(t.contrastLevel):new A(94,94,92,90).get(t.contrastLevel),isBackground:!0});o.surfaceContainerHigh=x.fromPalette({name:"surface_container_high",palette:t=>t.neutralPalette,tone:t=>t.isDark?new A(17,17,21,25).get(t.contrastLevel):new A(92,92,88,85).get(t.contrastLevel),isBackground:!0});o.surfaceContainerHighest=x.fromPalette({name:"surface_container_highest",palette:t=>t.neutralPalette,tone:t=>t.isDark?new A(22,22,26,30).get(t.contrastLevel):new A(90,90,84,80).get(t.contrastLevel),isBackground:!0});o.onSurface=x.fromPalette({name:"on_surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?90:10,background:t=>o.highestSurface(t),contrastCurve:new A(4.5,7,11,21)});o.surfaceVariant=x.fromPalette({name:"surface_variant",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?30:90,isBackground:!0});o.onSurfaceVariant=x.fromPalette({name:"on_surface_variant",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?80:30,background:t=>o.highestSurface(t),contrastCurve:new A(3,4.5,7,11)});o.inverseSurface=x.fromPalette({name:"inverse_surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?90:20});o.inverseOnSurface=x.fromPalette({name:"inverse_on_surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?20:95,background:t=>o.inverseSurface,contrastCurve:new A(4.5,7,11,21)});o.outline=x.fromPalette({name:"outline",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?60:50,background:t=>o.highestSurface(t),contrastCurve:new A(1.5,3,4.5,7)});o.outlineVariant=x.fromPalette({name:"outline_variant",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?30:80,background:t=>o.highestSurface(t),contrastCurve:new A(1,1,3,4.5)});o.shadow=x.fromPalette({name:"shadow",palette:t=>t.neutralPalette,tone:t=>0});o.scrim=x.fromPalette({name:"scrim",palette:t=>t.neutralPalette,tone:t=>0});o.surfaceTint=x.fromPalette({name:"surface_tint",palette:t=>t.primaryPalette,tone:t=>t.isDark?80:40,isBackground:!0});o.primary=x.fromPalette({name:"primary",palette:t=>t.primaryPalette,tone:t=>z(t)?t.isDark?100:0:t.isDark?80:40,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new A(3,4.5,7,7),toneDeltaPair:t=>new W(o.primaryContainer,o.primary,10,"nearer",!1)});o.onPrimary=x.fromPalette({name:"on_primary",palette:t=>t.primaryPalette,tone:t=>z(t)?t.isDark?10:90:t.isDark?20:100,background:t=>o.primary,contrastCurve:new A(4.5,7,11,21)});o.primaryContainer=x.fromPalette({name:"primary_container",palette:t=>t.primaryPalette,tone:t=>Mt(t)?t.sourceColorHct.tone:z(t)?t.isDark?85:25:t.isDark?30:90,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new A(1,1,3,4.5),toneDeltaPair:t=>new W(o.primaryContainer,o.primary,10,"nearer",!1)});o.onPrimaryContainer=x.fromPalette({name:"on_primary_container",palette:t=>t.primaryPalette,tone:t=>Mt(t)?x.foregroundTone(o.primaryContainer.tone(t),4.5):z(t)?t.isDark?0:100:t.isDark?90:30,background:t=>o.primaryContainer,contrastCurve:new A(3,4.5,7,11)});o.inversePrimary=x.fromPalette({name:"inverse_primary",palette:t=>t.primaryPalette,tone:t=>t.isDark?40:80,background:t=>o.inverseSurface,contrastCurve:new A(3,4.5,7,7)});o.secondary=x.fromPalette({name:"secondary",palette:t=>t.secondaryPalette,tone:t=>t.isDark?80:40,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new A(3,4.5,7,7),toneDeltaPair:t=>new W(o.secondaryContainer,o.secondary,10,"nearer",!1)});o.onSecondary=x.fromPalette({name:"on_secondary",palette:t=>t.secondaryPalette,tone:t=>z(t)?t.isDark?10:100:t.isDark?20:100,background:t=>o.secondary,contrastCurve:new A(4.5,7,11,21)});o.secondaryContainer=x.fromPalette({name:"secondary_container",palette:t=>t.secondaryPalette,tone:t=>{let e=t.isDark?30:90;return z(t)?t.isDark?30:85:Mt(t)?Ae(t.secondaryPalette.hue,t.secondaryPalette.chroma,e,!t.isDark):e},isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new A(1,1,3,4.5),toneDeltaPair:t=>new W(o.secondaryContainer,o.secondary,10,"nearer",!1)});o.onSecondaryContainer=x.fromPalette({name:"on_secondary_container",palette:t=>t.secondaryPalette,tone:t=>z(t)?t.isDark?90:10:Mt(t)?x.foregroundTone(o.secondaryContainer.tone(t),4.5):t.isDark?90:30,background:t=>o.secondaryContainer,contrastCurve:new A(3,4.5,7,11)});o.tertiary=x.fromPalette({name:"tertiary",palette:t=>t.tertiaryPalette,tone:t=>z(t)?t.isDark?90:25:t.isDark?80:40,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new A(3,4.5,7,7),toneDeltaPair:t=>new W(o.tertiaryContainer,o.tertiary,10,"nearer",!1)});o.onTertiary=x.fromPalette({name:"on_tertiary",palette:t=>t.tertiaryPalette,tone:t=>z(t)?t.isDark?10:90:t.isDark?20:100,background:t=>o.tertiary,contrastCurve:new A(4.5,7,11,21)});o.tertiaryContainer=x.fromPalette({name:"tertiary_container",palette:t=>t.tertiaryPalette,tone:t=>{if(z(t))return t.isDark?60:49;if(!Mt(t))return t.isDark?30:90;let e=t.tertiaryPalette.getHct(t.sourceColorHct.tone);return mt.fixIfDisliked(e).tone},isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new A(1,1,3,4.5),toneDeltaPair:t=>new W(o.tertiaryContainer,o.tertiary,10,"nearer",!1)});o.onTertiaryContainer=x.fromPalette({name:"on_tertiary_container",palette:t=>t.tertiaryPalette,tone:t=>z(t)?t.isDark?0:100:Mt(t)?x.foregroundTone(o.tertiaryContainer.tone(t),4.5):t.isDark?90:30,background:t=>o.tertiaryContainer,contrastCurve:new A(3,4.5,7,11)});o.error=x.fromPalette({name:"error",palette:t=>t.errorPalette,tone:t=>t.isDark?80:40,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new A(3,4.5,7,7),toneDeltaPair:t=>new W(o.errorContainer,o.error,10,"nearer",!1)});o.onError=x.fromPalette({name:"on_error",palette:t=>t.errorPalette,tone:t=>t.isDark?20:100,background:t=>o.error,contrastCurve:new A(4.5,7,11,21)});o.errorContainer=x.fromPalette({name:"error_container",palette:t=>t.errorPalette,tone:t=>t.isDark?30:90,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new A(1,1,3,4.5),toneDeltaPair:t=>new W(o.errorContainer,o.error,10,"nearer",!1)});o.onErrorContainer=x.fromPalette({name:"on_error_container",palette:t=>t.errorPalette,tone:t=>z(t)?t.isDark?90:10:t.isDark?90:30,background:t=>o.errorContainer,contrastCurve:new A(3,4.5,7,11)});o.primaryFixed=x.fromPalette({name:"primary_fixed",palette:t=>t.primaryPalette,tone:t=>z(t)?40:90,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new A(1,1,3,4.5),toneDeltaPair:t=>new W(o.primaryFixed,o.primaryFixedDim,10,"lighter",!0)});o.primaryFixedDim=x.fromPalette({name:"primary_fixed_dim",palette:t=>t.primaryPalette,tone:t=>z(t)?30:80,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new A(1,1,3,4.5),toneDeltaPair:t=>new W(o.primaryFixed,o.primaryFixedDim,10,"lighter",!0)});o.onPrimaryFixed=x.fromPalette({name:"on_primary_fixed",palette:t=>t.primaryPalette,tone:t=>z(t)?100:10,background:t=>o.primaryFixedDim,secondBackground:t=>o.primaryFixed,contrastCurve:new A(4.5,7,11,21)});o.onPrimaryFixedVariant=x.fromPalette({name:"on_primary_fixed_variant",palette:t=>t.primaryPalette,tone:t=>z(t)?90:30,background:t=>o.primaryFixedDim,secondBackground:t=>o.primaryFixed,contrastCurve:new A(3,4.5,7,11)});o.secondaryFixed=x.fromPalette({name:"secondary_fixed",palette:t=>t.secondaryPalette,tone:t=>z(t)?80:90,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new A(1,1,3,4.5),toneDeltaPair:t=>new W(o.secondaryFixed,o.secondaryFixedDim,10,"lighter",!0)});o.secondaryFixedDim=x.fromPalette({name:"secondary_fixed_dim",palette:t=>t.secondaryPalette,tone:t=>z(t)?70:80,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new A(1,1,3,4.5),toneDeltaPair:t=>new W(o.secondaryFixed,o.secondaryFixedDim,10,"lighter",!0)});o.onSecondaryFixed=x.fromPalette({name:"on_secondary_fixed",palette:t=>t.secondaryPalette,tone:t=>10,background:t=>o.secondaryFixedDim,secondBackground:t=>o.secondaryFixed,contrastCurve:new A(4.5,7,11,21)});o.onSecondaryFixedVariant=x.fromPalette({name:"on_secondary_fixed_variant",palette:t=>t.secondaryPalette,tone:t=>z(t)?25:30,background:t=>o.secondaryFixedDim,secondBackground:t=>o.secondaryFixed,contrastCurve:new A(3,4.5,7,11)});o.tertiaryFixed=x.fromPalette({name:"tertiary_fixed",palette:t=>t.tertiaryPalette,tone:t=>z(t)?40:90,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new A(1,1,3,4.5),toneDeltaPair:t=>new W(o.tertiaryFixed,o.tertiaryFixedDim,10,"lighter",!0)});o.tertiaryFixedDim=x.fromPalette({name:"tertiary_fixed_dim",palette:t=>t.tertiaryPalette,tone:t=>z(t)?30:80,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new A(1,1,3,4.5),toneDeltaPair:t=>new W(o.tertiaryFixed,o.tertiaryFixedDim,10,"lighter",!0)});o.onTertiaryFixed=x.fromPalette({name:"on_tertiary_fixed",palette:t=>t.tertiaryPalette,tone:t=>z(t)?100:10,background:t=>o.tertiaryFixedDim,secondBackground:t=>o.tertiaryFixed,contrastCurve:new A(4.5,7,11,21)});o.onTertiaryFixedVariant=x.fromPalette({name:"on_tertiary_fixed_variant",palette:t=>t.tertiaryPalette,tone:t=>z(t)?90:30,background:t=>o.tertiaryFixedDim,secondBackground:t=>o.tertiaryFixed,contrastCurve:new A(3,4.5,7,11)});var H=class{constructor(e){this.sourceColorArgb=e.sourceColorArgb,this.variant=e.variant,this.contrastLevel=e.contrastLevel,this.isDark=e.isDark,this.sourceColorHct=F.fromInt(e.sourceColorArgb),this.primaryPalette=e.primaryPalette,this.secondaryPalette=e.secondaryPalette,this.tertiaryPalette=e.tertiaryPalette,this.neutralPalette=e.neutralPalette,this.neutralVariantPalette=e.neutralVariantPalette,this.errorPalette=b.fromHueAndChroma(25,84)}static getRotatedHue(e,r,a){let n=e.hue;if(r.length!==a.length)throw new Error(`mismatch between hue length ${r.length} & rotations ${a.length}`);if(a.length===1)return G(e.hue+a[0]);let i=r.length;for(let s=0;s<=i-2;s++){let c=r[s],m=r[s+1];if(c<n&&n<m)return G(n+a[s])}return n}getArgb(e){return e.getArgb(this)}getHct(e){return e.getHct(this)}get primaryPaletteKeyColor(){return this.getArgb(o.primaryPaletteKeyColor)}get secondaryPaletteKeyColor(){return this.getArgb(o.secondaryPaletteKeyColor)}get tertiaryPaletteKeyColor(){return this.getArgb(o.tertiaryPaletteKeyColor)}get neutralPaletteKeyColor(){return this.getArgb(o.neutralPaletteKeyColor)}get neutralVariantPaletteKeyColor(){return this.getArgb(o.neutralVariantPaletteKeyColor)}get background(){return this.getArgb(o.background)}get onBackground(){return this.getArgb(o.onBackground)}get surface(){return this.getArgb(o.surface)}get surfaceDim(){return this.getArgb(o.surfaceDim)}get surfaceBright(){return this.getArgb(o.surfaceBright)}get surfaceContainerLowest(){return this.getArgb(o.surfaceContainerLowest)}get surfaceContainerLow(){return this.getArgb(o.surfaceContainerLow)}get surfaceContainer(){return this.getArgb(o.surfaceContainer)}get surfaceContainerHigh(){return this.getArgb(o.surfaceContainerHigh)}get surfaceContainerHighest(){return this.getArgb(o.surfaceContainerHighest)}get onSurface(){return this.getArgb(o.onSurface)}get surfaceVariant(){return this.getArgb(o.surfaceVariant)}get onSurfaceVariant(){return this.getArgb(o.onSurfaceVariant)}get inverseSurface(){return this.getArgb(o.inverseSurface)}get inverseOnSurface(){return this.getArgb(o.inverseOnSurface)}get outline(){return this.getArgb(o.outline)}get outlineVariant(){return this.getArgb(o.outlineVariant)}get shadow(){return this.getArgb(o.shadow)}get scrim(){return this.getArgb(o.scrim)}get surfaceTint(){return this.getArgb(o.surfaceTint)}get primary(){return this.getArgb(o.primary)}get onPrimary(){return this.getArgb(o.onPrimary)}get primaryContainer(){return this.getArgb(o.primaryContainer)}get onPrimaryContainer(){return this.getArgb(o.onPrimaryContainer)}get inversePrimary(){return this.getArgb(o.inversePrimary)}get secondary(){return this.getArgb(o.secondary)}get onSecondary(){return this.getArgb(o.onSecondary)}get secondaryContainer(){return this.getArgb(o.secondaryContainer)}get onSecondaryContainer(){return this.getArgb(o.onSecondaryContainer)}get tertiary(){return this.getArgb(o.tertiary)}get onTertiary(){return this.getArgb(o.onTertiary)}get tertiaryContainer(){return this.getArgb(o.tertiaryContainer)}get onTertiaryContainer(){return this.getArgb(o.onTertiaryContainer)}get error(){return this.getArgb(o.error)}get onError(){return this.getArgb(o.onError)}get errorContainer(){return this.getArgb(o.errorContainer)}get onErrorContainer(){return this.getArgb(o.onErrorContainer)}get primaryFixed(){return this.getArgb(o.primaryFixed)}get primaryFixedDim(){return this.getArgb(o.primaryFixedDim)}get onPrimaryFixed(){return this.getArgb(o.onPrimaryFixed)}get onPrimaryFixedVariant(){return this.getArgb(o.onPrimaryFixedVariant)}get secondaryFixed(){return this.getArgb(o.secondaryFixed)}get secondaryFixedDim(){return this.getArgb(o.secondaryFixedDim)}get onSecondaryFixed(){return this.getArgb(o.onSecondaryFixed)}get onSecondaryFixedVariant(){return this.getArgb(o.onSecondaryFixedVariant)}get tertiaryFixed(){return this.getArgb(o.tertiaryFixed)}get tertiaryFixedDim(){return this.getArgb(o.tertiaryFixedDim)}get onTertiaryFixed(){return this.getArgb(o.onTertiaryFixed)}get onTertiaryFixedVariant(){return this.getArgb(o.onTertiaryFixedVariant)}};var Tt=class t{constructor(e){this.input=e,this.hctsByTempCache=[],this.hctsByHueCache=[],this.tempsByHctCache=new Map,this.inputRelativeTemperatureCache=-1,this.complementCache=null}get hctsByTemp(){if(this.hctsByTempCache.length>0)return this.hctsByTempCache;let e=this.hctsByHue.concat([this.input]),r=this.tempsByHct;return e.sort((a,n)=>r.get(a)-r.get(n)),this.hctsByTempCache=e,e}get warmest(){return this.hctsByTemp[this.hctsByTemp.length-1]}get coldest(){return this.hctsByTemp[0]}analogous(e=5,r=12){let a=Math.round(this.input.hue),n=this.hctsByHue[a],i=this.relativeTemperature(n),s=[n],c=0;for(let g=0;g<360;g++){let p=Ct(a+g),P=this.hctsByHue[p],T=this.relativeTemperature(P),S=Math.abs(T-i);i=T,c+=S}let m=1,l=c/r,d=0;for(i=this.relativeTemperature(n);s.length<r;){let g=Ct(a+m),p=this.hctsByHue[g],P=this.relativeTemperature(p),T=Math.abs(P-i);d+=T;let S=s.length*l,C=d>=S,E=1;for(;C&&s.length<r;){s.push(p);let M=(s.length+E)*l;C=d>=M,E++}if(i=P,m++,m>360){for(;s.length<r;)s.push(p);break}}let h=[this.input],f=Math.floor((e-1)/2);for(let g=1;g<f+1;g++){let p=0-g;for(;p<0;)p=s.length+p;p>=s.length&&(p=p%s.length),h.splice(0,0,s[p])}let u=e-f-1;for(let g=1;g<u+1;g++){let p=g;for(;p<0;)p=s.length+p;p>=s.length&&(p=p%s.length),h.push(s[p])}return h}get complement(){if(this.complementCache!=null)return this.complementCache;let e=this.coldest.hue,r=this.tempsByHct.get(this.coldest),a=this.warmest.hue,i=this.tempsByHct.get(this.warmest)-r,s=t.isBetween(this.input.hue,e,a),c=s?a:e,m=s?e:a,l=1,d=1e3,h=this.hctsByHue[Math.round(this.input.hue)],f=1-this.inputRelativeTemperature;for(let u=0;u<=360;u+=1){let g=G(c+l*u);if(!t.isBetween(g,c,m))continue;let p=this.hctsByHue[Math.round(g)],P=(this.tempsByHct.get(p)-r)/i,T=Math.abs(f-P);T<d&&(d=T,h=p)}return this.complementCache=h,this.complementCache}relativeTemperature(e){let r=this.tempsByHct.get(this.warmest)-this.tempsByHct.get(this.coldest),a=this.tempsByHct.get(e)-this.tempsByHct.get(this.coldest);return r===0?.5:a/r}get inputRelativeTemperature(){return this.inputRelativeTemperatureCache>=0?this.inputRelativeTemperatureCache:(this.inputRelativeTemperatureCache=this.relativeTemperature(this.input),this.inputRelativeTemperatureCache)}get tempsByHct(){if(this.tempsByHctCache.size>0)return this.tempsByHctCache;let e=this.hctsByHue.concat([this.input]),r=new Map;for(let a of e)r.set(a,t.rawTemperature(a));return this.tempsByHctCache=r,r}get hctsByHue(){if(this.hctsByHueCache.length>0)return this.hctsByHueCache;let e=[];for(let r=0;r<=360;r+=1){let a=F.from(r,this.input.chroma,this.input.tone);e.push(a)}return this.hctsByHueCache=e,this.hctsByHueCache}static isBetween(e,r,a){return r<a?r<=e&&e<=a:r<=e||e<=a}static rawTemperature(e){let r=qt(e.toInt()),a=G(Math.atan2(r[2],r[1])*180/Math.PI),n=Math.sqrt(r[1]*r[1]+r[2]*r[2]);return-.5+.02*Math.pow(n,1.07)*Math.cos(G(a-50)*Math.PI/180)}};var Ot=class extends H{constructor(e,r,a){super({sourceColorArgb:e.toInt(),variant:N.CONTENT,contrastLevel:a,isDark:r,primaryPalette:b.fromHueAndChroma(e.hue,e.chroma),secondaryPalette:b.fromHueAndChroma(e.hue,Math.max(e.chroma-32,e.chroma*.5)),tertiaryPalette:b.fromInt(mt.fixIfDisliked(new Tt(e).analogous(3,6)[2]).toInt()),neutralPalette:b.fromHueAndChroma(e.hue,e.chroma/8),neutralVariantPalette:b.fromHueAndChroma(e.hue,e.chroma/8+4)})}};var bt=class t extends H{constructor(e,r,a){super({sourceColorArgb:e.toInt(),variant:N.EXPRESSIVE,contrastLevel:a,isDark:r,primaryPalette:b.fromHueAndChroma(G(e.hue+240),40),secondaryPalette:b.fromHueAndChroma(H.getRotatedHue(e,t.hues,t.secondaryRotations),24),tertiaryPalette:b.fromHueAndChroma(H.getRotatedHue(e,t.hues,t.tertiaryRotations),32),neutralPalette:b.fromHueAndChroma(e.hue+15,8),neutralVariantPalette:b.fromHueAndChroma(e.hue+15,12)})}};bt.hues=[0,21,51,121,151,191,271,321,360];bt.secondaryRotations=[45,95,45,20,45,90,45,45,45];bt.tertiaryRotations=[120,120,20,45,20,15,20,120,120];var Nt=class extends H{constructor(e,r,a){super({sourceColorArgb:e.toInt(),variant:N.FIDELITY,contrastLevel:a,isDark:r,primaryPalette:b.fromHueAndChroma(e.hue,e.chroma),secondaryPalette:b.fromHueAndChroma(e.hue,Math.max(e.chroma-32,e.chroma*.5)),tertiaryPalette:b.fromInt(mt.fixIfDisliked(new Tt(e).complement).toInt()),neutralPalette:b.fromHueAndChroma(e.hue,e.chroma/8),neutralVariantPalette:b.fromHueAndChroma(e.hue,e.chroma/8+4)})}};var Ht=class extends H{constructor(e,r,a){super({sourceColorArgb:e.toInt(),variant:N.FRUIT_SALAD,contrastLevel:a,isDark:r,primaryPalette:b.fromHueAndChroma(G(e.hue-50),48),secondaryPalette:b.fromHueAndChroma(G(e.hue-50),36),tertiaryPalette:b.fromHueAndChroma(e.hue,36),neutralPalette:b.fromHueAndChroma(e.hue,10),neutralVariantPalette:b.fromHueAndChroma(e.hue,16)})}};var Lt=class extends H{constructor(e,r,a){super({sourceColorArgb:e.toInt(),variant:N.MONOCHROME,contrastLevel:a,isDark:r,primaryPalette:b.fromHueAndChroma(e.hue,0),secondaryPalette:b.fromHueAndChroma(e.hue,0),tertiaryPalette:b.fromHueAndChroma(e.hue,0),neutralPalette:b.fromHueAndChroma(e.hue,0),neutralVariantPalette:b.fromHueAndChroma(e.hue,0)})}};var Et=class extends H{constructor(e,r,a){super({sourceColorArgb:e.toInt(),variant:N.NEUTRAL,contrastLevel:a,isDark:r,primaryPalette:b.fromHueAndChroma(e.hue,12),secondaryPalette:b.fromHueAndChroma(e.hue,8),tertiaryPalette:b.fromHueAndChroma(e.hue,16),neutralPalette:b.fromHueAndChroma(e.hue,2),neutralVariantPalette:b.fromHueAndChroma(e.hue,2)})}};var zt=class extends H{constructor(e,r,a){super({sourceColorArgb:e.toInt(),variant:N.RAINBOW,contrastLevel:a,isDark:r,primaryPalette:b.fromHueAndChroma(e.hue,48),secondaryPalette:b.fromHueAndChroma(e.hue,16),tertiaryPalette:b.fromHueAndChroma(G(e.hue+60),24),neutralPalette:b.fromHueAndChroma(e.hue,0),neutralVariantPalette:b.fromHueAndChroma(e.hue,0)})}};var Vt=class extends H{constructor(e,r,a){super({sourceColorArgb:e.toInt(),variant:N.TONAL_SPOT,contrastLevel:a,isDark:r,primaryPalette:b.fromHueAndChroma(e.hue,36),secondaryPalette:b.fromHueAndChroma(e.hue,16),tertiaryPalette:b.fromHueAndChroma(G(e.hue+60),24),neutralPalette:b.fromHueAndChroma(e.hue,6),neutralVariantPalette:b.fromHueAndChroma(e.hue,8)})}};var yt=class t extends H{constructor(e,r,a){super({sourceColorArgb:e.toInt(),variant:N.VIBRANT,contrastLevel:a,isDark:r,primaryPalette:b.fromHueAndChroma(e.hue,200),secondaryPalette:b.fromHueAndChroma(H.getRotatedHue(e,t.hues,t.secondaryRotations),24),tertiaryPalette:b.fromHueAndChroma(H.getRotatedHue(e,t.hues,t.tertiaryRotations),32),neutralPalette:b.fromHueAndChroma(e.hue,10),neutralVariantPalette:b.fromHueAndChroma(e.hue,12)})}};yt.hues=[0,41,61,101,131,181,251,301,360];yt.secondaryRotations=[18,15,10,12,15,18,15,12,12];yt.tertiaryRotations=[35,30,20,25,30,35,30,25,25];var ve={desired:4,fallbackColorARGB:4282549748,filter:!0};function Me(t,e){return t.score>e.score?-1:t.score<e.score?1:0}var lt=class t{constructor(){}static score(e,r){let{desired:a,fallbackColorARGB:n,filter:i}={...ve,...r},s=[],c=new Array(360).fill(0),m=0;for(let[u,g]of e.entries()){let p=F.fromInt(u);s.push(p);let P=Math.floor(p.hue);c[P]+=g,m+=g}let l=new Array(360).fill(0);for(let u=0;u<360;u++){let g=c[u]/m;for(let p=u-14;p<u+16;p++){let P=Ct(p);l[P]+=g}}let d=new Array;for(let u of s){let g=Ct(Math.round(u.hue)),p=l[g];if(i&&(u.chroma<t.CUTOFF_CHROMA||p<=t.CUTOFF_EXCITED_PROPORTION))continue;let P=p*100*t.WEIGHT_PROPORTION,T=u.chroma<t.TARGET_CHROMA?t.WEIGHT_CHROMA_BELOW:t.WEIGHT_CHROMA_ABOVE,S=(u.chroma-t.TARGET_CHROMA)*T,C=P+S;d.push({hct:u,score:C})}d.sort(Me);let h=[];for(let u=90;u>=15;u--){h.length=0;for(let{hct:g}of d)if(h.find(P=>_t(g.hue,P.hue)<u)||h.push(g),h.length>=a)break;if(h.length>=a)break}let f=[];h.length===0&&f.push(n);for(let u of h)f.push(u.toInt());return f}};lt.TARGET_CHROMA=48;lt.WEIGHT_PROPORTION=.7;lt.WEIGHT_CHROMA_ABOVE=.3;lt.WEIGHT_CHROMA_BELOW=.1;lt.CUTOFF_CHROMA=5;lt.CUTOFF_EXCITED_PROPORTION=.01;var se=Object.freeze(["content","tonal-spot","fruit-salad","rainbow","monochrome","vibrant","faithful","soft","dysfunctional","muted"]),ct=Object.freeze({enabled:!0,dynamic:!0,market:"zh-CN",paletteMode:"content",mode:"schedule",day:"07:00",night:"19:00",strength:28});function $t(t){return Number.isFinite(t)?Math.round(Math.min(100,Math.max(10,t))):ct.strength}function ie(t){return Math.sqrt(1-$t(t)/100)}var Ut=Object.freeze({light:.56,dark:.62});function Te(t){return t==="dark"?`rgba(0, 0, 0, ${Ut.dark})`:`rgba(255, 255, 255, ${Ut.light})`}function Se(t={}){(!t||typeof t!="object")&&(t={});let e=r=>typeof r=="string"&&/^([01]\d|2[0-3]):[0-5]\d$/.test(r);return{enabled:typeof t.enabled=="boolean"?t.enabled:!0,dynamic:typeof t.dynamic=="boolean"?t.dynamic:!0,market:["zh-CN","en-US"].includes(t.market)?t.market:ct.market,paletteMode:se.includes(t.paletteMode)?t.paletteMode:ct.paletteMode,mode:["follow","schedule","system","light","dark"].includes(t.mode)?t.mode:"schedule",day:e(t.day)?t.day:ct.day,night:e(t.night)?t.night:ct.night,strength:$t(t.strength)}}function Ie(t,e,r){let a=c=>Number(c.slice(0,2))*60+Number(c.slice(3)),n=t.getHours()*60+t.getMinutes(),i=a(e),s=a(r);return i===s?null:(i<s?n>=i&&n<s:n>=i||n<s)?"light":"dark"}function De(t=new Date){return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function le([t,e,r]){t/=255,e/=255,r/=255;let a=Math.max(t,e,r),n=Math.min(t,e,r),i=a-n,s=(a+n)/2,c=0,m=0;return i&&(m=i/(1-Math.abs(2*s-1)),c=a===t?(e-r)/i%6:a===e?(r-t)/i+2:(t-e)/i+4,c=(c*60+360)%360),[c,m*100,s*100]}function Fe([t,e,r]){e/=100,r/=100;let a=(1-Math.abs(2*r-1))*e,n=a*(1-Math.abs(t/60%2-1)),i=r-a/2;return(t<60?[a,n,0]:t<120?[n,a,0]:t<180?[0,a,n]:t<240?[0,n,a]:t<300?[n,0,a]:[a,0,n]).map(c=>Math.round((c+i)*255))}function Yt(t){let e=t.map(r=>(r/=255,r<=.04045?r/12.92:((r+.055)/1.055)**2.4));return e[0]*.2126+e[1]*.7152+e[2]*.0722}function ht(t,e){let r=Yt(t),a=Yt(e);return(Math.max(r,a)+.05)/(Math.min(r,a)+.05)}function Be(t){let e=new Map;for(let a=0;a+3<t.length;a+=4){if(t[a+3]<200)continue;let n=[t[a],t[a+1],t[a+2]],[i,s,c]=le(n);if(s<18||c<12||c>88)continue;let m=Math.floor(i/15),l=(.25+s/100)*(1-Math.abs(c-50)/65),d=e.get(m)||{weight:0,rgb:[0,0,0]};d.weight+=l,n.forEach((h,f)=>{d.rgb[f]+=h*l}),e.set(m,d)}let r=[...e.values()].sort((a,n)=>n.weight-a.weight)[0];if(!r){let a=0,n=[0,0,0];for(let i=0;i+3<t.length;i+=4)t[i+3]>=200&&(a++,n.forEach((s,c)=>{n[c]+=t[i+c]}));return a?n.map(i=>Math.round(i/a)):[92,116,132]}return r.rgb.map(a=>Math.round(a/r.weight))}var Jt=class extends Et{constructor(e,r,a){super(e,r,a);let n=e.hue;Object.assign(this,{primaryPalette:b.fromHueAndChroma(n,Math.min(e.chroma,20)),secondaryPalette:b.fromHueAndChroma(n,Math.min(e.chroma,8)),tertiaryPalette:b.fromHueAndChroma((n+30)%360,Math.min(e.chroma,12)),neutralPalette:b.fromHueAndChroma(n,2),neutralVariantPalette:b.fromHueAndChroma(n,4)})}},ce=Object.freeze({content:Ot,"tonal-spot":Vt,"fruit-salad":Ht,rainbow:zt,monochrome:Lt,vibrant:yt,faithful:Nt,soft:Et,dysfunctional:bt,muted:Jt}),St=new Map,$=t=>[Pt(t),At(t),vt(t)],Ee=t=>`rgb(${t.join(", ")})`;function Re(t,e){let r=gt(...t),a=`${e}:${r}`;if(!St.has(a)){let n=ce[e],i=F.fromInt(r);St.set(a,[new n(i,!1,0),new n(i,!0,0)]),St.size>22&&St.delete(St.keys().next().value)}return St.get(a)}function Oe(t,e,r){let a={},n=ie(e);for(let[i,s]of Re(t,r).entries()){let c=i===1,m=c?"dark":"light",l={"--dsw-alias-bg-base":$(s.surface),"--dsw-alias-bg-layer-1":$(s.surfaceContainerLow),"--dsw-alias-bg-layer-2":$(s.surfaceContainer),"--dsw-specific-sidebar-fill":$(s.surfaceContainerHigh),"--dsw-alias-border-l1":$(s.outlineVariant),"--dsw-alias-border-l2":$(s.outline)},d=(w,B,L)=>w.map((j,_)=>Math.round(j*(1-L)+B[_]*L));l["--dsw-alias-bg-layer-2"]=d(l["--dsw-alias-bg-layer-2"],$(s.secondaryContainer),.08),l["--dsw-specific-sidebar-fill"]=d(l["--dsw-specific-sidebar-fill"],$(s.tertiaryContainer),.18);let h=l["--dsw-alias-bg-layer-1"],f=d(l["--dsw-alias-bg-layer-2"],$(s.secondaryContainer),.2);l["--dsw-alias-bg-overlay"]=d(h,$(s.secondaryContainer),.04);let u=d(h,$(s.secondaryContainer),.24),g={"--dsw-alias-bg-layer-3":f,"--dsw-alias-bg-module-platform":f,"--dsw-alias-bg-multi-select":f,"--dsw-alias-card-fill":h,"--dsw-alias-card-fill-hover":u,"--dsw-alias-card-tile-fill":h,"--dsw-alias-onboarding-card-fill":h,"--dsw-alias-onboarding-secondary-fill":l["--dsw-alias-bg-layer-2"],"--dsw-alias-button-elevated-fill":h,"--dsw-alias-button-floating-fill":h,"--dsw-alias-button-floating-hover":u,"--dsw-alias-button-ghost-active-fill":f,"--dsw-alias-button-ghost-active-hover":u,"--dsw-alias-button-primary-dimmed":f,"--dsw-alias-interactive-bg-active":f,"--dsw-alias-interactive-bg-hover":u,"--dsw-alias-interactive-bg-hover-solid":u,"--dsw-alias-interactive-bg-hover-accent":f,"--dsw-menu-surface-fill":l["--dsw-alias-bg-overlay"],"--dsw-alias-menu-group-header-fill":h,"--dsw-specific-menu":l["--dsw-alias-bg-overlay"],"--dsw-specific-input-major":h,"--dsw-specific-login-input":l["--dsw-alias-bg-layer-2"],"--dsw-specific-selector":f,"--dsw-specific-tip":h,"--dsw-specific-sidebar-nav-item-active":f,"--dsw-specific-sidebar-nav-item-active-accent":f,"--dsw-specific-bubble":l["--dsw-alias-bg-layer-2"],"--dsw-specific-bubble-highlight":f,"--dsw-alias-markdown-code-block":l["--dsw-alias-bg-layer-2"],"--dsw-alias-markdown-code-block-banner":h,"--dsw-alias-markdown-inline-code":l["--dsw-alias-bg-layer-2"],"--dsw-alias-markdown-code-segment-selected":h,"--dsw-alias-markdown-code-segment-unselected":l["--dsw-alias-bg-layer-2"],"--dsw-alias-markdown-placeholder":f,"--dsw-alias-markdown-tag":f,"--dsw-alias-markdown-citation":f};Object.assign(l,g);let p=[h,l["--dsw-alias-bg-layer-2"],l["--dsw-alias-bg-overlay"],l["--dsw-specific-sidebar-fill"],f,u],P=Ut[m],T=c?0:255;for(let w of[0,255]){let B=w*(1-P)+T*P;p.push([B,B,B]),p.push(l["--dsw-alias-bg-base"].map(L=>L*n+B*(1-n)))}let S=(w,B,L=4.6)=>{let j=Math.round(B);for(;p.some(_=>ht($(w.tone(j)),_)<L)&&j>0&&j<100;)j+=c?1:-1;return $(w.tone(j))},C=S(s.primaryPalette,F.fromInt(s.primary).tone),E=$(s.primaryPalette.tone(Math.max(0,Math.min(100,F.fromInt(gt(...C)).tone+(c?7:-7))))),M=[[0,0,0],[255,255,255]].sort((w,B)=>Math.min(ht(B,C),ht(B,E))-Math.min(ht(w,C),ht(w,E)))[0];l["--dsw-alias-brand-primary"]=C,l["--dsw-alias-label-primary"]=S(s.neutralPalette,F.fromInt(s.onSurface).tone),l["--dsw-alias-label-secondary"]=S(s.neutralVariantPalette,F.fromInt(s.onSurfaceVariant).tone);let O=S(s.neutralVariantPalette,c?70:50);for(let w of["--dsw-alias-label-tertiary","--dsw-alias-label-caption","--dsw-alias-label-dimmed"])l[w]=O;for(let w of["--dsw-alias-brand-text","--dsw-alias-brand-primary-new-colorprimary-new-color","--dsw-alias-link"])l[w]=C;for(let w of["--dsw-alias-label-primary-bluish","--dsw-alias-label-primary-dimmed","--dsw-alias-menu-icon"])l[w]=l["--dsw-alias-label-primary"];for(let w of["--dsw-alias-button-primary-fill","--dsw-alias-button-contrast-fill"])l[w]=C;l["--dsw-alias-button-primary-hover"]=E,l["--dsw-alias-button-info-fill"]=$(s.primaryPalette.tone(35)),l["--dsw-alias-button-info-hover"]=$(s.primaryPalette.tone(28));for(let w of["--dsw-alias-label-primary-foreground","--dsw-alias-label-primary-inverted"])l[w]=M;l["--dsw-focus-ring-color"]=C,l["--dsw-alias-border-l2"]=S(s.neutralVariantPalette,c?60:50,3.1);for(let w of["--dsw-alias-border-selected","--dsw-alias-button-ghost-active-border"])l[w]=C;for(let w of["--dsw-alias-border-l3","--dsw-alias-border-l4","--dsw-alias-border-l2-darkmode-thin","--dsw-alias-onboarding-checkbox-border","--dsw-alias-scrollbar-bg-l1","--dsw-alias-scrollbar-bg-l2"])l[w]=l["--dsw-alias-border-l2"];for(let w of["--dsw-alias-scrollbar-hover-l1","--dsw-alias-scrollbar-hover-l2"])l[w]=C;let I=l["--dsw-alias-border-l3"];l["--dsw-alias-switch-thumb"]=ht([0,0,0],I)>ht([255,255,255],I)?[0,0,0]:[255,255,255];let R=$(s.neutralPalette.tone(14)),V=$(s.neutralPalette.tone(98));for(let w of["--dsw-alias-tooltip-bg","--dsw-alias-toast-bg","--dsw-alias-hovercard-bg"])l[w]=R;for(let w of["--dsw-alias-tooltip-label","--dsw-alias-toast-label","--dsw-alias-hovercard-label-primary"])l[w]=V;l["--dsw-alias-tooltip-key-bg"]=d(R,[255,255,255],.18),l["--dsw-alias-toast-action"]=$(s.primaryPalette.tone(80)),l["--dsw-alias-hovercard-label-secondary"]=$(s.neutralPalette.tone(85)),l["--dsw-alias-hovercard-label-tertiary"]=$(s.neutralPalette.tone(78));for(let[w,B]of Object.entries(l))a[w]||={},a[w][m]=w==="--dsw-alias-bg-base"?`rgba(${B.join(", ")}, ${n})`:Ee(B)}return a}function Ne(t,e=ct.strength,r=ct.paletteMode){e=$t(e);let a=[92,116,132];t=(Array.isArray(t)||ArrayBuffer.isView(t))&&t.length>=3?a.map((i,s)=>Number.isFinite(t[s])?Math.round(Math.max(0,Math.min(255,t[s]))):i):a;let n=typeof r=="string"&&Object.hasOwn(ce,r)?r:ct.paletteMode;return Oe(t,e,n)}var de="dsh.bing-daily-theme.preferences.v1",Xt="dsh.bing-daily-theme.boot.v1",Zt="bdt-boot-theme";function me(t,e,r){if(!t.enabled||!t.dynamic)return null;let a={background:"--dsw-alias-bg-layer-1",primary:"--dsw-alias-label-primary",secondary:"--dsw-alias-label-secondary",tertiary:"--dsw-alias-label-tertiary",border:"--dsw-alias-border-l2",brand:"--dsw-alias-brand-primary"},n={};for(let i of["light","dark"])n[i]=Object.fromEntries(Object.entries(a).map(([s,c])=>[s,e[c][i]]));return{version:1,market:t.market||"zh-CN",paletteMode:t.paletteMode,strength:t.strength,colors:n,imageUrl:r}}var he="body .nUhMVa_confirmPanel{--fold-bg:var(--dsw-alias-bg-layer-2)!important;--fold-border:var(--dsw-alias-border-l2)!important;--fold-ink:var(--dsw-alias-label-primary)!important;--fold-on-ink:var(--dsw-alias-bg-layer-1)!important}";var He=Object.freeze({canvas:"--dsw-specific-sidebar-fill",surface:"--dsw-alias-bg-layer-1",raised:"--dsw-alias-bg-layer-2",selected:"--dsw-specific-sidebar-nav-item-active",ink:"--dsw-alias-label-primary",muted:"--dsw-alias-label-secondary",border:"--dsw-alias-border-l2",brand:"--dsw-alias-brand-primary","on-brand":"--dsw-alias-label-primary-foreground",bubble:"--dsw-specific-bubble",code:"--dsw-alias-markdown-code-block",input:"--dsw-specific-input-major"});function pe(t,e){let r=e==="dark"?"dark":"light";return Object.fromEntries(Object.entries(He).map(([a,n])=>[`--bdt-mini-${a}`,t[n][r]]))}function fe(t,e){return t("span",{className:"bdt-mini-split","aria-hidden":!0,style:pe(e,"light")},ue(t,e,"light"),ue(t,e,"dark"),t("svg",{className:"bdt-mini-diagonal",viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-hidden":!0,focusable:!1},t("line",{x1:100,y1:0,x2:0,y2:100,vectorEffect:"non-scaling-stroke"})))}function ue(t,e,r){return t("span",{className:`bdt-mini bdt-mini-${r}`,"aria-hidden":!0,style:pe(e,r)},t("span",{className:"bdt-mini-app"},t("span",{className:"bdt-mini-sidebar"},t("span",{className:"bdt-mini-logo"},"DSH"),t("span",{className:"bdt-mini-nav bdt-mini-nav-active"},t("span",{className:"bdt-mini-line"})),t("span",{className:"bdt-mini-nav"},t("span",{className:"bdt-mini-line"})),t("span",{className:"bdt-mini-nav"},t("span",{className:"bdt-mini-line bdt-mini-short"})),t("span",{className:"bdt-mini-sidebar-footer"},t("span",{className:"bdt-mini-line bdt-mini-short"}))),t("span",{className:"bdt-mini-chat"},t("span",{className:"bdt-mini-heading"},t("span",{className:"bdt-mini-line"}),t("span",{className:"bdt-mini-badge"})),t("span",{className:"bdt-mini-bubble"},t("span",{className:"bdt-mini-line"})),t("span",{className:"bdt-mini-reply"},t("span",{className:"bdt-mini-line"}),t("span",{className:"bdt-mini-line bdt-mini-short"}),t("span",{className:"bdt-mini-code"},t("span",{className:"bdt-mini-code-line"}),t("span",{className:"bdt-mini-code-line bdt-mini-short"}))),t("span",{className:"bdt-mini-composer"},t("span",{className:"bdt-mini-line"}),t("span",{className:"bdt-mini-send"},"\u2191")))))}var ge=`
|
|
3
|
+
.bdt-mini-split{position:relative;display:block;height:116px;overflow:hidden;border-radius:7px;color:var(--bdt-mini-border);pointer-events:none;user-select:none}
|
|
4
|
+
.bdt-mini-split>.bdt-mini{position:absolute;inset:0}.bdt-mini-light{clip-path:polygon(0 0,100% 0,0 100%)}.bdt-mini-dark{clip-path:polygon(100% 0,100% 100%,0 100%)}
|
|
5
|
+
.bdt-mini-diagonal{position:absolute;inset:0;width:100%;height:100%;fill:none;stroke:currentColor;stroke-width:1.5}
|
|
6
|
+
.bdt-mini{display:block;border-radius:8px;color:var(--bdt-mini-ink);font-size:9px;line-height:1.2;user-select:none;pointer-events:none}
|
|
7
|
+
.bdt-mini-app{display:grid;grid-template-columns:29% minmax(0,1fr);height:116px;overflow:hidden;border:1px solid var(--bdt-mini-border);border-radius:7px;background:var(--bdt-mini-surface)}
|
|
8
|
+
.bdt-mini-sidebar{display:flex;flex-direction:column;gap:5px;min-width:0;padding:7px 5px;background:var(--bdt-mini-canvas);border-inline-end:1px solid var(--bdt-mini-border)}
|
|
9
|
+
.bdt-mini-logo{display:block;padding:0 3px 3px;font-weight:700;font-size:9px;letter-spacing:.3px}
|
|
10
|
+
.bdt-mini-nav{display:flex;align-items:center;min-height:12px;padding:4px;border-radius:3px;color:var(--bdt-mini-muted)}.bdt-mini-nav-active{background:var(--bdt-mini-selected);color:var(--bdt-mini-brand)}.bdt-mini-sidebar-footer{display:block;margin-top:auto;padding:4px;color:var(--bdt-mini-muted)}
|
|
11
|
+
.bdt-mini-line{display:block;width:85%;height:3px;flex-shrink:1;border-radius:2px;background:currentColor}.bdt-mini-short{width:58%}
|
|
12
|
+
.bdt-mini-chat{display:flex;flex-direction:column;gap:6px;min-width:0;padding:7px}
|
|
13
|
+
.bdt-mini-heading{display:flex;align-items:center;justify-content:space-between;gap:8px;color:var(--bdt-mini-muted)}.bdt-mini-heading>.bdt-mini-line{width:52%}.bdt-mini-badge{display:block;width:13px;height:6px;border-radius:3px;background:var(--bdt-mini-raised)}
|
|
14
|
+
.bdt-mini-bubble{display:block;align-self:flex-end;width:75%;padding:5px 6px;border-radius:5px;background:var(--bdt-mini-bubble)}
|
|
15
|
+
.bdt-mini-reply{display:flex;flex-direction:column;gap:4px;min-width:0}.bdt-mini-code{display:flex;flex-direction:column;gap:3px;padding:5px 6px;border-radius:4px;background:var(--bdt-mini-code)}.bdt-mini-code-line{display:block;width:80%;height:2px;border-radius:2px;background:var(--bdt-mini-muted)}.bdt-mini-code-line.bdt-mini-short{width:54%}
|
|
16
|
+
.bdt-mini-composer{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:22px;margin-top:auto;padding:3px 4px 3px 6px;border:1px solid var(--bdt-mini-border);border-radius:5px;background:var(--bdt-mini-input);color:var(--bdt-mini-muted)}.bdt-mini-composer>.bdt-mini-line{width:48%}.bdt-mini-send{display:flex;align-items:center;justify-content:center;flex:0 0 14px;height:14px;border-radius:4px;background:var(--bdt-mini-brand);color:var(--bdt-mini-on-brand);font-size:11px;font-weight:600}
|
|
17
|
+
`;function be(t,e,r,a){let n=t.createElement,i="bing-daily-theme",s="@nzlov/dsh-bing-wallpaper",c=de;return{inject:["slots","theme","locale"],apply(m){m.effect(()=>m.locale.register(i,"en",r.en)),m.effect(()=>m.locale.register(i,"zh",r.zh));let l=m.locale.bind(i),d;try{d=e.normalizeSettings(JSON.parse(localStorage.getItem(c)||"{}"))}catch{d=e.normalizeSettings()}let h={settings:d,busy:!1,issue:"",meta:null,url:"",accent:[92,116,132],scheme:m.theme.getTheme().active.colorScheme,storageIssue:!1},f=new Set,u=y=>{h={...h,...y},f.forEach(k=>k())},g=y=>(f.add(y),()=>f.delete(y)),p=()=>t.useSyncExternalStore(g,()=>h),P=!0,T,S,C="",E=a(m.theme,()=>{d={...d,mode:"follow"},R(),u({settings:d})},e.scheduledScheme),M=0,O="",I=0;function R(){try{localStorage.setItem(c,JSON.stringify(d)),u({storageIssue:!1})}catch{u({storageIssue:!0})}}function V(){E.restore()}function w(){E.sync(d)}function B(){if(!d.enabled||!d.dynamic||h.meta&&h.meta.market!==d.market)try{localStorage.removeItem(Xt)}catch{}if(!d.enabled||!h.url){T?.(),T=void 0;return}let y=e.makeTokens(d.dynamic?h.accent:[112,112,112],d.strength,d.dynamic?d.paletteMode:"monochrome");if(!d.dynamic)for(let D of Object.keys(y))D!=="--dsw-alias-bg-base"&&delete y[D];let k=T;if(T=m.theme.overrideTokens(s,y),k?.(),d.dynamic&&h.meta?.market===d.market)try{localStorage.setItem(Xt,JSON.stringify(me(d,y,h.meta?.imageUrl)))}catch{}}function L(y){let k=e.normalizeSettings({...d,...y});if(k.day===k.night){u({issue:"sameTime"});return}if(JSON.stringify(k)===JSON.stringify(d))return;let D=d.enabled,U=k.market!==d.market;U&&(I++,S?.abort(),M=0,O="",u({busy:!1})),(k.mode!==d.mode||!k.enabled)&&V(),d=k,R(),u({settings:d,issue:""}),B(),w(),d.enabled?(!D||U)&&_():(I++,S?.abort(),u({busy:!1}))}async function j(y,k){let D=URL.createObjectURL(y),U=new Image,Z;try{if(k.throwIfAborted(),U.src=D,await Promise.race([U.decode(),new Promise((v,J)=>{Z=()=>J(new DOMException("Aborted","AbortError")),k.addEventListener("abort",Z,{once:!0})})]),k.aborted)throw new DOMException("Aborted","AbortError");let q=document.createElement("canvas");q.width=64,q.height=64;let Q=q.getContext("2d",{willReadFrequently:!0});if(!Q)throw new Error("Canvas unavailable");Q.drawImage(U,0,0,64,64);let tt=e.extractAccent(Q.getImageData(0,0,64,64).data);return{url:D,accent:tt}}catch(q){throw URL.revokeObjectURL(D),q}finally{Z&&k.removeEventListener("abort",Z)}}async function _(){if(!P||!d.enabled||h.busy)return;let y=++I,k=d.market,D=new AbortController;S=D;let U=D.signal,Z=setTimeout(()=>D.abort(),3e4);u({busy:!0,issue:""}),M=Date.now();let q;try{let Q=await fetch(`/bing-daily-theme/api/daily?market=${k}`,{signal:U,credentials:"same-origin",cache:"no-store"});if(!Q.ok)throw new Error(`Metadata HTTP ${Q.status}`);let tt=await Q.json(),v=k==="en-US"?/^\/bing-daily-theme\/api\/image\?market=en-US&id=OHR\.[A-Za-z0-9][A-Za-z0-9_-]*_1920x1080\.jpg$/:/^\/bing-daily-theme\/api\/image\?id=OHR\.[A-Za-z0-9][A-Za-z0-9_-]*_1920x1080\.jpg$/;if(tt.market!==k||typeof tt.imageUrl!="string"||tt.imageUrl.length>300||!v.test(tt.imageUrl))throw new Error("Invalid wallpaper source or URL");if(!h.meta||tt.imageUrl!==h.meta.imageUrl||!h.url){let ut=await fetch(tt.imageUrl,{signal:U,credentials:"same-origin"});if(!ut.ok)throw new Error(`Image HTTP ${ut.status}`);let jt=await ut.blob();if(jt.size>12*1024*1024||!jt.type.startsWith("image/"))throw new Error("Invalid wallpaper image");q=await j(jt,U)}if(!P||y!==I){q&&URL.revokeObjectURL(q.url);return}let J=C;q&&(C=q.url),u({meta:tt,...q||{},issue:tt.stale?"stale":""}),B(),J&&J!==C&&URL.revokeObjectURL(J),O=e.localDate()}catch{P&&y===I&&u({issue:h.url?h.meta?.market!==k?"sourceFailed":"fetchFailed":"firstFetchFailed"})}finally{clearTimeout(Z),P&&y===I&&u({busy:!1})}}function dt(){w(),d.enabled&&(e.localDate()!==O||h.meta?.market!==d.market||["fetchFailed","firstFetchFailed","sourceFailed","stale"].includes(h.issue)||Date.now()-M>=36e5)&&Date.now()-M>=6e4&&_()}m.on("theme/change",y=>{u({scheme:y.active.colorScheme}),E.changed(y)});function wt(){t.useSyncExternalStore(y=>m.locale.subscribe(y),()=>m.locale.getSnapshot())}let ot=`
|
|
18
|
+
.bdt-page{max-width:720px;padding:24px;color:var(--dsw-alias-label-primary);font-size:14px;line-height:1.6}
|
|
19
|
+
.bdt-page h2{font-size:20px;margin:0 0 16px;font-weight:600}.bdt-page p{margin:6px 0 18px;color:var(--dsw-alias-label-secondary)}
|
|
20
|
+
.bdt-photo{position:relative;margin:0;overflow:hidden;border-radius:12px;background:var(--dsw-alias-bg-layer-2)}.bdt-preview{width:100%;aspect-ratio:16/9;min-height:240px;object-fit:cover;display:block;background:var(--dsw-alias-bg-layer-2)}
|
|
21
|
+
.bdt-card{padding:16px;border:1px solid var(--dsw-alias-border-l1);border-radius:12px;background:var(--dsw-alias-bg-layer-1);margin:16px 0}
|
|
22
|
+
.bdt-row{display:flex;justify-content:space-between;align-items:center;gap:16px;padding:12px 0;flex-wrap:wrap}.bdt-row+ .bdt-row{border-top:1px solid var(--dsw-alias-border-l1)}
|
|
23
|
+
.bdt-control{display:flex;gap:10px;align-items:center;flex-wrap:wrap}.bdt-page select,.bdt-page input[type=time],.bdt-page button{font:inherit;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:8px;padding:7px 10px;min-height:36px;max-width:100%}
|
|
24
|
+
.bdt-page button{cursor:pointer}.bdt-page button:disabled{cursor:wait;opacity:.55}.bdt-page :focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:3px}.bdt-page input{accent-color:var(--dsw-alias-brand-primary)}
|
|
25
|
+
.bdt-page a{color:var(--dsw-alias-brand-primary)}.bdt-muted{color:var(--dsw-alias-label-secondary);font-size:12px}.bdt-swatches{display:flex;gap:8px;margin-top:10px}.bdt-swatch{width:24px;height:24px;border-radius:50%;border:1px solid var(--dsw-alias-border-l2)}
|
|
26
|
+
.bdt-photo-caption{position:absolute;inset:auto 0 0;max-height:calc(100% - 64px);overflow:auto;padding:30px 16px 14px;color:var(--dsw-alias-tooltip-label);background:linear-gradient(to bottom,transparent,color-mix(in srgb,var(--dsw-alias-tooltip-bg) 82%,transparent) 26px,color-mix(in srgb,var(--dsw-alias-tooltip-bg) 90%,transparent));font-size:12px;line-height:1.5;overflow-wrap:anywhere}
|
|
27
|
+
.bdt-photo-heading{display:flex;align-items:baseline;flex-wrap:wrap;gap:4px 10px}.bdt-photo-heading strong{min-width:0;font-size:14px}.bdt-photo-date{white-space:nowrap}.bdt-photo-details{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:5px}.bdt-page .bdt-photo-caption a{min-width:0;color:inherit;text-underline-offset:2px}.bdt-photo-caption .bdt-swatches{flex-shrink:0;margin:0;gap:6px}.bdt-photo-caption .bdt-swatch{width:20px;height:20px;border-color:color-mix(in srgb,var(--dsw-alias-tooltip-label) 55%,transparent)}
|
|
28
|
+
.bdt-page .bdt-photo-refresh{position:absolute;top:12px;inset-inline-end:12px;display:flex;align-items:center;justify-content:center;width:44px;height:44px;min-height:44px;padding:0;border-radius:50%;border:1px solid color-mix(in srgb,var(--dsw-alias-tooltip-label) 55%,transparent);background:color-mix(in srgb,var(--dsw-alias-tooltip-bg) 86%,transparent);color:var(--dsw-alias-tooltip-label)}.bdt-photo-refresh svg{width:20px;height:20px}.bdt-page .bdt-photo-refresh:disabled{cursor:not-allowed}.bdt-page .bdt-photo-refresh[aria-busy=true]{cursor:wait}.bdt-page .bdt-photo-refresh:focus-visible{outline-color:var(--dsw-alias-tooltip-label);box-shadow:0 0 0 5px var(--dsw-alias-tooltip-bg)}.bdt-photo-refresh[aria-busy=true] svg{animation:bdt-refresh-spin 1s linear infinite}.bdt-photo-status{display:block;margin:8px 0 0;color:var(--dsw-alias-label-secondary);font-size:12px}
|
|
29
|
+
@keyframes bdt-refresh-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.bdt-photo-refresh[aria-busy=true] svg{animation:none}}
|
|
30
|
+
.bdt-palette-group{min-width:0;padding:12px 0;margin:0;border:0}.bdt-palette-group legend{padding:0;font:inherit}.bdt-palette-group+.bdt-row{border-top:1px solid var(--dsw-alias-border-l1)}
|
|
31
|
+
.bdt-palette-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr));gap:12px;margin-top:12px}
|
|
32
|
+
.bdt-palette-option{display:block;position:relative;min-width:0}.bdt-palette-choice{position:absolute;inset-inline-start:12px;top:12px;width:1px;height:1px;opacity:0;margin:0}
|
|
33
|
+
.bdt-palette-card{display:flex;flex-direction:column;gap:9px;height:100%;padding:8px;border:1px solid var(--dsw-alias-border-l2);border-radius:10px;background:var(--dsw-alias-bg-layer-1);cursor:pointer}
|
|
34
|
+
.bdt-palette-choice:enabled+.bdt-palette-card:hover{border-color:var(--dsw-alias-brand-primary)}.bdt-palette-choice:checked+.bdt-palette-card{border-color:var(--dsw-alias-brand-primary);box-shadow:0 0 0 1px var(--dsw-alias-brand-primary)}.bdt-palette-choice:focus-visible+.bdt-palette-card{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:4px}
|
|
35
|
+
.bdt-palette-caption{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:24px}.bdt-palette-name{min-width:0;overflow-wrap:anywhere;line-height:1.4}.bdt-palette-check{display:flex;align-items:center;justify-content:center;flex:0 0 18px;height:18px;border-radius:50%;font-size:12px;visibility:hidden;background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-primary-foreground)}.bdt-palette-choice:checked+.bdt-palette-card .bdt-palette-check{visibility:visible}
|
|
36
|
+
.bdt-palette-group:disabled .bdt-palette-card{cursor:not-allowed}.bdt-palette-group:disabled .bdt-palette-name{color:var(--dsw-alias-label-secondary)}
|
|
37
|
+
.bdt-palette-group,.bdt-palette-card,.bdt-mini,.bdt-mini *{box-sizing:border-box}
|
|
38
|
+
${ge}
|
|
39
|
+
@media(max-width:560px){.bdt-page{padding:16px}.bdt-row{gap:8px}.bdt-row>label{width:100%}}`;function xt(){t.useEffect(()=>{document.getElementById(Zt)?.remove()},[]);let y=p();if(!y.settings.enabled||!y.url)return null;let k=e.wallpaperShade(y.scheme);return n("style",null,`html{background-image:linear-gradient(${k},${k}),url(${JSON.stringify(y.url)});background-size:cover;background-position:center;background-attachment:fixed}body{background-color:transparent!important}${y.settings.dynamic?he:""}`)}function It(){wt();let y=p(),k=y.settings,D=(v,J,ut)=>n("div",{className:"bdt-row"},n("label",{htmlFor:`bdt-${v}`},l(v)),n("div",{className:"bdt-control"},J,ut)),U=v=>n("input",{id:`bdt-${v}`,type:"checkbox",checked:k[v],onChange:J=>L({[v]:J.target.checked})}),Z=t.useMemo(()=>e.makeTokens(k.dynamic?y.accent:[112,112,112],k.strength,k.dynamic?k.paletteMode:"monochrome"),[y.accent,k.strength,k.paletteMode,k.dynamic]),q=t.useMemo(()=>e.PALETTE_MODES.map(v=>({mode:v,tokens:e.makeTokens(y.accent,k.strength,v)})),[y.accent,k.strength]),Q=t.useId(),tt=typeof y.meta?.copyrightUrl=="string"&&/^https:\/\/(?:www|cn)\.bing\.com\//.test(y.meta.copyrightUrl)?y.meta.copyrightUrl:"https://www.bing.com/";return n("section",{className:"bdt-page","aria-label":l("title")},n("style",null,ot),n("h2",null,l("title")),n("figure",{className:"bdt-photo"},y.url?n("img",{className:"bdt-preview",src:y.url,alt:y.meta?.title||l("preview")}):n("div",{className:"bdt-preview",role:"img","aria-label":l("preview")}),y.meta&&n("figcaption",{className:"bdt-photo-caption"},n("div",{className:"bdt-photo-heading"},n("strong",null,y.meta.title||l("preview")),n("span",{className:"bdt-photo-date"},`${y.meta.date} \xB7 ${l(`market.${y.meta.market}`)}`)),n("div",{className:"bdt-photo-details"},n("a",{href:tt,target:"_blank",rel:"noopener noreferrer"},y.meta.copyright||l("source")),k.dynamic&&n("div",{className:"bdt-swatches","aria-label":l("palette")},...["light","dark"].map(v=>n("span",{key:v,className:"bdt-swatch",title:l(v),style:{backgroundColor:Z["--dsw-alias-brand-primary"][v]}}))))),n("button",{className:"bdt-photo-refresh",type:"button",disabled:y.busy||!k.enabled,"aria-label":l("refresh"),title:l("refresh"),"aria-busy":y.busy,onClick:()=>{_()}},n("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:!1},n("path",{d:"M3 12a9 9 0 0 1 15.36-6.36L21 8M21 3v5h-5M21 12a9 9 0 0 1-15.36 6.36L3 16M8 16H3v5"})))),n("span",{className:"bdt-photo-status",role:"status","aria-live":"polite"},k.enabled?y.busy?l("loading"):y.issue?l(y.issue):l(y.meta?y.meta.market===k.market?"ready":"sourceFailed":"waiting"):l("paused")),n("div",{className:"bdt-card"},D("enabled",U("enabled")),D("market",n("select",{id:"bdt-market",value:k.market,onChange:v=>L({market:v.target.value})},...["zh-CN","en-US"].map(v=>n("option",{key:v,value:v},l(`market.${v}`))))),D("dynamic",U("dynamic")),n("fieldset",{className:"bdt-palette-group",disabled:!k.dynamic},n("legend",null,l("paletteMode")),n("div",{className:"bdt-palette-grid"},...q.map(({mode:v,tokens:J})=>n("label",{key:v,className:"bdt-palette-option",htmlFor:`${Q}-${v}`},n("input",{id:`${Q}-${v}`,className:"bdt-palette-choice",type:"radio",name:Q,value:v,checked:k.paletteMode===v,onChange:()=>L({paletteMode:v})}),n("span",{className:"bdt-palette-card"},fe(n,J),n("span",{className:"bdt-palette-caption"},n("span",{className:"bdt-palette-name"},l(`palette.${v}`)),n("span",{className:"bdt-palette-check","aria-hidden":!0},"\u2713"))))))),D("mode",n("select",{id:"bdt-mode",value:k.mode,onChange:v=>L({mode:v.target.value})},...["schedule","system","follow","light","dark"].map(v=>n("option",{key:v,value:v},l(v))))),k.mode==="schedule"&&n("div",null,...["day","night"].map(v=>D(v,n("input",{id:`bdt-${v}`,type:"time",value:k[v],onChange:J=>L({[v]:J.target.value})})))),D("strength",n("input",{id:"bdt-strength",type:"range",min:10,max:100,step:1,value:k.strength,"aria-valuetext":`${k.strength}%`,onChange:v=>L({strength:Number(v.target.value)})}),n("output",{htmlFor:"bdt-strength"},`${k.strength}%`))),y.storageIssue&&n("p",{role:"status"},l("storageFailed")))}m.slots.inject("shell.overlay",()=>m.slots.register({name:"shell.overlay",id:"bing-daily-theme.wallpaper",order:-100},xt)),m.effect(()=>{let y=()=>m.slots.inject("settings.section",()=>m.slots.register({name:"settings.section",id:"bing-daily-theme",order:25,label:()=>l("title")},It)),k=y(),D=m.locale.subscribe(()=>{k(),k=y()});return()=>{D(),k()}}),m.effect(()=>{let y=setInterval(dt,6e4),k=()=>{document.visibilityState==="visible"&&dt()},D=()=>{M=0,dt()},U=Z=>{if(Z.key===c)try{L(e.normalizeSettings(JSON.parse(Z.newValue||"{}")))}catch{}};return document.addEventListener("visibilitychange",k),window.addEventListener("online",D),window.addEventListener("storage",U),w(),_(),()=>{P=!1,I++,clearInterval(y),S?.abort(),document.removeEventListener("visibilitychange",k),window.removeEventListener("online",D),window.removeEventListener("storage",U),document.getElementById(Zt)?.remove(),T?.(),V(),C&&URL.revokeObjectURL(C),f.clear()}})}}}function ye(t,e,r){let a=t.getTheme().preference,n="",i=!1;function s(){if(n&&t.getTheme().preference===n){i=!0;try{t.setTheme(a)}finally{i=!1}}n=""}return{restore:s,sync(c,m=new Date){if(!c.enabled||c.mode==="follow"){s();return}let l=c.mode==="schedule"?r(m,c.day,c.night):c.mode;if(l){n||(a=t.getTheme().preference),i=!0;try{t.getTheme().preference!==l&&t.setTheme(l),n=l}finally{i=!1}}},changed(c){!i&&n&&c.preference!==n&&(n="",e())}}}window.__ModuleLoader__.load({id:"@nzlov/dsh-bing-wallpaper",factory(t){return be(t("react"),Kt,{en:{title:"Bing daily wallpaper",paletteMode:"Colour mode","palette.content":"M3 Content","palette.tonal-spot":"M3 Tonal Spot","palette.fruit-salad":"M3 Fruit Salad","palette.rainbow":"M3 Rainbow","palette.monochrome":"M3 Monochrome","palette.vibrant":"Vibrant","palette.faithful":"Faithful","palette.soft":"Soft","palette.dysfunctional":"Dysfunctional","palette.muted":"Muted",enabled:"Wallpaper enabled",dynamic:"Extract theme colours",market:"Wallpaper source","market.zh-CN":"China","market.en-US":"International (US)",sourceFailed:"Could not switch sources. The previous source\u2019s wallpaper is still shown; check your connection and retry.",mode:"Day/night mode",schedule:"Local time schedule",system:"Follow system",follow:"Follow DSH appearance",light:"Light",dark:"Dark",day:"Light from",night:"Dark from",strength:"Wallpaper visibility",refresh:"Check for updates",loading:"Updating\u2026",ready:"Wallpaper is up to date",waiting:"Wallpaper paused or not yet loaded",preview:"Daily wallpaper preview",palette:"Light and dark accent colours",source:"View on Bing",paused:"Wallpaper and dynamic theme are paused",firstFetchFailed:"Wallpaper could not be loaded. Check your connection and retry.",fetchFailed:"Update failed. The previous wallpaper is kept; check your connection and retry.",stale:"Bing is unavailable. Showing the last successful wallpaper.",sameTime:"Light and dark times must be different.",storageFailed:"These controls could not be saved in this browser."},zh:{title:"Bing \u6BCF\u65E5\u58C1\u7EB8",paletteMode:"\u53D6\u8272\u6A21\u5F0F","palette.content":"M3 Content","palette.tonal-spot":"M3 Tonal Spot","palette.fruit-salad":"M3 Fruit Salad","palette.rainbow":"M3 Rainbow","palette.monochrome":"M3 Monochrome","palette.vibrant":"Vibrant","palette.faithful":"Faithful","palette.soft":"Soft","palette.dysfunctional":"Dysfunctional","palette.muted":"Muted",enabled:"\u542F\u7528\u58C1\u7EB8",dynamic:"\u4ECE\u58C1\u7EB8\u63D0\u53D6\u4E3B\u9898\u8272",market:"\u58C1\u7EB8\u6765\u6E90","market.zh-CN":"\u56FD\u5185\uFF08\u4E2D\u56FD\uFF09","market.en-US":"\u56FD\u9645\uFF08\u7F8E\u56FD\uFF09",sourceFailed:"\u5207\u6362\u6765\u6E90\u5931\u8D25\uFF0C\u4ECD\u663E\u793A\u4E0A\u4E00\u6765\u6E90\u7684\u58C1\u7EB8\uFF1B\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5\u3002",mode:"\u65E5\u591C\u5207\u6362\u65B9\u5F0F",schedule:"\u6309\u672C\u5730\u65F6\u95F4\u5207\u6362",system:"\u8DDF\u968F\u7CFB\u7EDF",follow:"\u8DDF\u968F DSH \u5916\u89C2",light:"\u6D45\u8272",dark:"\u6DF1\u8272",day:"\u6D45\u8272\u5F00\u59CB\u65F6\u95F4",night:"\u6DF1\u8272\u5F00\u59CB\u65F6\u95F4",strength:"\u58C1\u7EB8\u53EF\u89C1\u5EA6",refresh:"\u68C0\u67E5\u66F4\u65B0",loading:"\u6B63\u5728\u66F4\u65B0\u2026",ready:"\u58C1\u7EB8\u5DF2\u66F4\u65B0",waiting:"\u58C1\u7EB8\u5DF2\u6682\u505C\u6216\u5C1A\u672A\u52A0\u8F7D",preview:"\u6BCF\u65E5\u58C1\u7EB8\u9884\u89C8",palette:"\u6D45\u8272\u4E0E\u6DF1\u8272\u4E3B\u9898\u7684\u5F3A\u8C03\u8272",source:"\u5728 Bing \u67E5\u770B",paused:"\u58C1\u7EB8\u548C\u52A8\u6001\u4E3B\u9898\u5DF2\u6682\u505C",firstFetchFailed:"\u6682\u65F6\u65E0\u6CD5\u83B7\u53D6\u58C1\u7EB8\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5\u3002",fetchFailed:"\u66F4\u65B0\u5931\u8D25\uFF0C\u5DF2\u4FDD\u7559\u4E0A\u4E00\u5F20\u58C1\u7EB8\uFF1B\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5\u3002",stale:"Bing \u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u6B63\u5728\u663E\u793A\u4E0A\u6B21\u6210\u529F\u83B7\u53D6\u7684\u58C1\u7EB8\u3002",sameTime:"\u65E5\u95F4\u548C\u591C\u95F4\u7684\u5F00\u59CB\u65F6\u95F4\u4E0D\u80FD\u76F8\u540C\u3002",storageFailed:"\u65E0\u6CD5\u5728\u6B64\u6D4F\u89C8\u5668\u4FDD\u5B58\u8FD9\u4E9B\u63A7\u5236\u9879\u3002"}},ye)}});})();
|
|
40
|
+
/*! Bundled license information:
|
|
41
|
+
|
|
42
|
+
@material/material-color-utilities/utils/math_utils.js:
|
|
43
|
+
@material/material-color-utilities/utils/color_utils.js:
|
|
44
|
+
@material/material-color-utilities/hct/viewing_conditions.js:
|
|
45
|
+
@material/material-color-utilities/hct/cam16.js:
|
|
46
|
+
@material/material-color-utilities/hct/hct_solver.js:
|
|
47
|
+
@material/material-color-utilities/hct/hct.js:
|
|
48
|
+
@material/material-color-utilities/blend/blend.js:
|
|
49
|
+
@material/material-color-utilities/palettes/tonal_palette.js:
|
|
50
|
+
@material/material-color-utilities/palettes/core_palette.js:
|
|
51
|
+
@material/material-color-utilities/quantize/lab_point_provider.js:
|
|
52
|
+
@material/material-color-utilities/quantize/quantizer_wsmeans.js:
|
|
53
|
+
@material/material-color-utilities/quantize/quantizer_map.js:
|
|
54
|
+
@material/material-color-utilities/quantize/quantizer_wu.js:
|
|
55
|
+
@material/material-color-utilities/quantize/quantizer_celebi.js:
|
|
56
|
+
@material/material-color-utilities/scheme/scheme.js:
|
|
57
|
+
@material/material-color-utilities/scheme/scheme_android.js:
|
|
58
|
+
@material/material-color-utilities/score/score.js:
|
|
59
|
+
@material/material-color-utilities/utils/string_utils.js:
|
|
60
|
+
@material/material-color-utilities/utils/image_utils.js:
|
|
61
|
+
@material/material-color-utilities/utils/theme_utils.js:
|
|
62
|
+
@material/material-color-utilities/index.js:
|
|
63
|
+
(**
|
|
64
|
+
* @license
|
|
65
|
+
* Copyright 2021 Google LLC
|
|
66
|
+
*
|
|
67
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
68
|
+
* you may not use this file except in compliance with the License.
|
|
69
|
+
* You may obtain a copy of the License at
|
|
70
|
+
*
|
|
71
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
72
|
+
*
|
|
73
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
74
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
75
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
76
|
+
* See the License for the specific language governing permissions and
|
|
77
|
+
* limitations under the License.
|
|
78
|
+
*)
|
|
79
|
+
|
|
80
|
+
@material/material-color-utilities/contrast/contrast.js:
|
|
81
|
+
@material/material-color-utilities/dynamiccolor/dynamic_color.js:
|
|
82
|
+
@material/material-color-utilities/dynamiccolor/variant.js:
|
|
83
|
+
@material/material-color-utilities/dynamiccolor/material_dynamic_colors.js:
|
|
84
|
+
@material/material-color-utilities/dynamiccolor/dynamic_scheme.js:
|
|
85
|
+
@material/material-color-utilities/scheme/scheme_expressive.js:
|
|
86
|
+
@material/material-color-utilities/scheme/scheme_fruit_salad.js:
|
|
87
|
+
@material/material-color-utilities/scheme/scheme_monochrome.js:
|
|
88
|
+
@material/material-color-utilities/scheme/scheme_neutral.js:
|
|
89
|
+
@material/material-color-utilities/scheme/scheme_rainbow.js:
|
|
90
|
+
@material/material-color-utilities/scheme/scheme_tonal_spot.js:
|
|
91
|
+
@material/material-color-utilities/scheme/scheme_vibrant.js:
|
|
92
|
+
(**
|
|
93
|
+
* @license
|
|
94
|
+
* Copyright 2022 Google LLC
|
|
95
|
+
*
|
|
96
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
97
|
+
* you may not use this file except in compliance with the License.
|
|
98
|
+
* You may obtain a copy of the License at
|
|
99
|
+
*
|
|
100
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
*
|
|
102
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
103
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
104
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
105
|
+
* See the License for the specific language governing permissions and
|
|
106
|
+
* limitations under the License.
|
|
107
|
+
*)
|
|
108
|
+
|
|
109
|
+
@material/material-color-utilities/dislike/dislike_analyzer.js:
|
|
110
|
+
@material/material-color-utilities/dynamiccolor/contrast_curve.js:
|
|
111
|
+
@material/material-color-utilities/dynamiccolor/tone_delta_pair.js:
|
|
112
|
+
@material/material-color-utilities/temperature/temperature_cache.js:
|
|
113
|
+
@material/material-color-utilities/scheme/scheme_content.js:
|
|
114
|
+
@material/material-color-utilities/scheme/scheme_fidelity.js:
|
|
115
|
+
(**
|
|
116
|
+
* @license
|
|
117
|
+
* Copyright 2023 Google LLC
|
|
118
|
+
*
|
|
119
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
120
|
+
* you may not use this file except in compliance with the License.
|
|
121
|
+
* You may obtain a copy of the License at
|
|
122
|
+
*
|
|
123
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
124
|
+
*
|
|
125
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
126
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
127
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
128
|
+
* See the License for the specific language governing permissions and
|
|
129
|
+
* limitations under the License.
|
|
130
|
+
*)
|
|
131
|
+
*/
|
package/cordis.patch.yml
ADDED
package/icon.svg
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36" fill="none">
|
|
2
|
+
<circle cx="23.5" cy="11.5" r="4" fill="#C9A05B"/>
|
|
3
|
+
<path d="M5 26L14 12L23 26H5Z" fill="#5D8A8E"/>
|
|
4
|
+
<path d="M14 26L22 17L31 26H14Z" fill="#465F82"/>
|
|
5
|
+
<path d="M11.4 16L14 12L16.6 16L14 15L11.4 16Z" fill="#B9CDD0"/>
|
|
6
|
+
</svg>
|
package/index.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { createBingSource, DAILY_PATH, IMAGE_PATH, MARKET, isBingImageId, isBingMarket } from './bing-source.js'
|
|
2
|
+
import { bootThemeInjection } from './boot-theme.js'
|
|
3
|
+
|
|
4
|
+
// The carrier does not authenticate named routes. Connection is a real dependency.
|
|
5
|
+
export const inject = ['webServer', 'connection']
|
|
6
|
+
|
|
7
|
+
function response(request, status, value, extraHeaders = {}) {
|
|
8
|
+
const body = JSON.stringify(value)
|
|
9
|
+
return new Response(request.method === 'HEAD' ? null : body, {
|
|
10
|
+
status,
|
|
11
|
+
headers: {
|
|
12
|
+
'content-type': 'application/json; charset=utf-8',
|
|
13
|
+
'cache-control': 'private, no-store',
|
|
14
|
+
'x-content-type-options': 'nosniff',
|
|
15
|
+
'cross-origin-resource-policy': 'same-origin',
|
|
16
|
+
...extraHeaders,
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function waitFor(promise, signal) {
|
|
22
|
+
if (signal.aborted) return Promise.reject(signal.reason)
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
const abort = () => { signal.removeEventListener('abort', abort); reject(signal.reason) }
|
|
25
|
+
signal.addEventListener('abort', abort, { once: true })
|
|
26
|
+
// One disconnected reader must not cancel the refresh other readers share.
|
|
27
|
+
promise.then(value => {
|
|
28
|
+
signal.removeEventListener('abort', abort)
|
|
29
|
+
resolve(value)
|
|
30
|
+
}, error => {
|
|
31
|
+
signal.removeEventListener('abort', abort)
|
|
32
|
+
reject(error)
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function createResources({ source, admit }) {
|
|
38
|
+
async function serve(request, peer, kind) {
|
|
39
|
+
if (request.method !== 'GET' && request.method !== 'HEAD') {
|
|
40
|
+
return response(request, 405, { error: 'Method not allowed' }, { allow: 'GET, HEAD' })
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
// readResource callers have already admitted their Peer. HTTP has no Peer:
|
|
44
|
+
// re-use DSH's signed cookie / Host / Origin policy, never URL authority.
|
|
45
|
+
const admission = peer ? { peer } : admit(request)
|
|
46
|
+
if ('rejection' in admission) return response(request, admission.rejection, { error: 'Authentication required' })
|
|
47
|
+
if (admission.peer.signal.aborted) return response(request, 401, { error: 'Peer expired' })
|
|
48
|
+
if (admission.peer.principal.kind !== 'owner') return response(request, 403, { error: 'Owner access required' })
|
|
49
|
+
} catch {
|
|
50
|
+
// A missing/unavailable auth provider must never turn this into a public proxy.
|
|
51
|
+
return response(request, 503, { error: 'DSH authentication unavailable' })
|
|
52
|
+
}
|
|
53
|
+
if (request.signal.aborted) return response(request, 408, { error: 'Request cancelled' })
|
|
54
|
+
const url = new URL(request.url)
|
|
55
|
+
const expectedPath = kind === 'daily' ? DAILY_PATH : IMAGE_PATH
|
|
56
|
+
if (url.pathname !== expectedPath) return response(request, 404, { error: 'Not found' })
|
|
57
|
+
if (url.search.length > 1024) return response(request, 400, { error: 'Invalid query' })
|
|
58
|
+
const allowedKeys = kind === 'daily' ? ['market'] : ['market', 'id']
|
|
59
|
+
if ([...url.searchParams.keys()].some(name => !allowedKeys.includes(name))
|
|
60
|
+
|| allowedKeys.some(name => url.searchParams.getAll(name).length > 1)) {
|
|
61
|
+
return response(request, 400, { error: 'Invalid query' })
|
|
62
|
+
}
|
|
63
|
+
const market = url.searchParams.has('market') ? url.searchParams.get('market') : MARKET
|
|
64
|
+
if (!isBingMarket(market)) return response(request, 400, { error: 'Unsupported Bing market' })
|
|
65
|
+
if (kind === 'daily') {
|
|
66
|
+
try {
|
|
67
|
+
const metadata = await waitFor(source.daily(market), request.signal)
|
|
68
|
+
return response(request, 200, metadata)
|
|
69
|
+
} catch {
|
|
70
|
+
if (request.signal.aborted) return response(request, 408, { error: 'Request cancelled' })
|
|
71
|
+
return response(request, 502, { error: 'Bing wallpaper unavailable; please retry later' }, { 'retry-after': '60' })
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const id = url.searchParams.get('id')
|
|
75
|
+
if (!isBingImageId(id)) return response(request, 400, { error: 'Invalid Bing image ID' })
|
|
76
|
+
const image = source.image(id, market)
|
|
77
|
+
if (!image) return response(request, 404, { error: 'Image not cached; refresh daily metadata first' })
|
|
78
|
+
return new Response(request.method === 'HEAD' ? null : image.bytes, {
|
|
79
|
+
headers: {
|
|
80
|
+
'content-type': image.contentType,
|
|
81
|
+
'content-length': String(image.bytes.byteLength),
|
|
82
|
+
'cache-control': 'private, max-age=3600',
|
|
83
|
+
'x-content-type-options': 'nosniff',
|
|
84
|
+
'cross-origin-resource-policy': 'same-origin',
|
|
85
|
+
},
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
daily: (request, peer) => serve(request, peer, 'daily'),
|
|
90
|
+
image: (request, peer) => serve(request, peer, 'image'),
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function apply(ctx) {
|
|
95
|
+
// Structured injection runs before Client plugin loading. No index replacement.
|
|
96
|
+
ctx.on('webserver/index-inject', (table, peer) => {
|
|
97
|
+
if (peer.principal.kind === 'owner') table.push(bootThemeInjection())
|
|
98
|
+
})
|
|
99
|
+
ctx.effect(() => {
|
|
100
|
+
const source = createBingSource()
|
|
101
|
+
const resources = createResources({
|
|
102
|
+
source,
|
|
103
|
+
admit: request => ctx.connection.admit({ headers: request.headers }),
|
|
104
|
+
})
|
|
105
|
+
const disposers = []
|
|
106
|
+
try {
|
|
107
|
+
// webServer.register() returns a plain disposer; it is not context-owned.
|
|
108
|
+
disposers.push(ctx.webServer.register({ kind: 'exact', path: DAILY_PATH, resource: resources.daily }))
|
|
109
|
+
disposers.push(ctx.webServer.register({ kind: 'exact', path: IMAGE_PATH, resource: resources.image }))
|
|
110
|
+
} catch (error) {
|
|
111
|
+
source.dispose()
|
|
112
|
+
for (const dispose of disposers.reverse()) dispose()
|
|
113
|
+
throw error
|
|
114
|
+
}
|
|
115
|
+
return () => {
|
|
116
|
+
source.dispose() // Abort every outstanding upstream fetch before releasing routes.
|
|
117
|
+
for (const dispose of disposers.reverse()) dispose()
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
}
|
package/locale/en.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "Bing daily wallpaper",
|
|
4
|
+
"description": "Daily Bing wallpaper with image-derived colours, ten HCT styles, visibility up to 100%, and automatic light/dark appearance. Open Settings → Bing daily wallpaper. Offers Bing China and international (US) sources, keeps the last image when updates fail, and offers system, schedule and fixed appearance modes. Browser-local controls; appearance changes use DSH’s shared theme preference. Images remain subject to Bing and photographer rights."
|
|
5
|
+
},
|
|
6
|
+
"title": "Bing daily wallpaper",
|
|
7
|
+
"paletteMode": "Colour mode",
|
|
8
|
+
"palette.content": "M3 Content",
|
|
9
|
+
"palette.tonal-spot": "M3 Tonal Spot",
|
|
10
|
+
"palette.fruit-salad": "M3 Fruit Salad",
|
|
11
|
+
"palette.rainbow": "M3 Rainbow",
|
|
12
|
+
"palette.monochrome": "M3 Monochrome",
|
|
13
|
+
"palette.vibrant": "Vibrant",
|
|
14
|
+
"palette.faithful": "Faithful",
|
|
15
|
+
"palette.soft": "Soft",
|
|
16
|
+
"palette.dysfunctional": "Dysfunctional",
|
|
17
|
+
"palette.muted": "Muted",
|
|
18
|
+
"enabled": "Wallpaper enabled",
|
|
19
|
+
"dynamic": "Extract theme colours",
|
|
20
|
+
"market": "Wallpaper source",
|
|
21
|
+
"market.zh-CN": "China",
|
|
22
|
+
"market.en-US": "International (US)",
|
|
23
|
+
"sourceFailed": "Could not switch sources. The previous source’s wallpaper is still shown; check your connection and retry.",
|
|
24
|
+
"mode": "Day/night mode",
|
|
25
|
+
"schedule": "Local time schedule",
|
|
26
|
+
"system": "Follow system",
|
|
27
|
+
"follow": "Follow DSH appearance",
|
|
28
|
+
"light": "Light",
|
|
29
|
+
"dark": "Dark",
|
|
30
|
+
"day": "Light from",
|
|
31
|
+
"night": "Dark from",
|
|
32
|
+
"strength": "Wallpaper visibility",
|
|
33
|
+
"refresh": "Check for updates",
|
|
34
|
+
"loading": "Updating…",
|
|
35
|
+
"ready": "Wallpaper is up to date",
|
|
36
|
+
"waiting": "Wallpaper paused or not yet loaded",
|
|
37
|
+
"preview": "Daily wallpaper preview",
|
|
38
|
+
"palette": "Light and dark accent colours",
|
|
39
|
+
"source": "View on Bing",
|
|
40
|
+
"paused": "Wallpaper and dynamic theme are paused",
|
|
41
|
+
"firstFetchFailed": "Wallpaper could not be loaded. Check your connection and retry.",
|
|
42
|
+
"fetchFailed": "Update failed. The previous wallpaper is kept; check your connection and retry.",
|
|
43
|
+
"stale": "Bing is unavailable. Showing the last successful wallpaper.",
|
|
44
|
+
"sameTime": "Light and dark times must be different.",
|
|
45
|
+
"storageFailed": "These controls could not be saved in this browser."
|
|
46
|
+
}
|
package/locale/zh.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "Bing 每日壁纸",
|
|
4
|
+
"description": "每天更新 Bing 壁纸,从图片提取主题色,提供十种 HCT 风格,背景可见度可调至 100%,支持按时间、跟随系统或固定明暗模式。入口:设置 → Bing 每日壁纸。支持国内(中国)及国际(美国)Bing 壁纸来源,更新失败保留上一张。插件控制项保存在当前浏览器,明暗切换使用 DSH profile 共享的外观偏好。图片版权归 Bing 及原摄影作者所有。"
|
|
5
|
+
},
|
|
6
|
+
"title": "Bing 每日壁纸",
|
|
7
|
+
"paletteMode": "取色模式",
|
|
8
|
+
"palette.content": "M3 Content",
|
|
9
|
+
"palette.tonal-spot": "M3 Tonal Spot",
|
|
10
|
+
"palette.fruit-salad": "M3 Fruit Salad",
|
|
11
|
+
"palette.rainbow": "M3 Rainbow",
|
|
12
|
+
"palette.monochrome": "M3 Monochrome",
|
|
13
|
+
"palette.vibrant": "Vibrant",
|
|
14
|
+
"palette.faithful": "Faithful",
|
|
15
|
+
"palette.soft": "Soft",
|
|
16
|
+
"palette.dysfunctional": "Dysfunctional",
|
|
17
|
+
"palette.muted": "Muted",
|
|
18
|
+
"enabled": "启用壁纸",
|
|
19
|
+
"dynamic": "从壁纸提取主题色",
|
|
20
|
+
"market": "壁纸来源",
|
|
21
|
+
"market.zh-CN": "国内(中国)",
|
|
22
|
+
"market.en-US": "国际(美国)",
|
|
23
|
+
"sourceFailed": "切换来源失败,仍显示上一来源的壁纸;请检查网络后重试。",
|
|
24
|
+
"mode": "日夜切换方式",
|
|
25
|
+
"schedule": "按本地时间切换",
|
|
26
|
+
"system": "跟随系统",
|
|
27
|
+
"follow": "跟随 DSH 外观",
|
|
28
|
+
"light": "浅色",
|
|
29
|
+
"dark": "深色",
|
|
30
|
+
"day": "浅色开始时间",
|
|
31
|
+
"night": "深色开始时间",
|
|
32
|
+
"strength": "壁纸可见度",
|
|
33
|
+
"refresh": "检查更新",
|
|
34
|
+
"loading": "正在更新…",
|
|
35
|
+
"ready": "壁纸已更新",
|
|
36
|
+
"waiting": "壁纸已暂停或尚未加载",
|
|
37
|
+
"preview": "每日壁纸预览",
|
|
38
|
+
"palette": "浅色与深色主题的强调色",
|
|
39
|
+
"source": "在 Bing 查看",
|
|
40
|
+
"paused": "壁纸和动态主题已暂停",
|
|
41
|
+
"firstFetchFailed": "暂时无法获取壁纸,请检查网络后重试。",
|
|
42
|
+
"fetchFailed": "更新失败,已保留上一张壁纸;请检查网络后重试。",
|
|
43
|
+
"stale": "Bing 暂时不可用,正在显示上次成功获取的壁纸。",
|
|
44
|
+
"sameTime": "日间和夜间的开始时间不能相同。",
|
|
45
|
+
"storageFailed": "无法在此浏览器保存这些控制项。"
|
|
46
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nzlov/dsh-bing-wallpaper",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Daily Bing wallpaper, image-derived theme colours and automatic day/night appearance for DSH Web.",
|
|
6
|
+
"author": "nzlov",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+ssh://git@github.com/nzlov/dsh-bing-wallpaper.git"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public",
|
|
14
|
+
"registry": "https://registry.npmjs.org/"
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"dsh": ">=0.2.2-rc.4 <0.3.0"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": "./index.js",
|
|
21
|
+
"./client": "./client.js",
|
|
22
|
+
"./locale/*.json": "./locale/*.json",
|
|
23
|
+
"./icon": "./icon.svg"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"index.js",
|
|
27
|
+
"bing-source.js",
|
|
28
|
+
"boot-theme.js",
|
|
29
|
+
"client.js",
|
|
30
|
+
"cordis.patch.yml",
|
|
31
|
+
"locale/*.json",
|
|
32
|
+
"README.md",
|
|
33
|
+
"README.zh-CN.md",
|
|
34
|
+
"icon.svg",
|
|
35
|
+
"LICENSE",
|
|
36
|
+
"THIRD_PARTY_NOTICES.md",
|
|
37
|
+
"third-party"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "node scripts/build.mjs",
|
|
41
|
+
"prepack": "npm run build",
|
|
42
|
+
"test": "node --test test/*.test.js",
|
|
43
|
+
"check": "node --check index.js && node --check bing-source.js && node --check palette.js && node --check client-main.js && node --check appearance.js && node --check boot-theme.js && node --check compatibility.js && node --check palette-preview.js && node --check client.js"
|
|
44
|
+
},
|
|
45
|
+
"dsh": {
|
|
46
|
+
"bundle": {
|
|
47
|
+
"patch": "./cordis.patch.yml"
|
|
48
|
+
},
|
|
49
|
+
"client": {
|
|
50
|
+
"platform": "web",
|
|
51
|
+
"immediately": true,
|
|
52
|
+
"inject": [
|
|
53
|
+
"@deepseek-ai/dsh-client-ui-layout",
|
|
54
|
+
"@deepseek-ai/dsh-client-ui-theme",
|
|
55
|
+
"@deepseek-ai/dsh-client-ui-settings",
|
|
56
|
+
"@deepseek-ai/dsh-client-locale"
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@material/material-color-utilities": "0.3.0",
|
|
62
|
+
"esbuild": "0.28.2"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2021 Google LLC
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|