/** @jsx $mol_jsx */
namespace $ {
	$hyoo_crus_yard.masters = [
		"http://localhost:9090/"
		// "http://127.0.0.1:9090/"
		// $mol_dom_context.document.location.origin +'/',
	]

	// используем hyoo_crus_app_node чтобы сразу иметь крас ноду
	export class $hd_canary extends $hyoo_crus_app_node {
		@ $mol_mem
		_stat_update() {
			// console.log("asdddddddd")
			this.$.$mol_log3_done({
				place: this,
				message: "_stat_update",
				...{action:"tick", url: "_stat_update", title: "_stat_update" }
			});

			const home_land = this.$.$hyoo_crus_glob.home( $hd_canary_app_home ).land()
			const list = home_land.Node( $hyoo_crus_dict ).Item('')

			for (const ref of list.keys()) {
				try {
					const user = this.$.$hyoo_crus_glob.Node( $hyoo_crus_ref( ref as string ), $hd_canary_app_home )
					for (const site of user.Sites(null)?.remote_list() ?? []) { 
						site.tick()
					}
				} catch( error ) {
					$mol_fail_log( error )
					continue;
				}
			}
		}

		@ $mol_memo.method
		join() {
			return new $hd_canary_join
		}
	}

	export class $hd_canary_join extends $mol_rest_resource {
		
		GET( msg: $mol_rest_message ) {
			// const home_land = this.$.$hyoo_crus_glob.home( $hd_canary_app_home ).land()
			// home_land.give(null, $hyoo_crus_rank_join("just"))
			// msg.reply( home_land.ref().description! )


			const home_land = this.$.$hyoo_crus_glob.home( $hd_canary_app_home ).land()
			const list = home_land.Node( $hyoo_crus_dict ).Item('')
			list.land().give(null, $hyoo_crus_rank_rule)
			msg.reply( list.ref().description! )
		}
		
	}
}

$.$hd_canary.serve()

/*
npm start
+ hd/canary port=9090
*/