Spaces:
Runtime error
Runtime error
File size: 31,188 Bytes
b5ea024 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 |
function noop() {
}
function run(fn) {
return fn();
}
function blank_object() {
return /* @__PURE__ */ Object.create(null);
}
function run_all(fns) {
fns.forEach(run);
}
function is_function(thing) {
return typeof thing === "function";
}
function safe_not_equal(a, b) {
return a != a ? b == b : a !== b || (a && typeof a === "object" || typeof a === "function");
}
function is_empty(obj) {
return Object.keys(obj).length === 0;
}
function append(target, node) {
target.appendChild(node);
}
function append_styles(target, style_sheet_id, styles) {
const append_styles_to = get_root_for_style(target);
if (!append_styles_to.getElementById(style_sheet_id)) {
const style = element("style");
style.id = style_sheet_id;
style.textContent = styles;
append_stylesheet(append_styles_to, style);
}
}
function get_root_for_style(node) {
if (!node)
return document;
const root = node.getRootNode ? node.getRootNode() : node.ownerDocument;
if (root && root.host) {
return root;
}
return node.ownerDocument;
}
function append_stylesheet(node, style) {
append(node.head || node, style);
return style.sheet;
}
function insert(target, node, anchor) {
target.insertBefore(node, anchor || null);
}
function detach(node) {
if (node.parentNode) {
node.parentNode.removeChild(node);
}
}
function destroy_each(iterations, detaching) {
for (let i = 0; i < iterations.length; i += 1) {
if (iterations[i])
iterations[i].d(detaching);
}
}
function element(name) {
return document.createElement(name);
}
function text(data) {
return document.createTextNode(data);
}
function space() {
return text(" ");
}
function empty() {
return text("");
}
function listen(node, event, handler, options) {
node.addEventListener(event, handler, options);
return () => node.removeEventListener(event, handler, options);
}
function attr(node, attribute, value) {
if (value == null)
node.removeAttribute(attribute);
else if (node.getAttribute(attribute) !== value)
node.setAttribute(attribute, value);
}
function children(element2) {
return Array.from(element2.childNodes);
}
function set_data(text2, data) {
data = "" + data;
if (text2.data === data)
return;
text2.data = data;
}
function toggle_class(element2, name, toggle) {
element2.classList[toggle ? "add" : "remove"](name);
}
let current_component;
function set_current_component(component) {
current_component = component;
}
const dirty_components = [];
const binding_callbacks = [];
let render_callbacks = [];
const flush_callbacks = [];
const resolved_promise = /* @__PURE__ */ Promise.resolve();
let update_scheduled = false;
function schedule_update() {
if (!update_scheduled) {
update_scheduled = true;
resolved_promise.then(flush);
}
}
function add_render_callback(fn) {
render_callbacks.push(fn);
}
const seen_callbacks = /* @__PURE__ */ new Set();
let flushidx = 0;
function flush() {
if (flushidx !== 0) {
return;
}
const saved_component = current_component;
do {
try {
while (flushidx < dirty_components.length) {
const component = dirty_components[flushidx];
flushidx++;
set_current_component(component);
update(component.$$);
}
} catch (e) {
dirty_components.length = 0;
flushidx = 0;
throw e;
}
set_current_component(null);
dirty_components.length = 0;
flushidx = 0;
while (binding_callbacks.length)
binding_callbacks.pop()();
for (let i = 0; i < render_callbacks.length; i += 1) {
const callback = render_callbacks[i];
if (!seen_callbacks.has(callback)) {
seen_callbacks.add(callback);
callback();
}
}
render_callbacks.length = 0;
} while (dirty_components.length);
while (flush_callbacks.length) {
flush_callbacks.pop()();
}
update_scheduled = false;
seen_callbacks.clear();
set_current_component(saved_component);
}
function update($$) {
if ($$.fragment !== null) {
$$.update();
run_all($$.before_update);
const dirty = $$.dirty;
$$.dirty = [-1];
$$.fragment && $$.fragment.p($$.ctx, dirty);
$$.after_update.forEach(add_render_callback);
}
}
function flush_render_callbacks(fns) {
const filtered = [];
const targets = [];
render_callbacks.forEach((c) => fns.indexOf(c) === -1 ? filtered.push(c) : targets.push(c));
targets.forEach((c) => c());
render_callbacks = filtered;
}
const outroing = /* @__PURE__ */ new Set();
let outros;
function group_outros() {
outros = {
r: 0,
c: [],
p: outros
// parent group
};
}
function check_outros() {
if (!outros.r) {
run_all(outros.c);
}
outros = outros.p;
}
function transition_in(block, local) {
if (block && block.i) {
outroing.delete(block);
block.i(local);
}
}
function transition_out(block, local, detach2, callback) {
if (block && block.o) {
if (outroing.has(block))
return;
outroing.add(block);
outros.c.push(() => {
outroing.delete(block);
if (callback) {
if (detach2)
block.d(1);
callback();
}
});
block.o(local);
} else if (callback) {
callback();
}
}
function create_component(block) {
block && block.c();
}
function mount_component(component, target, anchor, customElement) {
const { fragment, after_update } = component.$$;
fragment && fragment.m(target, anchor);
if (!customElement) {
add_render_callback(() => {
const new_on_destroy = component.$$.on_mount.map(run).filter(is_function);
if (component.$$.on_destroy) {
component.$$.on_destroy.push(...new_on_destroy);
} else {
run_all(new_on_destroy);
}
component.$$.on_mount = [];
});
}
after_update.forEach(add_render_callback);
}
function destroy_component(component, detaching) {
const $$ = component.$$;
if ($$.fragment !== null) {
flush_render_callbacks($$.after_update);
run_all($$.on_destroy);
$$.fragment && $$.fragment.d(detaching);
$$.on_destroy = $$.fragment = null;
$$.ctx = [];
}
}
function make_dirty(component, i) {
if (component.$$.dirty[0] === -1) {
dirty_components.push(component);
schedule_update();
component.$$.dirty.fill(0);
}
component.$$.dirty[i / 31 | 0] |= 1 << i % 31;
}
function init(component, options, instance2, create_fragment2, not_equal, props, append_styles2, dirty = [-1]) {
const parent_component = current_component;
set_current_component(component);
const $$ = component.$$ = {
fragment: null,
ctx: [],
// state
props,
update: noop,
not_equal,
bound: blank_object(),
// lifecycle
on_mount: [],
on_destroy: [],
on_disconnect: [],
before_update: [],
after_update: [],
context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),
// everything else
callbacks: blank_object(),
dirty,
skip_bound: false,
root: options.target || parent_component.$$.root
};
append_styles2 && append_styles2($$.root);
let ready = false;
$$.ctx = instance2 ? instance2(component, options.props || {}, (i, ret, ...rest) => {
const value = rest.length ? rest[0] : ret;
if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
if (!$$.skip_bound && $$.bound[i])
$$.bound[i](value);
if (ready)
make_dirty(component, i);
}
return ret;
}) : [];
$$.update();
ready = true;
run_all($$.before_update);
$$.fragment = create_fragment2 ? create_fragment2($$.ctx) : false;
if (options.target) {
if (options.hydrate) {
const nodes = children(options.target);
$$.fragment && $$.fragment.l(nodes);
nodes.forEach(detach);
} else {
$$.fragment && $$.fragment.c();
}
if (options.intro)
transition_in(component.$$.fragment);
mount_component(component, options.target, options.anchor, options.customElement);
flush();
}
set_current_component(parent_component);
}
class SvelteComponent {
$destroy() {
destroy_component(this, 1);
this.$destroy = noop;
}
$on(type, callback) {
if (!is_function(callback)) {
return noop;
}
const callbacks = this.$$.callbacks[type] || (this.$$.callbacks[type] = []);
callbacks.push(callback);
return () => {
const index = callbacks.indexOf(callback);
if (index !== -1)
callbacks.splice(index, 1);
};
}
$set($$props) {
if (this.$$set && !is_empty($$props)) {
this.$$.skip_bound = true;
this.$$set($$props);
this.$$.skip_bound = false;
}
}
}
function add_css(target) {
append_styles(target, "svelte-6z96o6", ".svelte-6z96o6:where(._jsonList){list-style:none;margin:0;padding:0;padding-left:var(--jsonPaddingLeft, 1rem);border-left:var(--jsonBorderLeft, 1px dotted)}.svelte-6z96o6:where(._jsonBkt){color:var(--jsonBracketColor, currentcolor)}.svelte-6z96o6:where(._jsonBkt):not(.empty):hover{cursor:pointer;background:var(--jsonBracketHoverBackground, #e5e7eb)}.svelte-6z96o6:where(._jsonSep){color:var(--jsonSeparatorColor, currentcolor)}.svelte-6z96o6:where(._jsonKey){color:var(--jsonKeyColor, currentcolor)}.svelte-6z96o6:where(._jsonVal){color:var(--jsonValColor, #9ca3af)}:where(._jsonVal).string.svelte-6z96o6{color:var(--jsonValStringColor, #059669)}:where(._jsonVal).number.svelte-6z96o6{color:var(--jsonValNumberColor, #d97706)}:where(._jsonVal).boolean.svelte-6z96o6{color:var(--jsonValBooleanColor, #2563eb)}");
}
function get_each_context(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[10] = list[i];
child_ctx[12] = i;
return child_ctx;
}
function create_else_block(ctx) {
let span0;
let t0_value = (
/*brackets*/
ctx[6][0] + ""
);
let t0;
let t1;
let ul;
let t2;
let span1;
let t3_value = (
/*brackets*/
ctx[6][1] + ""
);
let t3;
let if_block_anchor;
let current;
let mounted;
let dispose;
let each_value = (
/*items*/
ctx[5]
);
let each_blocks = [];
for (let i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i));
}
const out = (i) => transition_out(each_blocks[i], 1, 1, () => {
each_blocks[i] = null;
});
let if_block = !/*_last*/
ctx[3] && create_if_block_4();
return {
c() {
span0 = element("span");
t0 = text(t0_value);
t1 = space();
ul = element("ul");
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
t2 = space();
span1 = element("span");
t3 = text(t3_value);
if (if_block)
if_block.c();
if_block_anchor = empty();
attr(span0, "class", "_jsonBkt svelte-6z96o6");
attr(span0, "role", "button");
attr(span0, "tabindex", "0");
toggle_class(
span0,
"isArray",
/*isArray*/
ctx[4]
);
attr(ul, "class", "_jsonList svelte-6z96o6");
attr(span1, "class", "_jsonBkt svelte-6z96o6");
attr(span1, "role", "button");
attr(span1, "tabindex", "0");
toggle_class(
span1,
"isArray",
/*isArray*/
ctx[4]
);
},
m(target, anchor) {
insert(target, span0, anchor);
append(span0, t0);
insert(target, t1, anchor);
insert(target, ul, anchor);
for (let i = 0; i < each_blocks.length; i += 1) {
if (each_blocks[i]) {
each_blocks[i].m(ul, null);
}
}
insert(target, t2, anchor);
insert(target, span1, anchor);
append(span1, t3);
if (if_block)
if_block.m(target, anchor);
insert(target, if_block_anchor, anchor);
current = true;
if (!mounted) {
dispose = [
listen(
span0,
"click",
/*clicked*/
ctx[8]
),
listen(
span0,
"keydown",
/*pressed*/
ctx[9]
),
listen(
span1,
"click",
/*clicked*/
ctx[8]
),
listen(
span1,
"keydown",
/*pressed*/
ctx[9]
)
];
mounted = true;
}
},
p(ctx2, dirty) {
if ((!current || dirty & /*brackets*/
64) && t0_value !== (t0_value = /*brackets*/
ctx2[6][0] + ""))
set_data(t0, t0_value);
if (!current || dirty & /*isArray*/
16) {
toggle_class(
span0,
"isArray",
/*isArray*/
ctx2[4]
);
}
if (dirty & /*json, items, depth, _cur, getType, format, isArray*/
55) {
each_value = /*items*/
ctx2[5];
let i;
for (i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context(ctx2, each_value, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
transition_in(each_blocks[i], 1);
} else {
each_blocks[i] = create_each_block(child_ctx);
each_blocks[i].c();
transition_in(each_blocks[i], 1);
each_blocks[i].m(ul, null);
}
}
group_outros();
for (i = each_value.length; i < each_blocks.length; i += 1) {
out(i);
}
check_outros();
}
if ((!current || dirty & /*brackets*/
64) && t3_value !== (t3_value = /*brackets*/
ctx2[6][1] + ""))
set_data(t3, t3_value);
if (!current || dirty & /*isArray*/
16) {
toggle_class(
span1,
"isArray",
/*isArray*/
ctx2[4]
);
}
if (!/*_last*/
ctx2[3]) {
if (if_block)
;
else {
if_block = create_if_block_4();
if_block.c();
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
} else if (if_block) {
if_block.d(1);
if_block = null;
}
},
i(local) {
if (current)
return;
for (let i = 0; i < each_value.length; i += 1) {
transition_in(each_blocks[i]);
}
current = true;
},
o(local) {
each_blocks = each_blocks.filter(Boolean);
for (let i = 0; i < each_blocks.length; i += 1) {
transition_out(each_blocks[i]);
}
current = false;
},
d(detaching) {
if (detaching)
detach(span0);
if (detaching)
detach(t1);
if (detaching)
detach(ul);
destroy_each(each_blocks, detaching);
if (detaching)
detach(t2);
if (detaching)
detach(span1);
if (if_block)
if_block.d(detaching);
if (detaching)
detach(if_block_anchor);
mounted = false;
run_all(dispose);
}
};
}
function create_if_block_2(ctx) {
let span;
let t0_value = (
/*brackets*/
ctx[6][0] + ""
);
let t0;
let t1;
let t2_value = (
/*brackets*/
ctx[6][1] + ""
);
let t2;
let if_block_anchor;
let mounted;
let dispose;
let if_block = !/*_last*/
ctx[3] && /*collapsed*/
ctx[7] && create_if_block_3();
return {
c() {
span = element("span");
t0 = text(t0_value);
t1 = text("...");
t2 = text(t2_value);
if (if_block)
if_block.c();
if_block_anchor = empty();
attr(span, "class", "_jsonBkt svelte-6z96o6");
attr(span, "role", "button");
attr(span, "tabindex", "0");
toggle_class(
span,
"isArray",
/*isArray*/
ctx[4]
);
},
m(target, anchor) {
insert(target, span, anchor);
append(span, t0);
append(span, t1);
append(span, t2);
if (if_block)
if_block.m(target, anchor);
insert(target, if_block_anchor, anchor);
if (!mounted) {
dispose = [
listen(
span,
"click",
/*clicked*/
ctx[8]
),
listen(
span,
"keydown",
/*pressed*/
ctx[9]
)
];
mounted = true;
}
},
p(ctx2, dirty) {
if (dirty & /*brackets*/
64 && t0_value !== (t0_value = /*brackets*/
ctx2[6][0] + ""))
set_data(t0, t0_value);
if (dirty & /*brackets*/
64 && t2_value !== (t2_value = /*brackets*/
ctx2[6][1] + ""))
set_data(t2, t2_value);
if (dirty & /*isArray*/
16) {
toggle_class(
span,
"isArray",
/*isArray*/
ctx2[4]
);
}
if (!/*_last*/
ctx2[3] && /*collapsed*/
ctx2[7]) {
if (if_block)
;
else {
if_block = create_if_block_3();
if_block.c();
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
} else if (if_block) {
if_block.d(1);
if_block = null;
}
},
i: noop,
o: noop,
d(detaching) {
if (detaching)
detach(span);
if (if_block)
if_block.d(detaching);
if (detaching)
detach(if_block_anchor);
mounted = false;
run_all(dispose);
}
};
}
function create_if_block(ctx) {
let span;
let t0_value = (
/*brackets*/
ctx[6][0] + ""
);
let t0;
let t1_value = (
/*brackets*/
ctx[6][1] + ""
);
let t1;
let if_block_anchor;
let if_block = !/*_last*/
ctx[3] && create_if_block_1();
return {
c() {
span = element("span");
t0 = text(t0_value);
t1 = text(t1_value);
if (if_block)
if_block.c();
if_block_anchor = empty();
attr(span, "class", "_jsonBkt empty svelte-6z96o6");
toggle_class(
span,
"isArray",
/*isArray*/
ctx[4]
);
},
m(target, anchor) {
insert(target, span, anchor);
append(span, t0);
append(span, t1);
if (if_block)
if_block.m(target, anchor);
insert(target, if_block_anchor, anchor);
},
p(ctx2, dirty) {
if (dirty & /*brackets*/
64 && t0_value !== (t0_value = /*brackets*/
ctx2[6][0] + ""))
set_data(t0, t0_value);
if (dirty & /*brackets*/
64 && t1_value !== (t1_value = /*brackets*/
ctx2[6][1] + ""))
set_data(t1, t1_value);
if (dirty & /*isArray*/
16) {
toggle_class(
span,
"isArray",
/*isArray*/
ctx2[4]
);
}
if (!/*_last*/
ctx2[3]) {
if (if_block)
;
else {
if_block = create_if_block_1();
if_block.c();
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
} else if (if_block) {
if_block.d(1);
if_block = null;
}
},
i: noop,
o: noop,
d(detaching) {
if (detaching)
detach(span);
if (if_block)
if_block.d(detaching);
if (detaching)
detach(if_block_anchor);
}
};
}
function create_if_block_7(ctx) {
let span0;
let t0;
let t1_value = (
/*i*/
ctx[10] + ""
);
let t1;
let t2;
let span1;
return {
c() {
span0 = element("span");
t0 = text('"');
t1 = text(t1_value);
t2 = text('"');
span1 = element("span");
span1.textContent = ":";
attr(span0, "class", "_jsonKey svelte-6z96o6");
attr(span1, "class", "_jsonSep svelte-6z96o6");
},
m(target, anchor) {
insert(target, span0, anchor);
append(span0, t0);
append(span0, t1);
append(span0, t2);
insert(target, span1, anchor);
},
p(ctx2, dirty) {
if (dirty & /*items*/
32 && t1_value !== (t1_value = /*i*/
ctx2[10] + ""))
set_data(t1, t1_value);
},
d(detaching) {
if (detaching)
detach(span0);
if (detaching)
detach(span1);
}
};
}
function create_else_block_1(ctx) {
let span;
let t_value = format(
/*json*/
ctx[0][
/*i*/
ctx[10]
]
) + "";
let t;
let span_class_value;
let if_block_anchor;
let if_block = (
/*idx*/
ctx[12] < /*items*/
ctx[5].length - 1 && create_if_block_6()
);
return {
c() {
span = element("span");
t = text(t_value);
if (if_block)
if_block.c();
if_block_anchor = empty();
attr(span, "class", span_class_value = "_jsonVal " + getType(
/*json*/
ctx[0][
/*i*/
ctx[10]
]
) + " svelte-6z96o6");
},
m(target, anchor) {
insert(target, span, anchor);
append(span, t);
if (if_block)
if_block.m(target, anchor);
insert(target, if_block_anchor, anchor);
},
p(ctx2, dirty) {
if (dirty & /*json, items*/
33 && t_value !== (t_value = format(
/*json*/
ctx2[0][
/*i*/
ctx2[10]
]
) + ""))
set_data(t, t_value);
if (dirty & /*json, items*/
33 && span_class_value !== (span_class_value = "_jsonVal " + getType(
/*json*/
ctx2[0][
/*i*/
ctx2[10]
]
) + " svelte-6z96o6")) {
attr(span, "class", span_class_value);
}
if (
/*idx*/
ctx2[12] < /*items*/
ctx2[5].length - 1
) {
if (if_block)
;
else {
if_block = create_if_block_6();
if_block.c();
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
} else if (if_block) {
if_block.d(1);
if_block = null;
}
},
i: noop,
o: noop,
d(detaching) {
if (detaching)
detach(span);
if (if_block)
if_block.d(detaching);
if (detaching)
detach(if_block_anchor);
}
};
}
function create_if_block_5(ctx) {
let jsonview;
let current;
jsonview = new JsonView({
props: {
json: (
/*json*/
ctx[0][
/*i*/
ctx[10]
]
),
depth: (
/*depth*/
ctx[1]
),
_cur: (
/*_cur*/
ctx[2] + 1
),
_last: (
/*idx*/
ctx[12] === /*items*/
ctx[5].length - 1
)
}
});
return {
c() {
create_component(jsonview.$$.fragment);
},
m(target, anchor) {
mount_component(jsonview, target, anchor);
current = true;
},
p(ctx2, dirty) {
const jsonview_changes = {};
if (dirty & /*json, items*/
33)
jsonview_changes.json = /*json*/
ctx2[0][
/*i*/
ctx2[10]
];
if (dirty & /*depth*/
2)
jsonview_changes.depth = /*depth*/
ctx2[1];
if (dirty & /*_cur*/
4)
jsonview_changes._cur = /*_cur*/
ctx2[2] + 1;
if (dirty & /*items*/
32)
jsonview_changes._last = /*idx*/
ctx2[12] === /*items*/
ctx2[5].length - 1;
jsonview.$set(jsonview_changes);
},
i(local) {
if (current)
return;
transition_in(jsonview.$$.fragment, local);
current = true;
},
o(local) {
transition_out(jsonview.$$.fragment, local);
current = false;
},
d(detaching) {
destroy_component(jsonview, detaching);
}
};
}
function create_if_block_6(ctx) {
let span;
return {
c() {
span = element("span");
span.textContent = ",";
attr(span, "class", "_jsonSep svelte-6z96o6");
},
m(target, anchor) {
insert(target, span, anchor);
},
d(detaching) {
if (detaching)
detach(span);
}
};
}
function create_each_block(ctx) {
let li;
let t0;
let show_if;
let current_block_type_index;
let if_block1;
let t1;
let current;
let if_block0 = !/*isArray*/
ctx[4] && create_if_block_7(ctx);
const if_block_creators = [create_if_block_5, create_else_block_1];
const if_blocks = [];
function select_block_type_1(ctx2, dirty) {
if (dirty & /*json, items*/
33)
show_if = null;
if (show_if == null)
show_if = !!(getType(
/*json*/
ctx2[0][
/*i*/
ctx2[10]
]
) === "object");
if (show_if)
return 0;
return 1;
}
current_block_type_index = select_block_type_1(ctx, -1);
if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
return {
c() {
li = element("li");
if (if_block0)
if_block0.c();
t0 = space();
if_block1.c();
t1 = space();
attr(li, "class", "svelte-6z96o6");
},
m(target, anchor) {
insert(target, li, anchor);
if (if_block0)
if_block0.m(li, null);
append(li, t0);
if_blocks[current_block_type_index].m(li, null);
append(li, t1);
current = true;
},
p(ctx2, dirty) {
if (!/*isArray*/
ctx2[4]) {
if (if_block0) {
if_block0.p(ctx2, dirty);
} else {
if_block0 = create_if_block_7(ctx2);
if_block0.c();
if_block0.m(li, t0);
}
} else if (if_block0) {
if_block0.d(1);
if_block0 = null;
}
let previous_block_index = current_block_type_index;
current_block_type_index = select_block_type_1(ctx2, dirty);
if (current_block_type_index === previous_block_index) {
if_blocks[current_block_type_index].p(ctx2, dirty);
} else {
group_outros();
transition_out(if_blocks[previous_block_index], 1, 1, () => {
if_blocks[previous_block_index] = null;
});
check_outros();
if_block1 = if_blocks[current_block_type_index];
if (!if_block1) {
if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
if_block1.c();
} else {
if_block1.p(ctx2, dirty);
}
transition_in(if_block1, 1);
if_block1.m(li, t1);
}
},
i(local) {
if (current)
return;
transition_in(if_block1);
current = true;
},
o(local) {
transition_out(if_block1);
current = false;
},
d(detaching) {
if (detaching)
detach(li);
if (if_block0)
if_block0.d();
if_blocks[current_block_type_index].d();
}
};
}
function create_if_block_4(ctx) {
let span;
return {
c() {
span = element("span");
span.textContent = ",";
attr(span, "class", "_jsonSep svelte-6z96o6");
},
m(target, anchor) {
insert(target, span, anchor);
},
d(detaching) {
if (detaching)
detach(span);
}
};
}
function create_if_block_3(ctx) {
let span;
return {
c() {
span = element("span");
span.textContent = ",";
attr(span, "class", "_jsonSep svelte-6z96o6");
},
m(target, anchor) {
insert(target, span, anchor);
},
d(detaching) {
if (detaching)
detach(span);
}
};
}
function create_if_block_1(ctx) {
let span;
return {
c() {
span = element("span");
span.textContent = ",";
attr(span, "class", "_jsonSep svelte-6z96o6");
},
m(target, anchor) {
insert(target, span, anchor);
},
d(detaching) {
if (detaching)
detach(span);
}
};
}
function create_fragment(ctx) {
let current_block_type_index;
let if_block;
let if_block_anchor;
let current;
const if_block_creators = [create_if_block, create_if_block_2, create_else_block];
const if_blocks = [];
function select_block_type(ctx2, dirty) {
if (!/*items*/
ctx2[5].length)
return 0;
if (
/*collapsed*/
ctx2[7]
)
return 1;
return 2;
}
current_block_type_index = select_block_type(ctx);
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
return {
c() {
if_block.c();
if_block_anchor = empty();
},
m(target, anchor) {
if_blocks[current_block_type_index].m(target, anchor);
insert(target, if_block_anchor, anchor);
current = true;
},
p(ctx2, [dirty]) {
let previous_block_index = current_block_type_index;
current_block_type_index = select_block_type(ctx2);
if (current_block_type_index === previous_block_index) {
if_blocks[current_block_type_index].p(ctx2, dirty);
} else {
group_outros();
transition_out(if_blocks[previous_block_index], 1, 1, () => {
if_blocks[previous_block_index] = null;
});
check_outros();
if_block = if_blocks[current_block_type_index];
if (!if_block) {
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
if_block.c();
} else {
if_block.p(ctx2, dirty);
}
transition_in(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
},
i(local) {
if (current)
return;
transition_in(if_block);
current = true;
},
o(local) {
transition_out(if_block);
current = false;
},
d(detaching) {
if_blocks[current_block_type_index].d(detaching);
if (detaching)
detach(if_block_anchor);
}
};
}
function getType(i) {
if (i === null)
return "null";
return typeof i;
}
function format(i) {
const t = getType(i);
if (t === "string")
return `"${i}"`;
if (t === "function")
return "f () {...}";
if (t === "symbol")
return i.toString();
return i;
}
function instance($$self, $$props, $$invalidate) {
let { json } = $$props;
let { depth = Infinity } = $$props;
let { _cur = 0 } = $$props;
let { _last = true } = $$props;
let items;
let isArray = false;
let brackets = ["", ""];
let collapsed = false;
function clicked() {
$$invalidate(7, collapsed = !collapsed);
}
function pressed(e) {
if (e instanceof KeyboardEvent && ["Enter", " "].includes(e.key))
clicked();
}
$$self.$$set = ($$props2) => {
if ("json" in $$props2)
$$invalidate(0, json = $$props2.json);
if ("depth" in $$props2)
$$invalidate(1, depth = $$props2.depth);
if ("_cur" in $$props2)
$$invalidate(2, _cur = $$props2._cur);
if ("_last" in $$props2)
$$invalidate(3, _last = $$props2._last);
};
$$self.$$.update = () => {
if ($$self.$$.dirty & /*json, isArray*/
17) {
{
$$invalidate(5, items = getType(json) === "object" ? Object.keys(json) : []);
$$invalidate(4, isArray = Array.isArray(json));
$$invalidate(6, brackets = isArray ? ["[", "]"] : ["{", "}"]);
}
}
if ($$self.$$.dirty & /*depth, _cur*/
6) {
$$invalidate(7, collapsed = depth < _cur);
}
};
return [
json,
depth,
_cur,
_last,
isArray,
items,
brackets,
collapsed,
clicked,
pressed
];
}
class JsonView extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, { json: 0, depth: 1, _cur: 2, _last: 3 }, add_css);
}
}
export {
JsonView
};
|