Delete PNG_info_beautyui.js
Browse files- PNG_info_beautyui.js +0 -783
PNG_info_beautyui.js
DELETED
|
@@ -1,783 +0,0 @@
|
|
| 1 |
-
(()=>{
|
| 2 |
-
var CRC32;
|
| 3 |
-
(function (factory) {
|
| 4 |
-
if (typeof DO_NOT_EXPORT_CRC === "undefined") {
|
| 5 |
-
if ("object" === typeof exports) {
|
| 6 |
-
factory(exports);
|
| 7 |
-
} else if ("function" === typeof define && define.amd) {
|
| 8 |
-
define(function () {
|
| 9 |
-
var module = {};
|
| 10 |
-
factory(module);
|
| 11 |
-
return module;
|
| 12 |
-
});
|
| 13 |
-
} else {
|
| 14 |
-
factory((CRC32 = {}));
|
| 15 |
-
}
|
| 16 |
-
} else {
|
| 17 |
-
factory((CRC32 = {}));
|
| 18 |
-
}
|
| 19 |
-
})(function (CRC32) {
|
| 20 |
-
CRC32.version = "0.3.0";
|
| 21 |
-
/* see perf/crc32table.js */
|
| 22 |
-
function signed_crc_table() {
|
| 23 |
-
var c = 0,
|
| 24 |
-
table = new Array(256);
|
| 25 |
-
|
| 26 |
-
for (var n = 0; n != 256; ++n) {
|
| 27 |
-
c = n;
|
| 28 |
-
c = c & 1 ? -306674912 ^ (c >>> 1) : c >>> 1;
|
| 29 |
-
c = c & 1 ? -306674912 ^ (c >>> 1) : c >>> 1;
|
| 30 |
-
c = c & 1 ? -306674912 ^ (c >>> 1) : c >>> 1;
|
| 31 |
-
c = c & 1 ? -306674912 ^ (c >>> 1) : c >>> 1;
|
| 32 |
-
c = c & 1 ? -306674912 ^ (c >>> 1) : c >>> 1;
|
| 33 |
-
c = c & 1 ? -306674912 ^ (c >>> 1) : c >>> 1;
|
| 34 |
-
c = c & 1 ? -306674912 ^ (c >>> 1) : c >>> 1;
|
| 35 |
-
c = c & 1 ? -306674912 ^ (c >>> 1) : c >>> 1;
|
| 36 |
-
table[n] = c;
|
| 37 |
-
}
|
| 38 |
-
|
| 39 |
-
return typeof Int32Array !== "undefined" ? new Int32Array(table) : table;
|
| 40 |
-
}
|
| 41 |
-
|
| 42 |
-
var table = signed_crc_table();
|
| 43 |
-
/* charCodeAt is the best approach for binary strings */
|
| 44 |
-
var use_buffer = typeof Buffer !== "undefined";
|
| 45 |
-
function crc32_bstr(bstr) {
|
| 46 |
-
if (bstr.length > 32768)
|
| 47 |
-
if (use_buffer) return crc32_buf_8(new Buffer(bstr));
|
| 48 |
-
var crc = -1,
|
| 49 |
-
L = bstr.length - 1;
|
| 50 |
-
for (var i = 0; i < L; ) {
|
| 51 |
-
crc = table[(crc ^ bstr.charCodeAt(i++)) & 0xff] ^ (crc >>> 8);
|
| 52 |
-
crc = table[(crc ^ bstr.charCodeAt(i++)) & 0xff] ^ (crc >>> 8);
|
| 53 |
-
}
|
| 54 |
-
if (i === L) crc = (crc >>> 8) ^ table[(crc ^ bstr.charCodeAt(i)) & 0xff];
|
| 55 |
-
return crc ^ -1;
|
| 56 |
-
}
|
| 57 |
-
|
| 58 |
-
function crc32_buf(buf) {
|
| 59 |
-
if (buf.length > 10000) return crc32_buf_8(buf);
|
| 60 |
-
for (var crc = -1, i = 0, L = buf.length - 3; i < L; ) {
|
| 61 |
-
crc = (crc >>> 8) ^ table[(crc ^ buf[i++]) & 0xff];
|
| 62 |
-
crc = (crc >>> 8) ^ table[(crc ^ buf[i++]) & 0xff];
|
| 63 |
-
crc = (crc >>> 8) ^ table[(crc ^ buf[i++]) & 0xff];
|
| 64 |
-
crc = (crc >>> 8) ^ table[(crc ^ buf[i++]) & 0xff];
|
| 65 |
-
}
|
| 66 |
-
while (i < L + 3) crc = (crc >>> 8) ^ table[(crc ^ buf[i++]) & 0xff];
|
| 67 |
-
return crc ^ -1;
|
| 68 |
-
}
|
| 69 |
-
|
| 70 |
-
function crc32_buf_8(buf) {
|
| 71 |
-
for (var crc = -1, i = 0, L = buf.length - 7; i < L; ) {
|
| 72 |
-
crc = (crc >>> 8) ^ table[(crc ^ buf[i++]) & 0xff];
|
| 73 |
-
crc = (crc >>> 8) ^ table[(crc ^ buf[i++]) & 0xff];
|
| 74 |
-
crc = (crc >>> 8) ^ table[(crc ^ buf[i++]) & 0xff];
|
| 75 |
-
crc = (crc >>> 8) ^ table[(crc ^ buf[i++]) & 0xff];
|
| 76 |
-
crc = (crc >>> 8) ^ table[(crc ^ buf[i++]) & 0xff];
|
| 77 |
-
crc = (crc >>> 8) ^ table[(crc ^ buf[i++]) & 0xff];
|
| 78 |
-
crc = (crc >>> 8) ^ table[(crc ^ buf[i++]) & 0xff];
|
| 79 |
-
crc = (crc >>> 8) ^ table[(crc ^ buf[i++]) & 0xff];
|
| 80 |
-
}
|
| 81 |
-
while (i < L + 7) crc = (crc >>> 8) ^ table[(crc ^ buf[i++]) & 0xff];
|
| 82 |
-
return crc ^ -1;
|
| 83 |
-
}
|
| 84 |
-
|
| 85 |
-
/* much much faster to intertwine utf8 and crc */
|
| 86 |
-
function crc32_str(str) {
|
| 87 |
-
for (var crc = -1, i = 0, L = str.length, c, d; i < L; ) {
|
| 88 |
-
c = str.charCodeAt(i++);
|
| 89 |
-
if (c < 0x80) {
|
| 90 |
-
crc = (crc >>> 8) ^ table[(crc ^ c) & 0xff];
|
| 91 |
-
} else if (c < 0x800) {
|
| 92 |
-
crc = (crc >>> 8) ^ table[(crc ^ (192 | ((c >> 6) & 31))) & 0xff];
|
| 93 |
-
crc = (crc >>> 8) ^ table[(crc ^ (128 | (c & 63))) & 0xff];
|
| 94 |
-
} else if (c >= 0xd800 && c < 0xe000) {
|
| 95 |
-
c = (c & 1023) + 64;
|
| 96 |
-
d = str.charCodeAt(i++) & 1023;
|
| 97 |
-
crc = (crc >>> 8) ^ table[(crc ^ (240 | ((c >> 8) & 7))) & 0xff];
|
| 98 |
-
crc = (crc >>> 8) ^ table[(crc ^ (128 | ((c >> 2) & 63))) & 0xff];
|
| 99 |
-
crc =
|
| 100 |
-
(crc >>> 8) ^ table[(crc ^ (128 | ((d >> 6) & 15) | (c & 3))) & 0xff];
|
| 101 |
-
crc = (crc >>> 8) ^ table[(crc ^ (128 | (d & 63))) & 0xff];
|
| 102 |
-
} else {
|
| 103 |
-
crc = (crc >>> 8) ^ table[(crc ^ (224 | ((c >> 12) & 15))) & 0xff];
|
| 104 |
-
crc = (crc >>> 8) ^ table[(crc ^ (128 | ((c >> 6) & 63))) & 0xff];
|
| 105 |
-
crc = (crc >>> 8) ^ table[(crc ^ (128 | (c & 63))) & 0xff];
|
| 106 |
-
}
|
| 107 |
-
}
|
| 108 |
-
return crc ^ -1;
|
| 109 |
-
}
|
| 110 |
-
CRC32.table = table;
|
| 111 |
-
CRC32.bstr = crc32_bstr;
|
| 112 |
-
CRC32.buf = crc32_buf;
|
| 113 |
-
CRC32.str = crc32_str;
|
| 114 |
-
});
|
| 115 |
-
|
| 116 |
-
var uint8 = new Uint8Array(4);
|
| 117 |
-
var int32 = new Int32Array(uint8.buffer);
|
| 118 |
-
var uint32 = new Uint32Array(uint8.buffer);
|
| 119 |
-
|
| 120 |
-
function extractChunks(data) {
|
| 121 |
-
if (data[0] !== 0x89) throw new Error("Invalid .png file header");
|
| 122 |
-
if (data[1] !== 0x50) throw new Error("Invalid .png file header");
|
| 123 |
-
if (data[2] !== 0x4e) throw new Error("Invalid .png file header");
|
| 124 |
-
if (data[3] !== 0x47) throw new Error("Invalid .png file header");
|
| 125 |
-
if (data[4] !== 0x0d)
|
| 126 |
-
throw new Error(
|
| 127 |
-
"Invalid .png file header: possibly caused by DOS-Unix line ending conversion?"
|
| 128 |
-
);
|
| 129 |
-
if (data[5] !== 0x0a)
|
| 130 |
-
throw new Error(
|
| 131 |
-
"Invalid .png file header: possibly caused by DOS-Unix line ending conversion?"
|
| 132 |
-
);
|
| 133 |
-
if (data[6] !== 0x1a) throw new Error("Invalid .png file header");
|
| 134 |
-
if (data[7] !== 0x0a)
|
| 135 |
-
throw new Error(
|
| 136 |
-
"Invalid .png file header: possibly caused by DOS-Unix line ending conversion?"
|
| 137 |
-
);
|
| 138 |
-
|
| 139 |
-
var ended = false;
|
| 140 |
-
var chunks = [];
|
| 141 |
-
var idx = 8;
|
| 142 |
-
|
| 143 |
-
while (idx < data.length) {
|
| 144 |
-
// Read the length of the current chunk,
|
| 145 |
-
// which is stored as a Uint32.
|
| 146 |
-
uint8[3] = data[idx++];
|
| 147 |
-
uint8[2] = data[idx++];
|
| 148 |
-
uint8[1] = data[idx++];
|
| 149 |
-
uint8[0] = data[idx++];
|
| 150 |
-
|
| 151 |
-
// Chunk includes name/type for CRC check (see below).
|
| 152 |
-
var length = uint32[0] + 4;
|
| 153 |
-
var chunk = new Uint8Array(length);
|
| 154 |
-
chunk[0] = data[idx++];
|
| 155 |
-
chunk[1] = data[idx++];
|
| 156 |
-
chunk[2] = data[idx++];
|
| 157 |
-
chunk[3] = data[idx++];
|
| 158 |
-
|
| 159 |
-
// Get the name in ASCII for identification.
|
| 160 |
-
var name =
|
| 161 |
-
String.fromCharCode(chunk[0]) +
|
| 162 |
-
String.fromCharCode(chunk[1]) +
|
| 163 |
-
String.fromCharCode(chunk[2]) +
|
| 164 |
-
String.fromCharCode(chunk[3]);
|
| 165 |
-
|
| 166 |
-
// The IHDR header MUST come first.
|
| 167 |
-
if (!chunks.length && name !== "IHDR") {
|
| 168 |
-
throw new Error("IHDR header missing");
|
| 169 |
-
}
|
| 170 |
-
|
| 171 |
-
// The IEND header marks the end of the file,
|
| 172 |
-
// so on discovering it break out of the loop.
|
| 173 |
-
if (name === "IEND") {
|
| 174 |
-
ended = true;
|
| 175 |
-
chunks.push({
|
| 176 |
-
name: name,
|
| 177 |
-
data: new Uint8Array(0),
|
| 178 |
-
});
|
| 179 |
-
|
| 180 |
-
break;
|
| 181 |
-
}
|
| 182 |
-
|
| 183 |
-
// Read the contents of the chunk out of the main buffer.
|
| 184 |
-
for (var i = 4; i < length; i++) {
|
| 185 |
-
chunk[i] = data[idx++];
|
| 186 |
-
}
|
| 187 |
-
|
| 188 |
-
// Read out the CRC value for comparison.
|
| 189 |
-
// It's stored as an Int32.
|
| 190 |
-
uint8[3] = data[idx++];
|
| 191 |
-
uint8[2] = data[idx++];
|
| 192 |
-
uint8[1] = data[idx++];
|
| 193 |
-
uint8[0] = data[idx++];
|
| 194 |
-
|
| 195 |
-
var crcActual = int32[0];
|
| 196 |
-
var crcExpect = CRC32.buf(chunk);
|
| 197 |
-
if (crcExpect !== crcActual) {
|
| 198 |
-
throw new Error(
|
| 199 |
-
"CRC values for " +
|
| 200 |
-
name +
|
| 201 |
-
" header do not match, PNG file is likely corrupted"
|
| 202 |
-
);
|
| 203 |
-
}
|
| 204 |
-
|
| 205 |
-
// The chunk data is now copied to remove the 4 preceding
|
| 206 |
-
// bytes used for the chunk name/type.
|
| 207 |
-
var chunkData = new Uint8Array(chunk.buffer.slice(4));
|
| 208 |
-
|
| 209 |
-
chunks.push({
|
| 210 |
-
name: name,
|
| 211 |
-
data: chunkData,
|
| 212 |
-
});
|
| 213 |
-
}
|
| 214 |
-
|
| 215 |
-
if (!ended) {
|
| 216 |
-
throw new Error(".png file ended prematurely: no IEND header was found");
|
| 217 |
-
}
|
| 218 |
-
|
| 219 |
-
return chunks;
|
| 220 |
-
}
|
| 221 |
-
//decode
|
| 222 |
-
function decode(data) {
|
| 223 |
-
if (data.data && data.name) {
|
| 224 |
-
data = data.data;
|
| 225 |
-
}
|
| 226 |
-
|
| 227 |
-
var naming = true;
|
| 228 |
-
var text = "";
|
| 229 |
-
var name = "";
|
| 230 |
-
|
| 231 |
-
for (var i = 0; i < data.length; i++) {
|
| 232 |
-
var code = data[i];
|
| 233 |
-
|
| 234 |
-
if (naming) {
|
| 235 |
-
if (code) {
|
| 236 |
-
name += String.fromCharCode(code);
|
| 237 |
-
} else {
|
| 238 |
-
naming = false;
|
| 239 |
-
}
|
| 240 |
-
} else {
|
| 241 |
-
if (code) {
|
| 242 |
-
text += String.fromCharCode(code);
|
| 243 |
-
} else {
|
| 244 |
-
throw new Error(
|
| 245 |
-
"Invalid NULL character found. 0x00 character is not permitted in tEXt content"
|
| 246 |
-
);
|
| 247 |
-
}
|
| 248 |
-
}
|
| 249 |
-
}
|
| 250 |
-
|
| 251 |
-
return {
|
| 252 |
-
keyword: name,
|
| 253 |
-
text: text,
|
| 254 |
-
};
|
| 255 |
-
}
|
| 256 |
-
|
| 257 |
-
const inputEvent = new Event("input");
|
| 258 |
-
const changeEvent = new Event("change");
|
| 259 |
-
let shadowRoot = null;
|
| 260 |
-
let result = {};
|
| 261 |
-
let png_info_blob = {};
|
| 262 |
-
//readNovelAITag函数参考于秋叶大佬并进行了优化
|
| 263 |
-
const readNovelAITag = async (file) => {
|
| 264 |
-
let chunks = [];
|
| 265 |
-
let textChunks = [];
|
| 266 |
-
try {
|
| 267 |
-
const buf = await file.arrayBuffer();
|
| 268 |
-
chunks = extractChunks(new Uint8Array(buf));
|
| 269 |
-
textChunks = chunks.filter(function (chunk) {
|
| 270 |
-
return chunk.name === "tEXt" || chunk.name === "iTXt";
|
| 271 |
-
});
|
| 272 |
-
textChunks = textChunks.map(function (chunk) {
|
| 273 |
-
if (chunk.name === "iTXt") {
|
| 274 |
-
let data = chunk.data.filter((x) => x != 0x0);
|
| 275 |
-
let txt = new TextDecoder().decode(data);
|
| 276 |
-
return {
|
| 277 |
-
keyword: "信息",
|
| 278 |
-
text: txt.slice(10),
|
| 279 |
-
};
|
| 280 |
-
}
|
| 281 |
-
return decode(chunk.data);
|
| 282 |
-
});
|
| 283 |
-
return textChunks;
|
| 284 |
-
} catch (err) {
|
| 285 |
-
console.error(err);
|
| 286 |
-
} finally {
|
| 287 |
-
chunks = null;
|
| 288 |
-
textChunks = null;
|
| 289 |
-
}
|
| 290 |
-
return [];
|
| 291 |
-
};
|
| 292 |
-
|
| 293 |
-
//dom转blob
|
| 294 |
-
async function convertDomImageToBlob(imageElement) {
|
| 295 |
-
const imageUrl = imageElement.src;
|
| 296 |
-
// const file = new File([blob], 'filename.png', {type: blob.type});
|
| 297 |
-
return await readStoragePng(imageUrl);
|
| 298 |
-
}
|
| 299 |
-
|
| 300 |
-
//base64转blob
|
| 301 |
-
async function readStoragePng(dataURI) {
|
| 302 |
-
var byteString = atob(dataURI.split(",")[1]);
|
| 303 |
-
|
| 304 |
-
// 获取 MIME 类型
|
| 305 |
-
var mimeString = dataURI.split(",")[0].split(":")[1].split(";")[0];
|
| 306 |
-
|
| 307 |
-
// 创建 Blob 对象
|
| 308 |
-
var blob = new Blob(
|
| 309 |
-
[
|
| 310 |
-
new Uint8Array(byteString.length).map(function (_, i) {
|
| 311 |
-
return byteString.charCodeAt(i);
|
| 312 |
-
}),
|
| 313 |
-
],
|
| 314 |
-
{ type: mimeString }
|
| 315 |
-
);
|
| 316 |
-
|
| 317 |
-
return blob;
|
| 318 |
-
}
|
| 319 |
-
|
| 320 |
-
//图片存到本地
|
| 321 |
-
let imgStorage=(img)=>{
|
| 322 |
-
localStorage.setItem("png_info_img", img.src);
|
| 323 |
-
}
|
| 324 |
-
//延迟获取dom到pnginfo_image更新完后
|
| 325 |
-
let delayPng_info = function () {
|
| 326 |
-
return new Promise((resolve) => {
|
| 327 |
-
this.shadowRoot = document.querySelector("gradio-app");
|
| 328 |
-
const observer = new MutationObserver((mutations) => {
|
| 329 |
-
mutations.forEach((mutation) => {
|
| 330 |
-
// 如果 id 为 pnginfo_image 的子元素被添加到 gradio-app 元素中
|
| 331 |
-
if (
|
| 332 |
-
mutation.addedNodes.length &&
|
| 333 |
-
mutation.addedNodes[0].id === "pnginfo_image"
|
| 334 |
-
) {
|
| 335 |
-
// 取消监听
|
| 336 |
-
observer.disconnect();
|
| 337 |
-
// 获取 id 为 pnginfo_image 的元素并进行操作
|
| 338 |
-
resolve(mutation.addedNodes[0]);
|
| 339 |
-
}
|
| 340 |
-
});
|
| 341 |
-
});
|
| 342 |
-
observer.observe(this.shadowRoot, { childList: true, subtree: true });
|
| 343 |
-
});
|
| 344 |
-
};
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
//此节点render-tree是否已形成
|
| 348 |
-
function isElementRendered(el) {
|
| 349 |
-
const style = window.getComputedStyle(el);
|
| 350 |
-
|
| 351 |
-
if (style.getPropertyValue('display') === 'none') {
|
| 352 |
-
return false;
|
| 353 |
-
}
|
| 354 |
-
|
| 355 |
-
// 判断是否有宽高
|
| 356 |
-
if (el.offsetWidth <= 0 || el.offsetHeight <= 0) {
|
| 357 |
-
return false;
|
| 358 |
-
}
|
| 359 |
-
|
| 360 |
-
return true;
|
| 361 |
-
}
|
| 362 |
-
|
| 363 |
-
let delay_png_change = function (png_info) {
|
| 364 |
-
return new Promise((resolve) => {
|
| 365 |
-
//用来判断点击事件进行resolve,因为初始化优先级没那么高,所以不用担心初始化的时候执行
|
| 366 |
-
const observer = new MutationObserver((mutations) => {
|
| 367 |
-
mutations.forEach((mutation) => {
|
| 368 |
-
// 如果 delay_png_change 存在了
|
| 369 |
-
if (
|
| 370 |
-
png_info.querySelector("img")
|
| 371 |
-
) {
|
| 372 |
-
// 取消监听
|
| 373 |
-
observer.disconnect();
|
| 374 |
-
// 获取 id 为 delay_tab_click 的元素并进行操作
|
| 375 |
-
resolve(png_info.querySelector("img"));
|
| 376 |
-
}
|
| 377 |
-
});
|
| 378 |
-
});
|
| 379 |
-
observer.observe(png_info, { childList: true, subtree: true });
|
| 380 |
-
});
|
| 381 |
-
};
|
| 382 |
-
|
| 383 |
-
let delay_tab_click = function () {
|
| 384 |
-
return new Promise((resolve) => {
|
| 385 |
-
//用来判断点击事件进行resolve,因为初始化优先级没那么高,所以不用担心初始化的时候执行
|
| 386 |
-
if(this.shadowRoot.querySelectorAll('#mode_img2img button')[2])
|
| 387 |
-
{
|
| 388 |
-
console.log('点击类读取')
|
| 389 |
-
resolve(this.shadowRoot.querySelectorAll('#mode_img2img button')[2]);
|
| 390 |
-
}
|
| 391 |
-
this.shadowRoot = document.querySelector("gradio-app");
|
| 392 |
-
const observer = new MutationObserver((mutations) => {
|
| 393 |
-
mutations.forEach((mutation) => {
|
| 394 |
-
// 如果 delay_tab_click 存在了
|
| 395 |
-
if (
|
| 396 |
-
this.shadowRoot.querySelectorAll('#mode_img2img button')[2]
|
| 397 |
-
) {
|
| 398 |
-
// 取消监听
|
| 399 |
-
observer.disconnect();
|
| 400 |
-
// 获取 id 为 delay_tab_click 的元素并进行操作
|
| 401 |
-
resolve(this.shadowRoot.querySelectorAll('#mode_img2img button')[2]);
|
| 402 |
-
}
|
| 403 |
-
});
|
| 404 |
-
});
|
| 405 |
-
observer.observe(this.shadowRoot, { childList: true, subtree: true });
|
| 406 |
-
});
|
| 407 |
-
};
|
| 408 |
-
|
| 409 |
-
let delay_canvas = function () {
|
| 410 |
-
return new Promise((resolve) => {
|
| 411 |
-
|
| 412 |
-
//用来判断点击事件进行resolve,因为初始化优先级没那么高,所以不用担心初始化的时候执行
|
| 413 |
-
if(this.shadowRoot.querySelector("#img2maskimg > div.svelte-rlgzoo.fixed-height > div > div:nth-child(2)"))
|
| 414 |
-
{
|
| 415 |
-
console.log('点击类读取')
|
| 416 |
-
resolve(this.shadowRoot.querySelector("#img2maskimg > div.svelte-rlgzoo.fixed-height > div > div:nth-child(2)"));
|
| 417 |
-
}
|
| 418 |
-
|
| 419 |
-
this.shadowRoot = document.querySelector("gradio-app");
|
| 420 |
-
const observer = new MutationObserver((mutations) => {
|
| 421 |
-
mutations.forEach((mutation) => {
|
| 422 |
-
// 如果 id 为 delay_canvas 被添加到 gradio-app 元素中且6个子标签也存在了
|
| 423 |
-
if (
|
| 424 |
-
this.shadowRoot.querySelector("#img2maskimg > div.svelte-rlgzoo.fixed-height > div > div:nth-child(2)")&&this.shadowRoot.querySelector("#img2maskimg > div.svelte-rlgzoo.fixed-height > div > div:nth-child(2)").children[6]&&this.shadowRoot.querySelector("#img2maskimg > div.svelte-rlgzoo.fixed-height > div > div:nth-child(2)").children[6].style.display!=='none'
|
| 425 |
-
) {
|
| 426 |
-
// 取消监听
|
| 427 |
-
observer.disconnect();
|
| 428 |
-
// 获取 delay_canvas 的元素并进行操作
|
| 429 |
-
resolve(this.shadowRoot.querySelector("#img2maskimg > div.svelte-rlgzoo.fixed-height > div > div:nth-child(2)"));
|
| 430 |
-
}
|
| 431 |
-
});
|
| 432 |
-
});
|
| 433 |
-
observer.observe(this.shadowRoot, { childList: true, subtree: true });
|
| 434 |
-
});
|
| 435 |
-
};
|
| 436 |
-
let txt2ImgFormFill = () => {
|
| 437 |
-
shadowRoot=this.shadowRoot
|
| 438 |
-
let result = this.result;
|
| 439 |
-
const inputEvent = new Event("input");
|
| 440 |
-
const changeEvent = new Event("change", {
|
| 441 |
-
bubbles: true,
|
| 442 |
-
});
|
| 443 |
-
shadowRoot.querySelector('[class="tab-nav scroll-hide svelte-1g805jl"]').children[0].click();
|
| 444 |
-
|
| 445 |
-
shadowRoot.querySelectorAll(
|
| 446 |
-
"#setting_CLIP_stop_at_last_layers input"
|
| 447 |
-
)[0].value = Number(result.Clipskip);
|
| 448 |
-
shadowRoot
|
| 449 |
-
.querySelectorAll("#setting_CLIP_stop_at_last_layers input")[0]
|
| 450 |
-
.dispatchEvent(inputEvent);
|
| 451 |
-
|
| 452 |
-
shadowRoot.querySelectorAll(
|
| 453 |
-
"#setting_CLIP_stop_at_last_layers input"
|
| 454 |
-
)[1].value = Number(result.Clipskip);
|
| 455 |
-
shadowRoot
|
| 456 |
-
.querySelectorAll("#setting_CLIP_stop_at_last_layers input")[1]
|
| 457 |
-
.dispatchEvent(inputEvent);
|
| 458 |
-
|
| 459 |
-
shadowRoot.querySelector("#txt2img_prompt textarea").value = result.prompt;
|
| 460 |
-
shadowRoot
|
| 461 |
-
.querySelector("#txt2img_prompt textarea")
|
| 462 |
-
.dispatchEvent(inputEvent);
|
| 463 |
-
|
| 464 |
-
shadowRoot.querySelector("#txt2img_neg_prompt textarea").value =
|
| 465 |
-
result.negativePrompt;
|
| 466 |
-
shadowRoot
|
| 467 |
-
.querySelector("#txt2img_neg_prompt textarea")
|
| 468 |
-
.dispatchEvent(inputEvent);
|
| 469 |
-
|
| 470 |
-
shadowRoot.querySelectorAll("#txt2img_steps input")[0].value = Number(
|
| 471 |
-
result.Steps
|
| 472 |
-
);
|
| 473 |
-
shadowRoot
|
| 474 |
-
.querySelectorAll("#txt2img_steps input")[0]
|
| 475 |
-
.dispatchEvent(inputEvent);
|
| 476 |
-
|
| 477 |
-
shadowRoot.querySelectorAll("#txt2img_steps input")[1].value = Number(
|
| 478 |
-
result.Steps
|
| 479 |
-
);
|
| 480 |
-
shadowRoot
|
| 481 |
-
.querySelectorAll("#txt2img_steps input")[1]
|
| 482 |
-
.dispatchEvent(inputEvent);
|
| 483 |
-
|
| 484 |
-
shadowRoot.querySelector(`[value="${result.Sampler}"]`).checked = true;
|
| 485 |
-
shadowRoot
|
| 486 |
-
.querySelector(`[value="${result.Sampler}"]`)
|
| 487 |
-
.dispatchEvent(changeEvent);
|
| 488 |
-
|
| 489 |
-
shadowRoot.querySelectorAll("#txt2img_width input")[0].value = Number(
|
| 490 |
-
result.Size.split("x")[0]
|
| 491 |
-
);
|
| 492 |
-
shadowRoot
|
| 493 |
-
.querySelectorAll("#txt2img_width input")[0]
|
| 494 |
-
.dispatchEvent(inputEvent);
|
| 495 |
-
|
| 496 |
-
shadowRoot.querySelectorAll("#txt2img_width input")[1].value = Number(
|
| 497 |
-
result.Size.split("x")[0]
|
| 498 |
-
);
|
| 499 |
-
shadowRoot
|
| 500 |
-
.querySelectorAll("#txt2img_width input")[1]
|
| 501 |
-
.dispatchEvent(inputEvent);
|
| 502 |
-
|
| 503 |
-
shadowRoot.querySelectorAll("#txt2img_height input")[0].value = Number(
|
| 504 |
-
result.Size.split("x")[1]
|
| 505 |
-
);
|
| 506 |
-
shadowRoot
|
| 507 |
-
.querySelectorAll("#txt2img_height input")[0]
|
| 508 |
-
.dispatchEvent(inputEvent);
|
| 509 |
-
|
| 510 |
-
shadowRoot.querySelectorAll("#txt2img_height input")[1].value = Number(
|
| 511 |
-
result.Size.split("x")[1]
|
| 512 |
-
);
|
| 513 |
-
shadowRoot
|
| 514 |
-
.querySelectorAll("#txt2img_height input")[1]
|
| 515 |
-
.dispatchEvent(inputEvent);
|
| 516 |
-
|
| 517 |
-
shadowRoot.querySelector("#txt2img_seed input").value = Number(result.Seed);
|
| 518 |
-
shadowRoot.querySelector("#txt2img_seed input").dispatchEvent(inputEvent);
|
| 519 |
-
|
| 520 |
-
//高清修复
|
| 521 |
-
shadowRoot.querySelector("#txt2img_enable_hr input").checked =
|
| 522 |
-
!!result.Hiresupscaler;
|
| 523 |
-
shadowRoot
|
| 524 |
-
.querySelector("#txt2img_enable_hr input")
|
| 525 |
-
.dispatchEvent(changeEvent);
|
| 526 |
-
|
| 527 |
-
if (!!result.Hiresupscaler) {
|
| 528 |
-
const inputElement = document.querySelector(
|
| 529 |
-
"#txt2img_hr_upscaler > label > div > div.wrap-inner.svelte-a6vu2r > div > input"
|
| 530 |
-
);
|
| 531 |
-
const mousevent = new MouseEvent("mousedown", {
|
| 532 |
-
view: window,
|
| 533 |
-
bubbles: true,
|
| 534 |
-
cancelable: true,
|
| 535 |
-
});
|
| 536 |
-
inputElement.dispatchEvent(mousevent);
|
| 537 |
-
queueMicrotask(() => {
|
| 538 |
-
//将函数加入到任务队列待下一次轮询在执行
|
| 539 |
-
const listElem = shadowRoot.querySelector(
|
| 540 |
-
`[data-value="${result.Hiresupscaler}"]`
|
| 541 |
-
);
|
| 542 |
-
listElem.dispatchEvent(mousevent);
|
| 543 |
-
});
|
| 544 |
-
}
|
| 545 |
-
|
| 546 |
-
shadowRoot.querySelectorAll("#txt2img_hires_steps input")[0].value =
|
| 547 |
-
Number(result.Hiressteps) || 0;
|
| 548 |
-
shadowRoot
|
| 549 |
-
.querySelectorAll("#txt2img_hires_steps input")[0]
|
| 550 |
-
.dispatchEvent(inputEvent);
|
| 551 |
-
|
| 552 |
-
shadowRoot.querySelectorAll("#txt2img_hires_steps input")[1].value =
|
| 553 |
-
Number(result.Hiressteps) || 0;
|
| 554 |
-
shadowRoot
|
| 555 |
-
.querySelectorAll("#txt2img_hires_steps input")[1]
|
| 556 |
-
.dispatchEvent(inputEvent);
|
| 557 |
-
|
| 558 |
-
shadowRoot.querySelectorAll("#txt2img_denoising_strength input")[0].value =
|
| 559 |
-
Number(result.Denoisingstrength) || 0;
|
| 560 |
-
shadowRoot
|
| 561 |
-
.querySelectorAll("#txt2img_denoising_strength input")[0]
|
| 562 |
-
.dispatchEvent(inputEvent);
|
| 563 |
-
|
| 564 |
-
shadowRoot.querySelectorAll("#txt2img_denoising_strength input")[1].value =
|
| 565 |
-
Number(result.Denoisingstrength) || 0;
|
| 566 |
-
shadowRoot
|
| 567 |
-
.querySelectorAll("#txt2img_denoising_strength input")[1]
|
| 568 |
-
.dispatchEvent(inputEvent);
|
| 569 |
-
|
| 570 |
-
shadowRoot.querySelectorAll("#txt2img_hr_scale input")[0].value =
|
| 571 |
-
Number(result.Hiresupscale) || 1;
|
| 572 |
-
shadowRoot
|
| 573 |
-
.querySelectorAll("#txt2img_hr_scale input")[0]
|
| 574 |
-
.dispatchEvent(inputEvent);
|
| 575 |
-
|
| 576 |
-
shadowRoot.querySelectorAll("#txt2img_hr_scale input")[1].value =
|
| 577 |
-
Number(result.Hiresupscale) || 1;
|
| 578 |
-
shadowRoot
|
| 579 |
-
.querySelectorAll("#txt2img_hr_scale input")[1]
|
| 580 |
-
.dispatchEvent(inputEvent);
|
| 581 |
-
};
|
| 582 |
-
|
| 583 |
-
let img2ImgFormFill = () => {
|
| 584 |
-
let result = this.result;
|
| 585 |
-
const inputEvent = new Event("input");
|
| 586 |
-
const changeEvent = new Event("change", {
|
| 587 |
-
bubbles: true,
|
| 588 |
-
});
|
| 589 |
-
this.shadowRoot.querySelector('[class="tab-nav scroll-hide svelte-1g805jl"]').children[1].click();
|
| 590 |
-
this.shadowRoot.querySelectorAll('#mode_img2img button')[0].click()
|
| 591 |
-
|
| 592 |
-
this.shadowRoot.querySelectorAll('#setting_CLIP_stop_at_last_layers input')[0].value = Number(result.Clipskip)
|
| 593 |
-
this.shadowRoot.querySelectorAll('#setting_CLIP_stop_at_last_layers input')[0].dispatchEvent(inputEvent);
|
| 594 |
-
|
| 595 |
-
this.shadowRoot.querySelectorAll('#setting_CLIP_stop_at_last_layers input')[1].value = Number(result.Clipskip)
|
| 596 |
-
this.shadowRoot.querySelectorAll('#setting_CLIP_stop_at_last_layers input')[1].dispatchEvent(inputEvent);
|
| 597 |
-
|
| 598 |
-
this.shadowRoot.querySelector('#img2img_prompt textarea').value = result.prompt
|
| 599 |
-
this.shadowRoot.querySelector('#img2img_prompt textarea').dispatchEvent(inputEvent);
|
| 600 |
-
|
| 601 |
-
this.shadowRoot.querySelector('#img2img_neg_prompt textarea').value = result.negativePrompt
|
| 602 |
-
this.shadowRoot.querySelector('#img2img_neg_prompt textarea').dispatchEvent(inputEvent);
|
| 603 |
-
|
| 604 |
-
this.shadowRoot.querySelectorAll('#img2img_steps input')[0].value = Number(result.Steps)
|
| 605 |
-
this.shadowRoot.querySelectorAll('#img2img_steps input')[0].dispatchEvent(inputEvent);
|
| 606 |
-
|
| 607 |
-
this.shadowRoot.querySelectorAll('#img2img_steps input')[1].value = Number(result.Steps)
|
| 608 |
-
this.shadowRoot.querySelectorAll('#img2img_steps input')[1].dispatchEvent(inputEvent);
|
| 609 |
-
|
| 610 |
-
this.shadowRoot.querySelectorAll(`[value="${result.Sampler}"]`)[1].checked = true;
|
| 611 |
-
this.shadowRoot.querySelectorAll(`[value="${result.Sampler}"]`)[1].dispatchEvent(changeEvent)
|
| 612 |
-
|
| 613 |
-
this.shadowRoot.querySelectorAll('#img2img_width input')[0].value = Number(result.Size.split('x')[0])
|
| 614 |
-
this.shadowRoot.querySelectorAll('#img2img_width input')[0].dispatchEvent(inputEvent);
|
| 615 |
-
|
| 616 |
-
this.shadowRoot.querySelectorAll('#img2img_width input')[1].value = Number(result.Size.split('x')[0])
|
| 617 |
-
this.shadowRoot.querySelectorAll('#img2img_width input')[1].dispatchEvent(inputEvent);
|
| 618 |
-
|
| 619 |
-
this.shadowRoot.querySelectorAll('#img2img_height input')[0].value = Number(result.Size.split('x')[1])
|
| 620 |
-
this.shadowRoot.querySelectorAll('#img2img_height input')[0].dispatchEvent(inputEvent);
|
| 621 |
-
|
| 622 |
-
this.shadowRoot.querySelectorAll('#img2img_height input')[1].value = Number(result.Size.split('x')[1])
|
| 623 |
-
this.shadowRoot.querySelectorAll('#img2img_height input')[1].dispatchEvent(inputEvent);
|
| 624 |
-
|
| 625 |
-
this.shadowRoot.querySelector('#img2img_seed input').value = Number(result.Seed)
|
| 626 |
-
this.shadowRoot.querySelector('#img2img_seed input').dispatchEvent(inputEvent);
|
| 627 |
-
//图生图调用pnginfo的png
|
| 628 |
-
const file = new File([this.png_info_blob], 'example.png');
|
| 629 |
-
const dataTransfer = new DataTransfer();
|
| 630 |
-
dataTransfer.items.add(file);
|
| 631 |
-
const fileList = dataTransfer.files;
|
| 632 |
-
this.shadowRoot.querySelector("#img2img_image input").files = fileList;
|
| 633 |
-
this.shadowRoot.querySelector('#img2img_image input').dispatchEvent(changeEvent);
|
| 634 |
-
};
|
| 635 |
-
|
| 636 |
-
let inpaintTabFormFill=async ()=> {
|
| 637 |
-
let result = this.result;
|
| 638 |
-
const inputEvent = new Event("input");
|
| 639 |
-
const changeEvent = new Event("change", {
|
| 640 |
-
bubbles: true,
|
| 641 |
-
});
|
| 642 |
-
//局部重绘监听手机自适应
|
| 643 |
-
let screenWidth = window.screen.width;
|
| 644 |
-
//当屏幕为手机或者平板才会执行
|
| 645 |
-
// if(screenWidth<=768){
|
| 646 |
-
let inpaintButton=await delay_tab_click()
|
| 647 |
-
inpaintButton.onclick=async ()=>{
|
| 648 |
-
let temp=await delay_canvas()
|
| 649 |
-
temp.classList.remove('wrap', 'svelte-yigbas');
|
| 650 |
-
temp.querySelectorAll('canvas').forEach(e => e.style.height = '');
|
| 651 |
-
temp.querySelectorAll('canvas').forEach(e => {e.style.width = '100%';console.log(e.style.width)});
|
| 652 |
-
}
|
| 653 |
-
// }
|
| 654 |
-
this.shadowRoot.querySelector('[class="tab-nav scroll-hide svelte-1g805jl"]').children[1].click();
|
| 655 |
-
this.shadowRoot.querySelectorAll('#mode_img2img button')[2].click()
|
| 656 |
-
this.shadowRoot.querySelectorAll('#setting_CLIP_stop_at_last_layers input')[0].value = Number(result.Clipskip)
|
| 657 |
-
this.shadowRoot.querySelectorAll('#setting_CLIP_stop_at_last_layers input')[0].dispatchEvent(inputEvent);
|
| 658 |
-
|
| 659 |
-
this.shadowRoot.querySelectorAll('#setting_CLIP_stop_at_last_layers input')[1].value = Number(result.Clipskip)
|
| 660 |
-
this.shadowRoot.querySelectorAll('#setting_CLIP_stop_at_last_layers input')[1].dispatchEvent(inputEvent);
|
| 661 |
-
|
| 662 |
-
this.shadowRoot.querySelector('#img2img_prompt textarea').value = result.prompt
|
| 663 |
-
this.shadowRoot.querySelector('#img2img_prompt textarea').dispatchEvent(inputEvent);
|
| 664 |
-
|
| 665 |
-
this.shadowRoot.querySelector('#img2img_neg_prompt textarea').value = result.negativePrompt
|
| 666 |
-
this.shadowRoot.querySelector('#img2img_neg_prompt textarea').dispatchEvent(inputEvent);
|
| 667 |
-
|
| 668 |
-
this.shadowRoot.querySelectorAll('#img2img_steps input')[0].value = Number(result.Steps)
|
| 669 |
-
this.shadowRoot.querySelectorAll('#img2img_steps input')[0].dispatchEvent(inputEvent);
|
| 670 |
-
|
| 671 |
-
this.shadowRoot.querySelectorAll('#img2img_steps input')[1].value = Number(result.Steps)
|
| 672 |
-
this.shadowRoot.querySelectorAll('#img2img_steps input')[1].dispatchEvent(inputEvent);
|
| 673 |
-
|
| 674 |
-
this.shadowRoot.querySelectorAll(`[value="${result.Sampler}"]`)[1].checked = true;
|
| 675 |
-
this.shadowRoot.querySelectorAll(`[value="${result.Sampler}"]`)[1].dispatchEvent(changeEvent)
|
| 676 |
-
|
| 677 |
-
this.shadowRoot.querySelectorAll('#img2img_width input')[0].value = Number(result.Size.split('x')[0])
|
| 678 |
-
this.shadowRoot.querySelectorAll('#img2img_width input')[0].dispatchEvent(inputEvent);
|
| 679 |
-
|
| 680 |
-
this.shadowRoot.querySelectorAll('#img2img_width input')[1].value = Number(result.Size.split('x')[0])
|
| 681 |
-
this.shadowRoot.querySelectorAll('#img2img_width input')[1].dispatchEvent(inputEvent);
|
| 682 |
-
|
| 683 |
-
this.shadowRoot.querySelectorAll('#img2img_height input')[0].value = Number(result.Size.split('x')[1])
|
| 684 |
-
this.shadowRoot.querySelectorAll('#img2img_height input')[0].dispatchEvent(inputEvent);
|
| 685 |
-
|
| 686 |
-
this.shadowRoot.querySelectorAll('#img2img_height input')[1].value = Number(result.Size.split('x')[1])
|
| 687 |
-
this.shadowRoot.querySelectorAll('#img2img_height input')[1].dispatchEvent(inputEvent);
|
| 688 |
-
|
| 689 |
-
this.shadowRoot.querySelector('#img2img_seed input').value = Number(result.Seed)
|
| 690 |
-
this.shadowRoot.querySelector('#img2img_seed input').dispatchEvent(inputEvent);
|
| 691 |
-
//图生图调用pnginfo的png
|
| 692 |
-
const file = new File([this.png_info_blob], 'example.png');
|
| 693 |
-
const dataTransfer = new DataTransfer();
|
| 694 |
-
dataTransfer.items.add(file);
|
| 695 |
-
const fileList = dataTransfer.files;
|
| 696 |
-
this.shadowRoot.querySelector("#img2maskimg input").files = fileList;
|
| 697 |
-
this.shadowRoot.querySelector('#img2maskimg input').dispatchEvent(changeEvent);
|
| 698 |
-
};
|
| 699 |
-
|
| 700 |
-
|
| 701 |
-
//PNGinfo事件
|
| 702 |
-
async function png_info_edit() {
|
| 703 |
-
let png_info = await delayPng_info();
|
| 704 |
-
this.result = JSON.parse(localStorage.getItem("tempPngInfo")) || {};
|
| 705 |
-
if (this.result.fillType === "txt2img") {
|
| 706 |
-
txt2ImgFormFill();
|
| 707 |
-
}
|
| 708 |
-
if (this.result.fillType === "img2img") {
|
| 709 |
-
img2ImgFormFill();
|
| 710 |
-
}
|
| 711 |
-
if (this.result.fillType === "inpaint_tab") {
|
| 712 |
-
inpaintTabFormFill();
|
| 713 |
-
}
|
| 714 |
-
const changeEvent = new Event("change", {
|
| 715 |
-
});
|
| 716 |
-
|
| 717 |
-
//注册图片解析事件
|
| 718 |
-
png_info.addEventListener("change", async (e) => {
|
| 719 |
-
// 获取用户选择的文件
|
| 720 |
-
const png_info_img = await delay_png_change(png_info);
|
| 721 |
-
try{imgStorage(png_info_img)}
|
| 722 |
-
catch(e){console.log('图太大。将不会被保存到本地,')}
|
| 723 |
-
finally{
|
| 724 |
-
let png_info_blob = await convertDomImageToBlob(png_info_img);
|
| 725 |
-
this.png_info_blob = png_info_blob;
|
| 726 |
-
let res = await readNovelAITag(png_info_blob);
|
| 727 |
-
this.shadowRoot.querySelector("#component-985 > div.svelte-1ed2p3z").innerHTML = res.length ? res[0].text : "这不是一张stablediffusion图片";
|
| 728 |
-
|
| 729 |
-
//js对象形式转化
|
| 730 |
-
const result = {};
|
| 731 |
-
// const match = inputString.match(/(?<=prompt:)(.*)(?=Negative prompt:)/s)[0].trim();]
|
| 732 |
-
result.prompt = res[0].text.match(/(.*)(?=Negative prompt:)/s)[0].trim();
|
| 733 |
-
result.negativePrompt = res[0].text
|
| 734 |
-
.match(/(?<=Negative prompt:)(.*)(?=Steps:)/s)[0]
|
| 735 |
-
.trim();
|
| 736 |
-
let resArr = res[0].text
|
| 737 |
-
.split(result.negativePrompt)[1]
|
| 738 |
-
.trim()
|
| 739 |
-
.split(",");
|
| 740 |
-
resArr.forEach((e) => {
|
| 741 |
-
result[e.split(":")[0].replace(/\s+/g, "")] = e.split(":")[1].trim();
|
| 742 |
-
});
|
| 743 |
-
this.result = result;
|
| 744 |
-
|
| 745 |
-
//txt2img
|
| 746 |
-
this.shadowRoot.querySelector("#txt2img_tab").onclick = () => {
|
| 747 |
-
this.result.fillType = "txt2img";
|
| 748 |
-
localStorage.setItem("tempPngInfo", JSON.stringify(this.result));
|
| 749 |
-
txt2ImgFormFill();
|
| 750 |
-
};
|
| 751 |
-
//img2img
|
| 752 |
-
this.shadowRoot.querySelector("#tab_pnginfo #img2img_tab").onclick =
|
| 753 |
-
() => {
|
| 754 |
-
this.result.fillType = "img2img";
|
| 755 |
-
localStorage.setItem("tempPngInfo", JSON.stringify(this.result));
|
| 756 |
-
img2ImgFormFill();
|
| 757 |
-
};
|
| 758 |
-
//inpaint_tab
|
| 759 |
-
this.shadowRoot.querySelector("#tab_pnginfo #inpaint_tab").onclick =
|
| 760 |
-
() => {
|
| 761 |
-
this.result.fillType = "inpaint_tab";
|
| 762 |
-
localStorage.setItem("tempPngInfo", JSON.stringify(this.result));
|
| 763 |
-
inpaintTabFormFill();
|
| 764 |
-
};
|
| 765 |
-
}
|
| 766 |
-
});
|
| 767 |
-
png_info.querySelector("div.svelte-rlgzoo.fixed-height > div").addEventListener("drop",()=>{
|
| 768 |
-
if(png_info.querySelector("div.svelte-rlgzoo.fixed-height > div > div > button:nth-child(2)"))
|
| 769 |
-
png_info.querySelector("div.svelte-rlgzoo.fixed-height > div > div > button:nth-child(2)").click()
|
| 770 |
-
png_info.dispatchEvent(changeEvent)
|
| 771 |
-
})
|
| 772 |
-
}
|
| 773 |
-
document.addEventListener("DOMContentLoaded", async () => {
|
| 774 |
-
//初始化图生图图片
|
| 775 |
-
if(localStorage.getItem("png_info_img"))
|
| 776 |
-
this.png_info_blob = await readStoragePng(
|
| 777 |
-
localStorage.getItem("png_info_img")
|
| 778 |
-
);
|
| 779 |
-
|
| 780 |
-
png_info_edit();
|
| 781 |
-
|
| 782 |
-
});
|
| 783 |
-
})()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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