:: shop_clothing[menu]
	<<actCLA 'Return'>>
		<<set $shop_clothing_current = undefined>>
		<<set $time.minutes += 1>>
		<<gt $store_return>>
	<</actCLA>>
	<<if !$shop_clothing_current>>
		<<set $shop_clothing_current = {
			label: 		$ARGS[0],
			shopId: 	$ARGS[1],
			type: 		$ARGS[2],
			vendor:		$ARGS[3],
			subtype:	$ARGS[4],
			baseprice: 	$ARGS[5]
		}>>

		<<if !$shop_clothing_current.shopId>>
			<<set $shop_clothing_current.shopId = $shop_clothing_current.type+'#'+'#'+$shop_clothing_current.vendor+'#'+$shop_clothing_current.subtype>>
		<</if>>

		<<if !$shop_clothing_current.baseprice>>
			<<set $shop_clothing_current.baseprice = 1000>>
		<</if>>
	<</if>>

	<h2>$shop_clothing_current.label</h2>

	<<if !$wardrobeShopFilter>>
		<<set $wardrobeShopFilter = {
			inhib: [0,1,2],
			price: [1,2],
			quality: [1,2,3,4,5,6,7],
			thinness: [1,2,3,4,5,6],
			topcut: [0,1,2,3,4],
			pantsShortness: [0,1,2,3,4,5,6],
			skirtShortness: [0,1,2,3,4,5,6],
			heels: [1,2,3,4,5,6],
			cut: [1,2,3,4,5,6],
		}>>
	<</if>>

	<<set _filterFields = []>>
	<div id="filters">
		<div id="wardrobe_type_overview_filter">
		<h2>Filters</h2>
		<span>Price:</span>
			<<multiselect '$wardrobeShopFilter.price' `[{id:1,label:"Affordable"},{id:2,label:"Not affordable"}]`>>
				<<replace ".itemsOverview">>
					<<include 'shop_items_overview'>>
				<</replace>>
			<</multiselect>>
		<<if $shop_clothing_current.type != 'purse'>>
			<span>Quality:</span>
				<<multiselect '$wardrobeShopFilter.quality' `[{id:1,label:"Crappy"},{id:2,label:"Very Low"},{id:3,label:"Low"},{id:4,label:"Average"},{id:5,label:"Reasonable"},{id:6,label:"Good"},{id:7,label:"Outstanding"}]`>>
					<<replace ".itemsOverview">>
						<<include 'shop_items_overview'>>
					<</replace>>
				<</multiselect>>
				<<run _filterFields.push('quality')>>
		<</if>>
		<<if $shop_clothing_current.type == 'clothes'>>
			<span>Revealing:</span>
				<<multiselect '$wardrobeShopFilter.inhib' `[{id:0,label:"Not too revealing"},{id:1,label:"Slightly too revealing"},{id:2,label:"Way too revealing"}]`>>
					<<replace ".itemsOverview">>
						<<include 'shop_items_overview'>>
					<</replace>>
				<</multiselect>>
			<span>Thinness:</span>
				<<multiselect '$wardrobeShopFilter.thinness' `[{id:1,label:"Obscures your figure"},{id:2,label:"Somewhat obscures your figure"},{id:3,label:"Somewhat shows your figure"},{id:4,label:"Shows your figure"},{id:5,label:"Shows every detail of your figure"},{id:6,label:"Reveals your intimate areas"}]`>>
					<<replace ".itemsOverview">>
						<<include 'shop_items_overview'>>
					<</replace>>
				<</multiselect>>
				<<run _filterFields.push('thinness')>>
			<span>Top:</span>
				<<multiselect '$wardrobeShopFilter.topcut' `[{id:1,label:"Modest"},{id:2,label:"Regular"},{id:3,label:"Daring"},{id:4,label:"Revealing"},{id:0,label:"None"}]`>>
					<<replace ".itemsOverview">>
						<<include 'shop_items_overview'>>
					<</replace>>
				<</multiselect>>
				<<run _filterFields.push('topcut')>>
			<<if $shop_clothing_current.subtype != 'dress'>>
				<span>Pants:</span>
					<<multiselect '$wardrobeShopFilter.pantsShortness' `[{id:1,label:"Long"},{id:2,label:"Calf-length"},{id:3,label:"Knee-length"},{id:4,label:"Thigh-length"},{id:5,label:"Crotch-length"},{id:6,label:"Privates-exposing"},{id:0,label:"None"}]`>>
						<<replace ".itemsOverview">>
							<<include 'shop_items_overview'>>
						<</replace>>
					<</multiselect>>
					<<run _filterFields.push('pantsShortness')>>
			<</if>>
			<<if $shop_clothing_current.subtype != 'outfit'>>
				<span>Skirt:</span>
					<<multiselect '$wardrobeShopFilter.skirtShortness' `[{id:1,label:"Floor-length"},{id:2,label:"Knee-length"},{id:3,label:"Standard"},{id:4,label:"Short"},{id:5,label:"Groin-length"},{id:6,label:"Privates-exposing"},{id:0,label:"None"}]`>>
						<<replace ".itemsOverview">>
							<<include 'shop_items_overview'>>
						<</replace>>
					<</multiselect>>
					<<run _filterFields.push('skirtShortness')>>
			<</if>>
		<</if>>
		<<if $shop_clothing_current.type == 'shoes'>>
			<span>Heels:</span>
				<<multiselect '$wardrobeShopFilter.heels' `[{id:1,label:"Flat"},{id:2,label:"Low"},{id:3,label:"Medium"},{id:4,label:"High"},{id:5,label:"Ultra High"},{id:6,label:"Fetish"}]`>>
					<<replace ".itemsOverview">>
						<<include 'shop_items_overview'>>
					<</replace>>
				<</multiselect>>
				<<run _filterFields.push('heels')>>
			<span>Cut:</span>
				<<multiselect '$wardrobeShopFilter.cut' `[{id:1,label:"Shoe"},{id:2,label:"Ankle Boot"},{id:3,label:"Calf High Boot"},{id:4,label:"Knee High Boot"},{id:5,label:"Thigh High Boot"},{id:6,label:"Groin High Boot"}]`>>
					<<replace ".itemsOverview">>
						<<include 'shop_items_overview'>>
					<</replace>>
				<</multiselect>>
				<<run _filterFields.push('cut')>>
		<</if>>
	</div>

	<<set _mainfilters = {
		type: $shop_clothing_current.type,
		vendor: $shop_clothing_current.vendor,
		subtype: $shop_clothing_current.subtype
	}>>




	<div class="itemsOverview shop">
		<<include 'shop_items_overview'>>
	</div>

