import { t as countries_default } from "./countries-Bar7Vz49.js";
import { b as FormMessageList, x as FormLabel } from "./splitted-input-diff-kvHJ6NHp.js";
import { Ct as createContextScope, St as Primitive, Zt as cn, an as useComposedRefs, dt as useControllableState, ft as Presence, wt as composeEventHandlers, yt as useSize } from "./connect-MjNGHHUz-BfDIyhte.js";
import { t as withFieldValidation } from "./with-field-validation-DGjBGqeq.js";
import { n as SelectDiff, t as Select } from "./select-Z-3s_k3i.js";
import { f as getCurrencies } from "./number-field-Bm2o1RCl.js";
import * as React$1 from "react";
import React, { useCallback, useEffect, useId, useMemo, useState } from "react";
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
//#region node_modules/@radix-ui/react-use-previous/dist/index.mjs
function usePrevious(value) {
	const ref = React$1.useRef({
		value,
		previous: value
	});
	return React$1.useMemo(() => {
		if (ref.current.value !== value) {
			ref.current.previous = ref.current.value;
			ref.current.value = value;
		}
		return ref.current.previous;
	}, [value]);
}
//#endregion
//#region node_modules/@radix-ui/react-checkbox/dist/index.mjs
var CHECKBOX_NAME = "Checkbox";
var [createCheckboxContext, createCheckboxScope] = createContextScope(CHECKBOX_NAME);
var [CheckboxProviderImpl, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
function CheckboxProvider(props) {
	const { __scopeCheckbox, checked: checkedProp, children, defaultChecked, disabled, form, name, onCheckedChange, required, value = "on", internal_do_not_use_render } = props;
	const [checked, setChecked] = useControllableState({
		prop: checkedProp,
		defaultProp: defaultChecked ?? false,
		onChange: onCheckedChange,
		caller: CHECKBOX_NAME
	});
	const [control, setControl] = React$1.useState(null);
	const [bubbleInput, setBubbleInput] = React$1.useState(null);
	const hasConsumerStoppedPropagationRef = React$1.useRef(false);
	const isFormControl = control ? !!form || !!control.closest("form") : true;
	const context = {
		checked,
		disabled,
		setChecked,
		control,
		setControl,
		name,
		form,
		value,
		hasConsumerStoppedPropagationRef,
		required,
		defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked,
		isFormControl,
		bubbleInput,
		setBubbleInput
	};
	return /* @__PURE__ */ jsx(CheckboxProviderImpl, {
		scope: __scopeCheckbox,
		...context,
		children: isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children
	});
}
var TRIGGER_NAME = "CheckboxTrigger";
var CheckboxTrigger = React$1.forwardRef(({ __scopeCheckbox, onKeyDown, onClick, ...checkboxProps }, forwardedRef) => {
	const { control, value, disabled, checked, required, setControl, setChecked, hasConsumerStoppedPropagationRef, isFormControl, bubbleInput } = useCheckboxContext(TRIGGER_NAME, __scopeCheckbox);
	const composedRefs = useComposedRefs(forwardedRef, setControl);
	const initialCheckedStateRef = React$1.useRef(checked);
	React$1.useEffect(() => {
		const form = control?.form;
		if (form) {
			const reset = () => setChecked(initialCheckedStateRef.current);
			form.addEventListener("reset", reset);
			return () => form.removeEventListener("reset", reset);
		}
	}, [control, setChecked]);
	return /* @__PURE__ */ jsx(Primitive.button, {
		type: "button",
		role: "checkbox",
		"aria-checked": isIndeterminate(checked) ? "mixed" : checked,
		"aria-required": required,
		"data-state": getState(checked),
		"data-disabled": disabled ? "" : void 0,
		disabled,
		value,
		...checkboxProps,
		ref: composedRefs,
		onKeyDown: composeEventHandlers(onKeyDown, (event) => {
			if (event.key === "Enter") event.preventDefault();
		}),
		onClick: composeEventHandlers(onClick, (event) => {
			setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
			if (bubbleInput && isFormControl) {
				hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
				if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
			}
		})
	});
});
CheckboxTrigger.displayName = TRIGGER_NAME;
var Checkbox$1 = React$1.forwardRef((props, forwardedRef) => {
	const { __scopeCheckbox, name, checked, defaultChecked, required, disabled, value, onCheckedChange, form, ...checkboxProps } = props;
	return /* @__PURE__ */ jsx(CheckboxProvider, {
		__scopeCheckbox,
		checked,
		defaultChecked,
		disabled,
		required,
		onCheckedChange,
		name,
		form,
		value,
		internal_do_not_use_render: ({ isFormControl }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(CheckboxTrigger, {
			...checkboxProps,
			ref: forwardedRef,
			__scopeCheckbox
		}), isFormControl && /* @__PURE__ */ jsx(CheckboxBubbleInput, { __scopeCheckbox })] })
	});
});
Checkbox$1.displayName = CHECKBOX_NAME;
var INDICATOR_NAME = "CheckboxIndicator";
var CheckboxIndicator = React$1.forwardRef((props, forwardedRef) => {
	const { __scopeCheckbox, forceMount, ...indicatorProps } = props;
	const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);
	return /* @__PURE__ */ jsx(Presence, {
		present: forceMount || isIndeterminate(context.checked) || context.checked === true,
		children: /* @__PURE__ */ jsx(Primitive.span, {
			"data-state": getState(context.checked),
			"data-disabled": context.disabled ? "" : void 0,
			...indicatorProps,
			ref: forwardedRef,
			style: {
				pointerEvents: "none",
				...props.style
			}
		})
	});
});
CheckboxIndicator.displayName = INDICATOR_NAME;
var BUBBLE_INPUT_NAME = "CheckboxBubbleInput";
var CheckboxBubbleInput = React$1.forwardRef(({ __scopeCheckbox, ...props }, forwardedRef) => {
	const { control, hasConsumerStoppedPropagationRef, checked, defaultChecked, required, disabled, name, value, form, bubbleInput, setBubbleInput } = useCheckboxContext(BUBBLE_INPUT_NAME, __scopeCheckbox);
	const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);
	const prevChecked = usePrevious(checked);
	const controlSize = useSize(control);
	React$1.useEffect(() => {
		const input = bubbleInput;
		if (!input) return;
		const inputProto = window.HTMLInputElement.prototype;
		const setChecked = Object.getOwnPropertyDescriptor(inputProto, "checked").set;
		const bubbles = !hasConsumerStoppedPropagationRef.current;
		if (prevChecked !== checked && setChecked) {
			const event = new Event("click", { bubbles });
			input.indeterminate = isIndeterminate(checked);
			setChecked.call(input, isIndeterminate(checked) ? false : checked);
			input.dispatchEvent(event);
		}
	}, [
		bubbleInput,
		prevChecked,
		checked,
		hasConsumerStoppedPropagationRef
	]);
	const defaultCheckedRef = React$1.useRef(isIndeterminate(checked) ? false : checked);
	return /* @__PURE__ */ jsx(Primitive.input, {
		type: "checkbox",
		"aria-hidden": true,
		defaultChecked: defaultChecked ?? defaultCheckedRef.current,
		required,
		disabled,
		name,
		value,
		form,
		...props,
		tabIndex: -1,
		ref: composedRefs,
		style: {
			...props.style,
			...controlSize,
			position: "absolute",
			pointerEvents: "none",
			opacity: 0,
			margin: 0,
			transform: "translateX(-100%)"
		}
	});
});
CheckboxBubbleInput.displayName = BUBBLE_INPUT_NAME;
function isFunction(value) {
	return typeof value === "function";
}
function isIndeterminate(checked) {
	return checked === "indeterminate";
}
function getState(checked) {
	return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
}
//#endregion
//#region node_modules/@powerhousedao/document-engineering/dist/src/ui/components/data-entry/checkbox/checkbox-base.js
const CheckboxBase = React$1.forwardRef(({ className, checked, invalid, ...props }, ref) => jsx(Checkbox$1, {
	ref,
	className: cn("peer size-4 shrink-0 rounded", "border-input border shadow-sm shadow-black/[.04]", "ring-offset-background transition-shadow", "focus-visible:border-ring focus-visible:ring-ring focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2", "disabled:cursor-not-allowed disabled:border-gray-700 disabled:data-[invalid=false]:data-[state=checked]:bg-gray-700 disabled:data-[invalid=false]:data-[state=indeterminate]:bg-gray-700 dark:disabled:data-[invalid=false]:data-[state=checked]:bg-gray-500 dark:disabled:data-[invalid=false]:data-[state=indeterminate]:bg-gray-500", "data-[state]:border-gray-700 dark:data-[state]:border-gray-500", "data-[state=checked]:bg-gray-900 data-[state=indeterminate]:bg-gray-900 dark:data-[state=checked]:bg-gray-400 dark:data-[state=indeterminate]:bg-gray-400", "data-[state=checked]:text-slate-50 data-[state=indeterminate]:text-slate-50 dark:data-[state=checked]:text-gray-900 dark:data-[state=indeterminate]:text-gray-900", !props.disabled && ["group-hover:border-gray-900 data-[state=checked]:group-hover:bg-gray-900 data-[state=indeterminate]:group-hover:bg-gray-900", "dark:group-hover:border-slate-50 dark:data-[state=checked]:group-hover:bg-slate-50 dark:data-[state=indeterminate]:group-hover:bg-slate-50"], "data-[invalid=true]:data-[state]:!border-red-800 data-[invalid=true]:data-[state=checked]:!bg-red-800 data-[invalid=true]:data-[state=indeterminate]:!bg-red-800", "dark:data-[invalid=true]:data-[state]:!border-red-800 dark:data-[invalid=true]:data-[state=checked]:!bg-red-800 dark:data-[invalid=true]:data-[state=indeterminate]:!bg-red-800", "data-[invalid=true]:group-hover:!border-red-900 data-[invalid=true]:data-[state=checked]:group-hover:!bg-red-900 data-[invalid=true]:data-[state=indeterminate]:group-hover:!bg-red-900", className),
	checked,
	"data-invalid": invalid,
	...props,
	children: jsx(CheckboxIndicator, {
		className: "flex items-center justify-center text-current",
		children: checked === "indeterminate" ? jsx("svg", {
			width: "9",
			height: "9",
			viewBox: "0 0 9 9",
			fill: "currentcolor",
			xmlns: "http://www.w3.org/2000/svg",
			children: jsx("path", {
				fillRule: "evenodd",
				clipRule: "evenodd",
				d: "M0.75 4.5C0.75 4.08579 1.08579 3.75 1.5 3.75H7.5C7.91421 3.75 8.25 4.08579 8.25 4.5C8.25 4.91421 7.91421 5.25 7.5 5.25H1.5C1.08579 5.25 0.75 4.91421 0.75 4.5Z"
			})
		}) : checked ? jsx("svg", {
			width: "9",
			height: "9",
			viewBox: "0 0 9 9",
			fill: "currentcolor",
			xmlns: "http://www.w3.org/2000/svg",
			children: jsx("path", {
				fillRule: "evenodd",
				clipRule: "evenodd",
				d: "M8.53547 0.62293C8.88226 0.849446 8.97976 1.3142 8.75325 1.66099L4.5083 8.1599C4.38833 8.34356 4.19397 8.4655 3.9764 8.49358C3.75883 8.52167 3.53987 8.45309 3.3772 8.30591L0.616113 5.80777C0.308959 5.52987 0.285246 5.05559 0.563148 4.74844C0.84105 4.44128 1.31533 4.41757 1.62249 4.69547L3.73256 6.60459L7.49741 0.840706C7.72393 0.493916 8.18868 0.396414 8.53547 0.62293Z"
			})
		}) : null
	})
}));
CheckboxBase.displayName = "CheckboxBase";
//#endregion
//#region node_modules/@powerhousedao/document-engineering/dist/src/ui/components/data-entry/checkbox/subcomponents/checkbox-diff.js
const CheckboxDiff = ({ value, label, required, disabled, baseValue = false, viewMode = "edition", name }) => {
	const id = useId();
	const hasDifference = useMemo(() => {
		if (baseValue === value) return {
			hasDiff: false,
			type: "neutral"
		};
		if (!baseValue && value === true) return {
			hasDiff: true,
			type: "addition"
		};
		return {
			hasDiff: true,
			type: "removal"
		};
	}, [baseValue, value]);
	return jsxs("div", {
		className: "flex flex-row items-center gap-2",
		"data-testid": "checkbox-diff",
		children: [jsx(CheckboxBase, {
			id,
			name,
			checked: value,
			disabled,
			required
		}), jsx(FormLabel, {
			htmlFor: id,
			required,
			disabled,
			inline: true,
			className: cn(hasDifference.hasDiff && (viewMode === "addition" || viewMode === "mixed") && hasDifference.type === "addition" ? "bg-green-600/30" : hasDifference.hasDiff && (viewMode === "removal" || viewMode === "mixed") && hasDifference.type === "removal" ? "bg-red-600/30" : void 0),
			children: label
		})]
	});
};
CheckboxDiff.displayName = "CheckboxDiff";
//#endregion
//#region node_modules/@powerhousedao/document-engineering/dist/src/ui/components/data-entry/checkbox/checkbox.js
const Checkbox = React.forwardRef(({ id: idProp, name, label, value, defaultValue, disabled, required, description, errors, warnings, onChange, className, viewMode = "edition", baseValue, ...props }, ref) => {
	const generatedId = useId();
	const id = idProp ?? generatedId;
	const hasError = !!errors?.length;
	const castValue = (value) => {
		if (value === "true") return true;
		if (value === "false") return false;
		return value;
	};
	if (viewMode === "edition") return jsxs("div", {
		className: cn("flex flex-col gap-2"),
		children: [
			jsxs("div", {
				className: cn("group flex items-center space-x-2", className),
				children: [jsx(CheckboxBase, {
					id,
					name,
					checked: castValue(value ?? defaultValue),
					disabled,
					onCheckedChange: onChange,
					required,
					invalid: hasError,
					"aria-invalid": hasError,
					ref,
					...props
				}), jsx(FormLabel, {
					htmlFor: id,
					required,
					disabled,
					hasError,
					description,
					className: cn(!disabled && "group-hover:cursor-pointer"),
					inline: true,
					children: label
				})]
			}),
			warnings && jsx(FormMessageList, {
				type: "warning",
				messages: warnings
			}),
			errors && jsx(FormMessageList, {
				type: "error",
				messages: errors
			})
		]
	});
	return jsx(CheckboxDiff, {
		value,
		label,
		required,
		disabled,
		baseValue,
		viewMode
	});
});
Checkbox.displayName = "Checkbox";
//#endregion
//#region node_modules/react-circle-flags/dist/index.modern.js
function n() {
	return (n = Object.assign ? Object.assign.bind() : function(a) {
		for (var n = 1; n < arguments.length; n++) {
			var e = arguments[n];
			for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && (a[t] = e[t]);
		}
		return a;
	}).apply(this, arguments);
}
function e(a, n) {
	if (null == a) return {};
	var e, t, r = {}, s = Object.keys(a);
	for (t = 0; t < s.length; t++) n.indexOf(e = s[t]) >= 0 || (r[e] = a[e]);
	return r;
}
var t = {
	ac: !0,
	ad: !0,
	ae: !0,
	af: !0,
	afar: !0,
	ag: !0,
	ai: !0,
	al: !0,
	am: !0,
	ao: !0,
	aq: !0,
	ar: !0,
	as: !0,
	at: !0,
	au: !0,
	"au-aboriginal": !0,
	"au-act": !0,
	"au-nsw": !0,
	"au-nt": !0,
	"au-qld": !0,
	"au-tas": !0,
	"au-vic": !0,
	"au-wa": !0,
	aw: !0,
	ax: !0,
	az: !0,
	ba: !0,
	bb: !0,
	bd: !0,
	be: !0,
	bf: !0,
	bg: !0,
	bh: !0,
	bi: !0,
	bj: !0,
	bl: !0,
	bm: !0,
	bn: !0,
	bo: !0,
	"bq-bo": !0,
	"bq-sa": !0,
	"bq-se": !0,
	bq: !0,
	br: !0,
	bs: !0,
	bt: !0,
	bv: !0,
	bw: !0,
	by: !0,
	bz: !0,
	"ca-bc": !0,
	ca: !0,
	cc: !0,
	cd: !0,
	cf: !0,
	cg: !0,
	"ch-gr": !0,
	ch: !0,
	ci: !0,
	ck: !0,
	cl: !0,
	cm: !0,
	"cn-xj": !0,
	cn: !0,
	co: !0,
	cp: !0,
	cq: !0,
	cr: !0,
	cu: !0,
	cv: !0,
	cw: !0,
	cx: !0,
	cy: !0,
	cz: !0,
	de: !0,
	dg: !0,
	dj: !0,
	dk: !0,
	dm: !0,
	do: !0,
	dz: !0,
	ea: !0,
	earth: !0,
	east_african_federation: !0,
	easter_island: !0,
	"ec-w": !0,
	ec: !0,
	ee: !0,
	eg: !0,
	eh: !0,
	er: !0,
	"es-ar": !0,
	"es-ce": !0,
	"es-cn": !0,
	"es-ct": !0,
	"es-ga": !0,
	"es-ib": !0,
	"es-ml": !0,
	"es-pv": !0,
	"es-variant": !0,
	es: !0,
	"et-or": !0,
	"et-ti": !0,
	et: !0,
	eu: !0,
	european_union: !0,
	ewe: !0,
	fi: !0,
	fj: !0,
	fk: !0,
	fm: !0,
	fo: !0,
	"fr-20r": !0,
	"fr-bre": !0,
	"fr-cp": !0,
	fr: !0,
	fx: !0,
	ga: !0,
	"gb-con": !0,
	"gb-eng": !0,
	"gb-nir": !0,
	"gb-ork": !0,
	"gb-sct": !0,
	"gb-wls": !0,
	gb: !0,
	gd: !0,
	"ge-ab": !0,
	ge: !0,
	gf: !0,
	gg: !0,
	gh: !0,
	gi: !0,
	gl: !0,
	gm: !0,
	gn: !0,
	gp: !0,
	gq: !0,
	gr: !0,
	gs: !0,
	gt: !0,
	gu: !0,
	guarani: !0,
	gw: !0,
	gy: !0,
	hausa: !0,
	hk: !0,
	hm: !0,
	hmong: !0,
	hn: !0,
	hr: !0,
	ht: !0,
	hu: !0,
	ic: !0,
	id: !0,
	"id-jb": !0,
	"id-jt": !0,
	ie: !0,
	il: !0,
	im: !0,
	"in-as": !0,
	"in-gj": !0,
	"in-ka": !0,
	"in-or": !0,
	"in-tn": !0,
	in: !0,
	io: !0,
	iq: !0,
	ir: !0,
	is: !0,
	"it-23": !0,
	"it-82": !0,
	"it-88": !0,
	it: !0,
	je: !0,
	jm: !0,
	jo: !0,
	jp: !0,
	kanuri: !0,
	ke: !0,
	kg: !0,
	kh: !0,
	ki: !0,
	kikuyu: !0,
	km: !0,
	kn: !0,
	kongo: !0,
	kp: !0,
	kr: !0,
	kurdistan: !0,
	kw: !0,
	ky: !0,
	kz: !0,
	la: !0,
	lb: !0,
	lc: !0,
	li: !0,
	lk: !0,
	lr: !0,
	ls: !0,
	lt: !0,
	lu: !0,
	lv: !0,
	ly: !0,
	ma: !0,
	malayali: !0,
	manipur: !0,
	maori: !0,
	mc: !0,
	md: !0,
	me: !0,
	mf: !0,
	mg: !0,
	mh: !0,
	mizoram: !0,
	mk: !0,
	ml: !0,
	mm: !0,
	mn: !0,
	mo: !0,
	mp: !0,
	mq: !0,
	mr: !0,
	ms: !0,
	mt: !0,
	mu: !0,
	mv: !0,
	mw: !0,
	mx: !0,
	my: !0,
	mz: !0,
	na: !0,
	nato: !0,
	nc: !0,
	ne: !0,
	nf: !0,
	ng: !0,
	ni: !0,
	"nl-fr": !0,
	nl: !0,
	no: !0,
	northern_cyprus: !0,
	np: !0,
	nr: !0,
	nu: !0,
	nz: !0,
	occitania: !0,
	olympics: !0,
	om: !0,
	otomi: !0,
	pa: !0,
	pe: !0,
	pf: !0,
	pg: !0,
	ph: !0,
	"pk-jk": !0,
	"pk-sd": !0,
	pk: !0,
	pl: !0,
	pm: !0,
	pn: !0,
	pr: !0,
	ps: !0,
	"pt-20": !0,
	"pt-30": !0,
	pt: !0,
	pw: !0,
	py: !0,
	qa: !0,
	quechua: !0,
	re: !0,
	ro: !0,
	rs: !0,
	ru: !0,
	"ru-ba": !0,
	"ru-ce": !0,
	"ru-cu": !0,
	"ru-da": !0,
	"ru-ko": !0,
	"ru-ta": !0,
	"ru-ud": !0,
	rw: !0,
	sa: !0,
	sami: !0,
	sb: !0,
	sc: !0,
	sd: !0,
	se: !0,
	sg: !0,
	"sh-ac": !0,
	"sh-hl": !0,
	"sh-ta": !0,
	sh: !0,
	si: !0,
	sj: !0,
	sk: !0,
	sl: !0,
	sm: !0,
	sn: !0,
	so: !0,
	somaliland: !0,
	south_ossetia: !0,
	soviet_union: !0,
	sr: !0,
	ss: !0,
	st: !0,
	su: !0,
	sv: !0,
	sx: !0,
	sy: !0,
	sz: !0,
	ta: !0,
	tc: !0,
	td: !0,
	tf: !0,
	tg: !0,
	th: !0,
	tibet: !0,
	tj: !0,
	tk: !0,
	tl: !0,
	tm: !0,
	tn: !0,
	to: !0,
	torres_strait_islands: !0,
	tr: !0,
	transnistria: !0,
	tt: !0,
	tv: !0,
	tw: !0,
	tz: !0,
	ua: !0,
	ug: !0,
	uk: !0,
	um: !0,
	un: !0,
	united_nations: !0,
	"us-hi": !0,
	us: !0,
	uy: !0,
	uz: !0,
	va: !0,
	vc: !0,
	ve: !0,
	vg: !0,
	vi: !0,
	vn: !0,
	vu: !0,
	wf: !0,
	wiphala: !0,
	ws: !0,
	xk: !0,
	xx: !0,
	ye: !0,
	yorubaland: !0,
	yt: !0,
	za: !0,
	zm: !0,
	zw: !0
}, s = ["countryCode", "cdnUrl"], c = function(a, e, t, r) {
	return void 0 === r && (r = ""), n({}, t, {
		title: t.title || a,
		height: t.height || 100,
		src: "" + (e || "https://react-circle-flags.pages.dev/") + r + a + ".svg"
	});
}, u = function(r) {
	var i = r.countryCode, u = r.cdnUrl, o = e(r, s);
	return React.createElement("img", n({ "data-testid": "circle-country-flag" }, c(function(a) {
		return t[a] ? a : "xx";
	}(i).toLowerCase(), u, o)));
};
//#endregion
//#region node_modules/@powerhousedao/document-engineering/dist/src/ui/components/data-entry/country-code-picker/country-code-picker.js
const renderCountryIcon = (showFlagIcons, countryCode) => {
	if (!showFlagIcons || !countryCode) return void 0;
	return jsx(u, {
		className: "size-4",
		countryCode: countryCode.toLowerCase(),
		height: 16
	});
};
const CountryCodePicker = React.forwardRef(({ label, required, value, defaultValue, onChange, placeholder, allowedCountries, excludedCountries, includeDependentAreas = false, optionFormat = "NamesOnly", showFlagIcons = true, enableSearch, viewMode = "edition", baseValue, ...props }, ref) => {
	const [internalValue, setInternalValue] = useState(value ?? defaultValue ?? "");
	const defaultOptions = countries_default.filter((country) => (includeDependentAreas ? true : country.independent) && country.cca2 !== "AQ").map((country) => ({
		value: country.cca2,
		label: optionFormat === "CodesOnly" ? country.cca2 : optionFormat === "NamesAndCodes" ? `${country.name.common} (${country.cca2})` : country.name.common,
		icon: showFlagIcons ? () => jsx(u, {
			className: "size-4",
			countryCode: country.cca2.toLowerCase(),
			height: 16
		}) : void 0
	})).sort((a, b) => a.label > b.label ? 1 : a.label < b.label ? -1 : 0);
	const allowedCountriesArray = Array.isArray(allowedCountries) ? allowedCountries : void 0;
	const excludedCountriesArray = Array.isArray(excludedCountries) ? excludedCountries : void 0;
	const options = allowedCountriesArray || excludedCountriesArray ? defaultOptions.filter((option) => {
		const isAllowedCountry = allowedCountriesArray ? allowedCountriesArray.includes(option.value) : true;
		const isExcludedCountry = excludedCountriesArray ? !excludedCountriesArray.includes(option.value) : true;
		return isAllowedCountry && isExcludedCountry;
	}) : defaultOptions;
	const selectedOption = options.find((option) => option.value === internalValue);
	const baseOption = options.find((option) => option.value === baseValue);
	const selectedLabel = selectedOption?.label ?? internalValue;
	const baseLabel = baseOption?.label ?? baseValue;
	const baseIcon = baseOption ? renderCountryIcon(showFlagIcons, baseValue ?? "") : void 0;
	const icon = selectedOption ? renderCountryIcon(showFlagIcons, internalValue) : void 0;
	const handleChange = useCallback((value) => {
		if (Array.isArray(value)) {
			console.warn("CountryCodePicker received array value, expected string");
			return;
		}
		setInternalValue(value);
		onChange?.(value);
	}, [onChange]);
	useEffect(() => {
		if (value !== void 0) setInternalValue(value);
	}, [value]);
	if (viewMode === "edition") return jsx(Select, {
		ref,
		options,
		selectionIcon: "checkmark",
		selectionIconPosition: "right",
		searchable: enableSearch,
		value: internalValue,
		onChange: handleChange,
		placeholder,
		label,
		required,
		...props
	});
	return jsx(SelectDiff, {
		value: selectedLabel,
		label,
		required,
		viewMode,
		baseValue: baseLabel,
		baseIcon,
		icon
	});
});
CountryCodePicker.displayName = "CountryCodePicker";
//#endregion
//#region node_modules/@powerhousedao/document-engineering/dist/src/ui/components/data-entry/currency-code-picker/currency-code-picker.js
const CurrencyCodePicker = React.forwardRef(({ placeholder, currencies = [], favoriteCurrencies = [], includeCurrencySymbols = true, symbolPosition = "right", searchable = false, contentAlign = "start", allowedTypes = "Both", value, defaultValue, onChange, label, required, viewMode = "edition", baseValue, ...props }, ref) => {
	const [internalValue, setInternalValue] = useState(value ?? defaultValue ?? "");
	const defaultCurrencies = currencies.length > 0 ? currencies : getCurrencies(allowedTypes);
	const options = useMemo(() => {
		const favoriteTickers = new Set(favoriteCurrencies);
		return defaultCurrencies.filter((currency) => currency.ticker && typeof currency.crypto === "boolean").map((currency) => {
			if (favoriteTickers.has(currency.ticker)) return null;
			let label = currency.label ?? currency.ticker;
			if (includeCurrencySymbols && currency.symbol) label = symbolPosition === "right" ? `${label} (${currency.symbol})` : `(${currency.symbol}) ${label}`;
			const option = {
				label,
				value: currency.ticker
			};
			if ("icon" in currency) option.icon = currency.icon;
			return option;
		}).filter(Boolean);
	}, [
		defaultCurrencies,
		includeCurrencySymbols,
		symbolPosition,
		favoriteCurrencies
	]);
	const favoriteOptions = useMemo(() => {
		const favoriteTickers = new Set(favoriteCurrencies);
		return defaultCurrencies.filter((currency) => favoriteTickers.has(currency.ticker)).map((currency) => {
			let label = currency.label ?? currency.ticker;
			if (includeCurrencySymbols && currency.symbol) label = symbolPosition === "right" ? `${label} (${currency.symbol})` : `(${currency.symbol}) ${label}`;
			const option = {
				label,
				value: currency.ticker
			};
			if ("icon" in currency) option.icon = currency.icon;
			return option;
		});
	}, [
		defaultCurrencies,
		favoriteCurrencies,
		includeCurrencySymbols,
		symbolPosition
	]);
	const allOptions = [...favoriteOptions, ...options];
	const selectedLabel = allOptions.find((option) => option.value === internalValue)?.label ?? internalValue;
	const baseLabel = allOptions.find((option) => option.value === baseValue)?.label ?? baseValue;
	const handleChange = useCallback((value) => {
		if (Array.isArray(value)) {
			console.warn("CurencyCodePicker received array value, expected string");
			return;
		}
		setInternalValue(value);
		onChange?.(value);
	}, [onChange]);
	useEffect(() => {
		if (value !== void 0) setInternalValue(value);
	}, [value]);
	if (viewMode === "edition") return jsx(Select, {
		ref,
		options,
		selectionIcon: "checkmark",
		searchable,
		placeholder,
		contentAlign,
		favoriteOptions,
		value: internalValue,
		onChange: handleChange,
		label,
		required,
		...props
	});
	return jsx(SelectDiff, {
		value: selectedLabel,
		label,
		required,
		viewMode,
		baseValue: baseLabel
	});
});
CurrencyCodePicker.displayName = "CurrencyCodePicker";
//#endregion
//#region node_modules/@powerhousedao/document-engineering/dist/src/scalars/components/country-code-field/country-code-field.js
const CountryCodeField = withFieldValidation(CountryCodePicker, { validations: { _validOption: ({ allowedCountries, excludedCountries, includeDependentAreas }) => (value) => {
	if (value === "" || value === void 0) return true;
	if (!countries_default.filter((country) => (includeDependentAreas ? true : country.independent) && country.cca2 !== "AQ").map((country) => country.cca2).includes(value)) return "Please select a valid country";
	if (Array.isArray(allowedCountries) && !allowedCountries.includes(value)) return "Please select a valid country";
	if (Array.isArray(excludedCountries) && excludedCountries.includes(value)) return "Please select a valid country";
	return true;
} } });
CountryCodeField.displayName = "CountryCodeField";
//#endregion
//#region node_modules/@powerhousedao/document-engineering/dist/src/scalars/components/currency-code-field/currency-code-field.js
const CurrencyCodeField = withFieldValidation(CurrencyCodePicker);
CurrencyCodeField.displayName = "CurrencyCodeField";
//#endregion
export { Checkbox as a, u as i, CountryCodeField as n, usePrevious as o, CurrencyCodePicker as r, CurrencyCodeField as t };

//# sourceMappingURL=currency-code-field-Bd5Mf2iJ.js.map