import { S as SvelteComponent, i as init, s as safe_not_equal, aa as add_render_callback, c as create_component, m as mount_component, l as listen, j as transition_in, k as transition_out, o as destroy_component, P as assign, Q as StatusTracker, a as space, A as empty, f as insert, R as get_spread_update, T as get_spread_object, C as group_outros, D as check_outros, n as detach, a6 as tick, H as binding_callbacks, e as element, b as attr, L as src_url_equal, d as toggle_class, g as append, B as destroy_each, z as run_all, ad as add_resize_listener, w as noop } from './index.4872dbae.js';
import { B as Block } from './Block.29585093.js';
import { B as BlockLabel } from './BlockLabel.be696951.js';
import { M as ModifyUpload } from './ModifyUpload.d0130108.js';
import { g as get_styles } from './styles.c72835fa.js';
import { I as Image } from './Image.24cafb16.js';

var Gallery_svelte_svelte_type_style_lang = '';

/* src/components/Gallery/Gallery.svelte generated by Svelte v3.49.0 */

function get_each_context(ctx, list, i) {
	const child_ctx = ctx.slice();
	child_ctx[26] = list[i];
	child_ctx[28] = i;
	return child_ctx;
}

function get_each_context_1(ctx, list, i) {
	const child_ctx = ctx.slice();
	child_ctx[26] = list[i];
	child_ctx[29] = list;
	child_ctx[28] = i;
	return child_ctx;
}

// (71:1) {#if show_label}
function create_if_block_3(ctx) {
	let blocklabel;
	let current;

	blocklabel = new BlockLabel({
			props: {
				show_label: /*show_label*/ ctx[1],
				Icon: Image,
				label: /*label*/ ctx[2] || "Gallery",
				disable: typeof /*style*/ ctx[6].container === "boolean" && !/*style*/ ctx[6].container
			}
		});

	return {
		c() {
			create_component(blocklabel.$$.fragment);
		},
		m(target, anchor) {
			mount_component(blocklabel, target, anchor);
			current = true;
		},
		p(ctx, dirty) {
			const blocklabel_changes = {};
			if (dirty & /*show_label*/ 2) blocklabel_changes.show_label = /*show_label*/ ctx[1];
			if (dirty & /*label*/ 4) blocklabel_changes.label = /*label*/ ctx[2] || "Gallery";
			if (dirty & /*style*/ 64) blocklabel_changes.disable = typeof /*style*/ ctx[6].container === "boolean" && !/*style*/ ctx[6].container;
			blocklabel.$set(blocklabel_changes);
		},
		i(local) {
			if (current) return;
			transition_in(blocklabel.$$.fragment, local);
			current = true;
		},
		o(local) {
			transition_out(blocklabel.$$.fragment, local);
			current = false;
		},
		d(detaching) {
			destroy_component(blocklabel, detaching);
		}
	};
}

