// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {Script, console2} from "forge-std/Script.sol";
import {OMNLJurisdictionPolicyRegistry} from "../../contracts/hybx-omnl/OMNLJurisdictionPolicyRegistry.sol";

/// @notice Publish Indonesia pilot policy (extend via env for more jurisdictions).
contract PublishJurisdictionPolicies is Script {
    function run() external {
        address registry = vm.envAddress("OMNL_JURISDICTION_REGISTRY");
        bytes32 policyHash = vm.envBytes32("OMNL_JURISDICTION_POLICY_HASH");
        uint256 pk = vm.envUint("PRIVATE_KEY");

        bytes32 jurId = keccak256(bytes(vm.envOr("OMNL_JURISDICTION_ID", string("ID"))));
        uint8 notaryTh = uint8(vm.envOr("OMNL_NOTARY_THRESHOLD", uint256(3)));
        uint8 reserveTh = uint8(vm.envOr("OMNL_RESERVE_ATTESTATION_THRESHOLD", uint256(3)));
        uint8 adminTh = uint8(vm.envOr("OMNL_ADMIN_MULTISIG_THRESHOLD", uint256(3)));
        bool prod = vm.envOr("OMNL_JURISDICTION_PRODUCTION_READY", true);

        vm.startBroadcast(pk);
        OMNLJurisdictionPolicyRegistry(registry).publishPolicy(
            jurId, policyHash, notaryTh, reserveTh, adminTh, prod
        );
        vm.stopBroadcast();
        console2.log("Published policy for jurisdiction", vm.toString(jurId));
    }
}
