import { r as resolve_wasm_src } from './file-url-fc87e7e1.js';
/* empty css                                                */import './Index-f62c49f9.js';
import './index-b5b16a51.js';
import './svelte/svelte.js';

/* home/runner/work/gradio/gradio/js/image/shared/Image.svelte generated by Svelte v4.2.2 */
const {
	SvelteComponent: SvelteComponent$1,
	append,
	assign,
	compute_rest_props,
	detach: detach$1,
	element: element$1,
	empty,
	exclude_internal_props,
	get_spread_update,
	handle_promise,
	init: init$1,
	insert: insert$1,
	noop,
	safe_not_equal: safe_not_equal$1,
	set_attributes,
	set_data,
	set_style,
	src_url_equal,
	text,
	toggle_class: toggle_class$1,
	update_await_block_branch
} = window.__gradio__svelte__internal;
function create_catch_block(ctx) {
	let p;
	let t_value = /*error*/ ctx[3].message + "";
	let t;

	return {
		c() {
			p = element$1("p");
			t = text(t_value);
			set_style(p, "color", "red");
		},
		m(target, anchor) {
			insert$1(target, p, anchor);
			append(p, t);
		},
		p(ctx, dirty) {
			if (dirty & /*src*/ 1 && t_value !== (t_value = /*error*/ ctx[3].message + "")) set_data(t, t_value);
		},
		d(detaching) {
			if (detaching) {
				detach$1(p);
			}
		}
	};
}

// (5:48)   <!-- svelte-ignore a11y-missing-attribute -->  <img src={resolved_src}
function create_then_block(ctx) {
	let img;
	let img_src_value;

	let img_levels = [
		{
			src: img_src_value = /*resolved_src*/ ctx[2]
		},
		/*$$restProps*/ ctx[1]
	];

	let img_data = {};

	for (let i = 0; i < img_levels.length; i += 1) {
		img_data = assign(img_data, img_levels[i]);
	}

	return {
		c() {
			img = element$1("img");
			set_attributes(img, img_data);
			toggle_class$1(img, "svelte-2xi6dn", true);
		},
		m(target, anchor) {
			insert$1(target, img, anchor);
		},
		p(ctx, dirty) {
			set_attributes(img, img_data = get_spread_update(img_levels, [
				dirty & /*src*/ 1 && !src_url_equal(img.src, img_src_value = /*resolved_src*/ ctx[2]) && { src: img_src_value },
				dirty & /*$$restProps*/ 2 && /*$$restProps*/ ctx[1]
			]));

			toggle_class$1(img, "svelte-2xi6dn", true);
		},
		d(detaching) {
			if (detaching) {
				detach$1(img);
			}
		}
	};
}

// (1:0) <script lang="ts">import { resolve_wasm_src }
function create_pending_block(ctx) {
	return { c: noop, m: noop, p: noop, d: noop };
}

function create_fragment$1(ctx) {
	let await_block_anchor;
	let promise;

	let info = {
		ctx,
		current: null,
		token: null,
		hasCatch: true,
		pending: create_pending_block,
		then: create_then_block,
		catch: create_catch_block,
		value: 2,
		error: 3
	};

	handle_promise(promise = resolve_wasm_src(/*src*/ ctx[0]), info);

	return {
		c() {
			await_block_anchor = empty();
			info.block.c();
		},
		m(target, anchor) {
			insert$1(target, await_block_anchor, anchor);
			info.block.m(target, info.anchor = anchor);
			info.mount = () => await_block_anchor.parentNode;
			info.anchor = await_block_anchor;
		},
		p(new_ctx, [dirty]) {
			ctx = new_ctx;
			info.ctx = ctx;

			if (dirty & /*src*/ 1 && promise !== (promise = resolve_wasm_src(/*src*/ ctx[0])) && handle_promise(promise, info)) ; else {
				update_await_block_branch(info, ctx, dirty);
			}
		},
		i: noop,
		o: noop,
		d(detaching) {
			if (detaching) {
				detach$1(await_block_anchor);
			}

			info.block.d(detaching);
			info.token = null;
			info = null;
		}
	};
}

function instance$1($$self, $$props, $$invalidate) {
	const omit_props_names = ["src"];
	let $$restProps = compute_rest_props($$props, omit_props_names);
	let { src = undefined } = $$props;

	$$self.$$set = $$new_props => {
		$$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
		$$invalidate(1, $$restProps = compute_rest_props($$props, omit_props_names));
		if ('src' in $$new_props) $$invalidate(0, src = $$new_props.src);
	};

	return [src, $$restProps];
}

class Image extends SvelteComponent$1 {
	constructor(options) {
		super();
		init$1(this, options, instance$1, create_fragment$1, safe_not_equal$1, { src: 0 });
	}
}

/* home/runner/work/gradio/gradio/js/image/Example.svelte generated by Svelte v4.2.2 */
const {
	SvelteComponent,
	attr,
	create_component,
	destroy_component,
	detach,
	element,
	init,
	insert,
	mount_component,
	safe_not_equal,
	toggle_class,
	transition_in,
	transition_out
} = window.__gradio__svelte__internal;
function create_fragment(ctx) {
	let div;
	let image;
	let current;

	image = new Image({
			props: {
				src: /*samples_dir*/ ctx[1] + /*value*/ ctx[0],
				alt: ""
			}
		});

	return {
		c() {
			div = element("div");
			create_component(image.$$.fragment);
			attr(div, "class", "container svelte-5cqjmr");
			toggle_class(div, "table", /*type*/ ctx[2] === "table");
			toggle_class(div, "gallery", /*type*/ ctx[2] === "gallery");
			toggle_class(div, "selected", /*selected*/ ctx[3]);
		},
		m(target, anchor) {
			insert(target, div, anchor);
			mount_component(image, div, null);
			current = true;
		},
		p(ctx, [dirty]) {
			const image_changes = {};
			if (dirty & /*samples_dir, value*/ 3) image_changes.src = /*samples_dir*/ ctx[1] + /*value*/ ctx[0];
			image.$set(image_changes);

			if (!current || dirty & /*type*/ 4) {
				toggle_class(div, "table", /*type*/ ctx[2] === "table");
			}

			if (!current || dirty & /*type*/ 4) {
				toggle_class(div, "gallery", /*type*/ ctx[2] === "gallery");
			}

			if (!current || dirty & /*selected*/ 8) {
				toggle_class(div, "selected", /*selected*/ ctx[3]);
			}
		},
		i(local) {
			if (current) return;
			transition_in(image.$$.fragment, local);
			current = true;
		},
		o(local) {
			transition_out(image.$$.fragment, local);
			current = false;
		},
		d(detaching) {
			if (detaching) {
				detach(div);
			}

			destroy_component(image);
		}
	};
}

function instance($$self, $$props, $$invalidate) {
	let { value } = $$props;
	let { samples_dir } = $$props;
	let { type } = $$props;
	let { selected = false } = $$props;

	$$self.$$set = $$props => {
		if ('value' in $$props) $$invalidate(0, value = $$props.value);
		if ('samples_dir' in $$props) $$invalidate(1, samples_dir = $$props.samples_dir);
		if ('type' in $$props) $$invalidate(2, type = $$props.type);
		if ('selected' in $$props) $$invalidate(3, selected = $$props.selected);
	};

	return [value, samples_dir, type, selected];
}

class Example extends SvelteComponent {
	constructor(options) {
		super();

		init(this, options, instance, create_fragment, safe_not_equal, {
			value: 0,
			samples_dir: 1,
			type: 2,
			selected: 3
		});
	}
}

export { Example as default };
//# sourceMappingURL=Example-be109ad1.js.map