// (83:1) {:else}
function create_else_block(ctx) {
	let t;
	let div;
	let current_block_type_index;
	let if_block1;
	let div_resize_listener;
	let current;
	let if_block0 = /*selected_image*/ ctx[7] !== null && create_if_block_2(ctx);
	const if_block_creators = [create_if_block_1, create_else_block_1];
	const if_blocks = [];

	function select_block_type_1(ctx, dirty) {
		if (/*value*/ ctx[5].length === 0) return 0;
		return 1;
	}

	current_block_type_index = select_block_type_1(ctx);
	if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);

	return {
		c() {
			if (if_block0) if_block0.c();
			t = space();
			div = element("div");
			if_block1.c();
			attr(div, "class", "overflow-y-auto h-full p-2");
			add_render_callback(() => /*div_elementresize_handler*/ ctx[23].call(div));
			toggle_class(div, "min-h-[350px]", /*style*/ ctx[6].height !== "auto");
			toggle_class(div, "max-h-[55vh]", /*style*/ ctx[6].height !== "auto");
			toggle_class(div, "xl:min-h-[450px]", /*style*/ ctx[6].height !== "auto");
		},
		m(target, anchor) {
			if (if_block0) if_block0.m(target, anchor);
			insert(target, t, anchor);
			insert(target, div, anchor);
			if_blocks[current_block_type_index].m(div, null);
			div_resize_listener = add_resize_listener(div, /*div_elementresize_handler*/ ctx[23].bind(div));
			current = true;
		},
		p(ctx, dirty) {
			if (/*selected_image*/ ctx[7] !== null) {
				if (if_block0) {
					if_block0.p(ctx, dirty);

					if (dirty & /*selected_image*/ 128) {
						transition_in(if_block0, 1);
					}
				} else {
					if_block0 = create_if_block_2(ctx);
					if_block0.c();
					transition_in(if_block0, 1);
					if_block0.m(t.parentNode, t);
				}
			} else if (if_block0) {
				group_outros();

				transition_out(if_block0, 1, 1, () => {
					if_block0 = null;
				});

				check_outros();
			}

			let previous_block_index = current_block_type_index;
			current_block_type_index = select_block_type_1(ctx);

			if (current_block_type_index === previous_block_index) {
				if_blocks[current_block_type_index].p(ctx, 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](ctx);
					if_block1.c();
				} else {
					if_block1.p(ctx, dirty);
				}

				transition_in(if_block1, 1);
				if_block1.m(div, null);
			}

			if (dirty & /*style*/ 64) {
				toggle_class(div, "min-h-[350px]", /*style*/ ctx[6].height !== "auto");
			}

			if (dirty & /*style*/ 64) {
				toggle_class(div, "max-h-[55vh]", /*style*/ ctx[6].height !== "auto");
			}

			if (dirty & /*style*/ 64) {
				toggle_class(div, "xl:min-h-[450px]", /*style*/ ctx[6].height !== "auto");
			}
		},
		i(local) {
			if (current) return;
			transition_in(if_block0);
			transition_in(if_block1);
			current = true;
		},
		o(local) {
			transition_out(if_block0);
			transition_out(if_block1);
			current = false;
		},
		d(detaching) {
			if (if_block0) if_block0.d(detaching);
			if (detaching) detach(t);
			if (detaching) detach(div);
			if_blocks[current_block_type_index].d();
			div_resize_listener();
		}
	};
}

// (79:1) {#if value === null}
function create_if_block(ctx) {
	let div1;
	let div0;
	let image;
	let current;
	image = new Image({});

	return {
		c() {
			div1 = element("div");
			div0 = element("div");
			create_component(image.$$.fragment);
			attr(div0, "class", "h-5 dark:text-white opacity-50");
			attr(div1, "class", "h-full min-h-[15rem] flex justify-center items-center");
		},
		m(target, anchor) {
			insert(target, div1, anchor);
			append(div1, div0);
			mount_component(image, div0, null);
			current = true;
		},
		p: noop,
		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(div1);
			destroy_component(image);
		}
	};
}

