div id="messages"
	#success-message.Feedback.Feedback--positive.u-hidden role="alert"
		.Feedback-icon
			i.Icon.bi.bi-hand-thumbs-up-fill.u-fontSizeXl
		h5.headline Successful
		span.message
		p
			a href="javascript:void(0)" onclick="javascript:this.closest('.Feedback').classList.add('u-hidden')" Dismiss
	#failure-message.Feedback.Feedback--negative.u-hidden role="alert"
		.Feedback-icon.bi.bi-hand-thumbs-down-fill
		h5.headline Not Successful!
		span.message Error encountered.
		p
			a href="javascript:void(0)" onclick="javascript:this.closest('.Feedback').classList.add('u-hidden')" Dismiss
	#waiting-message.Feedback.u-hidden role="alert"
		.Feedback-icon
			.Icon.Icon--loader.u-colorForeground.u-fontSizeXl
				<svg viewBox="0 0 66 66" role="presentation" class="Icon Icon--loader">
					<circle fill="none" stroke-width="12" stroke="currentColor" stroke-linecap="round" cx="33" cy="33" r="24" />
				</svg>
		h5.headline Sending...
div id="modals"
	#email-modal.Modal
		.Modal-content
			.Modal-header
				.Modal-title Email
				a href="javascript:void(0)" onclick="javascript:this.closest('.Modal').classList.toggle('is-open')" Dismiss
			.Modal-body

div id="event-lineup-#{event.id}" class="event-lineup"
	= form_with(url: url_for(event_lineup_submit_path :team_id=>team.id, :event_id=>event.id), method: :post, :html => { :onsubmit => "onSubmit(this,event)" }) do |form|
		=form.hidden_field name="event_lineup_id", value: !event_lineup.nil? ? event_lineup.id : nil
		.event-card.u-maxWidthSm
			.event-card-body
				div.Grid
					div.Grid-cell.u-sizeFill
						h3.title #{event.formatted_title}
					div.Grid-cell.u-sizeFit
						.ButtonGroup
							= form.submit("Save", class: "Button Button--orange")
							.Button.Button--orange.u-padSidesXs.Popup onclick="togglePopup(this)"
								.bi.bi-caret-down.u-spaceNone
								.Popup-container.Popup-container--down.Popup-container--rightHang data-popup="demo4a" style="width: 200px"
									.Popup-content
										.u-textBold
											
											a href="javascript:void(0)" onclick="emailModal(this, '#{url_for(event_lineup_email_path :team_id=>team.id, :event_id=>event.id)}')"
												i.bi.bi-envelope
												span Generate Email
											hr.Divider.u-spaceEndsNone
											a href=""
												p.u-padEndsSm.u-padSidesMd Action 2
				div.date #{event.start_date.strftime("%a, %b  %e, %l:%M %p")}
				div.location #{event.location_name}
				div.availability-bar=render("event/availability_bar", team:team, event:event, availability_summary: availability_summary)
		.Panel.u-maxWidthSm.starting
			.Panel-body
				.Panel-row.Panel-title.u-padXs 
					i.bi.bi-clipboard-check.me-1
					span Starting Lineup
				.Panel-row.Grid.Grid--fit.fw-bold.text-center.u-padXs
					- for pos in ["P", "C", "1B", "2B", "3B", "SS", "LF", "CF", "RF", "EH", "DH"]
						.Grid-cell.position-status #{pos}
				.slot-set
					- event_lineup_entry.select{|d| extract_flags(d)[1].exclude?(PositionLabelFlag::POSITION_ONLY)}.sort_by{|d| d['sequence']}.each_with_index do |d|
							- m = members.find{|m| m.id == d['member_id']}
							=render("lineup_slot",event_lineup_entry: by_member[m][:event_lineup_entry],availability: by_member[m][:availability], member:m, event:event, timeline: timeline, form: form, event_lineup:d)
		.Panel.u-maxWidthSm.position-only
			.Panel-body
				.Panel-row.Panel-title.u-padXs 
					i.bi.bi-clipboard-check.me-1
					span Position Only
				.slot-set
					- event_lineup_entry.select{ |d| extract_flags(d)[1].include?(PositionLabelFlag::POSITION_ONLY)}.sort_by{|d| d['sequence']}.each_with_index do |d|
						- m = members.find{|m| m.id == d['member_id']}
						=render("lineup_slot",event_lineup_entry: by_member[m][:event_lineup_entry],availability: by_member[m][:availability], member:m, event:event, timeline: timeline, form: form, event_lineup:d)
		
		.Panel.u-maxWidthSm.bench
			.Panel-body
				.Panel-row.Panel-title.u-padXs 
					i.bi.bi-clipboard-minus.me-1
					span Bench
				.slot-set
					- by_member.select{|m,d| !d[:availability].status_code.nil? and d[:availability].status_code != 0 and !m.is_non_player and d[:event_lineup_entry].nil?}.each_with_index do |(m, d), i|
						=render("lineup_slot",event_lineup_entry: by_member[m][:event_lineup_entry],availability: by_member[m][:availability], member:m, event:event, timeline: timeline, form: form, event_lineup:event_lineup)	
		
		.Panel.u-maxWidthSm.out
			.Panel-body
				.Panel-row.Panel-title.u-padXs 
					i.bi.bi-clipboard-x.me-1
					span Out
				.slot-set
					- by_member.select{|m,d| (d[:availability].status_code.nil? or d[:availability].status_code == 0) and !m.is_non_player and d[:event_lineup_entry].nil?}.each_with_index do |(m, d), i|
						=render("lineup_slot",event_lineup_entry: by_member[m][:event_lineup_entry],availability: by_member[m][:availability], member:m, event:event, timeline: timeline, form: form, event_lineup:event_lineup)	


script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"
=javascript_include_tag 'lineup'
javascript:
	colorPositions();
	refreshLineupOrder();
						

