function idnssmaskinit_x0(blk, sys)

%   Authors: R. Chen
%   Copyright 2022-2022 The MathWorks, Inc.

IsCT = (sys.Ts==0);
IsInternalInDialog = strcmp(get_param(blk,'x0type'),'internal');
if IsCT
    parentBlk = [blk '/NSS/Continuous Time'];
    ICblk = [blk '/NSS/Continuous Time/Integrator'];
    IsInternalInBlock = strcmpi(get_param(ICblk,'InitialConditionSource'),'internal');
else
    parentBlk = [blk '/NSS/Discrete Time'];
    ICblk = [blk '/NSS/Discrete Time/Delay'];
    IsInternalInBlock = strcmpi(get_param(ICblk,'InitialConditionSource'),'dialog');
end
if IsCT
    if IsInternalInDialog
        if IsInternalInBlock
            % null op
        else
            % remove line from Gain inport to integrator IC port
            delete_line(parentBlk,'Gain/1','Integrator/2');
            % remove integrator IC port
            set_param(ICblk,'InitialConditionSource','internal');
        end
    else
        if IsInternalInBlock
            % add integrator IC port
            set_param(ICblk,'InitialConditionSource','external');
            % add line from Gain inport to integrator IC port
            add_line(parentBlk,'Gain/1','Integrator/2','autorouting','on');
        else
            % null op
        end
    end
else
    if IsInternalInDialog
        if IsInternalInBlock
            % null op
        else
            % remove line from Gain inport to integrator IC port
            delete_line(parentBlk,'Gain/1','Delay/2');
            % remove integrator IC port
            set_param(ICblk,'InitialConditionSource','dialog');
        end
    else
        if IsInternalInBlock
            % add integrator IC port
            set_param(ICblk,'InitialConditionSource','input port');
            % add line from Gain inport to integrator IC port
            add_line(parentBlk,'Gain/1','Delay/2','autorouting','on');
        else
            % null op
        end
    end
end
