t = require('Modul:ku-tewandin')

local p = {}

function p.tew_kes(dem, neyini, frame)
   local args = frame:getParent().args
   local niha = args['niha']
   local bori = args['borî']
   local form = args['form']
   local pasgir = args['paşgir']
   local pesgir = args['pêşgir']
   local valahi = args['valahî']
   local leker = args[1]
   
   local niha2 = args['niha2']
   local niha3 = args['niha3']
   local bori2 = args['borî2']
   
   local bi = args['bi']
   local di = args['di']
   local na = args['na']
   local ne = args['ne']
     
  return t.kes(dem, form) .. ' ' .. t.tewandinDirej(leker, dem, neyini, form, pasgir, pesgir, valahi, niha, niha2, niha3, bori, bori2, bi, di, na, ne)
end
----------------------------------------------------------------------------------------
--                            ÇÊKIRINA TABLOYÊ
----------------------------------------------------------------------------------------
function p.tablo(frame)
   local args = frame:getParent().args
   local niha = args['niha']
   local bori = args['borî']
   local form = args['form']
   local pesgir = args['pêşgir']
   local pasgir = args['paşgir']
   local valahi = args['valahî']
   local leker = args[1]
   
   local niha2 = args['niha2']
   local niha3 = args['niha3']
   local bori2 = args['borî2']
   	
   function f1(i)
     local s = tostring(i)
     return '\n|colspan="2"|' .. p.tew_kes('IndPresent'..i, '', frame)
     ..'\n|colspan="2"|' .. p.tew_kes('IndPresent'..i, 'ne', frame)
     ..'\n|colspan="2"|' .. p.tew_kes('IndPreterite'..i, '', frame)
     ..'\n|colspan="2"|' .. p.tew_kes('IndPreterite'..i, 'ne', frame)
     ..'\n|-'
   end
   function f2(i)
     local s = tostring(i)
     return '\n|colspan="2"|' .. p.tew_kes('IndImperfect'..i, '', frame)
     ..'\n|colspan="2"|' .. p.tew_kes('IndImperfect'..i, 'ne', frame)
     ..'\n|colspan="2"|' .. p.tew_kes('IndPluperfect'..i, '', frame)
     ..'\n|colspan="2"|' .. p.tew_kes('IndPluperfect'..i, 'ne', frame)
     ..'\n|-'
   end
   function f3(i)
     local s = tostring(i)
     return '\n|colspan="2"|' .. p.tew_kes('IndFuture'..i, '', frame)
     ..'\n|colspan="2"|' .. p.tew_kes('IndFuture'..i, 'ne', frame)
     ..'\n|colspan="2"|' .. p.tew_kes('IndFuturePerfect'..i, '', frame)
     ..'\n|colspan="2"|' .. p.tew_kes('IndFuturePerfect'..i, 'ne', frame)
     ..'\n|-'
   end
   function f4(i)
     local s = tostring(i)
     return '\n|colspan="2"|' .. p.tew_kes('IndPerfect'..i, '', frame)
     ..'\n|colspan="2"|' .. p.tew_kes('IndPerfect'..i, 'ne', frame)
     ..'\n|colspan="2"|' .. p.tew_kes('IndPQPNCons'..i, '', frame)
     ..'\n|colspan="2"|' .. p.tew_kes('IndPQPNCons'..i, 'ne', frame)
     ..'\n|-'
   end
   function f5(i)
     local s = tostring(i)
     return '\n|colspan="2"|' .. p.tew_kes('SubPresent'..i, '', frame)
     ..'\n|colspan="2"|' .. p.tew_kes('SubPresent'..i, 'ne', frame)
     ..'\n|colspan="2"|' .. p.tew_kes('SubPreterite'..i, '', frame)
     ..'\n|colspan="2"|' .. p.tew_kes('SubPreterite'..i, 'ne', frame)
     ..'\n|-'
   end
   function f6(i)
     local s = tostring(i)
     return '\n|colspan="2"|' .. p.tew_kes('SubImperfect'..i, '', frame)
     ..'\n|colspan="2"|' .. p.tew_kes('SubImperfect'..i, 'ne', frame)
     ..'\n|colspan="2"|' .. p.tew_kes('SubPluperfect'..i, '', frame)
     ..'\n|colspan="2"|' .. p.tew_kes('SubPluperfect'..i, 'ne', frame)
     ..'\n|-'
   end
   function f7(i)
     local s = tostring(i)
     return '\n|colspan="2"|' .. p.tew_kes('CondPresent'..i, '', frame)
     ..'\n|colspan="2"|' .. p.tew_kes('CondPresent'..i, 'ne', frame)
     ..'\n|colspan="2"|' .. p.tew_kes('CondPreterite'..i, '', frame)
     ..'\n|colspan="2"|' .. p.tew_kes('CondPreterite'..i, 'ne', frame)
     ..'\n|-'
   end

   local y1 = f1(1)
   local y2 = f2(1)
   local y3 = f3(1)
   local y4 = f4(1)
   local y5 = f5(1)
   local y6 = f6(1)
   local y7 = f7(1)

   for i=2, 6 do
    local s = tostring(i)
    y1 = y1 .. f1(i)
    y2 = y2 .. f2(i)
    y3 = y3 .. f3(i)
    y4 = y4 .. f4(i)
    y5 = y5 .. f5(i)
    y6 = y6 .. f6(i)
    y7 = y7 .. f7(i)
   end

   if (pasgir == nil or pasgir == '') then pasgir = '' pasgirSer = '' else pasgirSer = '  ' .. pasgir end
   if (pesgir == nil or pesgir == '') then pesgir = '' pesgirSer = '' else pesgirSer = pesgir .. '  ' end
   if (niha2 == nil or niha2 == '') then niha2 = '' nihaSer2 = '' else nihaSer2 = ' / –' .. niha2 .. '–' end
   if (niha3 == nil or niha3 == '') then niha3 = '' nihaSer3 = '' else nihaSer3 = ' / –' .. niha3 .. '–' end
   if (bori2 == nil or bori2 == '') then bori2 = '' boriSer2 = '' else boriSer2 = ' / –' .. bori2 .. '–' end
	
	-- Cureyê lêkerê
	if (valahi or pasgir) then
		cure = "hevedudanî"
	elseif pesgir ~= nil and pesgir ~= '' then
		cure = "pêkhatî"
	else 
		cure = "xwerû"
	end
		
   local reng = '\n|colspan="2" bgcolor="#F4F4F4" | Erênî'
   ..'\n|colspan="2" bgcolor="#F4F4F4" | Neyînî'
   ..'\n|colspan="2" bgcolor="#F4F4F4" | Erênî'
   ..'\n|colspan="2" bgcolor="#F4F4F4" | Neyînî'

   return
   '{| cellspacing="0" cellpadding="4" align="center" style="border-collapse:collapse;"'
     ..'\n|-'
     ..'\n| colspan="8" style="font-size:small;text-align:center;color:blue;" | [[Wêne:Emblem-question-red.svg|17px|link=]] [[Gotûbêja modulê:ku-tewandin|Pirsgirêkan nîşan bide – Pêşniyaran bike]]'
     ..'\n|-'
     ..'\n|-style="border-bottom:solid 1px grey; border-top:solid 1px grey;"'
     ..'\n!id="1" colspan="8" bgcolor="#EEC591" align="center" | Tewandina lêkera [['.. leker .. ']]<br/><span style="font-weight:normal;">(' .. cure .. ', ' .. form .. ')</span></big><br/>'
     ..'\n|-'
     ..'\n|colspan="4" style="border-bottom:dotted 1px grey;" |'
     ..'\n!id="11" colspan="2" bgcolor="#FFFFE0" style="border-bottom:solid 1px grey;" | Dema niha'
     ..'\n!colspan="2" bgcolor=#ECECFF style="border-bottom:solid 1px grey;" | Dema borî'
     ..'\n|-'
     ..'\n|colspan="4" style="text-align:center; font-weight:bold; border-bottom:dotted 1px grey;" | Reh'     
     ..'\n|colspan="2" style="text-align:center; border-bottom:dotted 1px grey;" | ' .. pesgirSer .. '–' .. niha .. '–' .. nihaSer2 .. nihaSer3 .. pasgirSer
     ..'\n|colspan="2" style="text-align:center; border-bottom:dotted 1px grey;" | ' .. pesgirSer .. '–' .. bori .. '–' .. boriSer2 .. pasgirSer
     ..'\n|-'
     ..'\n|-style="border-bottom:solid 1px grey; border-top:solid 1px grey;"'
     ..'\n!id="1" colspan="8" bgcolor="#FFDCA8" align="center" | Raweya pêşkerî (daxuyanî) - <small><i>Indicative</i></small>'
     ..'\n|-style="border-bottom:solid 1px grey; border-top:solid 1px grey;"'
     ..'\n!id="11" colspan="4" bgcolor="#FFFFE0" | [[Pêvek:Rastnivîsî/Lêker/Dema niha|Dema niha]] - <small><i>Present</i></small>'
     ..'\n!colspan="4" bgcolor="#ECECFF" | [[Pêvek:Rastnivîsî/Lêker/Dema borî ya sade|Raboriya sade]] - <small><i>Preterite</i></small><br><small>Dema boriya têdeyî</small>'
     ..'\n|-'
     ..reng
     ..'\n|-' 
     ..y1
     ..'\n|-style="border-bottom:solid 1px grey; border-top:solid 1px grey;"'
     ..'\n!id="12" colspan="4" bgcolor="ECECFF" style="border-right:dotted 1px grey;" | Raboriya berdest - <small><i>Imperfect</i></small><br><small>Çîrokiya dema niha</small>'
     ..'\n!colspan="4" bgcolor="#ECECFF" | Raboriya dûr - <small><i>Pluperfect</i></small><br><small>Çirokiye boriya têdeyî</small>'
     ..'\n|-'
     ..reng
     ..'\n|-' 
     ..y2
     ..'\n|-style="border-bottom:solid 1px grey; border-top:solid 1px grey;"'
     ..'\n!id="13" colspan="4" bgcolor=#FFFFE0 | [[Pêvek:Rastnivîsî/Lêker/Dema bê|Dema bê]] - <small><i>Future</i></small>'
     ..'\n!colspan="4" bgcolor="#ECECFF" | Dahatiya pêş - <small><i>Future perfect</i></small>'
     ..'\n|-'
     ..reng
     ..'\n|-' 
     ..y3
     ..'\n|-style="border-bottom:solid 1px grey; border-top:solid 1px grey;"'
     ..'\n!id="14" colspan="4" bgcolor="#ECECFF" style="border-right:dotted 1px grey;" | Raboriya dûdar - <small><i>Perfect</i></small><br><small>Dema boriya dûdar</small>'
     ..'\n!colspan="4" bgcolor="#ECECFF" | Çîrokiya boriya dûdar - <small><i>Nonconfirmative pluperfect</i></small>'
     ..'\n|-' 
     ..reng
     ..'\n|-'   
     ..y4
     ..'\n|-style="border-bottom:solid 1px grey; border-top:solid 1px grey;"'
     ..'\n!id="2" colspan="8" bgcolor="#FFDCA8" | Raweya xwestekî (bilanî, daxwazî) - <small><i>Subjunctive</i></small>'
     ..'\n|-style="border-bottom:solid 1px grey; border-top:solid 1px grey;"'
     ..'\n!id="21" colspan="4" bgcolor="#FFFFE0" | Dema nihaya xwestekî - <small><i>Present subjunctive</i></small><br><small>Nihaya bilaniyê</small>'
     ..'\n!colspan="4" bgcolor="#ECECFF" | Dema boriya xwestekî - <small><i>Preterite subjunctive</i></small>'
     ..'\n|-' 
     ..reng
     ..'\n|-' 
     ..y5
     ..'\n|-style="border-bottom:solid 1px grey; border-top:solid 1px grey;"'
     ..'\n!id="22" colspan="4" bgcolor="#ECECFF" style="border-right:dotted 1px grey;" | Raboriya bilaniyê - <small><i>Imperfect subjunctive</i></small>'
     ..'\n!colspan="4" bgcolor="#ECECFF" | Raboriya dûr a bilaniyê - <small><i>Pluperfect subjunctive</i></small>'
     ..'\n|-'
     ..reng
     ..'\n|-' 
     ..y6
     ..'\n|-'
     ..'\n|-style="border-bottom:solid 1px grey; border-top:solid 1px grey;"'
     ..'\n!id="3" colspan="8" bgcolor="#FFDCA8" | Raweya mercî (hekînî) - <small><i>Conditional</i></small>'
     ..'\n|-style="border-bottom:solid 1px grey; border-top:solid 1px grey;"'
     ..'\n!id="31" colspan="4" bgcolor="#ECECFF" style="border-right:dotted 1px grey;" | Çîrokiya dema nihaya  mercî - <small><i>Present conditional</i></small>'
     ..'\n!colspan="4" bgcolor="#ECECFF" | Dema boriya mercî - <small><i>Preterite conditional</i></small>'
     ..'\n|-'
     ..reng
     ..'\n|-' 
     ..y7
     ..'\n|-'
     ..'\n|-style="border-bottom:solid 1px grey; border-top:solid 1px grey;"'
     ..'\n!id="4" colspan="8" bgcolor="#FFDCA8" | Raweya fermanî - <small><i>Imperative</i></small>'
     ..'\n|-style="border-bottom:solid 1px grey; border-top:solid 1px grey;"'
     ..'\n!id="41" colspan="8" bgcolor="#FFFFE0" | Dema niha - <small><i>Present</i></small>'
     ..'\n|-style="border-bottom:solid 1px grey; border-top:solid 1px grey;"'
     ..'\n|-'
     ..'\n|colspan="4" bgcolor="#F4F4F4" | Erênî'
     ..'\n|colspan="4" bgcolor="#F4F4F4" | Neyînî'
     ..'\n|-'
     ..'\n|colspan="4" | ' .. p.tew_kes('ImpPresent2', '', frame)
     ..'\n|colspan="4" | ' .. p.tew_kes('ImpPresent2', 'ne', frame)
     ..'\n|-'
     ..'\n|colspan="4" | ' .. p.tew_kes('ImpPresent5', '', frame)
     ..'\n|colspan="4" | ' .. p.tew_kes('ImpPresent5', 'ne', frame)
     ..'\n|}'
end

return p