data[$name]??$default;} public function require(string $name): mixed{return $this->data[$name]??throw new \InvalidArgumentException('Missing '.$name);} } final class Context { public readonly ApiClient $api; public function __construct(public readonly string $module,public readonly array $caller){$this->api=new ApiClient();} public function get(string $key): mixed{return $this->api->request('GET','/api/v1/storage/'.$this->module.'/'.rawurlencode($key));} public function put(string $key,mixed $value): mixed{return $this->api->request('PUT','/api/v1/storage/'.$this->module.'/'.rawurlencode($key),['value'=>$value]);} public function delete(string $key): mixed{return $this->api->request('DELETE','/api/v1/storage/'.$this->module.'/'.rawurlencode($key));} } final class ApiClient { private int $calls=0; public function get(string $path,array $query=[]): mixed{return $this->request('GET',$path,$query);} public function request(string $method,string $path,array $data=[]): mixed { if(++$this->calls>10)throw new \RuntimeException('Module API call limit.'); fwrite(STDOUT,json_encode(['kind'=>'call','method'=>$method,'path'=>$path,'data'=>(object)$data],JSON_THROW_ON_ERROR)."\n");fflush(STDOUT); $line=fgets(STDIN);$r=json_decode($line?:'',true,32,JSON_THROW_ON_ERROR);if(!($r['ok']??false))throw new \RuntimeException((string)($r['error']??'Core call failed'));return $r['data']; } } class Node implements \JsonSerializable { protected array $children=[]; public function __construct(protected string $type,protected string $id,protected array $props=[]){} public function prop(string $name,mixed $value): static{$this->props[$name]=$value;return $this;} public function add(Node $node): static{$this->children[]=$node;return $this;} public function jsonSerialize(): array{return ['id'=>$this->id,'type'=>$this->type,'version'=>'1.0.0','props'=>(object)$this->props,'children'=>array_map(fn($n)=>$n->jsonSerialize(),$this->children)];} public function render(Context $context): mixed{return $context->api->request('POST','/api/v1/components/render',['component'=>$this->jsonSerialize()]);} } class HtmlElement extends Node { protected string $tag='div'; public function __construct(string $id,array $props=[]){parent::__construct('tag.'.$this->tag,$id,$props);} public function text(string $text): static{return $this->prop('text',$text);} public function attribute(string $name,string|bool|int $value): static{$this->props['attributes'][$name]=$value;return $this;} public function classes(string $value): static{return $this->prop('class',$value);} } class Block extends Node {public function __construct(string $type,string $id,array $props=[]){parent::__construct('block.'.$type,$id,$props);}} class Module extends Node {public function __construct(string $type,string $id,array $props=[]){parent::__construct('module.'.$type,$id,$props);}} namespace Iist\Module\Html\Tags; class TagA extends \Iist\Module\HtmlElement {protected string $tag='a';} class TagAbbr extends \Iist\Module\HtmlElement {protected string $tag='abbr';} class TagAddress extends \Iist\Module\HtmlElement {protected string $tag='address';} class TagArea extends \Iist\Module\HtmlElement {protected string $tag='area';} class TagArticle extends \Iist\Module\HtmlElement {protected string $tag='article';} class TagAside extends \Iist\Module\HtmlElement {protected string $tag='aside';} class TagAudio extends \Iist\Module\HtmlElement {protected string $tag='audio';} class TagB extends \Iist\Module\HtmlElement {protected string $tag='b';} class TagBase extends \Iist\Module\HtmlElement {protected string $tag='base';} class TagBdi extends \Iist\Module\HtmlElement {protected string $tag='bdi';} class TagBdo extends \Iist\Module\HtmlElement {protected string $tag='bdo';} class TagBlockquote extends \Iist\Module\HtmlElement {protected string $tag='blockquote';} class TagBody extends \Iist\Module\HtmlElement {protected string $tag='body';} class TagBr extends \Iist\Module\HtmlElement {protected string $tag='br';} class TagButton extends \Iist\Module\HtmlElement {protected string $tag='button';} class TagCanvas extends \Iist\Module\HtmlElement {protected string $tag='canvas';} class TagCaption extends \Iist\Module\HtmlElement {protected string $tag='caption';} class TagCite extends \Iist\Module\HtmlElement {protected string $tag='cite';} class TagCode extends \Iist\Module\HtmlElement {protected string $tag='code';} class TagCol extends \Iist\Module\HtmlElement {protected string $tag='col';} class TagColgroup extends \Iist\Module\HtmlElement {protected string $tag='colgroup';} class TagData extends \Iist\Module\HtmlElement {protected string $tag='data';} class TagDatalist extends \Iist\Module\HtmlElement {protected string $tag='datalist';} class TagDd extends \Iist\Module\HtmlElement {protected string $tag='dd';} class TagDel extends \Iist\Module\HtmlElement {protected string $tag='del';} class TagDetails extends \Iist\Module\HtmlElement {protected string $tag='details';} class TagDfn extends \Iist\Module\HtmlElement {protected string $tag='dfn';} class TagDialog extends \Iist\Module\HtmlElement {protected string $tag='dialog';} class TagDiv extends \Iist\Module\HtmlElement {protected string $tag='div';} class TagDl extends \Iist\Module\HtmlElement {protected string $tag='dl';} class TagDt extends \Iist\Module\HtmlElement {protected string $tag='dt';} class TagEm extends \Iist\Module\HtmlElement {protected string $tag='em';} class TagEmbed extends \Iist\Module\HtmlElement {protected string $tag='embed';} class TagFieldset extends \Iist\Module\HtmlElement {protected string $tag='fieldset';} class TagFigcaption extends \Iist\Module\HtmlElement {protected string $tag='figcaption';} class TagFigure extends \Iist\Module\HtmlElement {protected string $tag='figure';} class TagFooter extends \Iist\Module\HtmlElement {protected string $tag='footer';} class TagForm extends \Iist\Module\HtmlElement {protected string $tag='form';} class TagH1 extends \Iist\Module\HtmlElement {protected string $tag='h1';} class TagH2 extends \Iist\Module\HtmlElement {protected string $tag='h2';} class TagH3 extends \Iist\Module\HtmlElement {protected string $tag='h3';} class TagH4 extends \Iist\Module\HtmlElement {protected string $tag='h4';} class TagH5 extends \Iist\Module\HtmlElement {protected string $tag='h5';} class TagH6 extends \Iist\Module\HtmlElement {protected string $tag='h6';} class TagHead extends \Iist\Module\HtmlElement {protected string $tag='head';} class TagHeader extends \Iist\Module\HtmlElement {protected string $tag='header';} class TagHgroup extends \Iist\Module\HtmlElement {protected string $tag='hgroup';} class TagHr extends \Iist\Module\HtmlElement {protected string $tag='hr';} class TagHtml extends \Iist\Module\HtmlElement {protected string $tag='html';} class TagI extends \Iist\Module\HtmlElement {protected string $tag='i';} class TagIframe extends \Iist\Module\HtmlElement {protected string $tag='iframe';} class TagImg extends \Iist\Module\HtmlElement {protected string $tag='img';} class TagInput extends \Iist\Module\HtmlElement {protected string $tag='input';} class TagIns extends \Iist\Module\HtmlElement {protected string $tag='ins';} class TagKbd extends \Iist\Module\HtmlElement {protected string $tag='kbd';} class TagLabel extends \Iist\Module\HtmlElement {protected string $tag='label';} class TagLegend extends \Iist\Module\HtmlElement {protected string $tag='legend';} class TagLi extends \Iist\Module\HtmlElement {protected string $tag='li';} class TagLink extends \Iist\Module\HtmlElement {protected string $tag='link';} class TagMain extends \Iist\Module\HtmlElement {protected string $tag='main';} class TagMap extends \Iist\Module\HtmlElement {protected string $tag='map';} class TagMark extends \Iist\Module\HtmlElement {protected string $tag='mark';} class TagMenu extends \Iist\Module\HtmlElement {protected string $tag='menu';} class TagMeta extends \Iist\Module\HtmlElement {protected string $tag='meta';} class TagMeter extends \Iist\Module\HtmlElement {protected string $tag='meter';} class TagNav extends \Iist\Module\HtmlElement {protected string $tag='nav';} class TagNoscript extends \Iist\Module\HtmlElement {protected string $tag='noscript';} class TagObject extends \Iist\Module\HtmlElement {protected string $tag='object';} class TagOl extends \Iist\Module\HtmlElement {protected string $tag='ol';} class TagOptgroup extends \Iist\Module\HtmlElement {protected string $tag='optgroup';} class TagOption extends \Iist\Module\HtmlElement {protected string $tag='option';} class TagOutput extends \Iist\Module\HtmlElement {protected string $tag='output';} class TagP extends \Iist\Module\HtmlElement {protected string $tag='p';} class TagPicture extends \Iist\Module\HtmlElement {protected string $tag='picture';} class TagPre extends \Iist\Module\HtmlElement {protected string $tag='pre';} class TagProgress extends \Iist\Module\HtmlElement {protected string $tag='progress';} class TagQ extends \Iist\Module\HtmlElement {protected string $tag='q';} class TagRp extends \Iist\Module\HtmlElement {protected string $tag='rp';} class TagRt extends \Iist\Module\HtmlElement {protected string $tag='rt';} class TagRuby extends \Iist\Module\HtmlElement {protected string $tag='ruby';} class TagS extends \Iist\Module\HtmlElement {protected string $tag='s';} class TagSamp extends \Iist\Module\HtmlElement {protected string $tag='samp';} class TagScript extends \Iist\Module\HtmlElement {protected string $tag='script';} class TagSearch extends \Iist\Module\HtmlElement {protected string $tag='search';} class TagSection extends \Iist\Module\HtmlElement {protected string $tag='section';} class TagSelect extends \Iist\Module\HtmlElement {protected string $tag='select';} class TagSelectedcontent extends \Iist\Module\HtmlElement {protected string $tag='selectedcontent';} class TagSlot extends \Iist\Module\HtmlElement {protected string $tag='slot';} class TagSmall extends \Iist\Module\HtmlElement {protected string $tag='small';} class TagSource extends \Iist\Module\HtmlElement {protected string $tag='source';} class TagSpan extends \Iist\Module\HtmlElement {protected string $tag='span';} class TagStrong extends \Iist\Module\HtmlElement {protected string $tag='strong';} class TagStyle extends \Iist\Module\HtmlElement {protected string $tag='style';} class TagSub extends \Iist\Module\HtmlElement {protected string $tag='sub';} class TagSummary extends \Iist\Module\HtmlElement {protected string $tag='summary';} class TagSup extends \Iist\Module\HtmlElement {protected string $tag='sup';} class TagTable extends \Iist\Module\HtmlElement {protected string $tag='table';} class TagTbody extends \Iist\Module\HtmlElement {protected string $tag='tbody';} class TagTd extends \Iist\Module\HtmlElement {protected string $tag='td';} class TagTemplate extends \Iist\Module\HtmlElement {protected string $tag='template';} class TagTextarea extends \Iist\Module\HtmlElement {protected string $tag='textarea';} class TagTfoot extends \Iist\Module\HtmlElement {protected string $tag='tfoot';} class TagTh extends \Iist\Module\HtmlElement {protected string $tag='th';} class TagThead extends \Iist\Module\HtmlElement {protected string $tag='thead';} class TagTime extends \Iist\Module\HtmlElement {protected string $tag='time';} class TagTitle extends \Iist\Module\HtmlElement {protected string $tag='title';} class TagTr extends \Iist\Module\HtmlElement {protected string $tag='tr';} class TagTrack extends \Iist\Module\HtmlElement {protected string $tag='track';} class TagU extends \Iist\Module\HtmlElement {protected string $tag='u';} class TagUl extends \Iist\Module\HtmlElement {protected string $tag='ul';} class TagVar extends \Iist\Module\HtmlElement {protected string $tag='var';} class TagVideo extends \Iist\Module\HtmlElement {protected string $tag='video';} class TagWbr extends \Iist\Module\HtmlElement {protected string $tag='wbr';}