// (84:2) {#if selected_image !== null}
function create_if_block_2(ctx) {
	let div1;
	let modifyupload;
	let t0;
	let img;
	let img_src_value;
	let t1;
	let div0;
	let current;
	let mounted;
	let dispose;
	modifyupload = new ModifyUpload({});
	modifyupload.$on("clear", /*clear_handler*/ ctx[17]);
	let each_value_1 = /*value*/ ctx[5];
	let each_blocks = [];

	for (let i = 0; i < each_value_1.length; i += 1) {
		each_blocks[i] = create_each_block_1(get_each_context_1(ctx, each_value_1, i));
	}

	return {
		c() {
			div1 = element("div");
			create_component(modifyupload.$$.fragment);
			t0 = space();
			img = element("img");
			t1 = space();
			div0 = element("div");

			for (let i = 0; i < each_blocks.length; i += 1) {
				each_blocks[i].c();
			}

			attr(img, "class", "w-full object-contain h-[calc(100%-50px)]");
			if (!src_url_equal(img.src, img_src_value = /*value*/ ctx[5][/*selected_image*/ ctx[7]])) attr(img, "src", img_src_value);
			attr(img, "alt", "");
			attr(div0, "class", "absolute h-[60px] bg-white dark:bg-gray-900 overflow-x-scroll scroll-hide w-full bottom-0 flex gap-1.5 items-center py-2 text-sm px-3 justify-center");
			attr(div1, "class", "absolute inset-0 z-10 flex flex-col bg-white/90 dark:bg-gray-900 backdrop-blur h-full");
			toggle_class(div1, "min-h-[350px]", /*style*/ ctx[6].height !== "auto");
			toggle_class(div1, "max-h-[55vh]", /*style*/ ctx[6].height !== "auto");
			toggle_class(div1, "xl:min-h-[450px]", /*style*/ ctx[6].height !== "auto");
		},
		m(target, anchor) {
			insert(target, div1, anchor);
			mount_component(modifyupload, div1, null);
			append(div1, t0);
			append(div1, img);
			append(div1, t1);
			append(div1, div0);

			for (let i = 0; i < each_blocks.length; i += 1) {
				each_blocks[i].m(div0, null);
			}

			/*div0_binding*/ ctx[21](div0);
			current = true;

			if (!mounted) {
				dispose = [
					listen(img, "click", /*click_handler*/ ctx[18]),
					listen(div1, "keydown", /*on_keydown*/ ctx[15])
				];

				mounted = true;
			}
		},
		p(ctx, dirty) {
			if (!current || dirty & /*value, selected_image*/ 160 && !src_url_equal(img.src, img_src_value = /*value*/ ctx[5][/*selected_image*/ ctx[7]])) {
				attr(img, "src", img_src_value);
			}

			if (dirty & /*selected_image, el, value*/ 1184) {
				each_value_1 = /*value*/ ctx[5];
				let i;

				for (i = 0; i < each_value_1.length; i += 1) {
					const child_ctx = get_each_context_1(ctx, each_value_1, i);

					if (each_blocks[i]) {
						each_blocks[i].p(child_ctx, dirty);
					} else {
						each_blocks[i] = create_each_block_1(child_ctx);
						each_blocks[i].c();
						each_blocks[i].m(div0, null);
					}
				}

				for (; i < each_blocks.length; i += 1) {
					each_blocks[i].d(1);
				}

				each_blocks.length = each_value_1.length;
			}

			if (dirty & /*style*/ 64) {
				toggle_class(div1, "min-h-[350px]", /*style*/ ctx[6].height !== "auto");
			}

			if (dirty & /*style*/ 64) {
				toggle_class(div1, "max-h-[55vh]", /*style*/ ctx[6].height !== "auto");
			}

			if (dirty & /*style*/ 64) {
				toggle_class(div1, "xl:min-h-[450px]", /*style*/ ctx[6].height !== "auto");
			}
		},
		i(local) {
			if (current) return;
			transition_in(modifyupload.$$.fragment, local);
			current = true;
		},
		o(local) {
			transition_out(modifyupload.$$.fragment, local);
			current = false;
		},
		d(detaching) {
			if (detaching) detach(div1);
			destroy_component(modifyupload);
			destroy_each(each_blocks, detaching);
			/*div0_binding*/ ctx[21](null);
			mounted = false;
			run_all(dispose);
		}
	};
}

// (105:5) {#each value as image, i}
function create_each_block_1(ctx) {
	let button;
	let img;
	let img_src_value;
	let t;
	let button_class_value;
	let i = /*i*/ ctx[28];
	let mounted;
	let dispose;
	const assign_button = () => /*button_binding*/ ctx[19](button, i);
	const unassign_button = () => /*button_binding*/ ctx[19](null, i);

	function click_handler_1() {
		return /*click_handler_1*/ ctx[20](/*i*/ ctx[28]);
	}

	return {
		c() {
			button = element("button");
			img = element("img");
			t = space();
			attr(img, "alt", "");
			attr(img, "class", "h-full w-full overflow-hidden object-contain");
			if (!src_url_equal(img.src, img_src_value = /*image*/ ctx[26])) attr(img, "src", img_src_value);

			attr(button, "class", button_class_value = "gallery-item !flex-none !h-9 !w-9 transition-all duration-75 " + (/*selected_image*/ ctx[7] === /*i*/ ctx[28]
			? '!ring-2 !ring-orange-500 hover:!ring-orange-500'
			: 'scale-90 transform') + " svelte-1g9btlg");
		},
		m(target, anchor) {
			insert(target, button, anchor);
			append(button, img);
			append(button, t);
			assign_button();

			if (!mounted) {
				dispose = listen(button, "click", click_handler_1);
				mounted = true;
			}
		},
		p(new_ctx, dirty) {
			ctx = new_ctx;

			if (dirty & /*value*/ 32 && !src_url_equal(img.src, img_src_value = /*image*/ ctx[26])) {
				attr(img, "src", img_src_value);
			}

			if (dirty & /*selected_image*/ 128 && button_class_value !== (button_class_value = "gallery-item !flex-none !h-9 !w-9 transition-all duration-75 " + (/*selected_image*/ ctx[7] === /*i*/ ctx[28]
			? '!ring-2 !ring-orange-500 hover:!ring-orange-500'
			: 'scale-90 transform') + " svelte-1g9btlg")) {
				attr(button, "class", button_class_value);
			}

			if (i !== /*i*/ ctx[28]) {
				unassign_button();
				i = /*i*/ ctx[28];
				assign_button();
			}
		},
		d(detaching) {
			if (detaching) detach(button);
			unassign_button();
			mounted = false;
			dispose();
		}
	};
}

