وحدة:بطاقة/قالب/عملة مشفرة

local generic = require( 'وحدة:بطاقة/أدوات' )

local function ifExist(localdata,item,params)

   if type(params.required) == 'string' then return localdata[params.required] end
   if type(params.required) == 'table' then
      for _,v in ipairs(params.required) do
          if localdata[v] then
             return localdata[v] 
           end
      end
   end
   if type(params.lookfor) == 'table' then
      local d = nil
      for _,v in ipairs(params.lookfor) do
          d = localdata[v] or d
      end
      if d then return ' ' end
   end

   return nil
end

local function tableMerge(t1, t2)

	if type(t1) == 'string' then t1={t1} end
	if type(t2) == 'string' then t2={t2} end
	if type(t2) ~= 'table' then return t1 end

	for _, v in ipairs(t2) do
		table.insert( t1, v ) 
	end
	return t1
end

local function showInfoPoint(label,required ,datas)
  local lookfor={}
  local rows={}

  for k,v in pairs(datas) do
     lookfor = tableMerge(lookfor, v)
  end

  table.insert( rows, {type = 'row' 
		, label = label
		, value = ifExist
        , required = required
        , lookfor = lookfor
	} )

  for k,v in pairs(datas) do
      table.insert( rows, {type = 'row' , style={['font-size']='small', ['font-weight']= 'normal'}
		, label = '←  '..k
		, value = v
	  } )
  end

  return { type = 'multi' ,rows = rows }
end

