:: wardrobe_macros[widget]
	<<widget 'itemStoreSet'>>
		<<set _type = _args[0]>>
		<<set _vendor = _args[1]>>
		<<set _id = _args[2]>>
		<<set _subtype = _args[3]>>
		<<set _storeSetting = _args[4]>>
		<<run itemSetLocation(_type,_vendor,_id,_subtype,_storeSetting)>>
	<</widget>>

	<<widget 'itemsOverview'>>
		<<set _type to _args[0]>>
		<<set _locationFilter to _args[1]>>/*Deprecated */

		<<set _subtypeFilter to undefined>>
		<<if _args[2]>>
			<<set _subtypeFilter to _args[2]>>
		<</if>>

		<<set _vendorFilter to undefined>>
		<<if _args[3]>>
			<<set _vendorFilter to _args[3]>>
		<</if>>

		<<set _flags = {}>>
		<<if _args[4]>>
			<<set _flags to _args[4]>>
		<</if>>

		<<set _additionalFilters = _args[5] || {}>>


		<<set _replaceMode = false>><<if _flags.replaceMode>><<set _replaceMode = true>><</if>>
		<<set _returnPassage = 'wardrobe'>><<if _flags.returnPassage>><<set _returnPassage = _flags.returnPassage>><</if>>
		<<set _lastWornSet = undefined>><<if _flags.lastWornSet>><<set _lastWornSet = _flags.lastWornSet>><</if>> <!-- only works with replace-mode-->

		<div class="itemsOverview">
			<<for _vendor range setup.vendors[_type]>>
				<<if _vendorFilter and _vendorFilter != _vendor>><<continue>><</if>>

				<<set _filters = Object.assign({},{type:_type,vendor:_vendor,subtype:_subtypeFilter},_additionalFilters)>>
				<<set _items = $wardrobe.itemsFiltered(_filters)>>
				<<if Object.keys(_items).length > 0>>
					<<image `setup.outfitItemImagePath.vendors[_vendor]`>>
				<</if>>
				<<for _itemId, _item range _items>>
					<<set _styleClass = 'item linkedImage '>>
					<<if _item.l == 1>>
						<<set _styleClass += 'stored'>>
					<<elseif _item.l == 2>>
						<<set _styleClass += 'unwanted'>>
					<</if>>
					<<if $wardrobe.isWearing(_itemId)>>
						<<set _styleClass += 'wearing'>>
					<</if>>
					
					<<set _bmiMode = $wardrobe.wearableBMI(_itemId)>>
					<<if _bmiMode == 2 || _bmiMode == 3 || (_item.health > 0 && _item.health < 10)>>
						<<set _styleClass += 'warning'>>
					<</if>>
					<<set _wearable = $wardrobe.wearable(_itemId)>>
					<div @class=_styleClass>
						<<image _item.image>>
						<<if !_wearable.owned>>
							<div class="notOwnedOverlay"></div>
						<<elseif !_wearable.health>>
							<div class="destroyedOverlay"></div>
						<<elseif !_wearable.inhibition>>
							<div class="insufficientInhibitionOverlay"></div>
						<<elseif !_wearable.hips>>
							<div class="destroyedOverlay"></div>
						<<elseif !_wearable.total>>
							<div class="destroyedOverlay"></div>
						<</if>>

						<<capture _itemId, _item, _returnPassage, _lastWornSet,_wearable>>

							<<link "Wear">>
								<<if !_wearable.owned>>
									<<msg "You have lost this item.">>
								<<elseif !_wearable.health>>
									<<msg "This outfit is completely worn-out. You don't want to wear it.">>
								<<elseif !_wearable.inhibition>>
									<<msg "You don't feel comfortable wearing this outfit.">>
								<<elseif !_wearable.hips>>
									<<msg "This outfit doesn't fit you.">>
								<<elseif _wearable.various.length > 0>>
									<<msg _wearable.various[0]>>
								<<elseif _wearable.total>>
									<<if _replaceMode>>
										<<if _lastWornSet>><<run $wardrobe.lastWornSet(_lastWornSet)>><</if>>
										<<run $wardrobe.stripAll()>>
									<</if>>
									<<run $wardrobe.wear(_itemId)>>
									<<gt _returnPassage>>
								<<else>>
									<<msg "You can't wear that.">>
								<</if>>
							<</link>>
							<<if !_replaceMode>>
								<<if _item.l > 0>>
									<<link "Wardrobe">>
										<<run $wardrobe.sendToLocation(_itemId,0)>>
										<<regt>>
									<</link>>
								<</if>>
								<<if _item.l != 1>>
									<<link "Store">>
										<<run $wardrobe.sendToLocation(_itemId,1)>>
										<<regt>>
									<</link>>
								<</if>>
								<<if _item.l < 2>>
									<<link "Unwanted">>
										<<run $wardrobe.sendToLocation(_itemId,2)>>
										<<regt>>
									<</link>>
								<</if>>
								<<link "Details">>
									<<gt "wardrobe_item_details" _itemId>>
								<</link>>
							<</if>>
						<</capture>>
					</div>
				<</for>>
			<</for>>
		</div>
	<</widget>>