// (136:3) {:else}
function create_else_block_1(ctx) {
	let div;
	let div_class_value;
	let each_value = /*value*/ 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));
	}

	return {
		c() {
			div = element("div");

			for (let i = 0; i < each_blocks.length; i += 1) {
				each_blocks[i].c();
			}

			attr(div, "class", div_class_value = "grid gap-2 " + /*classes*/ ctx[12] + " svelte-1g9btlg");
			toggle_class(div, "pt-6", /*show_label*/ ctx[1]);
		},
		m(target, anchor) {
			insert(target, div, anchor);

			for (let i = 0; i < each_blocks.length; i += 1) {
				each_blocks[i].m(div, null);
			}
		},
		p(ctx, dirty) {
			if (dirty & /*selected_image, can_zoom, value*/ 8352) {
				each_value = /*value*/ ctx[5];
				let i;

				for (i = 0; i < each_value.length; i += 1) {
					const child_ctx = get_each_context(ctx, each_value, i);

					if (each_blocks[i]) {
						each_blocks[i].p(child_ctx, dirty);
					} else {
						each_blocks[i] = create_each_block(child_ctx);
						each_blocks[i].c();
						each_blocks[i].m(div, null);
					}
				}

				for (; i < each_blocks.length; i += 1) {
					each_blocks[i].d(1);
				}

				each_blocks.length = each_value.length;
			}

			if (dirty & /*classes*/ 4096 && div_class_value !== (div_class_value = "grid gap-2 " + /*classes*/ ctx[12] + " svelte-1g9btlg")) {
				attr(div, "class", div_class_value);
			}

			if (dirty & /*classes, show_label*/ 4098) {
				toggle_class(div, "pt-6", /*show_label*/ ctx[1]);
			}
		},
		i: noop,
		o: noop,
		d(detaching) {
			if (detaching) detach(div);
			destroy_each(each_blocks, detaching);
		}
	};
}

// (132:3) {#if value.length === 0}
function create_if_block_1(ctx) {
	let div1;
	let div0;
	let image;
	let current;
	image = new Image({});

	return {
		c() {
			div1 = element("div");
			div0 = element("div");
			create_component(image.$$.fragment);
			attr(div0, "class", "h-5 dark:text-white opacity-50");
			attr(div1, "class", "h-full min-h-[15rem] flex justify-center items-center");
		},
		m(target, anchor) {
			insert(target, div1, anchor);
			append(div1, div0);
			mount_component(image, div0, null);
			current = true;
		},
		p: noop,
		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(div1);
			destroy_component(image);
		}
	};
}

// (138:5) {#each value as image, i}
function create_each_block(ctx) {
	let button;
	let img;
	let img_src_value;
	let t;
	let mounted;
	let dispose;

	function click_handler_2() {
		return /*click_handler_2*/ ctx[22](/*i*/ ctx[28]);
	}

	return {
		c() {
			button = element("button");
			img = element("img");
			t = space();
			attr(img, "alt", "");
			attr(img, "class", "h-full w-full overflow-hidden object-contain");
			if (!src_url_equal(img.src, img_src_value = /*image*/ ctx[26])) attr(img, "src", img_src_value);
			attr(button, "class", "gallery-item svelte-1g9btlg");
		},
		m(target, anchor) {
			insert(target, button, anchor);
			append(button, img);
			append(button, t);

			if (!mounted) {
				dispose = listen(button, "click", click_handler_2);
				mounted = true;
			}
		},
		p(new_ctx, dirty) {
			ctx = new_ctx;

			if (dirty & /*value*/ 32 && !src_url_equal(img.src, img_src_value = /*image*/ ctx[26])) {
				attr(img, "src", img_src_value);
			}
		},
		d(detaching) {
			if (detaching) detach(button);
			mounted = false;
			dispose();
		}
	};
}

