Iran has taken a beating militarily, but demonstrated it can exact economic costs that Trump and his aides underestimated, unleashing the worst-ever global energy shock, analysts say.