1import Index$1 from './Index-0d7ad3de.js'; 2import { T as Textbox } from './Textbox-c0ac40a6.js'; 3import { a as Button, B as Block } from './Button-c2bc75a7.js'; 4import { $ as $format } from './Index-9d23d982.js'; 5/* empty css */import './index-12d4b00b.js'; 6import Index from './Index-24a33ce1.js'; 7import './BlockTitle-570a9594.js'; 8import './Info-5e7930a9.js'; 9import './Check-f7edb5d9.js'; 10import './Copy-a69620a8.js'; 11import './svelte/svelte.js'; 12 13const Login_svelte_svelte_type_style_lang = ''; 14 15/* src/Login.svelte generated by Svelte v4.2.2 */ 16const { 17 SvelteComponent, 18 add_flush_callback, 19 append, 20 attr, 21 bind, 22 binding_callbacks, 23 component_subscribe, 24 create_component, 25 destroy_component, 26 detach, 27 element, 28 init, 29 insert, 30 mount_component, 31 safe_not_equal, 32 set_data, 33 space, 34 text, 35 toggle_class, 36 transition_in, 37 transition_out 38} = window.__gradio__svelte__internal; 39function create_if_block_2(ctx) { 40 let p; 41 42 return { 43 c() { 44 p = element("p"); 45 attr(p, "class", "auth svelte-1ogxbi0"); 46 }, 47 m(target, anchor) { 48 insert(target, p, anchor); 49 p.innerHTML = /*auth_message*/ ctx[0]; 50 }, 51 p(ctx, dirty) { 52 if (dirty & /*auth_message*/ 1) p.innerHTML = /*auth_message*/ ctx[0]; }, 53 d(detaching) { 54 if (detaching) { 55 detach(p); 56 } 57 } 58 }; 59} 60 61// (39:2) {#if space_id} 62function create_if_block_1(ctx) { 63 let p; 64 let t_value = /*$_*/ ctx[6]("login.enable_cookies") + ""; 65 let t; 66 67 return { 68 c() { 69 p = element("p"); 70 t = text(t_value); 71 attr(p, "class", "auth svelte-1ogxbi0"); 72 }, 73 m(target, anchor) { 74 insert(target, p, anchor); 75 append(p, t); 76 }, 77 p(ctx, dirty) { 78 if (dirty & /*$_*/ 64 && t_value !== (t_value = /*$_*/ ctx[6]("login.enable_cookies") + "")) set_data(t, t_value); 79 }, 80 d(detaching) { 81 if (detaching) { 82 detach(p); 83 } 84 } 85 }; 86} 87 88// (44:2) {#if incorrect_credentials} 89function create_if_block(ctx) { 90 let p; 91 let t_value = /*$_*/ ctx[6]("login.incorrect_credentials") + ""; 92 let t; 93 94 return { 95 c() { 96 p = element("p"); 97 t = text(t_value); 98 attr(p, "class", "creds svelte-1ogxbi0"); 99 }, 100 m(target, anchor) { 101 insert(target, p, anchor); 102 append(p, t); 103 }, 104 p(ctx, dirty) { 105 if (dirty & /*$_*/ 64 && t_value !== (t_value = /*$_*/ ctx[6]("login.incorrect_credentials") + "")) set_data(t, t_value); 106 }, 107 d(detaching) { 108 if (detaching) { 109 detach(p); 110 } 111 } 112 }; 113} 114 115// (48:3) <Block> 116function create_default_slot_4(ctx) { 117 let textbox; 118 let updating_value; 119 let current; 120 121 function textbox_value_binding(value) { 122 /*textbox_value_binding*/ ctx[9](value); 123 } 124 125 let textbox_props = { 126 label: "username", 127 lines: 1, 128 show_label: true, 129 max_lines: 1 130 }; 131 132 if (/*username*/ ctx[3] !== void 0) { 133 textbox_props.value = /*username*/ ctx[3]; 134 } 135 136 textbox = new Textbox({ props: textbox_props }); 137 binding_callbacks.push(() => bind(textbox, 'value', textbox_value_binding)); 138 textbox.$on("submit", /*submit*/ ctx[7]); 139 140 return { 141 c() { 142 create_component(textbox.$$.fragment); 143 }, 144 m(target, anchor) { 145 mount_component(textbox, target, anchor); 146 current = true; 147 }, 148 p(ctx, dirty) { 149 const textbox_changes = {}; 150 151 if (!updating_value && dirty & /*username*/ 8) { 152 updating_value = true; 153 textbox_changes.value = /*username*/ ctx[3]; 154 add_flush_callback(() => updating_value = false); 155 } 156 157 textbox.$set(textbox_changes); 158 }, 159 i(local) { 160 if (current) return; 161 transition_in(textbox.$$.fragment, local); 162 current = true; 163 }, 164 o(local) { 165 transition_out(textbox.$$.fragment, local); 166 current = false; 167 }, 168 d(detaching) { 169 destroy_component(textbox, detaching); 170 } 171 }; 172} 173 174// (59:3) <Block> 175function create_default_slot_3(ctx) { 176 let textbox; 177 let updating_value; 178 let current; 179 180 function textbox_value_binding_1(value) { 181 /*textbox_value_binding_1*/ ctx[10](value); 182 } 183 184 let textbox_props = { 185 label: "password", 186 lines: 1, 187 show_label: true, 188 max_lines: 1, 189 type: "password" 190 }; 191 192 if (/*password*/ ctx[4] !== void 0) { 193 textbox_props.value = /*password*/ ctx[4]; 194 } 195 196 textbox = new Textbox({ props: textbox_props }); 197 binding_callbacks.push(() => bind(textbox, 'value', textbox_value_binding_1)); 198 textbox.$on("submit", /*submit*/ ctx[7]); 199 200 return { 201 c() { 202 create_component(textbox.$$.fragment); 203 }, 204 m(target, anchor) { 205 mount_component(textbox, target, anchor); 206 current = true; 207 }, 208 p(ctx, dirty) { 209 const textbox_changes = {}; 210 211 if (!updating_value && dirty & /*password*/ 16) { 212 updating_value = true; 213 textbox_changes.value = /*password*/ ctx[4]; 214 add_flush_callback(() => updating_value = false); 215 } 216 217 textbox.$set(textbox_changes); 218 }, 219 i(local) { 220 if (current) return; 221 transition_in(textbox.$$.fragment, local); 222 current = true; 223 }, 224 o(local) { 225 transition_out(textbox.$$.fragment, local); 226 current = false;
227 }, 228 d(detaching) { 229 destroy_component(textbox, detaching); 230 } 231 }; 232} 233 234// (47:2) <Form> 235function create_default_slot_2(ctx) { 236 let block0; 237 let t; 238 let block1; 239 let current; 240 241 block0 = new Block({ 242 props: { 243 $$slots: { default: [create_default_slot_4] }, 244 $$scope: { ctx } 245 } 246 }); 247 248 block1 = new Block({ 249 props: { 250 $$slots: { default: [create_default_slot_3] }, 251 $$scope: { ctx } 252 } 253 }); 254 255 return { 256 c() { 257 create_component(block0.$$.fragment); 258 t = space(); 259 create_component(block1.$$.fragment); 260 }, 261 m(target, anchor) { 262 mount_component(block0, target, anchor); 263 insert(target, t, anchor); 264 mount_component(block1, target, anchor); 265 current = true; 266 }, 267 p(ctx, dirty) { 268 const block0_changes = {}; 269 270 if (dirty & /*$$scope, username*/ 2056) { 271 block0_changes.$$scope = { dirty, ctx }; 272 } 273 274 block0.$set(block0_changes); 275 const block1_changes = {}; 276 277 if (dirty & /*$$scope, password*/ 2064) { 278 block1_changes.$$scope = { dirty, ctx }; 279 } 280 281 block1.$set(block1_changes); 282 }, 283 i(local) { 284 if (current) return; 285 transition_in(block0.$$.fragment, local); 286 transition_in(block1.$$.fragment, local); 287 current = true; 288 }, 289 o(local) { 290 transition_out(block0.$$.fragment, local); 291 transition_out(block1.$$.fragment, local); 292 current = false; 293 }, 294 d(detaching) { 295 if (detaching) { 296 detach(t); 297 } 298 299 destroy_component(block0, detaching); 300 destroy_component(block1, detaching); 301 } 302 }; 303} 304 305// (72:2) <BaseButton size="lg" variant="primary" on:click={submit} > 306function create_default_slot_1(ctx) { 307 let t_value = /*$_*/ ctx[6]("login.login") + ""; 308 let t; 309 310 return { 311 c() { 312 t = text(t_value); 313 }, 314 m(target, anchor) { 315 insert(target, t, anchor); 316 }, 317 p(ctx, dirty) { 318 if (dirty & /*$_*/ 64 && t_value !== (t_value = /*$_*/ ctx[6]("login.login") + "")) set_data(t, t_value); 319 }, 320 d(detaching) { 321 if (detaching) { 322 detach(t); 323 } 324 } 325 }; 326} 327 328// (34:1) <Column variant="panel" min_width={480}> 329function create_default_slot(ctx) { 330 let h2; 331 let t0_value = /*$_*/ ctx[6]("login.login") + ""; 332 let t0; 333 let t1; 334 let t2; 335 let t3; 336 let t4; 337 let form; 338 let t5; 339 let basebutton; 340 let current; 341 let if_block0 = /*auth_message*/ ctx[0] && create_if_block_2(ctx); 342 let if_block1 = /*space_id*/ ctx[2] && create_if_block_1(ctx); 343 let if_block2 = /*incorrect_credentials*/ ctx[5] && create_if_block(ctx); 344 345 form = new Index$1({ 346 props: { 347 $$slots: { default: [create_default_slot_2] }, 348 $$scope: { ctx } 349 } 350 }); 351 352 basebutton = new Button({ 353 props: { 354 size: "lg", 355 variant: "primary", 356 $$slots: { default: [create_default_slot_1] }, 357 $$scope: { ctx } 358 } 359 }); 360 361 basebutton.$on("click", /*submit*/ ctx[7]); 362 363 return { 364 c() { 365 h2 = element("h2"); 366 t0 = text(t0_value); 367 t1 = space(); 368 if (if_block0) if_block0.c(); 369 t2 = space(); 370 if (if_block1) if_block1.c(); 371 t3 = space(); 372 if (if_block2) if_block2.c(); 373 t4 = space(); 374 create_component(form.$$.fragment); 375 t5 = space(); 376 create_component(basebutton.$$.fragment); 377 attr(h2, "class", "svelte-1ogxbi0"); 378 }, 379 m(target, anchor) { 380 insert(target, h2, anchor); 381 append(h2, t0); 382 insert(target, t1, anchor); 383 if (if_block0) if_block0.m(target, anchor); 384 insert(target, t2, anchor); 385 if (if_block1) if_block1.m(target, anchor); 386 insert(target, t3, anchor); 387 if (if_block2) if_block2.m(target, anchor); 388 insert(target, t4, anchor); 389 mount_component(form, target, anchor); 390 insert(target, t5, anchor); 391 mount_component(basebutton, target, anchor); 392 current = true; 393 }, 394 p(ctx, dirty) { 395 if ((!current || dirty & /*$_*/ 64) && t0_value !== (t0_value = /*$_*/ ctx[6]("login.login") + "")) set_data(t0, t0_value); 396 397 if (/*auth_message*/ ctx[0]) { 398 if (if_block0) { 399 if_block0.p(ctx, dirty); 400 } else { 401 if_block0 = create_if_block_2(ctx); 402 if_block0.c(); 403 if_block0.m(t2.parentNode, t2); 404 } 405 } else if (if_block0) { 406 if_block0.d(1); 407 if_block0 = null; 408 } 409 410 if (/*space_id*/ ctx[2]) { 411 if (if_block1) { 412 if_block1.p(ctx, dirty); 413 } else { 414 if_block1 = create_if_block_1(ctx); 415 if_block1.c(); 416 if_block1.m(t3.parentNode, t3); 417 } 418 } else if (if_block1) { 419 if_block1.d(1); 420 if_block1 = null; 421 } 422 423 if (/*incorrect_credentials*/ ctx[5]) { 424 if (if_block2) { 425 if_block2.p(ctx, dirty); 426 } else { 427 if_block2 = create_if_block(ctx); 428 if_block2.c(); 429 if_block2.m(t4.parentNode, t4); 430 } 431 } else if (if_block2) { 432 if_block2.d(1); 433 if_block2 = null; 434 } 435 436 const form_changes = {}; 437
438 if (dirty & /*$$scope, password, username*/ 2072) { 439 form_changes.$$scope = { dirty, ctx }; 440 } 441 442 form.$set(form_changes); 443 const basebutton_changes = {}; 444 445 if (dirty & /*$$scope, $_*/ 2112) { 446 basebutton_changes.$$scope = { dirty, ctx }; 447 } 448 449 basebutton.$set(basebutton_changes); 450 }, 451 i(local) { 452 if (current) return; 453 transition_in(form.$$.fragment, local); 454 transition_in(basebutton.$$.fragment, local); 455 current = true; 456 }, 457 o(local) { 458 transition_out(form.$$.fragment, local); 459 transition_out(basebutton.$$.fragment, local); 460 current = false; 461 }, 462 d(detaching) { 463 if (detaching) { 464 detach(h2); 465 detach(t1); 466 detach(t2); 467 detach(t3); 468 detach(t4); 469 detach(t5); 470 } 471 472 if (if_block0) if_block0.d(detaching); 473 if (if_block1) if_block1.d(detaching); 474 if (if_block2) if_block2.d(detaching); 475 destroy_component(form, detaching); 476 destroy_component(basebutton, detaching); 477 } 478 }; 479} 480 481function create_fragment(ctx) { 482 let div; 483 let column; 484 let current; 485 486 column = new Index({ 487 props: { 488 variant: "panel", 489 min_width: 480, 490 $$slots: { default: [create_default_slot] }, 491 $$scope: { ctx } 492 } 493 }); 494 495 return { 496 c() { 497 div = element("div"); 498 create_component(column.$$.fragment); 499 attr(div, "class", "wrap svelte-1ogxbi0"); 500 toggle_class(div, "min-h-screen", /*app_mode*/ ctx[1]); 501 }, 502 m(target, anchor) { 503 insert(target, div, anchor); 504 mount_component(column, div, null); 505 current = true; 506 }, 507 p(ctx, [dirty]) { 508 const column_changes = {}; 509 510 if (dirty & /*$$scope, $_, password, username, incorrect_credentials, space_id, auth_message*/ 2173) { 511 column_changes.$$scope = { dirty, ctx }; 512 } 513 514 column.$set(column_changes); 515 516 if (!current || dirty & /*app_mode*/ 2) { 517 toggle_class(div, "min-h-screen", /*app_mode*/ ctx[1]); 518 } 519 }, 520 i(local) { 521 if (current) return; 522 transition_in(column.$$.fragment, local); 523 current = true; 524 }, 525 o(local) { 526 transition_out(column.$$.fragment, local); 527 current = false; 528 }, 529 d(detaching) { 530 if (detaching) { 531 detach(div); 532 } 533 534 destroy_component(column); 535 } 536 }; 537} 538 539function instance($$self, $$props, $$invalidate) { 540 let $_; 541 component_subscribe($$self, $format, $$value => $$invalidate(6, $_ = $$value)); 542 let { root } = $$props; 543 let { auth_message } = $$props; 544 let { app_mode } = $$props; 545 let { space_id } = $$props; 546 let username = ""; 547 let password = ""; 548 let incorrect_credentials = false; 549 550 const submit = async () => { 551 const formData = new FormData(); 552 formData.append("username", username); 553 formData.append("password", password); 554 let response = await fetch(root + "/login", { method: "POST", body: formData }); 555 556 if (response.status === 400) { 557 $$invalidate(5, incorrect_credentials = true); 558 $$invalidate(3, username = ""); 559 $$invalidate(4, password = ""); 560 } else if (response.status == 200) { 561 location.reload(); 562 } 563 }; 564 565 function textbox_value_binding(value) { 566 username = value; 567 $$invalidate(3, username); 568 } 569 570 function textbox_value_binding_1(value) { 571 password = value; 572 $$invalidate(4, password); 573 } 574 575 $$self.$$set = $$props => {
576 if ('root' in $$props) $$invalidate(8, root = $$props.root); 577 if ('auth_message' in $$props) $$invalidate(0, auth_message = $$props.auth_message); 578 if ('app_mode' in $$props) $$invalidate(1, app_mode = $$props.app_mode); 579 if ('space_id' in $$props) $$invalidate(2, space_id = $$props.space_id); 580 }; 581 582 return [ 583 auth_message, 584 app_mode, 585 space_id, 586 username, 587 password, 588 incorrect_credentials, 589 $_, 590 submit, 591 root, 592 textbox_value_binding, 593 textbox_value_binding_1 594 ]; 595} 596 597class Login extends SvelteComponent { 598 constructor(options) { 599 super(); 600 601 init(this, options, instance, create_fragment, safe_not_equal, { 602 root: 8, 603 auth_message: 0, 604 app_mode: 1, 605 space_id: 2 606 }); 607 } 608} 609 610export { Login as default }; 611//# sourceMappingURL=Login-705c24c9.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.