// (62:0) <Block  {visible}  variant="solid"  color="grey"  padding={false}  {elem_id}  disable={typeof style.container === "boolean" && !style.container} >
function create_default_slot(ctx) {
	let statustracker;
	let t0;
	let t1;
	let current_block_type_index;
	let if_block1;
	let if_block1_anchor;
	let current;
	const statustracker_spread_levels = [/*loading_status*/ ctx[0]];
	let statustracker_props = {};

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

	statustracker = new StatusTracker({ props: statustracker_props });
	let if_block0 = /*show_label*/ ctx[1] && create_if_block_3(ctx);
	const if_block_creators = [create_if_block, create_else_block];
	const if_blocks = [];

	function select_block_type(ctx, dirty) {
		if (/*value*/ ctx[5] === null) return 0;
		return 1;
	}

	current_block_type_index = select_block_type(ctx);
	if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);

	return {
		c() {
			create_component(statustracker.$$.fragment);
			t0 = space();
			if (if_block0) if_block0.c();
			t1 = space();
			if_block1.c();
			if_block1_anchor = empty();
		},
		m(target, anchor) {
			mount_component(statustracker, target, anchor);
			insert(target, t0, anchor);
			if (if_block0) if_block0.m(target, anchor);
			insert(target, t1, anchor);
			if_blocks[current_block_type_index].m(target, anchor);
			insert(target, if_block1_anchor, anchor);
			current = true;
		},
		p(ctx, dirty) {
			const statustracker_changes = (dirty & /*loading_status*/ 1)
			? get_spread_update(statustracker_spread_levels, [get_spread_object(/*loading_status*/ ctx[0])])
			: {};

			statustracker.$set(statustracker_changes);

			if (/*show_label*/ ctx[1]) {
				if (if_block0) {
					if_block0.p(ctx, dirty);

					if (dirty & /*show_label*/ 2) {
						transition_in(if_block0, 1);
					}
				} else {
					if_block0 = create_if_block_3(ctx);
					if_block0.c();
					transition_in(if_block0, 1);
					if_block0.m(t1.parentNode, t1);
				}
			} else if (if_block0) {
				group_outros();

				transition_out(if_block0, 1, 1, () => {
					if_block0 = null;
				});

				check_outros();
			}

			let previous_block_index = current_block_type_index;
			current_block_type_index = select_block_type(ctx);

			if (current_block_type_index === previous_block_index) {
				if_blocks[current_block_type_index].p(ctx, 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](ctx);
					if_block1.c();
				} else {
					if_block1.p(ctx, dirty);
				}

				transition_in(if_block1, 1);
				if_block1.m(if_block1_anchor.parentNode, if_block1_anchor);
			}
		},
		i(local) {
			if (current) return;
			transition_in(statustracker.$$.fragment, local);
			transition_in(if_block0);
			transition_in(if_block1);
			current = true;
		},
		o(local) {
			transition_out(statustracker.$$.fragment, local);
			transition_out(if_block0);
			transition_out(if_block1);
			current = false;
		},
		d(detaching) {
			destroy_component(statustracker, detaching);
			if (detaching) detach(t0);
			if (if_block0) if_block0.d(detaching);
			if (detaching) detach(t1);
			if_blocks[current_block_type_index].d(detaching);
			if (detaching) detach(if_block1_anchor);
		}
	};
}

function create_fragment(ctx) {
	let block;
	let current;
	let mounted;
	let dispose;
	add_render_callback(/*onwindowresize*/ ctx[16]);

	block = new Block({
			props: {
				visible: /*visible*/ ctx[4],
				variant: "solid",
				color: "grey",
				padding: false,
				elem_id: /*elem_id*/ ctx[3],
				disable: typeof /*style*/ ctx[6].container === "boolean" && !/*style*/ ctx[6].container,
				$$slots: { default: [create_default_slot] },
				$$scope: { ctx }
			}
		});

	return {
		c() {
			create_component(block.$$.fragment);
		},
		m(target, anchor) {
			mount_component(block, target, anchor);
			current = true;

			if (!mounted) {
				dispose = listen(window, "resize", /*onwindowresize*/ ctx[16]);
				mounted = true;
			}
		},
		p(ctx, [dirty]) {
			const block_changes = {};
			if (dirty & /*visible*/ 16) block_changes.visible = /*visible*/ ctx[4];
			if (dirty & /*elem_id*/ 8) block_changes.elem_id = /*elem_id*/ ctx[3];
			if (dirty & /*style*/ 64) block_changes.disable = typeof /*style*/ ctx[6].container === "boolean" && !/*style*/ ctx[6].container;

			if (dirty & /*$$scope, value, height, style, classes, show_label, selected_image, can_zoom, container, el, next, label, loading_status*/ 1073774055) {
				block_changes.$$scope = { dirty, ctx };
			}

			block.$set(block_changes);
		},
		i(local) {
			if (current) return;
			transition_in(block.$$.fragment, local);
			current = true;
		},
		o(local) {
			transition_out(block.$$.fragment, local);
			current = false;
		},
		d(detaching) {
			destroy_component(block, detaching);
			mounted = false;
			dispose();
		}
	};
}

