<?php
declare(strict_types=1);
namespace PpPhp\Core\Designer\Generation\Contracts;
final class GeneratedApplication{
 public function __construct(private readonly string $applicationId,private readonly string $title,private readonly array $pages=[],private readonly array $assets=[],private readonly array $routes=[],private readonly string $shell='',private readonly array $meta=[]){ }
 public static function create(string $applicationId,string $title,array $pages,array $assets,array $routes,string $shell,array $meta=[]):self{return new self($applicationId,$title,$pages,$assets,$routes,$shell,$meta);} 
 public function applicationId():string{return $this->applicationId;} public function pages():array{return $this->pages;}
 public function manifest():array{ return ['applicationId'=>$this->applicationId,'title'=>$this->title,'version'=>'1.0.0','generatedAt'=>date('c'),'pages'=>count($this->pages),'routes'=>count($this->routes),'assets'=>count((array)($this->assets['manifest']['assets']??$this->assets['assets']??[])),'pageIndex'=>array_map(static fn($p)=>['id'=>$p->id(),'pageType'=>$p->pageType(),'path'=>$p->path()],$this->pages),'meta'=>$this->meta]; }
 public function toArray():array{ $s=['pages'=>count($this->pages),'dashboardPages'=>count(array_filter($this->pages,static fn($p)=>$p->pageType()==='dashboard')),'gridPages'=>count(array_filter($this->pages,static fn($p)=>in_array($p->pageType(),['list','grid'],true))),'formPages'=>count(array_filter($this->pages,static fn($p)=>in_array($p->pageType(),['add','edit','view','form'],true))),'authPages'=>count(array_filter($this->pages,static fn($p)=>in_array($p->pageType(),['login','register','forgot_password','reset_password','change_password','profile','user_info','access_denied'],true))),'routes'=>count($this->routes)]; return ['applicationId'=>$this->applicationId,'title'=>$this->title,'pages'=>array_map(static fn($p)=>$p->toArray(),$this->pages),'assets'=>$this->assets,'routes'=>$this->routes,'shell'=>$this->shell,'manifest'=>$this->manifest(),'summary'=>$s];}
}