:: shop_items_overview
	<<set _items to $wardrobe.shopItemList($shop_clothing_current.shopId,_mainfilters,$shop_clothing_current.baseprice)>>
	<<set _items to $wardrobe.filterItems(_items,objectFilter($wardrobeShopFilter,_filterFields))>>
	<<run console.log('Shop Items:',_items)>>
	<<set _freeMoney = $finances.available>>
	<<for _item range _items>>
		<<set _hideItem = false>>
		<<set _itemInhibMode = $wardrobe.wearbleInhibition(_item.id)>>
		<<capture _item>>
			<<set _styleClass = 'item linkedImage '>>
			<<if $wardrobe.has(_item.id)>>
				<<set _styleClass += 'owned '>>
				<<if !$wardrobe.filters.shop_owned>><<set _hideItem = true>><</if>>
			<</if>>
			<<if _freeMoney < _item.price>>
				<<set _styleClass += 'insufficientFunds '>>
				<<if !$wardrobeShopFilter.price.includes(2)>>
					<<set _hideItem = true>>
				<</if>>
			<<else>>
				<<if !$wardrobeShopFilter.price.includes(1)>>
					<<set _hideItem = true>>
				<</if>>
			<</if>>
			<<if $shop_clothing_current.type == 'clothes'>>
				<<switch _itemInhibMode>>
					<<case 2>>
						<<if !$wardrobeShopFilter.inhib.includes(0)>><<set _hideItem = true>><</if>>
					<<case 1>>
						<<if !$wardrobeShopFilter.inhib.includes(1)>><<set _hideItem = true>><</if>>
					<<default>>
						<<set _styleClass += 'inhibBlock '>>
						<<if !$wardrobeShopFilter.inhib.includes(2)>><<set _hideItem = true>><</if>>
				<</switch>>
			<</if>>

			<<if !_hideItem>>
				<div @class=_styleClass>
					<<image `$wardrobe.itemImage(_item.id)`>>
					<<link `_item.price.toLocaleString()+' ₽'`>>
						<<gt 'shop_item' `_item.id` `_item.price`>>
					<</link>>
				</div>
			<</if>>
		<</capture>>
	<</for>>


:: shop_overview[widget]
<!-- <<shop `{vendor:cats}` `[{label:'Pussycats Dresses',type:'clothes',subtype:'dress'}]`>> -->
<<widget 'shop'>>
	<<set $shop_clothing_current = undefined>> <!-- For security, should be unset by the Return-link in shop_clothing already -->

	<<set $store_return to passage()>>
	<<set _commonSettings to _args[0]>>
	<<set _devisions to _args[1]>>

	<<for _devision range _devisions>>
		<<set _devisionData to Object.assign({},_commonSettings,_devision)>>
		<<act _devisionData.label undefined `{capture:['_devisionData']}`>>
			<<gt 'shop_clothing' _devisionData.label _devisionData.shopId _devisionData.type _devisionData.vendor _devisionData.subtype _devisionData.baseprice >>
		<</act>>
	<</for>>

<</widget>>

:: shop_item[menu]
    <<set _item_id = $location_var[$here][0]>>
	<<set _itemData = $wardrobe.itemData(_item_id)>>
	<<set _item_price = $location_var[$here][1]>>
	<<set _price_string = _item_price.toLocaleString()+' ₽'>>

	<<set _itemInhibMode = $wardrobe.wearbleInhibition(_item_id)>>
	<<debugVar _itemData>>



	<<image `$wardrobe.itemImage(_item_id)`>>
	<<itemDescription _item_id>>


	<<if _itemInhibMode == 1>>
		<p>This outfit is a little more revealing than you would be completely comfortable with.</p>
	<</if>>

	<p>
		<<if $wardrobe.has(_item_id)>>
			You own this item.
		<<elseif _itemInhibMode == 0>>
			<p>You don't feel daring enough to wear an outfit this revealing and can't bring yourself to buy it.</p>
		<<else>>
			<<if $finances.cash >= _item_price>>
				<<act `"Buy with cash ("+_price_string+")"`>>
					<<run $wardrobe.add(_item_id)>>
					<<set $finances.cash -= _item_price>>
					<<gt $store_return>>
				<</act>>
			<</if>>
			<<if $finances.bankAvailable >= _item_price>>
				<<act `"Buy with bank card ("+_price_string+")"`>>
					<<run $wardrobe.add(_item_id)>>
					<<set $finances.bank -= _item_price>>
					<<gt $store_return>>
				<</act>>
			<</if>>


			<<if $finances.cash < _item_price and $finances.bankAvailable < _item_price >>
				You don't have the <<money _item_price>> to afford this.
			<</if>>
		<</if>>
	</p>
	<p><<act 'Back'>><<gt 'shop_clothing'>><</act>></p>