function instance($$self, $$props, $$invalidate) {
	let previous;
	let next;
	let can_zoom;
	let classes;
	let { loading_status } = $$props;
	let { show_label } = $$props;
	let { label } = $$props;
	let { elem_id = "" } = $$props;
	let { visible = true } = $$props;
	let { value = null } = $$props;
	let { style = {} } = $$props;
	let selected_image = null;

	function on_keydown(e) {
		switch (e.code) {
			case "Escape":
				e.preventDefault();
				$$invalidate(7, selected_image = null);
				break;
			case "ArrowLeft":
				e.preventDefault();
				$$invalidate(7, selected_image = previous);
				break;
			case "ArrowRight":
				e.preventDefault();
				$$invalidate(7, selected_image = next);
				break;
		}
	}

	let el = [];
	let container;

	async function scroll_to_img(index) {
		if (typeof index !== "number") return;
		await tick();
		el[index].focus();
		const { left: container_left, width: container_width } = container.getBoundingClientRect();
		const { left, width } = el[index].getBoundingClientRect();
		const relative_left = left - container_left;
		const pos = relative_left + width / 2 - container_width / 2 + container.scrollLeft;

		container.scrollTo({
			left: pos < 0 ? 0 : pos,
			behavior: "smooth"
		});
	}

	let height = 0;
	let window_height = 0;

	function onwindowresize() {
		$$invalidate(9, window_height = window.innerHeight);
	}

	const clear_handler = () => $$invalidate(7, selected_image = null);
	const click_handler = () => $$invalidate(7, selected_image = next);

	function button_binding($$value, i) {
		binding_callbacks[$$value ? 'unshift' : 'push'](() => {
			el[i] = $$value;
			$$invalidate(10, el);
		});
	}

	const click_handler_1 = i => $$invalidate(7, selected_image = i);

	function div0_binding($$value) {
		binding_callbacks[$$value ? 'unshift' : 'push'](() => {
			container = $$value;
			$$invalidate(11, container);
		});
	}

	const click_handler_2 = i => $$invalidate(7, selected_image = can_zoom ? i : selected_image);

	function div_elementresize_handler() {
		height = this.clientHeight;
		$$invalidate(8, height);
	}

	$$self.$$set = $$props => {
		if ('loading_status' in $$props) $$invalidate(0, loading_status = $$props.loading_status);
		if ('show_label' in $$props) $$invalidate(1, show_label = $$props.show_label);
		if ('label' in $$props) $$invalidate(2, label = $$props.label);
		if ('elem_id' in $$props) $$invalidate(3, elem_id = $$props.elem_id);
		if ('visible' in $$props) $$invalidate(4, visible = $$props.visible);
		if ('value' in $$props) $$invalidate(5, value = $$props.value);
		if ('style' in $$props) $$invalidate(6, style = $$props.style);
	};

	$$self.$$.update = () => {
		if ($$self.$$.dirty & /*selected_image, value*/ 160) {
			previous = ((selected_image ?? 0) + (value?.length ?? 0) - 1) % (value?.length ?? 0);
		}

		if ($$self.$$.dirty & /*selected_image, value*/ 160) {
			$$invalidate(14, next = ((selected_image ?? 0) + 1) % (value?.length ?? 0));
		}

		if ($$self.$$.dirty & /*selected_image*/ 128) {
			scroll_to_img(selected_image);
		}

		if ($$self.$$.dirty & /*window_height, height*/ 768) {
			$$invalidate(13, can_zoom = window_height >= height);
		}

		if ($$self.$$.dirty & /*style*/ 64) {
			$$invalidate(12, { classes } = get_styles(style, ["grid"]), classes);
		}
	};

	return [
		loading_status,
		show_label,
		label,
		elem_id,
		visible,
		value,
		style,
		selected_image,
		height,
		window_height,
		el,
		container,
		classes,
		can_zoom,
		next,
		on_keydown,
		onwindowresize,
		clear_handler,
		click_handler,
		button_binding,
		click_handler_1,
		div0_binding,
		click_handler_2,
		div_elementresize_handler
	];
}

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

		init(this, options, instance, create_fragment, safe_not_equal, {
			loading_status: 0,
			show_label: 1,
			label: 2,
			elem_id: 3,
			visible: 4,
			value: 5,
			style: 6
		});
	}
}

var Gallery$1 = Gallery;

const modes = ["static"];

export { Gallery$1 as Component, modes };