return  {
    maincolor = '#CEDEFF' -- اللون المستعمل لعنوان البطاقة
    ,wikimod = 'Wikidata.Ca'
    ,parts = { -- محتويات البطاقة
        generic.title(),
        generic.logo(),
        generic.mainimage(),
        {type = 'images'
            , imageparameters =  {'صورة_1','image_1'}
            , captionparameter ={'تعليق_1','caption_1','image_title_1'}
        },
        {type = 'images'
            , imageparameters =  {'صورة_2','image_2'}
            , captionparameter ={'تعليق_2','caption_2','image_title_2'}
        },


   {type = 'table' , title ='التسمية' ,rows = {
        {type = 'row' 
                , label = 'تسمية الجمع'
                , value = {'جمع','plural'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = '[[علامة العملة|العلامة]]'
                , value = {'علامة','symbol'}
                , wikidata = {property='P5810'}
        },
        {type = 'row' 
                , label = '[[رمز التداول]]'
                , value = {'رمز','ticker_symbol'}
                --, wikidata = {property='P249'}
        },
        {type = 'row' 
                , label = 'الاسم المستعار'
                , value = {'اسم_مستعار','nickname'}
                , wikidata = {property='P1449'}
        },
        {type = 'row' 
                , label = 'الأسماء السابقة'
                , value = {'أسماء_سابقة','previous_names'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = 'الدقة'
                , value = {'دقة','precision'}
                --, wikidata = {property='P'}
        },
        showInfoPoint(
                'Superunits'
                , nil
                ,{['superunit_ratio_1'] = {'superunit_name_1'}
                , ['superunit_ratio_2'] = {'superunit_name_2'}
                , ['superunit_ratio_3'] = {'superunit_name_3'}
                , ['superunit_ratio_4'] = {'superunit_name_4'}
                , ['superunit_ratio_5'] = {'superunit_name_5'}
                }
            ),
        showInfoPoint(
                'Subunits'
                , nil
                ,{['subunit_ratio_1'] = {'subunit_ratio_1'}
                , ['subunit_ratio_2'] = {'subunit_ratio_2'}
                , ['subunit_ratio_3'] = {'subunit_ratio_3'}
                , ['subunit_ratio_4'] = {'subunit_ratio_4'}
                , ['subunit_ratio_5'] = {'subunit_ratio_5'}
                }
            ),
   }},
   {type = 'table' , title ='التطوير' ,rows = {
        
		{type = 'mixed', label = '[[تصميم البرمجيات|المطور الأصلي]]'
			, value = {'مؤلف','author'}
			,  wikidata={ property = 'P170 OR P112',conjunction = "<br />"}
		},
        {type = 'row' 
                , label = '[[ورقة بيضاء]]'
                , value = {'ورقة_بيضاء','white_paper'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = 'Implementation(s)'
                , value = {'implementations'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = 'أول إصدار'
                , value = {'أول_إصدار','initial_release_version'}
                , wikidata = {property='P571'}
        },
        {type = 'row' 
                , label = '[[مراحل إصدار البرمجيات|آخر إصدار]]'
                , value = {'آخر إصدار','latest_release_version'}
                --, wikidata = {property='P'}
        },
		{type = 'mixed', valueClass='url', label = '[[مستودع برمجيات|المستودع]]'
           , value = {'مستودع','code_repository','repository','repo'}
			,wikidata  = { property='P1324',list='bestrank'
					, formatting='weblink'
					, conjunction="<br />"
				}
		},
        {type = 'row' 
                , label = 'حالة التطوير'
                , value = {'status'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = '[[تفرع معدل (برمجة)|تفرع عن]]'
                , value = {'تفرع_عن','forked_from','project_fork_of'}
                --, wikidata = {property='P'}
        },
		{type = 'mixed', label = '[[لغة برمجة|لغة البرمجة]]'
			, value = {'لغة','لغة_برمجة','programming_languages'}
			, wikidata={property = 'P277',conjunction = "<br />"}
		},
        {type = 'mixed', label = '[[نظام التشغيل]]'
			, value = {'نظام_التشغيل','operating_system'}
			, wikidata={property = 'P306', list='bestrank' ,conjunction = "<br />"}
		},
		{type = 'mixed', label = '[[مطور برمجيات|المطورون]]'
			, value = {'مطور','المطور','developer'}
			, wikidata={ property = 'P178',conjunction = "<br />"}
		},
		{type = 'mixed', label = 'النموذج المصدري', 
			value = {'نموذج_مصدري','source_model'},
            property = 'P6216'
		},
		{type = 'mixed', label = '[[رخصة البرمجيات|الرخصة]]'
			, value = {'رخصة','license','الترخيص'}
			, wikidata={property = 'P275'}
		},
        generic.website(),
   }},
   {type = 'table' , title ='Ledger' ,rows = {
        {type = 'row' 
                , label = {'ledger_start_title'}, defaultlabel='Ledger start'
                , value = {'ledger_start'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = {'ledger_start_title_2'}
                , value = {'ledger_start_2'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = {'ledger_start_title_3'}
                , value = {'ledger_start_3'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = {'ledger_start_title_4'}
                , value = {'ledger_start_4'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = {'ledger_start_title_5'}
                , value = {'ledger_start_5'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = 'Split height'
                , value = {'split_height'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = 'Split date'
                , value = {'split_date'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = 'Split from'
                , value = {'split_from'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = 'Split ratio'
                , value = {'split_ratio'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = '[[Trusted timestamping|Timestamping scheme]]'
                , value = {'timestamping'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = 'Merged mining parent'
                , value = {'merged_mining_parent'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = '[[دالة التجزئة]]'
                , value = {'دالة تجزئة','hash_function'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = {'issuing_authority_title'} , defaultlabel='Issuance schedule'
                , value = {'issuance','issuance_schedule|}}}}}}'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = 'Block reward'
                , value = {'block_reward'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = 'Block time'
                , value = {'block_time'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = 'Block explorer'
                , value = {'block_explorer'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = 'Circulating supply'
                , value = {'circulating_supply'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = 'Supply limit'
                , value = {'supply_limit'}
                --, wikidata = {property='P'}
        },
   }},
   {type = 'table' , title ='القيمة' ,rows = {
        {type = 'row' 
                , label = '[[سعر الصرف]]'
                , value = {'سعر الصرف','exchange_rate'}
                , wikidata = {property='P2284', formatting='unit'}
        },
        {type = 'row' 
                , label = '[[رسملة سوقية]]'
                , value = {'رسملة سوقية','market_cap'}
                --, wikidata = {property='P'}
        },
   }},
    {type = 'table' , title ='الاستعمال' ,rows = {
        {type = 'row' 
                , label = 'استعمال مرخص'
                , value = {'دول_مستعملة','using_countries'}
                --, wikidata = {property='P'}
        },
    }},
    {type = 'table' , title ='الهوامش' ,rows = {
        {type = 'row1col' 
                , value = {'هوامش','footnotes'}
        },
    }}
 }
}